1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=cfi-icall -o - %s | FileCheck %s
3 #if !__has_builtin(__builtin_function_start)
4 #error "missing __builtin_function_start"
8 // CHECK: @e = global ptr no_cfi @_Z1av
9 const void *e
= __builtin_function_start(a
);
11 constexpr void (*d
)() = &a
;
12 // CHECK: @f = global ptr no_cfi @_Z1av
13 const void *f
= __builtin_function_start(d
);
16 // CHECK: @g = global [2 x ptr] [ptr @_Z1bv, ptr no_cfi @_Z1bv]
17 void *g
[] = {(void *)b
, __builtin_function_start(b
)};
34 // CHECK: define {{.*}}i32 @_ZNK1A1iEv(ptr {{.*}}%this)
35 int A::i() const { return 0; }
37 // CHECK: define {{.*}}i32 @_ZNK1A1iEi(ptr noundef {{.*}}%this, i32 noundef %n)
38 int A::i(int n
) const { return 0; }
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
));
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
);