1 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu | FileCheck -check-prefix=X86 %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=X86 %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=X86 %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 ptr, align 4
18 declare ptr @my_emutls_get_address(ptr)
20 define dso_local i32 @my_get_xyz() {
21 ; X86-LABEL: my_get_xyz:
22 ; X86: movl $my_emutls_v_xyz, (%esp)
23 ; X86-NEXT: calll my_emutls_get_address
24 ; X86-NEXT: movl (%eax), %eax
25 ; X86-NEXT: addl $12, %esp
26 ; X86-NEXT: .cfi_def_cfa_offset 4
29 ; X64-LABEL: my_get_xyz:
30 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
31 ; X64-NEXT: callq my_emutls_get_address
32 ; X64-NEXT: movl (%rax), %eax
34 ; X64-NEXT: .cfi_def_cfa_offset 8
37 %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz)
38 %0 = load i32, ptr %call, align 4
42 @i1 = dso_local thread_local global i32 15
43 @i2 = external thread_local global i32
44 @i3 = internal thread_local global i32 15
45 @i4 = hidden thread_local global i32 15
46 @i5 = external hidden thread_local global i32
47 @s1 = dso_local thread_local global i16 15
48 @b1 = dso_local thread_local global i8 0
50 define dso_local i32 @f1() {
52 ; X86: movl $__emutls_v.i1, (%esp)
53 ; X86-NEXT: calll __emutls_get_address
54 ; X86-NEXT: movl (%eax), %eax
55 ; X86-NEXT: addl $12, %esp
56 ; X86-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
67 %tmp1 = load i32, ptr @i1
71 define dso_local ptr @f2() {
73 ; X86: movl $__emutls_v.i1, (%esp)
74 ; X86-NEXT: calll __emutls_get_address
75 ; X86-NEXT: addl $12, %esp
76 ; X86-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
89 define dso_local i32 @f3() nounwind {
91 ; X86: movl $__emutls_v.i2, (%esp)
92 ; X86-NEXT: calll __emutls_get_address
93 ; X86-NEXT: movl (%eax), %eax
94 ; X86-NEXT: addl $12, %esp
97 %tmp1 = load i32, ptr @i2
101 define dso_local ptr @f4() {
103 ; X86: movl $__emutls_v.i2, (%esp)
104 ; X86-NEXT: calll __emutls_get_address
105 ; X86-NEXT: addl $12, %esp
106 ; X86-NEXT: .cfi_def_cfa_offset 4
112 define dso_local i32 @f5() nounwind {
114 ; X86: movl $__emutls_v.i3, (%esp)
115 ; X86-NEXT: calll __emutls_get_address
116 ; X86-NEXT: movl (%eax), %eax
117 ; X86-NEXT: addl $12, %esp
120 %tmp1 = load i32, ptr @i3
124 define dso_local ptr @f6() {
126 ; X86: movl $__emutls_v.i3, (%esp)
127 ; X86-NEXT: calll __emutls_get_address
128 ; X86-NEXT: addl $12, %esp
129 ; X86-NEXT: .cfi_def_cfa_offset 4
135 define dso_local i32 @f7() {
137 ; X86: movl $__emutls_v.i4, (%esp)
138 ; X86-NEXT: calll __emutls_get_address
139 ; X86-NEXT: movl (%eax), %eax
140 ; X86-NEXT: addl $12, %esp
141 ; X86-NEXT: .cfi_def_cfa_offset 4
144 %tmp1 = load i32, ptr @i4
148 define dso_local ptr @f8() {
150 ; X86: movl $__emutls_v.i4, (%esp)
151 ; X86-NEXT: calll __emutls_get_address
152 ; X86-NEXT: addl $12, %esp
153 ; X86-NEXT: .cfi_def_cfa_offset 4
159 define dso_local i32 @f9() {
161 ; X86: movl $__emutls_v.i5, (%esp)
162 ; X86-NEXT: calll __emutls_get_address
163 ; X86-NEXT: movl (%eax), %eax
164 ; X86-NEXT: addl $12, %esp
165 ; X86-NEXT: .cfi_def_cfa_offset 4
168 %tmp1 = load i32, ptr @i5
172 define dso_local ptr @f10() {
174 ; X86: movl $__emutls_v.i5, (%esp)
175 ; X86-NEXT: calll __emutls_get_address
176 ; X86-NEXT: addl $12, %esp
177 ; X86-NEXT: .cfi_def_cfa_offset 4
183 define dso_local i16 @f11() {
185 ; X86: movl $__emutls_v.s1, (%esp)
186 ; X86-NEXT: calll __emutls_get_address
187 ; X86-NEXT: movzwl (%eax), %eax
188 ; X86-NEXT: addl $12, %esp
189 ; X86-NEXT: .cfi_def_cfa_offset 4
192 %tmp1 = load i16, ptr @s1
196 define dso_local i32 @f12() {
198 ; X86: movl $__emutls_v.s1, (%esp)
199 ; X86-NEXT: calll __emutls_get_address
200 ; X86-NEXT: movswl (%eax), %eax
201 ; X86-NEXT: addl $12, %esp
202 ; X86-NEXT: .cfi_def_cfa_offset 4
205 %tmp1 = load i16, ptr @s1
206 %tmp2 = sext i16 %tmp1 to i32
210 define dso_local i8 @f13() {
212 ; X86: movl $__emutls_v.b1, (%esp)
213 ; X86-NEXT: calll __emutls_get_address
214 ; X86-NEXT: movzbl (%eax), %eax
215 ; X86-NEXT: addl $12, %esp
216 ; X86-NEXT: .cfi_def_cfa_offset 4
219 %tmp1 = load i8, ptr @b1
223 define dso_local i32 @f14() {
225 ; X86: movl $__emutls_v.b1, (%esp)
226 ; X86-NEXT: calll __emutls_get_address
227 ; X86-NEXT: movsbl (%eax), %eax
228 ; X86-NEXT: addl $12, %esp
229 ; X86-NEXT: .cfi_def_cfa_offset 4
232 %tmp1 = load i8, ptr @b1
233 %tmp2 = sext i8 %tmp1 to i32
237 ;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.
239 ; X86-LABEL: __emutls_v.i1:
243 ; X86-NEXT: .long __emutls_t.i1
245 ; X86-LABEL: __emutls_t.i1:
248 ; X86-NOT: __emutls_v.i2
250 ; X86-LABEL: __emutls_v.i3:
254 ; X86-NEXT: .long __emutls_t.i3
256 ; X86-LABEL: __emutls_t.i3:
259 ; X86-LABEL: __emutls_v.i4:
263 ; X86-NEXT: .long __emutls_t.i4
265 ; X86-LABEL: __emutls_t.i4:
268 ; X86-NOT: __emutls_v.i5:
269 ; X86: .hidden __emutls_v.i5
270 ; X86-NOT: __emutls_v.i5:
272 ; X86-LABEL: __emutls_v.s1:
276 ; X86-NEXT: .long __emutls_t.s1
278 ; X86-LABEL: __emutls_t.s1:
279 ; X86-NEXT: .short 15
281 ; X86-LABEL: __emutls_v.b1:
287 ; X86-NOT: __emutls_t.b1
289 ;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.
291 ; X64-LABEL: __emutls_v.i1:
295 ; X64-NEXT: .quad __emutls_t.i1
297 ; X64-LABEL: __emutls_t.i1:
300 ; X64-NOT: __emutls_v.i2
302 ; X64-LABEL: __emutls_v.i3:
306 ; X64-NEXT: .quad __emutls_t.i3
308 ; X64-LABEL: __emutls_t.i3:
311 ; X64-LABEL: __emutls_v.i4:
315 ; X64-NEXT: .quad __emutls_t.i4
317 ; X64-LABEL: __emutls_t.i4:
320 ; X64-NOT: __emutls_v.i5:
321 ; X64: .hidden __emutls_v.i5
322 ; X64-NOT: __emutls_v.i5:
324 ; X64-LABEL: __emutls_v.s1:
328 ; X64-NEXT: .quad __emutls_t.s1
330 ; X64-LABEL: __emutls_t.s1:
331 ; X64-NEXT: .short 15
333 ; X64-LABEL: __emutls_v.b1:
339 ; X64-NOT: __emutls_t.b1