blob: 7204c10f9b34b172e16d65cf50114ea9c46cb057 [file] [log] [blame]
Chih-Hung Hsieh1e859582015-07-28 16:24:05 +00001; RUN: llc < %s -emulated-tls -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X32 %s
2; RUN: llc < %s -emulated-tls -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64 %s
3; RUN: llc < %s -emulated-tls -march=x86 -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X32 %s
4; RUN: llc < %s -emulated-tls -march=x86-64 -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
5
6; Use my_emutls_get_address like __emutls_get_address.
7@my_emutls_v_xyz = external global i8*, align 4
8declare i8* @my_emutls_get_address(i8*)
9
10define i32 @my_get_xyz() {
11; X32-LABEL: my_get_xyz:
12; X32: movl my_emutls_v_xyz@GOT(%ebx), %eax
13; X32-NEXT: movl %eax, (%esp)
14; X32-NEXT: calll my_emutls_get_address@PLT
15; X64-LABEL: my_get_xyz:
16; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi
17; X64-NEXT: callq my_emutls_get_address@PLT
18; X64-NEXT: movl (%rax), %eax
19
20entry:
21 %call = call i8* @my_emutls_get_address(i8* bitcast (i8** @my_emutls_v_xyz to i8*))
22 %0 = bitcast i8* %call to i32*
23 %1 = load i32, i32* %0, align 4
24 ret i32 %1
25}
26
27@i = thread_local global i32 15
28@j = internal thread_local global i32 42
29@k = internal thread_local global i32 0, align 8
30
31define i32 @f1() {
32entry:
33 %tmp1 = load i32, i32* @i
34 ret i32 %tmp1
35}
36
37; X32-LABEL: f1:
38; X32: movl __emutls_v.i@GOT(%ebx), %eax
39; X32-NEXT: movl %eax, (%esp)
40; X32-NEXT: calll __emutls_get_address@PLT
41; X64-LABEL: f1:
42; X64: movq __emutls_v.i@GOTPCREL(%rip), %rdi
43; X64-NEXT: callq __emutls_get_address@PLT
44; X64-NEXT: movl (%rax), %eax
45
46@i2 = external thread_local global i32
47
48define i32* @f2() {
49entry:
50 ret i32* @i
51}
52
53; X32-LABEL: f2:
54; X64-LABEL: f2:
55
56
57define i32 @f3() {
58entry:
59 %tmp1 = load i32, i32* @i ; <i32> [#uses=1]
60 ret i32 %tmp1
61}
62
63; X32-LABEL: f3:
64; X64-LABEL: f3:
65
66
67define i32* @f4() nounwind {
68entry:
69 ret i32* @i
70}
71
72; X32-LABEL: f4:
73; X64-LABEL: f4:
74
75
76define i32 @f5() nounwind {
77entry:
78 %0 = load i32, i32* @j, align 4
79 %1 = load i32, i32* @k, align 4
80 %add = add nsw i32 %0, %1
81 ret i32 %add
82}
83
84; X32-LABEL: f5:
85; X32: movl __emutls_v.j@GOT(%ebx), %eax
86; X32-NEXT: movl %eax, (%esp)
87; X32-NEXT: calll __emutls_get_address@PLT
88; X32-NEXT: movl (%eax), %esi
89; X32-NEXT: movl __emutls_v.k@GOT(%ebx), %eax
90; X32-NEXT: movl %eax, (%esp)
91; X32-NEXT: calll __emutls_get_address@PLT
92; X32-NEXT: addl (%eax), %esi
93; X32-NEXT: movl %esi, %eax
94
95; X64-LABEL: f5:
96; X64: movq __emutls_v.j@GOTPCREL(%rip), %rdi
97; X64-NEXT: callq __emutls_get_address@PLT
98; X64-NEXT: movl (%rax), %ebx
99; X64-NEXT: movq __emutls_v.k@GOTPCREL(%rip), %rdi
100; X64-NEXT: callq __emutls_get_address@PLT
101; X64-NEXT: addl (%rax), %ebx
102; X64-NEXT: movl %ebx, %eax
103
104;;;;; 32-bit targets
105
106; X32: .section .data.rel.local,
107; X32-LABEL: __emutls_v.i:
108; X32-NEXT: .long 4
109; X32-NEXT: .long 4
110; X32-NEXT: .long 0
111; X32-NEXT: .long __emutls_t.i
112
113; X32: .section .rodata,
114; X32-LABEL: __emutls_t.i:
115; X32-NEXT: .long 15
116
117; X32: .section .data.rel.local,
118; X32-LABEL: __emutls_v.j:
119; X32-NEXT: .long 4
120; X32-NEXT: .long 4
121; X32-NEXT: .long 0
122; X32-NEXT: .long __emutls_t.j
123
124; X32: .section .rodata,
125; X32-LABEL: __emutls_t.j:
126; X32-NEXT: .long 42
127
128; X32: .data
129; X32-LABEL: __emutls_v.k:
130; X32-NEXT: .long 4
131; X32-NEXT: .long 8
132; X32-NEXT: .long 0
133; X32-NEXT: .long 0
134
135; X32-NOT: __emutls_t.k:
136
137;;;;; 64-bit targets
138
139; X64: .section .data.rel.local,
140; X64-LABEL: __emutls_v.i:
141; X64-NEXT: .quad 4
142; X64-NEXT: .quad 4
143; X64-NEXT: .quad 0
144; X64-NEXT: .quad __emutls_t.i
145
146; X64: .section .rodata,
147; X64-LABEL: __emutls_t.i:
148; X64-NEXT: .long 15
149
150; X64: .section .data.rel.local,
151; X64-LABEL: __emutls_v.j:
152; X64-NEXT: .quad 4
153; X64-NEXT: .quad 4
154; X64-NEXT: .quad 0
155; X64-NEXT: .quad __emutls_t.j
156
157; X64: .section .rodata,
158; X64-LABEL: __emutls_t.j:
159; X64-NEXT: .long 42
160
161; X64: .data
162; X64-LABEL: __emutls_v.k:
163; X64-NEXT: .quad 4
164; X64-NEXT: .quad 8
165; X64-NEXT: .quad 0
166; X64-NEXT: .quad 0
167
168; X64-NOT: __emutls_t.k: