1 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
2 ; RUN: | FileCheck -check-prefix=X86 %s
3 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
4 ; RUN: | FileCheck -check-prefix=X64 %s
5 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \
6 ; RUN: | FileCheck -check-prefix=X86 %s
7 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
8 ; RUN: | FileCheck -check-prefix=X64 %s
10 ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
11 ; RUN: | FileCheck -check-prefix=NoEMU %s
12 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
13 ; RUN: | FileCheck -check-prefix=NoEMU %s
14 ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android29 -relocation-model=pic \
15 ; RUN: | FileCheck -check-prefix=NoEMU %s
16 ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \
17 ; RUN: | FileCheck -check-prefix=X86 %s
18 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
19 ; RUN: | FileCheck -check-prefix=X64 %s
23 ; Use my_emutls_get_address like __emutls_get_address.
24 @my_emutls_v_xyz = external global ptr, align 4
25 declare ptr @my_emutls_get_address(ptr)
27 define dso_local i32 @my_get_xyz() {
28 ; X86-LABEL: my_get_xyz:
29 ; X86: movl my_emutls_v_xyz@GOT(%ebx), %eax
30 ; X86-NEXT: movl %eax, (%esp)
31 ; X86-NEXT: calll my_emutls_get_address@PLT
32 ; X86-NEXT: movl (%eax), %eax
33 ; X86-NEXT: addl $8, %esp
34 ; X86-NEXT: .cfi_def_cfa_offset 8
36 ; X86-NEXT: .cfi_def_cfa_offset 4
38 ; X64-LABEL: my_get_xyz:
39 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
40 ; X64-NEXT: callq my_emutls_get_address@PLT
41 ; X64-NEXT: movl (%rax), %eax
43 ; X64-NEXT: .cfi_def_cfa_offset 8
47 %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz)
48 %0 = load i32, ptr %call, align 4
52 @i = dso_local thread_local global i32 15
53 @i2 = external thread_local global i32
55 define dso_local i32 @f1() {
57 ; X86: leal __emutls_v.i@GOTOFF(%ebx), %eax
58 ; X86-NEXT: movl %eax, (%esp)
59 ; X86-NEXT: calll __emutls_get_address@PLT
60 ; X86-NEXT: movl (%eax), %eax
61 ; X86-NEXT: addl $8, %esp
62 ; X86-NEXT: .cfi_def_cfa_offset 8
64 ; X86-NEXT: .cfi_def_cfa_offset 4
67 ; X64: leaq __emutls_v.i(%rip), %rdi
68 ; X64-NEXT: callq __emutls_get_address@PLT
69 ; X64-NEXT: movl (%rax), %eax
71 ; X64-NEXT: .cfi_def_cfa_offset 8
75 %tmp1 = load i32, ptr @i
79 define dso_local ptr @f2() {
81 ; X86: leal __emutls_v.i@GOTOFF(%ebx), %eax
82 ; X86-NEXT: movl %eax, (%esp)
83 ; X86-NEXT: calll __emutls_get_address@PLT
85 ; X64: leaq __emutls_v.i(%rip), %rdi
86 ; X64-NEXT: callq __emutls_get_address@PLT
92 define dso_local i32 @f3() {
94 ; X86: movl __emutls_v.i2@GOT(%ebx), %eax
95 ; X86-NEXT: movl %eax, (%esp)
96 ; X86-NEXT: calll __emutls_get_address@PLT
98 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
99 ; X64-NEXT: callq __emutls_get_address@PLT
102 %tmp1 = load i32, ptr @i2
106 define dso_local ptr @f4() {
108 ; X86: movl __emutls_v.i2@GOT(%ebx), %eax
109 ; X86-NEXT: movl %eax, (%esp)
110 ; X86-NEXT: calll __emutls_get_address@PLT
112 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
113 ; X64-NEXT: callq __emutls_get_address@PLT
122 ; X86-LABEL: __emutls_v.i:
126 ; X86-NEXT: .long __emutls_t.i
128 ; X86: .section .rodata,
129 ; X86-LABEL: __emutls_t.i:
132 ; X86-NOT: __emutls_v.i2
133 ; X86-NOT: __emutls_t.i2
138 ; X64-LABEL: __emutls_v.i:
142 ; X64-NEXT: .quad __emutls_t.i
144 ; X64: .section .rodata,
145 ; X64-LABEL: __emutls_t.i:
148 ; X64-NOT: __emutls_v.i2
149 ; X64-NOT: __emutls_t.i2
152 !llvm.module.flags = !{!0, !1}
153 !0 = !{i32 1, !"PIC Level", i32 1}
154 !1 = !{i32 1, !"PIE Level", i32 1}