1 ; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -enable-pie \
2 ; RUN: | FileCheck -check-prefix=X32 %s
3 ; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie \
4 ; RUN: | FileCheck -check-prefix=X64 %s
5 ; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic -enable-pie \
6 ; RUN: | FileCheck -check-prefix=X32 %s
7 ; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic -enable-pie \
8 ; RUN: | FileCheck -check-prefix=X64 %s
10 ; Use my_emutls_get_address like __emutls_get_address.
11 @my_emutls_v_xyz = external global i8*, align 4
12 declare i8* @my_emutls_get_address(i8*)
14 define i32 @my_get_xyz() {
15 ; X32-LABEL: my_get_xyz:
16 ; X32: movl my_emutls_v_xyz@GOT(%ebx), %eax
17 ; X32-NEXT: movl %eax, (%esp)
18 ; X32-NEXT: calll my_emutls_get_address@PLT
19 ; X32-NEXT: movl (%eax), %eax
20 ; X32-NEXT: addl $8, %esp
23 ; X64-LABEL: my_get_xyz:
24 ; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
25 ; X64-NEXT: callq my_emutls_get_address@PLT
26 ; X64-NEXT: movl (%rax), %eax
31 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
32 %0 = bitcast i8* %call to i32*
33 %1 = load i32, i32* %0, align 4
37 @i = thread_local global i32 15
38 @i2 = external thread_local global i32
42 ; X32: movl __emutls_v.i@GOT(%ebx), %eax
43 ; X32-NEXT: movl %eax, (%esp)
44 ; X32-NEXT: calll __emutls_get_address@PLT
45 ; X32-NEXT: movl (%eax), %eax
46 ; X32-NEXT: addl $8, %esp
50 ; X64: movq __emutls_v.i@GOTPCREL(%rip), %rdi
51 ; X64-NEXT: callq __emutls_get_address@PLT
52 ; X64-NEXT: movl (%rax), %eax
57 %tmp1 = load i32, i32* @i
63 ; X32: movl __emutls_v.i@GOT(%ebx), %eax
64 ; X32-NEXT: movl %eax, (%esp)
65 ; X32-NEXT: calll __emutls_get_address@PLT
67 ; X64: movq __emutls_v.i@GOTPCREL(%rip), %rdi
68 ; X64-NEXT: callq __emutls_get_address@PLT
76 ; X32: movl __emutls_v.i2@GOT(%ebx), %eax
77 ; X32-NEXT: movl %eax, (%esp)
78 ; X32-NEXT: calll __emutls_get_address@PLT
80 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
81 ; X64-NEXT: callq __emutls_get_address@PLT
84 %tmp1 = load i32, i32* @i2
90 ; X32: movl __emutls_v.i2@GOT(%ebx), %eax
91 ; X32-NEXT: movl %eax, (%esp)
92 ; X32-NEXT: calll __emutls_get_address@PLT
94 ; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi
95 ; X64-NEXT: callq __emutls_get_address@PLT
104 ; X32-LABEL: __emutls_v.i:
108 ; X32-NEXT: .long __emutls_t.i
110 ; X32: .section .rodata,
111 ; X32-LABEL: __emutls_t.i:
114 ; X32-NOT: __emutls_v.i2
115 ; X32-NOT: __emutls_t.i2
120 ; X64-LABEL: __emutls_v.i:
124 ; X64-NEXT: .quad __emutls_t.i
126 ; X64: .section .rodata,
127 ; X64-LABEL: __emutls_t.i:
130 ; X64-NOT: __emutls_v.i2
131 ; X64-NOT: __emutls_t.i2