1 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
2 ; RUN: | FileCheck -check-prefix=X32 %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=X32 %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-android -relocation-model=pic \
15 ; RUN: | FileCheck -check-prefix=X32 %s
16 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
17 ; RUN: | FileCheck -check-prefix=X64 %s
21 ; Use my_emutls_get_address like __emutls_get_address.
22 @my_emutls_v_xyz = external global i8*, align 4
23 declare i8* @my_emutls_get_address(i8*)
25 define i32 @my_get_xyz() {
26 ; X32-LABEL: my_get_xyz:
27 ; X32: movl my_emutls_v_xyz@GOT(%ebx), %eax
28 ; X32-NEXT: movl %eax, (%esp)
29 ; X32-NEXT: calll my_emutls_get_address@PLT
30 ; X32-NEXT: movl (%eax), %eax
31 ; X32-NEXT: addl $8, %esp
32 ; X32-NEXT: .cfi_def_cfa_offset 8
34 ; X32-NEXT: .cfi_def_cfa_offset 4
36 ; X64-LABEL: my_get_xyz:
37 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
38 ; X64-NEXT: callq my_emutls_get_address@PLT
39 ; X64-NEXT: movl (%rax), %eax
41 ; X64-NEXT: .cfi_def_cfa_offset 8
45 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
46 %0 = bitcast i8* %call to i32*
47 %1 = load i32, i32* %0, align 4
51 @i = thread_local global i32 15
52 @i2 = external thread_local global i32
56 ; X32: leal __emutls_v.i@GOTOFF(%ebx), %eax
57 ; X32-NEXT: movl %eax, (%esp)
58 ; X32-NEXT: calll __emutls_get_address@PLT
59 ; X32-NEXT: movl (%eax), %eax
60 ; X32-NEXT: addl $8, %esp
61 ; X32-NEXT: .cfi_def_cfa_offset 8
63 ; X32-NEXT: .cfi_def_cfa_offset 4
66 ; X64: leaq __emutls_v.i(%rip), %rdi
67 ; X64-NEXT: callq __emutls_get_address@PLT
68 ; X64-NEXT: movl (%rax), %eax
70 ; X64-NEXT: .cfi_def_cfa_offset 8
74 %tmp1 = load i32, i32* @i
80 ; X32: leal __emutls_v.i@GOTOFF(%ebx), %eax
81 ; X32-NEXT: movl %eax, (%esp)
82 ; X32-NEXT: calll __emutls_get_address@PLT
84 ; X64: leaq __emutls_v.i(%rip), %rdi
85 ; X64-NEXT: callq __emutls_get_address@PLT
93 ; X32: movl __emutls_v.i2@GOT(%ebx), %eax
94 ; X32-NEXT: movl %eax, (%esp)
95 ; X32-NEXT: calll __emutls_get_address@PLT
97 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
98 ; X64-NEXT: callq __emutls_get_address@PLT
101 %tmp1 = load i32, i32* @i2
107 ; X32: movl __emutls_v.i2@GOT(%ebx), %eax
108 ; X32-NEXT: movl %eax, (%esp)
109 ; X32-NEXT: calll __emutls_get_address@PLT
111 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
112 ; X64-NEXT: callq __emutls_get_address@PLT
121 ; X32-LABEL: __emutls_v.i:
125 ; X32-NEXT: .long __emutls_t.i
127 ; X32: .section .rodata,
128 ; X32-LABEL: __emutls_t.i:
131 ; X32-NOT: __emutls_v.i2
132 ; X32-NOT: __emutls_t.i2
137 ; X64-LABEL: __emutls_v.i:
141 ; X64-NEXT: .quad __emutls_t.i
143 ; X64: .section .rodata,
144 ; X64-LABEL: __emutls_t.i:
147 ; X64-NOT: __emutls_v.i2
148 ; X64-NOT: __emutls_t.i2
151 !llvm.module.flags = !{!0, !1}
152 !0 = !{i32 1, !"PIC Level", i32 1}
153 !1 = !{i32 1, !"PIE Level", i32 1}