1 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -Wno-strict-prototypes -Wno-incompatible-function-pointer-types -fcf-protection=branch -triple i386-linux-gnu %s -o - | FileCheck %s
3 // CHECK: @t5 = weak{{.*}} global i32 2
4 int t5
__attribute__((weak
)) = 2;
6 // CHECK: @t13 ={{.*}} global %struct.s0 zeroinitializer, section "SECT"
8 struct s0 t13
__attribute__((section("SECT"))) = { 0 };
10 // CHECK: @t14.x = internal global i32 0, section "SECT"
12 static int x
__attribute__((section("SECT"))) = 0;
15 // CHECK: @t18 ={{.*}} global i32 1, align 4
16 extern int t18
__attribute__((weak_import
));
19 // CHECK: @t16 = extern_weak global i32
20 extern int t16
__attribute__((weak_import
));
22 // CHECK: @t6 = protected global i32 0
23 int t6
__attribute__((visibility("protected")));
25 // CHECK: @t12 ={{.*}} global i32 0, section "SECT"
26 int t12
__attribute__((section("SECT")));
28 // CHECK: @t9 = weak{{.*}} alias void (...), bitcast (void ()* @__t8 to void (...)*)
30 void t9() __attribute__((weak
, alias("__t8")));
32 // CHECK: declare extern_weak i32 @t15()
33 int __attribute__((weak_import
)) t15(void);
38 // CHECK: define{{.*}} void @t1() [[NR:#[0-9]+]] {
39 void t1(void) __attribute__((noreturn
));
40 void t1(void) { while (1) {} }
42 // CHECK: define{{.*}} void @t2() [[NUW:#[0-9]+]] {
43 void t2(void) __attribute__((nothrow
));
46 // CHECK: define weak{{.*}} void @t3() [[NUW]] {
47 void t3(void) __attribute__((weak
));
50 // CHECK: define hidden void @t4() [[NUW]] {
51 void t4(void) __attribute__((visibility("hidden")));
54 // CHECK: define{{.*}} void @t7() [[NR]] {
55 void t7(void) __attribute__((noreturn
, nothrow
));
56 void t7(void) { while (1) {} }
58 // CHECK: define{{.*}} void @t72() [[COLDDEF:#[0-9]+]] {
59 void t71(void) __attribute__((cold
));
60 void t72(void) __attribute__((cold
));
61 void t72(void) { t71(); }
62 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
63 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
65 // CHECK: define{{.*}} void @t82() [[HOTDEF:#[0-9]+]] {
66 void t81(void) __attribute__((hot
));
67 void t82(void) __attribute__((hot
));
68 void t82(void) { t81(); }
69 // CHECK: call void @t81() [[HOTSITE:#[0-9]+]]
70 // CHECK: declare void @t81() [[HOTDECL:#[0-9]+]]
72 // CHECK: define{{.*}} void @t10() [[NUW]] section "xSECT" {
73 void t10(void) __attribute__((section("xSECT")));
75 // CHECK: define{{.*}} void @t11() [[NUW]] section "xSECT" {
76 void __attribute__((section("xSECT"))) t11(void) {}
78 // CHECK: define{{.*}} i32 @t19() [[NUW]] {
79 extern int t19(void) __attribute__((weak_import
));
84 // CHECK:define{{.*}} void @t20() [[NUW]] {
85 // CHECK: call void @abort()
86 // CHECK-NEXT: unreachable
91 void (__attribute__((fastcall
)) *fptr
)(int);
95 // CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)*, void (i32)** @fptr
96 // CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 inreg noundef 10)
99 // PR9356: We might want to err on this, but for now at least make sure we
100 // use the section in the definition.
101 void __attribute__((section(".foo"))) t22(void);
102 void __attribute__((section(".bar"))) t22(void) {}
104 // CHECK: define{{.*}} void @t22() [[NUW]] section ".bar"
106 // CHECK: define{{.*}} void @t23() [[NOCF_CHECK_FUNC:#[0-9]+]]
107 void __attribute__((nocf_check
)) t23(void) {}
109 // CHECK: call void %{{[a-z0-9]+}}() [[NOCF_CHECK_CALL:#[0-9]+]]
110 typedef void (*f_t
)(void);
112 __attribute__((nocf_check
)) f_t p
= f1
;
116 // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
117 // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
118 // CHECK: attributes [[COLDDEF]] = { cold {{.*}}}
119 // CHECK: attributes [[COLDDECL]] = { cold {{.*}}}
120 // CHECK: attributes [[HOTDEF]] = { hot {{.*}}}
121 // CHECK: attributes [[HOTDECL]] = { hot {{.*}}}
122 // CHECK: attributes [[NOCF_CHECK_FUNC]] = { nocf_check {{.*}}}
123 // CHECK: attributes [[COLDSITE]] = { cold {{.*}}}
124 // CHECK: attributes [[HOTSITE]] = { hot {{.*}}}
125 // CHECK: attributes [[NOCF_CHECK_CALL]] = { nocf_check }