1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=cfi-icall -o - %s | FileCheck %s 2 3 #if !__has_builtin(__builtin_function_start) 4 #error "missing __builtin_function_start" 5 #endif 6 a(void)7void a(void) {} 8 // CHECK: @e = global ptr no_cfi @_Z1av 9 const void *e = __builtin_function_start(a); 10 11 constexpr void (*d)() = &a; 12 // CHECK: @f = global ptr no_cfi @_Z1av 13 const void *f = __builtin_function_start(d); 14 b(void)15void b(void) {} 16 // CHECK: @g = global [2 x ptr] [ptr @_Z1bv, ptr no_cfi @_Z1bv] 17 void *g[] = {(void *)b, __builtin_function_start(b)}; 18 c(void * p)19void c(void *p) {} 20 21 class A { 22 public: 23 void f(); 24 virtual void g(); 25 static void h(); 26 int i() const; 27 int i(int n) const; 28 }; 29 f()30void A::f() {} g()31void A::g() {} h()32void A::h() {} 33 34 // CHECK: define {{.*}}i32 @_ZNK1A1iEv(ptr {{.*}}%this) i() const35int A::i() const { return 0; } 36 37 // CHECK: define {{.*}}i32 @_ZNK1A1iEi(ptr noundef {{.*}}%this, i32 noundef %n) i(int n) const38int A::i(int n) const { return 0; } 39 h(void)40void h(void) { 41 // CHECK: store ptr no_cfi @_Z1bv, ptr %g 42 void *g = __builtin_function_start(b); 43 // CHECK: call void @_Z1cPv(ptr noundef no_cfi @_Z1av) 44 c(__builtin_function_start(a)); 45 46 // CHECK: store ptr no_cfi @_ZN1A1fEv, ptr %Af 47 void *Af = __builtin_function_start(&A::f); 48 // CHECK: store ptr no_cfi @_ZN1A1gEv, ptr %Ag 49 void *Ag = __builtin_function_start(&A::g); 50 // CHECK: store ptr no_cfi @_ZN1A1hEv, ptr %Ah 51 void *Ah = __builtin_function_start(&A::h); 52 // CHECK: store ptr no_cfi @_ZNK1A1iEv, ptr %Ai1 53 void *Ai1 = __builtin_function_start((int(A::*)() const) & A::i); 54 // CHECK: store ptr no_cfi @_ZNK1A1iEi, ptr %Ai2 55 void *Ai2 = __builtin_function_start((int(A::*)(int) const) & A::i); 56 } 57