Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / cxx11-thread-local.cpp
blob1a6e289c9c2bd4957d99af12e9534fe329db9dad
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
2 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
3 // RUN: %clang_cc1 -std=c++11 -femulated-tls -emit-llvm %s -o - \
4 // RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
5 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
6 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple powerpc64-unknown-aix-xcoff | FileCheck --check-prefixes=CHECK,AIX,LINUX_AIX %s
8 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
9 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX,CHECK-OPT %s
10 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -femulated-tls -emit-llvm %s -o - \
11 // RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefixes=CHECK,LINUX,LINUX_AIX %s
12 // RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
14 int f();
15 int g();
17 // LINUX_AIX-DAG: @a ={{.*}} thread_local global i32 0
18 // DARWIN-DAG: @a = internal thread_local global i32 0
19 thread_local int a = f();
20 extern thread_local int b;
21 // CHECK-DAG: @c ={{.*}} global i32 0
22 int c = b;
23 // CHECK-DAG: @_ZL1d = internal thread_local global i32 0
24 static thread_local int d = g();
26 struct U { static thread_local int m; };
27 // LINUX_AIX-DAG: @_ZN1U1mE ={{.*}} thread_local global i32 0
28 // DARWIN-DAG: @_ZN1U1mE = internal thread_local global i32 0
29 thread_local int U::m = f();
31 namespace MismatchedInitType {
32 // Check that we don't crash here when we're forced to create a new global
33 // variable (with a different type) when we add the initializer.
34 union U {
35 int a;
36 float f;
37 constexpr U() : f(0.0) {}
39 static thread_local U u;
40 void *p = &u;
43 template<typename T> struct V { static thread_local int m; };
44 template<typename T> thread_local int V<T>::m = g();
46 template<typename T> struct W { static thread_local int m; };
47 template<typename T> thread_local int W<T>::m = 123;
49 struct Dtor { ~Dtor(); };
50 template<typename T> struct X { static thread_local Dtor m; };
51 template<typename T> thread_local Dtor X<T>::m;
53 // CHECK-DAG: @e ={{.*}} global
54 void *e = V<int>::m + W<int>::m + &X<int>::m;
56 template thread_local int V<float>::m;
57 template thread_local int W<float>::m;
58 template thread_local Dtor X<float>::m;
60 extern template thread_local int V<char>::m;
61 extern template thread_local int W<char>::m;
62 extern template thread_local Dtor X<char>::m;
64 void *e2 = V<char>::m + W<char>::m + &X<char>::m;
66 // CHECK-DAG: @_ZN1VIiE1mE = linkonce_odr thread_local global i32 0
67 // CHECK-DAG: @_ZN1WIiE1mE = linkonce_odr thread_local global i32 123
68 // CHECK-DAG: @_ZN1XIiE1mE = linkonce_odr thread_local global {{.*}}
69 // CHECK-DAG: @_ZN1VIfE1mE = weak_odr thread_local global i32 0
70 // CHECK-DAG: @_ZN1WIfE1mE = weak_odr thread_local global i32 123
71 // CHECK-DAG: @_ZN1XIfE1mE = weak_odr thread_local global {{.*}}
73 // CHECK-DAG: @_ZZ1fvE1n = internal thread_local global i32 0
75 // CHECK-DAG: @_ZGVZ1fvE1n = internal thread_local global i8 0
77 // CHECK-DAG: @_ZZ8tls_dtorvE1s = internal thread_local global
78 // CHECK-DAG: @_ZGVZ8tls_dtorvE1s = internal thread_local global i8 0
80 // CHECK-DAG: @_ZZ8tls_dtorvE1t = internal thread_local global
81 // CHECK-DAG: @_ZGVZ8tls_dtorvE1t = internal thread_local global i8 0
83 // CHECK-DAG: @_ZZ8tls_dtorvE1u = internal thread_local global
84 // CHECK-DAG: @_ZGVZ8tls_dtorvE1u = internal thread_local global i8 0
85 // CHECK-DAG: @_ZGRZ8tls_dtorvE1u_ = internal thread_local global
87 // CHECK-DAG: @_ZGVN1VIiE1mE = linkonce_odr thread_local global i64 0
89 // CHECK-DAG: @__tls_guard = internal thread_local global i8 0
91 // CHECK-DAG: @llvm.global_ctors = appending global {{.*}} @[[GLOBAL_INIT:[^ ]*]]
93 // LINUX_AIX-DAG: @_ZTH1a ={{.*}} alias void (), ptr @__tls_init
94 // DARWIN-DAG: @_ZTH1a = internal alias void (), ptr @__tls_init
95 // LINUX_AIX-DAG: @_ZTHN1U1mE ={{.*}} alias void (), ptr @__tls_init
96 // DARWIN-DAG: @_ZTHN1U1mE = internal alias void (), ptr @__tls_init
97 // CHECK-DAG: @_ZTHN1VIiE1mE = linkonce_odr alias void (), ptr @[[V_M_INIT:[^, ]*]]
98 // CHECK-DAG: @_ZTHN1XIiE1mE = linkonce_odr alias void (), ptr @[[X_M_INIT:[^, ]*]]
99 // CHECK-DAG: @_ZTHN1VIfE1mE = weak_odr alias void (), ptr @[[VF_M_INIT:[^, ]*]]
100 // CHECK-DAG: @_ZTHN1XIfE1mE = weak_odr alias void (), ptr @[[XF_M_INIT:[^, ]*]]
101 // FIXME: We really want a CHECK-DAG-NOT for these.
102 // CHECK-NOT: @_ZTHN1WIiE1mE =
103 // CHECK-NOT: @_ZTHN1WIfE1mE =
104 // CHECK-NOT: @_ZTHL1d =
107 // Individual variable initialization functions:
109 // CHECK: define {{.*}} @[[A_INIT:.*]]()
110 // CHECK: call{{.*}} i32 @_Z1fv()
111 // CHECK: [[A_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @a)
112 // CHECK-NEXT: store i32 {{.*}}, ptr [[A_ADDR]], align 4
114 // CHECK-LABEL: define{{.*}} i32 @_Z1fv()
115 int f() {
116 // CHECK: %[[GUARD:.*]] = load i8, ptr @_ZGVZ1fvE1n, align 1
117 // CHECK: %[[NEED_INIT:.*]] = icmp eq i8 %[[GUARD]], 0
118 // CHECK: br i1 %[[NEED_INIT]]{{.*}}
120 // CHECK: %[[CALL:.*]] = call{{.*}} i32 @_Z1gv()
121 // CHECK: [[N_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZZ1fvE1n)
122 // CHECK: store i32 %[[CALL]], ptr [[N_ADDR]], align 4
123 // CHECK: store i8 1, ptr @_ZGVZ1fvE1n
124 // CHECK: br label
125 static thread_local int n = g();
127 // CHECK: [[N_ADDR2:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZZ1fvE1n)
128 // CHECK: load i32, ptr [[N_ADDR2]], align 4
129 return n;
132 // CHECK: define {{.*}} @[[C_INIT:.*]]()
133 // LINUX_AIX: call ptr @_ZTW1b()
134 // DARWIN: call cxx_fast_tlscc ptr @_ZTW1b()
135 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
136 // CHECK-NEXT: store i32 %{{.*}}, ptr @c, align 4
138 // LINUX_AIX-LABEL: define linkonce_odr hidden noundef ptr @_ZTW1b()
139 // LINUX: br i1 icmp ne (ptr @_ZTH1b, ptr null),
140 // AIX-NOT: br i1 icmp ne (ptr @_ZTH1b, ptr null),
141 // not null:
142 // LINUX_AIX: call void @_ZTH1b()
143 // LINUX: br label
144 // AIX-NOT: br label
145 // finally:
146 // LINUX_AIX: [[B_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @b)
147 // LINUX_AIX: ret ptr [[B_ADDR]]
148 // DARWIN-LABEL: declare cxx_fast_tlscc noundef ptr @_ZTW1b()
149 // There is no definition of the thread wrapper on Darwin for external TLV.
151 // CHECK: define {{.*}} @[[D_INIT:.*]]()
152 // CHECK: call{{.*}} i32 @_Z1gv()
153 // CHECK-NEXT: [[D_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZL1d)
154 // CHECK-NEXT: store i32 %{{.*}}, ptr [[D_ADDR]], align 4
156 // CHECK: define {{.*}} @[[U_M_INIT:.*]]()
157 // CHECK: call{{.*}} i32 @_Z1fv()
158 // CHECK-NEXT: [[UM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1U1mE)
159 // CHECK-NEXT: store i32 %{{.*}}, ptr [[UM_ADDR]], align 4
161 // CHECK: define {{.*}} @[[E_INIT:.*]]()
162 // LINUX_AIX: call ptr @_ZTWN1VIiE1mE()
163 // DARWIN: call cxx_fast_tlscc ptr @_ZTWN1VIiE1mE()
164 // CHECK-NEXT: load i32, ptr %{{.*}}, align 4
165 // LINUX_AIX: call ptr @_ZTWN1XIiE1mE()
166 // DARWIN: call cxx_fast_tlscc ptr @_ZTWN1XIiE1mE()
167 // CHECK: store {{.*}} @e
169 // LINUX_AIX-LABEL: define weak_odr hidden noundef ptr @_ZTWN1VIiE1mE()
170 // DARWIN-LABEL: define weak_odr hidden cxx_fast_tlscc noundef ptr @_ZTWN1VIiE1mE()
171 // LINUX_AIX: call void @_ZTHN1VIiE1mE()
172 // DARWIN: call cxx_fast_tlscc void @_ZTHN1VIiE1mE()
173 // CHECK: [[VM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1VIiE1mE)
174 // CHECK: ret ptr [[VM_ADDR]]
176 // LINUX_AIX-LABEL: define weak_odr hidden noundef ptr @_ZTWN1WIiE1mE()
177 // DARWIN-LABEL: define weak_odr hidden cxx_fast_tlscc noundef ptr @_ZTWN1WIiE1mE()
178 // CHECK-NOT: call
179 // CHECK: [[WM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1WIiE1mE)
180 // CHECK: ret ptr [[WM_ADDR]]
182 // LINUX_AIX-LABEL: define weak_odr hidden {{.*}}ptr @_ZTWN1XIiE1mE()
183 // DARWIN-LABEL: define weak_odr hidden cxx_fast_tlscc {{.*}}ptr @_ZTWN1XIiE1mE()
184 // LINUX_AIX: call void @_ZTHN1XIiE1mE()
185 // DARWIN: call cxx_fast_tlscc void @_ZTHN1XIiE1mE()
186 // CHECK: [[XM_ADDR:%.+]] = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @_ZN1XIiE1mE)
187 // CHECK: ret ptr [[XM_ADDR]]
189 // LINUX_AIX: define internal void @[[VF_M_INIT]]()
190 // DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
191 // CHECK-NOT: comdat
192 // CHECK: load i8, ptr @_ZGVN1VIfE1mE
193 // CHECK: %[[VF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
194 // CHECK: br i1 %[[VF_M_INITIALIZED]],
195 // need init:
196 // CHECK: store i8 1, ptr @_ZGVN1VIfE1mE
197 // CHECK: call{{.*}} i32 @_Z1gv()
198 // CHECK: [[VFM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1VIfE1mE)
199 // CHECK: store i32 %{{.*}}, ptr [[VFM_ADDR]], align 4
200 // CHECK: br label
202 // LINUX_AIX: define internal void @[[XF_M_INIT]]()
203 // DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
204 // CHECK-NOT: comdat
205 // CHECK: load i8, ptr @_ZGVN1XIfE1mE
206 // CHECK: %[[XF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
207 // CHECK: br i1 %[[XF_M_INITIALIZED]],
208 // need init:
209 // CHECK: store i8 1, ptr @_ZGVN1XIfE1mE
210 // AIX-NOT: br
211 // LINUX: call {{.*}}__cxa_thread_atexit
212 // AIX: call {{.*}}__pt_atexit_np
213 // DARWIN: call {{.*}}_tlv_atexit
214 // CHECK: br label
216 // LINUX: declare i32 @__cxa_thread_atexit(ptr, ptr, ptr)
217 // AIX: declare i32 @__pt_atexit_np(i32, ptr, ...)
218 // DARWIN: declare i32 @_tlv_atexit(ptr, ptr, ptr)
220 // DARWIN: declare cxx_fast_tlscc noundef ptr @_ZTWN1VIcE1mE()
221 // LINUX_AIX: define linkonce_odr hidden noundef ptr @_ZTWN1VIcE1mE() {{#[0-9]+}}{{( comdat)?}} {
222 // LINUX: br i1 icmp ne (ptr @_ZTHN1VIcE1mE,
223 // AIX-NOT: br i1 icmp ne (ptr @_ZTHN1VIcE1mE
224 // LINUX_AIX: call void @_ZTHN1VIcE1mE()
225 // LINUX_AIX: [[VEM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1VIcE1mE)
226 // LINUX_AIX: ret ptr [[VEM_ADDR]]
228 // DARWIN: declare cxx_fast_tlscc noundef ptr @_ZTWN1WIcE1mE()
229 // LINUX_AIX: define linkonce_odr hidden noundef ptr @_ZTWN1WIcE1mE() {{#[0-9]+}}{{( comdat)?}} {
230 // LINUX: br i1 icmp ne (ptr @_ZTHN1WIcE1mE,
231 // AIX-NOT: br i1 icmp ne (ptr @_ZTHN1WIcE1mE,
232 // LINUX_AIX: call void @_ZTHN1WIcE1mE()
233 // LINUX_AIX: [[WEM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1WIcE1mE)
234 // LINUX_AIX: ret ptr [[WEM_ADDR]]
236 // DARWIN: declare cxx_fast_tlscc {{.*}}ptr @_ZTWN1XIcE1mE()
237 // LINUX_AIX: define linkonce_odr hidden {{.*}}ptr @_ZTWN1XIcE1mE() {{#[0-9]+}}{{( comdat)?}} {
238 // LINUX: br i1 icmp ne (ptr @_ZTHN1XIcE1mE,
239 // AIX-NOT: br i1 icmp ne (ptr @_ZTHN1XIcE1mE,
240 // LINUX_AIX: call void @_ZTHN1XIcE1mE()
241 // LINUX_AIX: [[XEM_ADDR:%.+]] = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @_ZN1XIcE1mE)
242 // LINUX_AIX: ret ptr [[XEM_ADDR]]
244 struct S { S(); ~S(); };
245 struct T { ~T(); };
247 // CHECK-LABEL: define{{.*}} void @_Z8tls_dtorv()
248 void tls_dtor() {
249 // CHECK: load i8, ptr @_ZGVZ8tls_dtorvE1s
250 // CHECK: call void @_ZN1SC1Ev(ptr {{[^,]*}} @_ZZ8tls_dtorvE1s)
251 // LINUX: call i32 @__cxa_thread_atexit({{.*}}@_ZN1SD1Ev, {{.*}} @_ZZ8tls_dtorvE1s{{.*}} @__dso_handle
252 // AIX: call i32 (i32, ptr, ...) @__pt_atexit_np(i32 0, {{.*}}@__dtor__ZZ8tls_dtorvE1s){{.*}}
253 // DARWIN: call i32 @_tlv_atexit({{.*}}@_ZN1SD1Ev, {{.*}} @_ZZ8tls_dtorvE1s{{.*}} @__dso_handle
254 // CHECK: store i8 1, ptr @_ZGVZ8tls_dtorvE1s
255 static thread_local S s;
257 // CHECK: load i8, ptr @_ZGVZ8tls_dtorvE1t
258 // CHECK-NOT: _ZN1T
259 // LINUX: call i32 @__cxa_thread_atexit({{.*}}@_ZN1TD1Ev, {{.*}}@_ZZ8tls_dtorvE1t{{.*}} @__dso_handle
260 // AIX: call i32 (i32, ptr, ...) @__pt_atexit_np(i32 0, {{.*}}@__dtor__ZZ8tls_dtorvE1t){{.*}}
261 // DARWIN: call i32 @_tlv_atexit({{.*}}@_ZN1TD1Ev, {{.*}}@_ZZ8tls_dtorvE1t{{.*}} @__dso_handle
262 // CHECK: store i8 1, ptr @_ZGVZ8tls_dtorvE1t
263 static thread_local T t;
265 // CHECK: load i8, ptr @_ZGVZ8tls_dtorvE1u
266 // CHECK: call void @_ZN1SC1Ev(ptr {{[^,]*}} @_ZGRZ8tls_dtorvE1u_)
267 // LINUX: call i32 @__cxa_thread_atexit({{.*}}@_ZN1SD1Ev, {{.*}} @_ZGRZ8tls_dtorvE1u_{{.*}} @__dso_handle
268 // AIX: call i32 (i32, ptr, ...) @__pt_atexit_np(i32 0, {{.*}}__dtor__ZZ8tls_dtorvE1u){{.*}}
269 // DARWIN: call i32 @_tlv_atexit({{.*}}@_ZN1SD1Ev, {{.*}} @_ZGRZ8tls_dtorvE1u_{{.*}} @__dso_handle
270 // CHECK: store i8 1, ptr @_ZGVZ8tls_dtorvE1u
271 static thread_local const S &u = S();
274 // AIX: define {{.*}}@__dtor__ZZ8tls_dtorvE1s(i32 noundef signext %0, ...){{.*}}{
275 // AIX: entry:
276 // AIX: %.addr = alloca i32, align 4
277 // AIX: store i32 %0, ptr %.addr, align 4
278 // AIX: call void @_ZN1SD1Ev(ptr @_ZZ8tls_dtorvE1s)
279 // AIX: ret i32 0
280 // AIX: }
282 // AIX: define {{.*}}@__dtor__ZZ8tls_dtorvE1t(i32 noundef signext %0, ...){{.*}}{
283 // AIX: entry:
284 // AIX: %.addr = alloca i32, align 4
285 // AIX: store i32 %0, ptr %.addr, align 4
286 // AIX: call void @_ZN1TD1Ev(ptr @_ZZ8tls_dtorvE1t)
287 // AIX: ret i32 0
288 // AIX: }
290 // AIX: define {{.*}}@__dtor__ZZ8tls_dtorvE1u(i32 noundef signext %0, ...){{.*}}{
291 // AIX: entry:
292 // AIX: %.addr = alloca i32, align 4
293 // AIX: store i32 %0, ptr %.addr, align 4
294 // AIX: call void @_ZN1SD1Ev(ptr @_ZGRZ8tls_dtorvE1u_)
295 // AIX: ret i32 0
296 // AIX: }
298 // CHECK: define {{.*}} @_Z7PR15991v(
299 int PR15991() {
300 thread_local int n;
301 auto l = [] { return n; };
302 return l();
305 struct PR19254 {
306 static thread_local int n;
307 int f();
309 // CHECK: define {{.*}} @_ZN7PR192541fEv(
310 int PR19254::f() {
311 // LINUX_AIX: call void @_ZTHN7PR192541nE(
312 // DARWIN: call cxx_fast_tlscc ptr @_ZTWN7PR192541nE(
313 return this->n;
316 namespace {
317 thread_local int anon_i{f()};
319 void set_anon_i() {
320 anon_i = 2;
322 // LINUX_AIX-LABEL: define internal noundef ptr @_ZTWN12_GLOBAL__N_16anon_iE()
323 // DARWIN-LABEL: define internal cxx_fast_tlscc noundef ptr @_ZTWN12_GLOBAL__N_16anon_iE()
325 // LINUX_AIX: define internal void @[[V_M_INIT]]()
326 // DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
327 // CHECK-NOT: comdat
328 // CHECK: load i8, ptr @_ZGVN1VIiE1mE
329 // CHECK: %[[V_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
330 // CHECK: br i1 %[[V_M_INITIALIZED]],
331 // need init:
332 // CHECK: store i8 1, ptr @_ZGVN1VIiE1mE
333 // CHECK: call{{.*}} i32 @_Z1gv()
334 // CHECK: [[VEM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1VIiE1mE)
335 // CHECK: store i32 %{{.*}}, ptr [[VEM_ADDR]], align 4
336 // CHECK: br label
338 // LINUX_AIX: define internal void @[[X_M_INIT]]()
339 // DARWIN: define internal cxx_fast_tlscc void @[[X_M_INIT]]()
340 // CHECK-NOT: comdat
341 // CHECK: load i8, ptr @_ZGVN1XIiE1mE
342 // CHECK: %[[X_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
343 // CHECK: br i1 %[[X_M_INITIALIZED]],
344 // need init:
345 // CHECK: store i8 1, ptr @_ZGVN1XIiE1mE
346 // LINUX: call {{.*}}__cxa_thread_atexit
347 // AIX: call {{.*}}__pt_atexit_np
348 // DARWIN: call {{.*}}_tlv_atexit
349 // CHECK: br label
351 // CHECK: define {{.*}}@[[GLOBAL_INIT:.*]]()
352 // CHECK: call void @[[C_INIT]]()
353 // CHECK: call void @[[E_INIT]]()
356 // CHECK: define {{.*}}@__tls_init()
357 // CHECK: load i8, ptr @__tls_guard
358 // CHECK: %[[NEED_TLS_INIT:.*]] = icmp eq i8 %{{.*}}, 0
359 // CHECK: br i1 %[[NEED_TLS_INIT]],
360 // init:
361 // CHECK: store i8 1, ptr @__tls_guard
362 // CHECK-OPT: call ptr @llvm.invariant.start.p0(i64 1, ptr @__tls_guard)
363 // CHECK-NOT: call void @[[V_M_INIT]]()
364 // CHECK: call void @[[A_INIT]]()
365 // CHECK-NOT: call void @[[V_M_INIT]]()
366 // CHECK: call void @[[D_INIT]]()
367 // CHECK-NOT: call void @[[V_M_INIT]]()
368 // CHECK: call void @[[U_M_INIT]]()
369 // CHECK-NOT: call void @[[V_M_INIT]]()
372 // LINUX_AIX: define weak_odr hidden noundef ptr @_ZTW1a()
373 // DARWIN: define cxx_fast_tlscc noundef ptr @_ZTW1a()
374 // LINUX_AIX: call void @_ZTH1a()
375 // DARWIN: call cxx_fast_tlscc void @_ZTH1a()
376 // CHECK: [[A_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @a)
377 // CHECK: ret ptr [[A_ADDR]]
378 // CHECK: }
381 // Should not emit a thread wrapper for internal-linkage unused variable 'd'.
382 // We separately check that 'd' does in fact get initialized with the other
383 // thread-local variables in this TU.
384 // CHECK-NOT: define {{.*}} @_ZTWL1d()
386 // LINUX_AIX-LABEL: define weak_odr hidden noundef ptr @_ZTWN1U1mE()
387 // DARWIN-LABEL: define cxx_fast_tlscc noundef ptr @_ZTWN1U1mE()
388 // LINUX_AIX: call void @_ZTHN1U1mE()
389 // DARWIN: call cxx_fast_tlscc void @_ZTHN1U1mE()
390 // CHECK: [[UM_ADDR:%.+]] = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @_ZN1U1mE)
391 // CHECK: ret ptr [[UM_ADDR]]
393 // LINUX_AIX: declare extern_weak void @_ZTH1b() [[ATTR:#[0-9]+]]
395 // AIX: define linkonce_odr void @_ZTHN1WIiE1mE(){{.*}} {
396 // AIX-NEXT: ret void
397 // AIX-NEXT: }
398 // CHECK-NOT: @_ZTHN1WIfE1mE =
399 // AIX: define weak_odr void @_ZTHN1WIfE1mE(){{.*}} {
400 // AIX-NEXT: ret void
401 // AIX-NEXT: }
403 // LINUX_AIX: attributes [[ATTR]] = { {{.+}} }