llvm-project/clang/test/CodeGen/indirect-noundef.cpp
hyeongyu kim 1b1c8d83d3 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
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
2022-01-16 18:54:17 +09:00

40 lines
1.6 KiB
C++

// RUN: %clang -cc1 -x c++ -triple x86_64-unknown-unknown -O0 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang -cc1 -x c++ -triple x86_64-unknown-unknown -O0 -emit-llvm -fsanitize-memory-param-retval -o - %s | FileCheck %s
// no-sanitize-memory-param-retval does NOT conflict with enable-noundef-analysis
// RUN: %clang -cc1 -x c++ -triple x86_64-unknown-unknown -O0 -emit-llvm -fno-sanitize-memory-param-retval -o - %s | FileCheck %s
// RUN: %clang -cc1 -x c++ -triple x86_64-unknown-unknown -O0 -emit-llvm -fno-sanitize-memory-param-retval -o - %s | FileCheck %s
union u1 {
int val;
};
// CHECK: @indirect_callee_int_ptr = [[GLOBAL:(dso_local )?global]] i32 (i32)*
int (*indirect_callee_int_ptr)(int);
// CHECK: @indirect_callee_union_ptr = [[GLOBAL]] i32 (i32)*
union u1 (*indirect_callee_union_ptr)(union u1);
// CHECK: [[DEFINE:define( dso_local)?]] noundef i32 @{{.*}}indirect_callee_int{{.*}}(i32 noundef %
int indirect_callee_int(int a) { return a; }
// CHECK: [[DEFINE]] i32 @{{.*}}indirect_callee_union{{.*}}(i32 %
union u1 indirect_callee_union(union u1 a) {
return a;
}
int main() {
// CHECK: call noundef i32 @{{.*}}indirect_callee_int{{.*}}(i32 noundef 0)
indirect_callee_int(0);
// CHECK: call i32 @{{.*}}indirect_callee_union{{.*}}(i32 %
indirect_callee_union((union u1){0});
indirect_callee_int_ptr = indirect_callee_int;
indirect_callee_union_ptr = indirect_callee_union;
// CHECK: call noundef i32 %{{.*}}(i32 noundef 0)
indirect_callee_int_ptr(0);
// CHECK: call i32 %{{.*}}(i32 %
indirect_callee_union_ptr((union u1){});
return 0;
}