1 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
2 // RUN: -std=c++2a < %s | \
3 // RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s
5 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
6 // RUN: -std=c++2a < %s | \
7 // RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s
17 int foo() { return 3; }
37 static Test4 staticLocal
;
41 // CHECK: @_ZGVZN5test41fEvE11staticLocal = internal global i64 0, align 8
42 // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }]
43 // CHECK: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__D_a, ptr null }]
45 // CHECK: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]+]] {
47 // CHECK: call void @_ZN5test15Test1C1Ev(ptr {{[^,]*}} @_ZN5test12t1E)
48 // CHECK: %0 = call i32 @atexit(ptr @__dtor__ZN5test12t1E)
52 // CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] {
54 // CHECK: call void @_ZN5test15Test1D1Ev(ptr @_ZN5test12t1E)
58 // CHECK: declare i32 @atexit(ptr)
60 // CHECK: define internal void @__finalize__ZN5test12t1E() [[ATTR:#[0-9]+]] {
62 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test12t1E)
63 // CHECK: %needs_destruct = icmp eq i32 %0, 0
64 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
66 // CHECK: destruct.call:
67 // CHECK: call void @__dtor__ZN5test12t1E()
68 // CHECK: br label %destruct.end
70 // CHECK: destruct.end:
74 // CHECK: declare i32 @unatexit(ptr)
76 // CHECK: define internal void @__cxx_global_var_init.1() [[ATTR:#[0-9]+]] {
78 // CHECK: call void @_ZN5test15Test1C1Ev(ptr {{[^,]*}} @_ZN5test12t2E)
79 // CHECK: %0 = call i32 @atexit(ptr @__dtor__ZN5test12t2E)
83 // CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
85 // CHECK: call void @_ZN5test15Test1D1Ev(ptr @_ZN5test12t2E)
89 // CHECK: define internal void @__finalize__ZN5test12t2E() [[ATTR:#[0-9]+]] {
91 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test12t2E)
92 // CHECK: %needs_destruct = icmp eq i32 %0, 0
93 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
95 // CHECK: destruct.call:
96 // CHECK: call void @__dtor__ZN5test12t2E()
97 // CHECK: br label %destruct.end
99 // CHECK: destruct.end:
103 // CHECK: define internal void @__cxx_global_var_init.2() [[ATTR:#[0-9]+]] {
105 // CHECK32: %call = call noundef i32 @_ZN5test23fooEv()
106 // CHECK64: %call = call noundef signext i32 @_ZN5test23fooEv()
107 // CHECK: store i32 %call, ptr @_ZN5test21xE
111 // CHECK: define internal void @__cxx_global_var_init.3() [[ATTR:#[0-9]+]] {
113 // CHECK: %0 = call i32 @atexit(ptr @__dtor__ZN5test31tE)
117 // CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] {
119 // CHECK: call void @_ZN5test35Test3D1Ev(ptr @_ZN5test31tE)
123 // CHECK: define internal void @__finalize__ZN5test31tE() [[ATTR:#[0-9]+]] {
125 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test31tE)
126 // CHECK: %needs_destruct = icmp eq i32 %0, 0
127 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
129 // CHECK: destruct.call:
130 // CHECK: call void @__dtor__ZN5test31tE()
131 // CHECK: br label %destruct.end
133 // CHECK: destruct.end:
137 // CHECK: define void @_ZN5test41fEv() [[ATTR:#[0-9]+]] {
139 // CHECK: %0 = load atomic i8, ptr @_ZGVZN5test41fEvE11staticLocal acquire, align 8
140 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0
141 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end
143 // CHECK: init.check:
144 // CHECK: %1 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN5test41fEvE11staticLocal)
145 // CHECK: %tobool = icmp ne i32 %1, 0
146 // CHECK: br i1 %tobool, label %init, label %init.end
149 // CHECK: call void @_ZN5test45Test4C1Ev(ptr {{[^,]*}} @_ZZN5test41fEvE11staticLocal)
150 // CHECK: %2 = call i32 @atexit(ptr @__dtor__ZZN5test41fEvE11staticLocal)
151 // CHECK: call void @__cxa_guard_release(ptr @_ZGVZN5test41fEvE11staticLocal)
152 // CHECK: br label %init.end
158 // CHECK: define internal void @__dtor__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] {
160 // CHECK: call void @_ZN5test45Test4D1Ev(ptr @_ZZN5test41fEvE11staticLocal)
164 // CHECK: define internal void @__finalize__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] {
166 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZZN5test41fEvE11staticLocal)
167 // CHECK: %needs_destruct = icmp eq i32 %0, 0
168 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
170 // CHECK: destruct.call:
171 // CHECK: call void @__dtor__ZZN5test41fEvE11staticLocal()
172 // CHECK: br label %destruct.end
174 // CHECK: destruct.end:
178 // CHECK: define internal void @_GLOBAL__sub_I__() [[ATTR:#[0-9]+]] {
180 // CHECK: call void @__cxx_global_var_init()
181 // CHECK: call void @__cxx_global_var_init.1()
182 // CHECK: call void @__cxx_global_var_init.2()
183 // CHECK: call void @__cxx_global_var_init.3()
187 // CHECK: define internal void @_GLOBAL__D_a() [[ATTR:#[0-9]+]] {
189 // CHECK: call void @__finalize__ZZN5test41fEvE11staticLocal()
190 // CHECK: call void @__finalize__ZN5test31tE()
191 // CHECK: call void @__finalize__ZN5test12t2E()
192 // CHECK: call void @__finalize__ZN5test12t1E()