xref: /llvm-project/llvm/test/CodeGen/AArch64/emutls_generic.ll (revision b71f2fcd46790dd63dd2688c208139ea26f027d4)
1; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -relocation-model=pic \
2; RUN:     | FileCheck -check-prefix=ARM_64 %s
3; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -relocation-model=pic -O3 \
4; RUN:     | FileCheck -check-prefix=ARM_64 %s
5; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -O3 \
6; RUN:     | FileCheck -check-prefix=ARM_64 %s
7; RUN: llc < %s -emulated-tls -mtriple=aarch64-windows-gnu -O3 \
8; RUN:     | FileCheck -check-prefix=ARM_64 %s
9; RUN: llc < %s -emulated-tls -mtriple=aarch64-apple-darwin -O3 \
10; RUN:     | FileCheck -check-prefix=DARWIN %s
11
12; RUN: llc < %s -mtriple=aarch64-linux-android -relocation-model=pic \
13; RUN:     | FileCheck -check-prefix=ARM_64 %s
14; RUN: llc < %s -mtriple=aarch64-linux-android -relocation-model=pic -O3 \
15; RUN:     | FileCheck -check-prefix=ARM_64 %s
16; RUN: llc < %s -mtriple=aarch64-linux-android -O3 \
17; RUN:     | FileCheck -check-prefix=ARM_64 %s
18; aarch64-windows-gnu needs explicit -emulated-tls
19; RUN: llc < %s -mtriple=aarch64-apple-darwin -O3 \
20; RUN:     | FileCheck -check-prefix=NoEMU %s
21; RUN: llc < %s -mtriple=aarch64-linux-android29 -O3 \
22; RUN:     | FileCheck -check-prefix=NoEMU %s
23
24; NoEMU-NOT: __emutls
25
26; Make sure that TLS symbols are emitted in expected order.
27
28@external_x = external thread_local global i32, align 8
29@external_y = thread_local global i8 7, align 2
30@internal_y = internal thread_local global i64 9, align 16
31
32define ptr @get_external_x() {
33entry:
34  ret ptr @external_x
35}
36
37define ptr @get_external_y() {
38entry:
39  ret ptr @external_y
40}
41
42define ptr @get_internal_y() {
43entry:
44  ret ptr @internal_y
45}
46
47; ARM_64-LABEL:  get_external_x:
48; ARM_64:      __emutls_v.external_x
49; ARM_64:      __emutls_get_address
50; ARM_64-LABEL:  get_external_y:
51; ARM_64:      __emutls_v.external_y
52; ARM_64:      __emutls_get_address
53; ARM_64-LABEL:  get_internal_y:
54; ARM_64:      __emutls_v.internal_y
55; ARM_64:      __emutls_get_address
56; ARM_64-NOT:   __emutls_t.external_x
57; ARM_64-NOT:   __emutls_v.external_x:
58; ARM_64:        .data{{$}}
59; ARM_64:        .globl __emutls_v.external_y
60; ARM_64:        .p2align 3
61; ARM_64-LABEL:  __emutls_v.external_y:
62; ARM_64-NEXT:   .xword 1
63; ARM_64-NEXT:   .xword 2
64; ARM_64-NEXT:   .xword 0
65; ARM_64-NEXT:   .xword __emutls_t.external_y
66; ARM_64-NOT:    __emutls_v.external_x:
67; ARM_64:        .section .r{{o?}}data,
68; ARM_64-LABEL:  __emutls_t.external_y:
69; ARM_64-NEXT:   .byte 7
70; ARM_64:        .data{{$}}
71; ARM_64-NOT:    .globl __emutls_v
72; ARM_64:        .p2align 3
73; ARM_64-LABEL:  __emutls_v.internal_y:
74; ARM_64-NEXT:   .xword 8
75; ARM_64-NEXT:   .xword 16
76; ARM_64-NEXT:   .xword 0
77; ARM_64-NEXT:   .xword __emutls_t.internal_y
78; ARM_64:        .section .r{{o?}}data,
79; ARM_64-LABEL:  __emutls_t.internal_y:
80; ARM_64-NEXT:   .xword 9
81
82; DARWIN-LABEL:  _get_external_x:
83; DARWIN:        ___emutls_v.external_x
84; DARWIN:        ___emutls_get_address
85; DARWIN-LABEL:  _get_external_y:
86; DARWIN:        ___emutls_v.external_y
87; DARWIN:        ___emutls_get_address
88; DARWIN-LABEL:  _get_internal_y:
89; DARWIN:        ___emutls_v.internal_y
90; DARWIN:        ___emutls_get_address
91; DARWIN-NOT:    ___emutls_t.external_x
92; DARWIN-NOT:    ___emutls_v.external_x:
93; DARWIN:        .section __DATA,__data
94; DARWIN:        .globl ___emutls_v.external_y
95; DARWIN:        .p2align 3
96; DARWIN-LABEL:  ___emutls_v.external_y:
97; DARWIN-NEXT:   .quad 1
98; DARWIN-NEXT:   .quad 2
99; DARWIN-NEXT:   .quad 0
100; DARWIN-NEXT:   .quad ___emutls_t.external_y
101; DARWIN-NOT:    ___emutls_v.external_x:
102; DARWIN:        .section __TEXT,__const
103; DARWIN-LABEL:  ___emutls_t.external_y:
104; DARWIN-NEXT:   .byte 7
105; DARWIN:        .section __DATA,__data
106; DARWIN-NOT:    .globl ___emutls_v
107; DARWIN:        .p2align 3
108; DARWIN-LABEL:  ___emutls_v.internal_y:
109; DARWIN-NEXT:   .quad 8
110; DARWIN-NEXT:   .quad 16
111; DARWIN-NEXT:   .quad 0
112; DARWIN-NEXT:   .quad ___emutls_t.internal_y
113; DARWIN:        .section __TEXT,__const
114; DARWIN-LABEL:  ___emutls_t.internal_y:
115; DARWIN-NEXT:   .quad 9
116