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
28 template <typename
= void>
37 template A
<> A
<>::instance
;
40 A
<int> *a
= new A
<int>;
44 A
<int> A
<int>::instance
= bar();
47 // CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8
48 // CHECK: @_ZGVN5test21AIvE8instanceE = weak_odr global i64 0, align 8
49 // CHECK: @_ZGVN5test12t1IiEE = linkonce_odr global i64 0, align 8
50 // CHECK: @llvm.global_ctors = appending global [4 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.1, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.2, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.4, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }]
51 // CHECK: @llvm.global_dtors = appending global [4 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__finalize__ZN5test12t2E, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__finalize__ZN5test21AIvE8instanceE, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @__finalize__ZN5test12t1IiEE, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__D_a, ptr null }]
53 // CHECK: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]+]] {
55 // CHECK32: call void @_ZN5test15Test1C1Ei(ptr noundef{{[^,]*}} @_ZN5test12t0E, i32 noundef 2)
56 // CHECK64: call void @_ZN5test15Test1C1Ei(ptr noundef{{[^,]*}} @_ZN5test12t0E, i32 noundef signext 2)
57 // CHECK: %0 = call i32 @atexit(ptr @__dtor__ZN5test12t0E)
61 // CHECK: define internal void @__dtor__ZN5test12t0E() [[ATTR:#[0-9]+]] {
63 // CHECK: call void @_ZN5test15Test1D1Ev(ptr @_ZN5test12t0E)
67 // CHECK: define internal void @__finalize__ZN5test12t0E() [[ATTR:#[0-9]+]] {
69 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test12t0E)
70 // CHECK: %needs_destruct = icmp eq i32 %0, 0
71 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
73 // CHECK: destruct.call:
74 // CHECK: call void @__dtor__ZN5test12t0E()
75 // CHECK: br label %destruct.end
77 // CHECK: destruct.end:
81 // CHECK: define internal void @__cxx_global_var_init.1() [[ATTR:#[0-9]+]] {
83 // CHECK: %0 = load atomic i8, ptr @_ZGVN5test12t2E acquire, align 8
84 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0
85 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end
88 // CHECK: %1 = call i32 @__cxa_guard_acquire(ptr @_ZGVN5test12t2E)
89 // CHECK: %tobool = icmp ne i32 %1, 0
90 // CHECK: br i1 %tobool, label %init, label %init.end
93 // CHECK32: call void @_ZN5test15Test1C1Ei(ptr noundef{{[^,]*}} @_ZN5test12t2E, i32 noundef 2)
94 // CHECK64: call void @_ZN5test15Test1C1Ei(ptr noundef{{[^,]*}} @_ZN5test12t2E, i32 noundef signext 2)
95 // CHECK: %2 = call i32 @atexit(ptr @__dtor__ZN5test12t2E)
96 // CHECK: call void @__cxa_guard_release(ptr @_ZGVN5test12t2E)
97 // CHECK: br label %init.end
103 // CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
105 // CHECK: call void @_ZN5test15Test1D1Ev(ptr @_ZN5test12t2E)
109 // CHECK: define internal void @__finalize__ZN5test12t2E() [[ATTR:#[0-9]+]] {
111 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test12t2E)
112 // CHECK: %needs_destruct = icmp eq i32 %0, 0
113 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
115 // CHECK: destruct.call:
116 // CHECK: call void @__dtor__ZN5test12t2E()
117 // CHECK: br label %destruct.end
119 // CHECK: destruct.end:
123 // CHECK: define internal void @__cxx_global_var_init.2() [[ATTR:#[0-9]+]] {
125 // CHECK: %0 = load i8, ptr @_ZGVN5test21AIvE8instanceE, align 8
126 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0
127 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end
129 // CHECK: init.check:
130 // CHECK: store i8 1, ptr @_ZGVN5test21AIvE8instanceE, align 8
131 // CHECK: call void @_ZN5test21AIvEC1Ev(ptr {{[^,]*}} @_ZN5test21AIvE8instanceE)
132 // CHECK: %1 = call i32 @atexit(ptr @__dtor__ZN5test21AIvE8instanceE)
133 // CHECK: br label %init.end
139 // CHECK: define internal void @__dtor__ZN5test21AIvE8instanceE() [[ATTR:#[0-9]+]] {
141 // CHECK: call void @_ZN5test21AIvED1Ev(ptr @_ZN5test21AIvE8instanceE)
145 // CHECK: define internal void @__finalize__ZN5test21AIvE8instanceE() [[ATTR:#[0-9]+]] {
147 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test21AIvE8instanceE)
148 // CHECK: %needs_destruct = icmp eq i32 %0, 0
149 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
151 // CHECK: destruct.call:
152 // CHECK: call void @__dtor__ZN5test21AIvE8instanceE()
153 // CHECK: br label %destruct.end
155 // CHECK: destruct.end:
159 // CHECK: define internal void @__cxx_global_var_init.3() [[ATTR:#[0-9]+]] {
161 // CHECK: %call = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN5test23barEv()
162 // CHECK: %0 = call i32 @atexit(ptr @__dtor__ZN5test21AIiE8instanceE)
166 // CHECK: define internal void @__dtor__ZN5test21AIiE8instanceE() [[ATTR:#[0-9]+]] {
168 // CHECK: call void @_ZN5test21AIiED1Ev(ptr @_ZN5test21AIiE8instanceE)
172 // CHECK: define internal void @__finalize__ZN5test21AIiE8instanceE() [[ATTR:#[0-9]+]] {
174 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test21AIiE8instanceE)
175 // CHECK: %needs_destruct = icmp eq i32 %0, 0
176 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
178 // CHECK: destruct.call:
179 // CHECK: call void @__dtor__ZN5test21AIiE8instanceE()
180 // CHECK: br label %destruct.end
182 // CHECK: destruct.end:
186 // CHECK: define internal void @__cxx_global_var_init.4() [[ATTR:#[0-9]+]] {
188 // CHECK: %0 = load i8, ptr @_ZGVN5test12t1IiEE, align 8
189 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0
190 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end
192 // CHECK: init.check:
193 // CHECK: store i8 1, ptr @_ZGVN5test12t1IiEE, align 8
194 // CHECK32: call void @_ZN5test15Test1C1Ei(ptr {{[^,]*}} @_ZN5test12t1IiEE, i32 noundef 2)
195 // CHECK64: call void @_ZN5test15Test1C1Ei(ptr {{[^,]*}} @_ZN5test12t1IiEE, i32 noundef signext 2)
196 // CHECK: %1 = call i32 @atexit(ptr @__dtor__ZN5test12t1IiEE)
197 // CHECK: br label %init.end
203 // CHECK: define internal void @__dtor__ZN5test12t1IiEE() [[ATTR:#[0-9]+]] {
205 // CHECK: call void @_ZN5test15Test1D1Ev(ptr @_ZN5test12t1IiEE)
209 // CHECK: define internal void @__finalize__ZN5test12t1IiEE() [[ATTR:#[0-9]+]] {
211 // CHECK: %0 = call i32 @unatexit(ptr @__dtor__ZN5test12t1IiEE)
212 // CHECK: %needs_destruct = icmp eq i32 %0, 0
213 // CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end
215 // CHECK: destruct.call:
216 // CHECK: call void @__dtor__ZN5test12t1IiEE()
217 // CHECK: br label %destruct.end
219 // CHECK: destruct.end:
223 // CHECK: define internal void @_GLOBAL__sub_I__() [[ATTR:#[0-9]+]] {
225 // CHECK: call void @__cxx_global_var_init()
226 // CHECK: call void @__cxx_global_var_init.3()
230 // CHECK: define internal void @_GLOBAL__D_a() [[ATTR:#[0-9]+]] {
232 // CHECK: call void @__finalize__ZN5test21AIiE8instanceE()
233 // CHECK: call void @__finalize__ZN5test12t0E()