1 ; RUN: llc < %s -emulated-tls -march=x86 -mtriple=i386-linux-gnu | FileCheck -check-prefix=X32 %s
2 ; RUN: llc < %s -emulated-tls -march=x86-64 -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s
3 ; RUN: llc < %s -emulated-tls -march=x86 -mtriple=x86-linux-android | FileCheck -check-prefix=X32 %s
4 ; RUN: llc < %s -emulated-tls -march=x86-64 -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
6 ; Copied from tls.ll; emulated TLS model is not implemented
7 ; for *-pc-win32 and *-pc-winows targets yet.
9 ; Use my_emutls_get_address like __emutls_get_address.
10 @my_emutls_v_xyz = external global i8*, align 4
11 declare i8* @my_emutls_get_address(i8*)
13 define i32 @my_get_xyz() {
14 ; X32-LABEL: my_get_xyz:
15 ; X32: movl $my_emutls_v_xyz, (%esp)
16 ; X32-NEXT: calll my_emutls_get_address
17 ; X32-NEXT: movl (%eax), %eax
18 ; X32-NEXT: addl $12, %esp
20 ; X64-LABEL: my_get_xyz:
21 ; X64: movl $my_emutls_v_xyz, %edi
22 ; X64-NEXT: callq my_emutls_get_address
23 ; X64-NEXT: movl (%rax), %eax
28 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
29 %0 = bitcast i8* %call to i32*
30 %1 = load i32, i32* %0, align 4
34 @i1 = thread_local global i32 15
35 @i2 = external thread_local global i32
36 @i3 = internal thread_local global i32 15
37 @i4 = hidden thread_local global i32 15
38 @i5 = external hidden thread_local global i32
39 @s1 = thread_local global i16 15
40 @b1 = thread_local global i8 0
44 ; X32: movl $__emutls_v.i1, (%esp)
45 ; X32-NEXT: calll __emutls_get_address
46 ; X32-NEXT: movl (%eax), %eax
47 ; X32-NEXT: addl $12, %esp
50 ; X64: movl $__emutls_v.i1, %edi
51 ; X64-NEXT: callq __emutls_get_address
52 ; X64-NEXT: movl (%rax), %eax
57 %tmp1 = load i32, i32* @i1
63 ; X32: movl $__emutls_v.i1, (%esp)
64 ; X32-NEXT: calll __emutls_get_address
65 ; X32-NEXT: addl $12, %esp
68 ; X64: movl $__emutls_v.i1, %edi
69 ; X64-NEXT: callq __emutls_get_address
77 define i32 @f3() nounwind {
79 ; X32: movl $__emutls_v.i2, (%esp)
80 ; X32-NEXT: calll __emutls_get_address
81 ; X32-NEXT: movl (%eax), %eax
82 ; X32-NEXT: addl $12, %esp
86 %tmp1 = load i32, i32* @i2
92 ; X32: movl $__emutls_v.i2, (%esp)
93 ; X32-NEXT: calll __emutls_get_address
94 ; X32-NEXT: addl $12, %esp
101 define i32 @f5() nounwind {
103 ; X32: movl $__emutls_v.i3, (%esp)
104 ; X32-NEXT: calll __emutls_get_address
105 ; X32-NEXT: movl (%eax), %eax
106 ; X32-NEXT: addl $12, %esp
110 %tmp1 = load i32, i32* @i3
116 ; X32: movl $__emutls_v.i3, (%esp)
117 ; X32-NEXT: calll __emutls_get_address
118 ; X32-NEXT: addl $12, %esp
127 ; X32: movl $__emutls_v.i4, (%esp)
128 ; X32-NEXT: calll __emutls_get_address
129 ; X32-NEXT: movl (%eax), %eax
130 ; X32-NEXT: addl $12, %esp
134 %tmp1 = load i32, i32* @i4
140 ; X32: movl $__emutls_v.i4, (%esp)
141 ; X32-NEXT: calll __emutls_get_address
142 ; X32-NEXT: addl $12, %esp
151 ; X32: movl $__emutls_v.i5, (%esp)
152 ; X32-NEXT: calll __emutls_get_address
153 ; X32-NEXT: movl (%eax), %eax
154 ; X32-NEXT: addl $12, %esp
158 %tmp1 = load i32, i32* @i5
164 ; X32: movl $__emutls_v.i5, (%esp)
165 ; X32-NEXT: calll __emutls_get_address
166 ; X32-NEXT: addl $12, %esp
175 ; X32: movl $__emutls_v.s1, (%esp)
176 ; X32-NEXT: calll __emutls_get_address
177 ; X32-NEXT: movzwl (%eax), %eax
178 ; X32-NEXT: addl $12, %esp
182 %tmp1 = load i16, i16* @s1
188 ; X32: movl $__emutls_v.s1, (%esp)
189 ; X32-NEXT: calll __emutls_get_address
190 ; X32-NEXT: movswl (%eax), %eax
191 ; X32-NEXT: addl $12, %esp
195 %tmp1 = load i16, i16* @s1
196 %tmp2 = sext i16 %tmp1 to i32
202 ; X32: movl $__emutls_v.b1, (%esp)
203 ; X32-NEXT: calll __emutls_get_address
204 ; X32-NEXT: movb (%eax), %al
205 ; X32-NEXT: addl $12, %esp
209 %tmp1 = load i8, i8* @b1
215 ; X32: movl $__emutls_v.b1, (%esp)
216 ; X32-NEXT: calll __emutls_get_address
217 ; X32-NEXT: movsbl (%eax), %eax
218 ; X32-NEXT: addl $12, %esp
222 %tmp1 = load i8, i8* @b1
223 %tmp2 = sext i8 %tmp1 to i32
227 ;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.
229 ; X32 .section .data.rel.local,
230 ; X32-LABEL: __emutls_v.i1:
234 ; X32-NEXT: .long __emutls_t.i1
236 ; X32 .section .rodata,
237 ; X32-LABEL: __emutls_t.i1:
240 ; X32-NOT: __emutls_v.i2
242 ; X32 .section .data.rel.local,
243 ; X32-LABEL: __emutls_v.i3:
247 ; X32-NEXT: .long __emutls_t.i3
249 ; X32 .section .rodata,
250 ; X32-LABEL: __emutls_t.i3:
253 ; X32 .section .data.rel.local,
254 ; X32-LABEL: __emutls_v.i4:
258 ; X32-NEXT: .long __emutls_t.i4
260 ; X32 .section .rodata,
261 ; X32-LABEL: __emutls_t.i4:
264 ; X32-NOT: __emutls_v.i5:
265 ; X32 .hidden __emutls_v.i5
266 ; X32-NOT: __emutls_v.i5:
268 ; X32 .section .data.rel.local,
269 ; X32-LABEL: __emutls_v.s1:
273 ; X32-NEXT: .long __emutls_t.s1
275 ; X32 .section .rodata,
276 ; X32-LABEL: __emutls_t.s1:
277 ; X32-NEXT: .short 15
279 ; X32 .section .data.rel.local,
280 ; X32-LABEL: __emutls_v.b1:
286 ; X32-NOT: __emutls_t.b1
288 ;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.
290 ; X64 .section .data.rel.local,
291 ; X64-LABEL: __emutls_v.i1:
295 ; X64-NEXT: .quad __emutls_t.i1
297 ; X64 .section .rodata,
298 ; X64-LABEL: __emutls_t.i1:
301 ; X64-NOT: __emutls_v.i2
303 ; X64 .section .data.rel.local,
304 ; X64-LABEL: __emutls_v.i3:
308 ; X64-NEXT: .quad __emutls_t.i3
310 ; X64 .section .rodata,
311 ; X64-LABEL: __emutls_t.i3:
314 ; X64 .section .data.rel.local,
315 ; X64-LABEL: __emutls_v.i4:
319 ; X64-NEXT: .quad __emutls_t.i4
321 ; X64 .section .rodata,
322 ; X64-LABEL: __emutls_t.i4:
325 ; X64-NOT: __emutls_v.i5:
326 ; X64 .hidden __emutls_v.i5
327 ; X64-NOT: __emutls_v.i5:
329 ; X64 .section .data.rel.local,
330 ; X64-LABEL: __emutls_v.s1:
334 ; X64-NEXT: .quad __emutls_t.s1
336 ; X64 .section .rodata,
337 ; X64-LABEL: __emutls_t.s1:
338 ; X64-NEXT: .short 15
340 ; X64 .section .data.rel.local,
341 ; X64-LABEL: __emutls_v.b1:
347 ; X64-NOT: __emutls_t.b1