1 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X32 %s
2 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64 %s
3 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X32 %s
4 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
6 ; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
7 ; RUN: llc < %s -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
8 ; RUN: llc < %s -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X32 %s
9 ; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
13 ; Use my_emutls_get_address like __emutls_get_address.
14 @my_emutls_v_xyz = external global i8*, align 4
15 declare i8* @my_emutls_get_address(i8*)
17 define i32 @my_get_xyz() {
18 ; X32-LABEL: my_get_xyz:
19 ; X32: movl my_emutls_v_xyz@GOT(%ebx), %eax
20 ; X32-NEXT: movl %eax, (%esp)
21 ; X32-NEXT: calll my_emutls_get_address@PLT
22 ; X64-LABEL: my_get_xyz:
23 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
24 ; X64-NEXT: callq my_emutls_get_address@PLT
25 ; 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 @i = thread_local global i32 15
35 @j = internal thread_local global i32 42
36 @k = internal thread_local global i32 0, align 8
40 %tmp1 = load i32, i32* @i
45 ; X32: movl __emutls_v.i@GOT(%ebx), %eax
46 ; X32-NEXT: movl %eax, (%esp)
47 ; X32-NEXT: calll __emutls_get_address@PLT
49 ; X64: movq __emutls_v.i@GOTPCREL(%rip), %rdi
50 ; X64-NEXT: callq __emutls_get_address@PLT
51 ; X64-NEXT: movl (%rax), %eax
53 @i2 = external thread_local global i32
66 %tmp1 = load i32, i32* @i ; <i32> [#uses=1]
74 define i32* @f4() nounwind {
83 define i32 @f5() nounwind {
85 %0 = load i32, i32* @j, align 4
86 %1 = load i32, i32* @k, align 4
87 %add = add nsw i32 %0, %1
92 ; X32: leal __emutls_v.j@GOTOFF(%ebx), %eax
93 ; X32-NEXT: movl %eax, (%esp)
94 ; X32-NEXT: calll __emutls_get_address@PLT
95 ; X32-NEXT: movl (%eax), %esi
96 ; X32-NEXT: leal __emutls_v.k@GOTOFF(%ebx), %eax
97 ; X32-NEXT: movl %eax, (%esp)
98 ; X32-NEXT: calll __emutls_get_address@PLT
99 ; X32-NEXT: addl (%eax), %esi
100 ; X32-NEXT: movl %esi, %eax
103 ; X64: leaq __emutls_v.j(%rip), %rdi
104 ; X64-NEXT: callq __emutls_get_address@PLT
105 ; X64-NEXT: movl (%rax), %ebx
106 ; X64-NEXT: leaq __emutls_v.k(%rip), %rdi
107 ; X64-NEXT: callq __emutls_get_address@PLT
108 ; X64-NEXT: addl (%rax), %ebx
109 ; X64-NEXT: movl %ebx, %eax
114 ; X32: .globl __emutls_v.i
115 ; X32-LABEL: __emutls_v.i:
119 ; X32-NEXT: .long __emutls_t.i
121 ; X32: .section .rodata,
122 ; X32-LABEL: __emutls_t.i:
127 ; X32-LABEL: __emutls_v.j:
131 ; X32-NEXT: .long __emutls_t.j
133 ; X32: .section .rodata,
134 ; X32-LABEL: __emutls_t.j:
139 ; X32-LABEL: __emutls_v.k:
145 ; X32-NOT: __emutls_t.k:
150 ; X64: .globl __emutls_v.i
151 ; X64-LABEL: __emutls_v.i:
155 ; X64-NEXT: .quad __emutls_t.i
157 ; X64: .section .rodata,
158 ; X64-LABEL: __emutls_t.i:
163 ; X64-LABEL: __emutls_v.j:
167 ; X64-NEXT: .quad __emutls_t.j
169 ; X64: .section .rodata,
170 ; X64-LABEL: __emutls_t.j:
175 ; X64-LABEL: __emutls_v.k:
181 ; X64-NOT: __emutls_t.k: