1 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X86 %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=X86 %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=x86_64-linux-android29 -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
9 ; RUN: llc < %s -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X86 %s
10 ; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
11 ; RUN: llc < %s -mtriple=i386-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X86 %s
12 ; RUN: llc < %s -mtriple=x86_64-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X64 %s
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 i32 @my_get_xyz() {
21 ; X86-LABEL: my_get_xyz:
22 ; X86: movl my_emutls_v_xyz@GOT(%ebx), %eax
23 ; X86-NEXT: movl %eax, (%esp)
24 ; X86-NEXT: calll my_emutls_get_address@PLT
25 ; X64-LABEL: my_get_xyz:
26 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
27 ; X64-NEXT: callq my_emutls_get_address@PLT
28 ; X64-NEXT: movl (%rax), %eax
31 %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz)
32 %0 = load i32, ptr %call, align 4
36 @i = thread_local global i32 15
37 @j = internal thread_local global i32 42
38 @k = internal thread_local global i32 0, align 8
42 %tmp1 = load i32, ptr @i
47 ; X86: movl __emutls_v.i@GOT(%ebx), %eax
48 ; X86-NEXT: movl %eax, (%esp)
49 ; X86-NEXT: calll __emutls_get_address@PLT
51 ; X64: movq __emutls_v.i@GOTPCREL(%rip), %rdi
52 ; X64-NEXT: callq __emutls_get_address@PLT
53 ; X64-NEXT: movl (%rax), %eax
55 @i2 = external thread_local global i32
68 %tmp1 = load i32, ptr @i ; <i32> [#uses=1]
76 define ptr @f4() nounwind {
85 define i32 @f5() nounwind {
87 %0 = load i32, ptr @j, align 4
88 %1 = load i32, ptr @k, align 4
89 %add = add nsw i32 %0, %1
94 ; X86: leal __emutls_v.j@GOTOFF(%ebx), %eax
95 ; X86-NEXT: movl %eax, (%esp)
96 ; X86-NEXT: calll __emutls_get_address@PLT
97 ; X86-NEXT: movl (%eax), %esi
98 ; X86-NEXT: leal __emutls_v.k@GOTOFF(%ebx), %eax
99 ; X86-NEXT: movl %eax, (%esp)
100 ; X86-NEXT: calll __emutls_get_address@PLT
101 ; X86-NEXT: addl (%eax), %esi
102 ; X86-NEXT: movl %esi, %eax
105 ; X64: leaq __emutls_v.j(%rip), %rdi
106 ; X64-NEXT: callq __emutls_get_address@PLT
107 ; X64-NEXT: movl (%rax), %ebx
108 ; X64-NEXT: leaq __emutls_v.k(%rip), %rdi
109 ; X64-NEXT: callq __emutls_get_address@PLT
110 ; X64-NEXT: addl (%rax), %ebx
111 ; X64-NEXT: movl %ebx, %eax
116 ; X86: .globl __emutls_v.i
117 ; X86-LABEL: __emutls_v.i:
121 ; X86-NEXT: .long __emutls_t.i
123 ; X86: .section .rodata,
124 ; X86-LABEL: __emutls_t.i:
129 ; X86-LABEL: __emutls_v.j:
133 ; X86-NEXT: .long __emutls_t.j
135 ; X86: .section .rodata,
136 ; X86-LABEL: __emutls_t.j:
141 ; X86-LABEL: __emutls_v.k:
147 ; X86-NOT: __emutls_t.k:
152 ; X64: .globl __emutls_v.i
153 ; X64-LABEL: __emutls_v.i:
157 ; X64-NEXT: .quad __emutls_t.i
159 ; X64: .section .rodata,
160 ; X64-LABEL: __emutls_t.i:
165 ; X64-LABEL: __emutls_v.j:
169 ; X64-NEXT: .quad __emutls_t.j
171 ; X64: .section .rodata,
172 ; X64-LABEL: __emutls_t.j:
177 ; X64-LABEL: __emutls_v.k:
183 ; X64-NOT: __emutls_t.k: