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
6 // RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
7 // RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s
8 // RUN: %clang_cc1 -triple arm64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s
9 // RUN: %clang_cc1 -triple x86_64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s
10 // RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN
11 // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN
12 // RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN
13 // RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=MACSAN
15 int foo(int) __attribute__ ((ifunc("foo_ifunc")));
17 static int f1(int i
) {
21 static int f2(int i
) {
25 typedef int (*foo_t
)(int);
29 static foo_t
foo_ifunc(void) {
30 return global
? f1
: f2
;
37 extern void goo(void);
43 extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));
45 void* goo_ifunc(void) {
48 // CHECK: @foo = ifunc i32 (i32), ptr @foo_ifunc
49 // CHECK: @goo = ifunc void (), ptr @goo_ifunc
51 // CHECK: call i32 @foo(i32
52 // CHECK: call void @goo()
54 // SAN: define internal nonnull ptr @foo_ifunc() #[[#FOO_IFUNC:]] {
55 // MACSAN: define internal nonnull ptr @foo_ifunc() #[[#FOO_IFUNC:]] {
57 // SAN: define dso_local noalias ptr @goo_ifunc() #[[#GOO_IFUNC:]] {
58 // MACSAN: define noalias ptr @goo_ifunc() #[[#GOO_IFUNC:]] {
60 // SAN-DAG: attributes #[[#FOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
61 // MACSAN-DAG: attributes #[[#FOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
63 // SAN-DAG: attributes #[[#GOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}
64 // MACSAN-DAG: attributes #[[#GOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}