xref: /llvm-project/clang/test/CodeGen/PowerPC/aix-init-priority-attribute.cpp (revision 39db5e1ed87363a9ffea81e53520b542201b3262)
1*39db5e1eSNikita Popov // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s | \
2f563bd74SQiu Chaofan // RUN:   FileCheck %s
3*39db5e1eSNikita Popov // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s | \
4f563bd74SQiu Chaofan // RUN:   FileCheck %s
5f563bd74SQiu Chaofan 
6f563bd74SQiu Chaofan struct test {
testtest7f563bd74SQiu Chaofan   test() {}
~testtest8f563bd74SQiu Chaofan   ~test() {}
9f563bd74SQiu Chaofan };
10f563bd74SQiu Chaofan 
11f563bd74SQiu Chaofan __attribute__((init_priority(200)))
12f563bd74SQiu Chaofan test t1;
13f563bd74SQiu Chaofan __attribute__((init_priority(200)))
14f563bd74SQiu Chaofan test t2;
15f563bd74SQiu Chaofan __attribute__((init_priority(300)))
16f563bd74SQiu Chaofan test t3;
17f563bd74SQiu Chaofan __attribute__((init_priority(150)))
18f563bd74SQiu Chaofan test t4;
19f563bd74SQiu Chaofan test t5;
20f563bd74SQiu Chaofan 
21*39db5e1eSNikita Popov // CHECK: @llvm.global_ctors = appending global [4 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 150, ptr @_GLOBAL__I_000150, ptr null }, { i32, ptr, ptr } { i32 200, ptr @_GLOBAL__I_000200, ptr null }, { i32, ptr, ptr } { i32 300, ptr @_GLOBAL__I_000300, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }]
22*39db5e1eSNikita Popov // CHECK: @llvm.global_dtors = appending global [4 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 150, ptr @_GLOBAL__a_000150, ptr null }, { i32, ptr, ptr } { i32 200, ptr @_GLOBAL__a_000200, ptr null }, { i32, ptr, ptr } { i32 300, ptr @_GLOBAL__a_000300, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__D_a, ptr null }]
23f563bd74SQiu Chaofan 
24f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__I_000150() [[ATTR:#[0-9]+]] {
25f563bd74SQiu Chaofan // CHECK: entry:
26f563bd74SQiu Chaofan // CHECK:   call void @__cxx_global_var_init.3()
27f563bd74SQiu Chaofan // CHECK:   ret void
28f563bd74SQiu Chaofan // CHECK: }
29f563bd74SQiu Chaofan 
30f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__I_000200() [[ATTR:#[0-9]+]] {
31f563bd74SQiu Chaofan // CHECK: entry:
32f563bd74SQiu Chaofan // CHECK:   call void @__cxx_global_var_init()
33f563bd74SQiu Chaofan // CHECK:   call void @__cxx_global_var_init.1()
34f563bd74SQiu Chaofan // CHECK:   ret void
35f563bd74SQiu Chaofan // CHECK: }
36f563bd74SQiu Chaofan 
37f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__I_000300() [[ATTR:#[0-9]+]] {
38f563bd74SQiu Chaofan // CHECK: entry:
39f563bd74SQiu Chaofan // CHECK:   call void @__cxx_global_var_init.2()
40f563bd74SQiu Chaofan // CHECK:   ret void
41f563bd74SQiu Chaofan // CHECK: }
42f563bd74SQiu Chaofan 
43f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__sub_I__() [[ATTR:#[0-9]+]] {
44f563bd74SQiu Chaofan // CHECK: entry:
45f563bd74SQiu Chaofan // CHECK:   call void @__cxx_global_var_init.4()
46f563bd74SQiu Chaofan // CHECK:   ret void
47f563bd74SQiu Chaofan // CHECK: }
48f563bd74SQiu Chaofan 
49f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__a_000150() [[ATTR:#[0-9]+]] {
50f563bd74SQiu Chaofan // CHECK: entry:
51f563bd74SQiu Chaofan // CHECK:   call void @__finalize_t4()
52f563bd74SQiu Chaofan // CHECK:   ret void
53f563bd74SQiu Chaofan // CHECK: }
54f563bd74SQiu Chaofan 
55f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__a_000200() [[ATTR:#[0-9]+]] {
56f563bd74SQiu Chaofan // CHECK: entry:
57f563bd74SQiu Chaofan // CHECK:   call void @__finalize_t2()
58f563bd74SQiu Chaofan // CHECK:   call void @__finalize_t1()
59f563bd74SQiu Chaofan // CHECK:   ret void
60f563bd74SQiu Chaofan // CHECK: }
61f563bd74SQiu Chaofan 
62f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__a_000300() [[ATTR:#[0-9]+]] {
63f563bd74SQiu Chaofan // CHECK: entry:
64f563bd74SQiu Chaofan // CHECK:   call void @__finalize_t3()
65f563bd74SQiu Chaofan // CHECK:   ret void
66f563bd74SQiu Chaofan // CHECK: }
67f563bd74SQiu Chaofan 
68f563bd74SQiu Chaofan // CHECK: define internal void @_GLOBAL__D_a() [[ATTR:#[0-9]+]] {
69f563bd74SQiu Chaofan // CHECK: entry:
70f563bd74SQiu Chaofan // CHECK:   call void @__finalize_t5()
71f563bd74SQiu Chaofan // CHECK:   ret void
72f563bd74SQiu Chaofan // CHECK: }
73