1; RUN: llc < %s -emulated-tls -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
2; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
3
4; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
5; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
6
7; Make sure that TLS symboles are emitted in expected order.
8
9@external_x = external thread_local global i32
10@external_y = thread_local global i32 7
11@internal_y = internal thread_local global i32 9
12
13define i32* @get_external_x() {
14entry:
15  ret i32* @external_x
16}
17
18define i32* @get_external_y() {
19entry:
20  ret i32* @external_y
21}
22
23define i32* @get_internal_y() {
24entry:
25  ret i32* @internal_y
26}
27
28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 32-bit mode
29; CHECK-LABEL: get_external_x:
30; CHECK:  __emutls_v.external_x
31; CHECK:  __emutls_get_address
32
33; CHECK-LABEL: get_external_y:
34; CHECK:  __emutls_v.external_y
35; CHECK:  __emutls_get_address
36
37; CHECK-LABEL: get_internal_y:
38; CHECK:  __emutls_v.internal_y
39; CHECK:  __emutls_get_address
40
41; CHECK-NOT: __emutls_v.external_x:
42
43; CHECK:       .p2align 2
44; CHECK-LABEL: __emutls_v.external_y:
45; CHECK-NEXT:  .long 4
46; CHECK-NEXT:  .long 4
47; CHECK-NEXT:  .long 0
48; CHECK-NEXT:  .long __emutls_t.external_y
49; CHECK-LABEL: __emutls_t.external_y:
50; CHECK-NEXT:  .long 7
51
52; CHECK:       .p2align 2
53; CHECK-LABEL: __emutls_v.internal_y:
54; CHECK-NEXT:  .long 4
55; CHECK-NEXT:  .long 4
56; CHECK-NEXT:  .long 0
57; CHECK-NEXT:  .long __emutls_t.internal_y
58; CHECK-LABEL: __emutls_t.internal_y:
59; CHECK-NEXT:  .long 9
60
61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 64-bit mode
62; X64-LABEL: get_external_x:
63; X64:  __emutls_v.external_x
64; X64:  __emutls_get_address
65
66; X64-LABEL: get_external_y:
67; X64:  __emutls_v.external_y
68; X64:  __emutls_get_address
69
70; X64-LABEL: get_internal_y:
71; X64:  __emutls_v.internal_y
72; X64:  __emutls_get_address
73
74; X64-NOT: __emutls_v.external_x:
75
76; X64:       .p2align 3
77; X64-LABEL: __emutls_v.external_y:
78; X64-NEXT:  .quad 4
79; X64-NEXT:  .quad 4
80; X64-NEXT:  .quad 0
81; X64-NEXT:  .quad __emutls_t.external_y
82; X64-LABEL: __emutls_t.external_y:
83; X64-NEXT:  .long 7
84
85; X64:       .p2align 3
86; X64-LABEL: __emutls_v.internal_y:
87; X64-NEXT:  .quad 4
88; X64-NEXT:  .quad 4
89; X64-NEXT:  .quad 0
90; X64-NEXT:  .quad __emutls_t.internal_y
91; X64-LABEL: __emutls_t.internal_y:
92; X64-NEXT:  .long 9
93