Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2) This patch updates test files after D105169. Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows: (1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached. (2) The remaining tests are updated manually. Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D108453 Resolve lit failures in clang after 8ca4b3e's land Fix lit test failures in clang-ppc* and clang-x64-windows-msvc Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc Fix internal_clone(aarch64) inline assembly
81 lines
3.8 KiB
Plaintext
81 lines
3.8 KiB
Plaintext
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
|
|
// Basic C++ test for update_cc_test_checks
|
|
// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
|
|
|
|
class Foo {
|
|
int x;
|
|
|
|
public:
|
|
explicit Foo(int x);
|
|
~Foo();
|
|
// CHECK-LABEL: @_ZNK3Foo23function_defined_inlineEi(
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
|
|
// CHECK-NEXT: [[ARG_ADDR:%.*]] = alloca i32, align 4
|
|
// CHECK-NEXT: store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
|
|
// CHECK-NEXT: [[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
|
|
// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [[CLASS_FOO:%.*]], %class.Foo* [[THIS1]], i32 0, i32 0
|
|
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[X]], align 4
|
|
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
|
|
// CHECK-NEXT: ret i32 [[ADD]]
|
|
//
|
|
inline int function_defined_inline(int arg) const {
|
|
return arg + x;
|
|
}
|
|
inline int function_defined_out_of_line(int arg) const;
|
|
};
|
|
|
|
// CHECK-LABEL: @_ZN3FooC1Ei(
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
|
|
// CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32, align 4
|
|
// CHECK-NEXT: store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
|
|
// CHECK-NEXT: [[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[X_ADDR]], align 4
|
|
// CHECK-NEXT: call void @_ZN3FooC2Ei(%class.Foo* noundef [[THIS1]], i32 noundef [[TMP0]])
|
|
// CHECK-NEXT: ret void
|
|
//
|
|
Foo::Foo(int x) : x(x) {}
|
|
// CHECK-LABEL: @_ZN3FooD1Ev(
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
|
|
// CHECK-NEXT: store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: [[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: call void @_ZN3FooD2Ev(%class.Foo* noundef [[THIS1]]) #[[ATTR3:[0-9]+]]
|
|
// CHECK-NEXT: ret void
|
|
//
|
|
Foo::~Foo() {}
|
|
// CHECK-LABEL: @_ZNK3Foo28function_defined_out_of_lineEi(
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
|
|
// CHECK-NEXT: [[ARG_ADDR:%.*]] = alloca i32, align 4
|
|
// CHECK-NEXT: store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
|
|
// CHECK-NEXT: [[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
|
|
// CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [[CLASS_FOO:%.*]], %class.Foo* [[THIS1]], i32 0, i32 0
|
|
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[X]], align 4
|
|
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
|
|
// CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP0]], [[TMP1]]
|
|
// CHECK-NEXT: ret i32 [[SUB]]
|
|
//
|
|
int Foo::function_defined_out_of_line(int arg) const { return x - arg; }
|
|
|
|
// Call the inline methods to ensure the LLVM IR is generated:
|
|
// CHECK-LABEL: @main(
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[F:%.*]] = alloca [[CLASS_FOO:%.*]], align 4
|
|
// CHECK-NEXT: call void @_ZN3FooC1Ei(%class.Foo* noundef [[F]], i32 noundef 1)
|
|
// CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_ZNK3Foo23function_defined_inlineEi(%class.Foo* noundef [[F]], i32 noundef 2)
|
|
// CHECK-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZNK3Foo28function_defined_out_of_lineEi(%class.Foo* noundef [[F]], i32 noundef 3)
|
|
// CHECK-NEXT: call void @_ZN3FooD1Ev(%class.Foo* noundef [[F]]) #[[ATTR3]]
|
|
// CHECK-NEXT: ret i32 0
|
|
//
|
|
int main() {
|
|
Foo f(1);
|
|
f.function_defined_inline(2);
|
|
f.function_defined_out_of_line(3);
|
|
}
|