1 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu | FileCheck -check-prefix=X32 %s
2 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s
3 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
4 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
6 ; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck -check-prefix=NoEMU %s
7 ; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=NoEMU %s
8 ; RUN: llc < %s -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
9 ; RUN: llc < %s -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
11 ; Copied from tls.ll; emulated TLS model is not implemented
12 ; for *-pc-win32 and *-pc-windows targets yet.
16 ; Use my_emutls_get_address like __emutls_get_address.
17 @my_emutls_v_xyz = external global i8*, align 4
18 declare i8* @my_emutls_get_address(i8*)
20 define i32 @my_get_xyz() {
21 ; X32-LABEL: my_get_xyz:
22 ; X32: movl $my_emutls_v_xyz, (%esp)
23 ; X32-NEXT: calll my_emutls_get_address
24 ; X32-NEXT: movl (%eax), %eax
25 ; X32-NEXT: addl $12, %esp
26 ; X32-NEXT: .cfi_def_cfa_offset 4
28 ; X64-LABEL: my_get_xyz:
29 ; X64: movl $my_emutls_v_xyz, %edi
30 ; X64-NEXT: callq my_emutls_get_address
31 ; X64-NEXT: movl (%rax), %eax
33 ; X64-NEXT: .cfi_def_cfa_offset 8
37 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
38 %0 = bitcast i8* %call to i32*
39 %1 = load i32, i32* %0, align 4
43 @i1 = thread_local global i32 15
44 @i2 = external thread_local global i32
45 @i3 = internal thread_local global i32 15
46 @i4 = hidden thread_local global i32 15
47 @i5 = external hidden thread_local global i32
48 @s1 = thread_local global i16 15
49 @b1 = thread_local global i8 0
53 ; X32: movl $__emutls_v.i1, (%esp)
54 ; X32-NEXT: calll __emutls_get_address
55 ; X32-NEXT: movl (%eax), %eax
56 ; X32-NEXT: addl $12, %esp
57 ; X32-NEXT: .cfi_def_cfa_offset 4
60 ; X64: movl $__emutls_v.i1, %edi
61 ; X64-NEXT: callq __emutls_get_address
62 ; X64-NEXT: movl (%rax), %eax
64 ; X64-NEXT: .cfi_def_cfa_offset 8
68 %tmp1 = load i32, i32* @i1
74 ; X32: movl $__emutls_v.i1, (%esp)
75 ; X32-NEXT: calll __emutls_get_address
76 ; X32-NEXT: addl $12, %esp
77 ; X32-NEXT: .cfi_def_cfa_offset 4
80 ; X64: movl $__emutls_v.i1, %edi
81 ; X64-NEXT: callq __emutls_get_address
83 ; X64-NEXT: .cfi_def_cfa_offset 8
90 define i32 @f3() nounwind {
92 ; X32: movl $__emutls_v.i2, (%esp)
93 ; X32-NEXT: calll __emutls_get_address
94 ; X32-NEXT: movl (%eax), %eax
95 ; X32-NEXT: addl $12, %esp
99 %tmp1 = load i32, i32* @i2
105 ; X32: movl $__emutls_v.i2, (%esp)
106 ; X32-NEXT: calll __emutls_get_address
107 ; X32-NEXT: addl $12, %esp
108 ; X32-NEXT: .cfi_def_cfa_offset 4
115 define i32 @f5() nounwind {
117 ; X32: movl $__emutls_v.i3, (%esp)
118 ; X32-NEXT: calll __emutls_get_address
119 ; X32-NEXT: movl (%eax), %eax
120 ; X32-NEXT: addl $12, %esp
124 %tmp1 = load i32, i32* @i3
130 ; X32: movl $__emutls_v.i3, (%esp)
131 ; X32-NEXT: calll __emutls_get_address
132 ; X32-NEXT: addl $12, %esp
133 ; X32-NEXT: .cfi_def_cfa_offset 4
142 ; X32: movl $__emutls_v.i4, (%esp)
143 ; X32-NEXT: calll __emutls_get_address
144 ; X32-NEXT: movl (%eax), %eax
145 ; X32-NEXT: addl $12, %esp
146 ; X32-NEXT: .cfi_def_cfa_offset 4
150 %tmp1 = load i32, i32* @i4
156 ; X32: movl $__emutls_v.i4, (%esp)
157 ; X32-NEXT: calll __emutls_get_address
158 ; X32-NEXT: addl $12, %esp
159 ; X32-NEXT: .cfi_def_cfa_offset 4
168 ; X32: movl $__emutls_v.i5, (%esp)
169 ; X32-NEXT: calll __emutls_get_address
170 ; X32-NEXT: movl (%eax), %eax
171 ; X32-NEXT: addl $12, %esp
172 ; X32-NEXT: .cfi_def_cfa_offset 4
176 %tmp1 = load i32, i32* @i5
182 ; X32: movl $__emutls_v.i5, (%esp)
183 ; X32-NEXT: calll __emutls_get_address
184 ; X32-NEXT: addl $12, %esp
185 ; X32-NEXT: .cfi_def_cfa_offset 4
194 ; X32: movl $__emutls_v.s1, (%esp)
195 ; X32-NEXT: calll __emutls_get_address
196 ; X32-NEXT: movzwl (%eax), %eax
197 ; X32-NEXT: addl $12, %esp
198 ; X32-NEXT: .cfi_def_cfa_offset 4
202 %tmp1 = load i16, i16* @s1
208 ; X32: movl $__emutls_v.s1, (%esp)
209 ; X32-NEXT: calll __emutls_get_address
210 ; X32-NEXT: movswl (%eax), %eax
211 ; X32-NEXT: addl $12, %esp
212 ; X32-NEXT: .cfi_def_cfa_offset 4
216 %tmp1 = load i16, i16* @s1
217 %tmp2 = sext i16 %tmp1 to i32
223 ; X32: movl $__emutls_v.b1, (%esp)
224 ; X32-NEXT: calll __emutls_get_address
225 ; X32-NEXT: movb (%eax), %al
226 ; X32-NEXT: addl $12, %esp
227 ; X32-NEXT: .cfi_def_cfa_offset 4
231 %tmp1 = load i8, i8* @b1
237 ; X32: movl $__emutls_v.b1, (%esp)
238 ; X32-NEXT: calll __emutls_get_address
239 ; X32-NEXT: movsbl (%eax), %eax
240 ; X32-NEXT: addl $12, %esp
241 ; X32-NEXT: .cfi_def_cfa_offset 4
245 %tmp1 = load i8, i8* @b1
246 %tmp2 = sext i8 %tmp1 to i32
250 ;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.
252 ; X32 .section .data.rel.local,
253 ; X32-LABEL: __emutls_v.i1:
257 ; X32-NEXT: .long __emutls_t.i1
259 ; X32 .section .rodata,
260 ; X32-LABEL: __emutls_t.i1:
263 ; X32-NOT: __emutls_v.i2
265 ; X32 .section .data.rel.local,
266 ; X32-LABEL: __emutls_v.i3:
270 ; X32-NEXT: .long __emutls_t.i3
272 ; X32 .section .rodata,
273 ; X32-LABEL: __emutls_t.i3:
276 ; X32 .section .data.rel.local,
277 ; X32-LABEL: __emutls_v.i4:
281 ; X32-NEXT: .long __emutls_t.i4
283 ; X32 .section .rodata,
284 ; X32-LABEL: __emutls_t.i4:
287 ; X32-NOT: __emutls_v.i5:
288 ; X32 .hidden __emutls_v.i5
289 ; X32-NOT: __emutls_v.i5:
291 ; X32 .section .data.rel.local,
292 ; X32-LABEL: __emutls_v.s1:
296 ; X32-NEXT: .long __emutls_t.s1
298 ; X32 .section .rodata,
299 ; X32-LABEL: __emutls_t.s1:
300 ; X32-NEXT: .short 15
302 ; X32 .section .data.rel.local,
303 ; X32-LABEL: __emutls_v.b1:
309 ; X32-NOT: __emutls_t.b1
311 ;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.
313 ; X64 .section .data.rel.local,
314 ; X64-LABEL: __emutls_v.i1:
318 ; X64-NEXT: .quad __emutls_t.i1
320 ; X64 .section .rodata,
321 ; X64-LABEL: __emutls_t.i1:
324 ; X64-NOT: __emutls_v.i2
326 ; X64 .section .data.rel.local,
327 ; X64-LABEL: __emutls_v.i3:
331 ; X64-NEXT: .quad __emutls_t.i3
333 ; X64 .section .rodata,
334 ; X64-LABEL: __emutls_t.i3:
337 ; X64 .section .data.rel.local,
338 ; X64-LABEL: __emutls_v.i4:
342 ; X64-NEXT: .quad __emutls_t.i4
344 ; X64 .section .rodata,
345 ; X64-LABEL: __emutls_t.i4:
348 ; X64-NOT: __emutls_v.i5:
349 ; X64 .hidden __emutls_v.i5
350 ; X64-NOT: __emutls_v.i5:
352 ; X64 .section .data.rel.local,
353 ; X64-LABEL: __emutls_v.s1:
357 ; X64-NEXT: .quad __emutls_t.s1
359 ; X64 .section .rodata,
360 ; X64-LABEL: __emutls_t.s1:
361 ; X64-NEXT: .short 15
363 ; X64 .section .data.rel.local,
364 ; X64-LABEL: __emutls_v.b1:
370 ; X64-NOT: __emutls_t.b1