Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / ifunc.c
blob0b0a0549620f8b8679a4bb116919947bc029c21e
1 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
4 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
5 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=memory -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
7 int foo(int) __attribute__ ((ifunc("foo_ifunc")));
9 static int f1(int i) {
10 return i + 1;
13 static int f2(int i) {
14 return i + 2;
17 typedef int (*foo_t)(int);
19 int global;
21 static foo_t foo_ifunc(void) {
22 return global ? f1 : f2;
25 int bar(void) {
26 return foo(1);
29 extern void goo(void);
31 void bar2(void) {
32 goo();
35 extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));
37 void* goo_ifunc(void) {
38 return 0;
40 // CHECK: @foo = ifunc i32 (i32), ptr @foo_ifunc
41 // CHECK: @goo = ifunc void (), ptr @goo_ifunc
43 // CHECK: call i32 @foo(i32
44 // CHECK: call void @goo()
46 // SAN: define internal nonnull ptr @foo_ifunc() #[[#FOO_IFUNC:]] {
48 // SAN: define dso_local noalias ptr @goo_ifunc() #[[#GOO_IFUNC:]] {
50 // SAN-DAG: attributes #[[#FOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
52 // SAN-DAG: attributes #[[#GOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}