79 lines · c
1// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s3// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN4// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN5// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsanitize=memory -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN6// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s7// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s8// RUN: %clang_cc1 -triple arm64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s9// RUN: %clang_cc1 -triple x86_64-apple-macosx -O2 -emit-llvm -o - %s | FileCheck %s10// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN11// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN12// RUN: %clang_cc1 -triple arm64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN13// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN14// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=AVR15// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s16// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s17// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN18// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN19 20 21/// The ifunc is emitted before its resolver.22int foo(int) __attribute__ ((ifunc("foo_ifunc")));23 24static int f1(int i) {25 return i + 1;26}27 28static int f2(int i) {29 return i + 2;30}31 32typedef int (*foo_t)(int);33 34int global;35 36static foo_t foo_ifunc(void) {37 return global ? f1 : f2;38}39 40int bar(void) {41 return foo(1);42}43 44extern void goo(void);45 46void bar2(void) {47 goo();48}49 50extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));51 52void* goo_ifunc(void) {53 return 0;54}55 56/// The ifunc is emitted after its resolver.57void *hoo_ifunc(void) { return 0; }58extern void hoo(int) __attribute__ ((ifunc("hoo_ifunc")));59 60// CHECK: @foo = ifunc i32 (i32), ptr @foo_ifunc61// CHECK: @goo = ifunc void (), ptr @goo_ifunc62// CHECK: @hoo = ifunc void (i32), ptr @hoo_ifunc63 64// AVR: @foo = ifunc i16 (i16), ptr addrspace(1) @foo_ifunc65// AVR: @goo = ifunc void (), ptr addrspace(1) @goo_ifunc66// AVR: @hoo = ifunc void (i16), ptr addrspace(1) @hoo_ifunc67 68// CHECK: call i32 @foo(i3269// CHECK: call void @goo()70 71// SAN: define {{(dso_local )?}}noalias {{(noundef )?}}ptr @goo_ifunc() #[[#GOO_IFUNC:]] {72 73// SAN: define {{(dso_local )?}}noalias {{(noundef )?}}ptr @hoo_ifunc() #[[#GOO_IFUNC]] {74 75// SAN: define internal {{(noundef )?}}nonnull ptr @foo_ifunc() #[[#FOO_IFUNC:]] {76 77// SAN-DAG: attributes #[[#GOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}78// SAN-DAG: attributes #[[#FOO_IFUNC]] = {{{.*}} disable_sanitizer_instrumentation {{.*}}79