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 i8*, align 4
18 declare i8* @my_emutls_get_address(i8*)
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 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 = dso_local 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 = dso_local thread_local global i16 15
49 @b1 = dso_local thread_local global i8 0
51 define dso_local i32 @f1() {
53 ; X86: movl $__emutls_v.i1, (%esp)
54 ; X86-NEXT: calll __emutls_get_address
55 ; X86-NEXT: movl (%eax), %eax
56 ; X86-NEXT: addl $12, %esp
57 ; X86-NEXT: .cfi_def_cfa_offset 4
61 ; X64: movl $__emutls_v.i1, %edi
62 ; X64-NEXT: callq __emutls_get_address
63 ; X64-NEXT: movl (%rax), %eax
65 ; X64-NEXT: .cfi_def_cfa_offset 8
68 %tmp1 = load i32, i32* @i1
72 define dso_local i32* @f2() {
74 ; X86: movl $__emutls_v.i1, (%esp)
75 ; X86-NEXT: calll __emutls_get_address
76 ; X86-NEXT: addl $12, %esp
77 ; X86-NEXT: .cfi_def_cfa_offset 4
81 ; X64: movl $__emutls_v.i1, %edi
82 ; X64-NEXT: callq __emutls_get_address
84 ; X64-NEXT: .cfi_def_cfa_offset 8
90 define dso_local i32 @f3() nounwind {
92 ; X86: movl $__emutls_v.i2, (%esp)
93 ; X86-NEXT: calll __emutls_get_address
94 ; X86-NEXT: movl (%eax), %eax
95 ; X86-NEXT: addl $12, %esp
98 %tmp1 = load i32, i32* @i2
102 define dso_local i32* @f4() {
104 ; X86: movl $__emutls_v.i2, (%esp)
105 ; X86-NEXT: calll __emutls_get_address
106 ; X86-NEXT: addl $12, %esp
107 ; X86-NEXT: .cfi_def_cfa_offset 4
113 define dso_local i32 @f5() nounwind {
115 ; X86: movl $__emutls_v.i3, (%esp)
116 ; X86-NEXT: calll __emutls_get_address
117 ; X86-NEXT: movl (%eax), %eax
118 ; X86-NEXT: addl $12, %esp
121 %tmp1 = load i32, i32* @i3
125 define dso_local i32* @f6() {
127 ; X86: movl $__emutls_v.i3, (%esp)
128 ; X86-NEXT: calll __emutls_get_address
129 ; X86-NEXT: addl $12, %esp
130 ; X86-NEXT: .cfi_def_cfa_offset 4
136 define dso_local i32 @f7() {
138 ; X86: movl $__emutls_v.i4, (%esp)
139 ; X86-NEXT: calll __emutls_get_address
140 ; X86-NEXT: movl (%eax), %eax
141 ; X86-NEXT: addl $12, %esp
142 ; X86-NEXT: .cfi_def_cfa_offset 4
145 %tmp1 = load i32, i32* @i4
149 define dso_local i32* @f8() {
151 ; X86: movl $__emutls_v.i4, (%esp)
152 ; X86-NEXT: calll __emutls_get_address
153 ; X86-NEXT: addl $12, %esp
154 ; X86-NEXT: .cfi_def_cfa_offset 4
160 define dso_local i32 @f9() {
162 ; X86: movl $__emutls_v.i5, (%esp)
163 ; X86-NEXT: calll __emutls_get_address
164 ; X86-NEXT: movl (%eax), %eax
165 ; X86-NEXT: addl $12, %esp
166 ; X86-NEXT: .cfi_def_cfa_offset 4
169 %tmp1 = load i32, i32* @i5
173 define dso_local i32* @f10() {
175 ; X86: movl $__emutls_v.i5, (%esp)
176 ; X86-NEXT: calll __emutls_get_address
177 ; X86-NEXT: addl $12, %esp
178 ; X86-NEXT: .cfi_def_cfa_offset 4
184 define dso_local i16 @f11() {
186 ; X86: movl $__emutls_v.s1, (%esp)
187 ; X86-NEXT: calll __emutls_get_address
188 ; X86-NEXT: movzwl (%eax), %eax
189 ; X86-NEXT: addl $12, %esp
190 ; X86-NEXT: .cfi_def_cfa_offset 4
193 %tmp1 = load i16, i16* @s1
197 define dso_local i32 @f12() {
199 ; X86: movl $__emutls_v.s1, (%esp)
200 ; X86-NEXT: calll __emutls_get_address
201 ; X86-NEXT: movswl (%eax), %eax
202 ; X86-NEXT: addl $12, %esp
203 ; X86-NEXT: .cfi_def_cfa_offset 4
206 %tmp1 = load i16, i16* @s1
207 %tmp2 = sext i16 %tmp1 to i32
211 define dso_local i8 @f13() {
213 ; X86: movl $__emutls_v.b1, (%esp)
214 ; X86-NEXT: calll __emutls_get_address
215 ; X86-NEXT: movb (%eax), %al
216 ; X86-NEXT: addl $12, %esp
217 ; X86-NEXT: .cfi_def_cfa_offset 4
220 %tmp1 = load i8, i8* @b1
224 define dso_local i32 @f14() {
226 ; X86: movl $__emutls_v.b1, (%esp)
227 ; X86-NEXT: calll __emutls_get_address
228 ; X86-NEXT: movsbl (%eax), %eax
229 ; X86-NEXT: addl $12, %esp
230 ; X86-NEXT: .cfi_def_cfa_offset 4
233 %tmp1 = load i8, i8* @b1
234 %tmp2 = sext i8 %tmp1 to i32
238 ;;;;;;;;;;;;;; 32-bit __emutls_v. and __emutls_t.
240 ; X86-LABEL: __emutls_v.i1:
244 ; X86-NEXT: .long __emutls_t.i1
246 ; X86-LABEL: __emutls_t.i1:
249 ; X86-NOT: __emutls_v.i2
251 ; X86-LABEL: __emutls_v.i3:
255 ; X86-NEXT: .long __emutls_t.i3
257 ; X86-LABEL: __emutls_t.i3:
260 ; X86-LABEL: __emutls_v.i4:
264 ; X86-NEXT: .long __emutls_t.i4
266 ; X86-LABEL: __emutls_t.i4:
269 ; X86-NOT: __emutls_v.i5:
270 ; X86: .hidden __emutls_v.i5
271 ; X86-NOT: __emutls_v.i5:
273 ; X86-LABEL: __emutls_v.s1:
277 ; X86-NEXT: .long __emutls_t.s1
279 ; X86-LABEL: __emutls_t.s1:
280 ; X86-NEXT: .short 15
282 ; X86-LABEL: __emutls_v.b1:
288 ; X86-NOT: __emutls_t.b1
290 ;;;;;;;;;;;;;; 64-bit __emutls_v. and __emutls_t.
292 ; X64-LABEL: __emutls_v.i1:
296 ; X64-NEXT: .quad __emutls_t.i1
298 ; X64-LABEL: __emutls_t.i1:
301 ; X64-NOT: __emutls_v.i2
303 ; X64-LABEL: __emutls_v.i3:
307 ; X64-NEXT: .quad __emutls_t.i3
309 ; X64-LABEL: __emutls_t.i3:
312 ; X64-LABEL: __emutls_v.i4:
316 ; X64-NEXT: .quad __emutls_t.i4
318 ; X64-LABEL: __emutls_t.i4:
321 ; X64-NOT: __emutls_v.i5:
322 ; X64: .hidden __emutls_v.i5
323 ; X64-NOT: __emutls_v.i5:
325 ; X64-LABEL: __emutls_v.s1:
329 ; X64-NEXT: .quad __emutls_t.s1
331 ; X64-LABEL: __emutls_t.s1:
332 ; X64-NEXT: .short 15
334 ; X64-LABEL: __emutls_v.b1:
340 ; X64-NOT: __emutls_t.b1