1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -emulated-tls -relocation-model=pic < %s \
3 ; RUN: | FileCheck -check-prefix=RV32 %s
4 ; RUN: llc -mtriple=riscv64 -emulated-tls -relocation-model=pic < %s \
5 ; RUN: | FileCheck -check-prefix=RV64 %s
7 @external_x = external thread_local global i32, align 8
8 @y = thread_local global i8 7, align 2
9 @internal_z = internal thread_local global i64 9, align 16
11 define ptr @get_external_x() nounwind {
12 ; RV32-LABEL: get_external_x:
13 ; RV32: # %bb.0: # %entry
14 ; RV32-NEXT: addi sp, sp, -16
15 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
16 ; RV32-NEXT: .Lpcrel_hi0:
17 ; RV32-NEXT: auipc a0, %got_pcrel_hi(__emutls_v.external_x)
18 ; RV32-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0)
19 ; RV32-NEXT: call __emutls_get_address
20 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
21 ; RV32-NEXT: addi sp, sp, 16
24 ; RV64-LABEL: get_external_x:
25 ; RV64: # %bb.0: # %entry
26 ; RV64-NEXT: addi sp, sp, -16
27 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
28 ; RV64-NEXT: .Lpcrel_hi0:
29 ; RV64-NEXT: auipc a0, %got_pcrel_hi(__emutls_v.external_x)
30 ; RV64-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
31 ; RV64-NEXT: call __emutls_get_address
32 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
33 ; RV64-NEXT: addi sp, sp, 16
39 define ptr @get_y() nounwind {
41 ; RV32: # %bb.0: # %entry
42 ; RV32-NEXT: addi sp, sp, -16
43 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
44 ; RV32-NEXT: .Lpcrel_hi1:
45 ; RV32-NEXT: auipc a0, %got_pcrel_hi(__emutls_v.y)
46 ; RV32-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi1)(a0)
47 ; RV32-NEXT: call __emutls_get_address
48 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
49 ; RV32-NEXT: addi sp, sp, 16
53 ; RV64: # %bb.0: # %entry
54 ; RV64-NEXT: addi sp, sp, -16
55 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
56 ; RV64-NEXT: .Lpcrel_hi1:
57 ; RV64-NEXT: auipc a0, %got_pcrel_hi(__emutls_v.y)
58 ; RV64-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi1)(a0)
59 ; RV64-NEXT: call __emutls_get_address
60 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
61 ; RV64-NEXT: addi sp, sp, 16
67 define ptr @get_internal_z() nounwind {
68 ; RV32-LABEL: get_internal_z:
69 ; RV32: # %bb.0: # %entry
70 ; RV32-NEXT: addi sp, sp, -16
71 ; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
72 ; RV32-NEXT: .Lpcrel_hi2:
73 ; RV32-NEXT: auipc a0, %pcrel_hi(__emutls_v.internal_z)
74 ; RV32-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2)
75 ; RV32-NEXT: call __emutls_get_address
76 ; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
77 ; RV32-NEXT: addi sp, sp, 16
80 ; RV64-LABEL: get_internal_z:
81 ; RV64: # %bb.0: # %entry
82 ; RV64-NEXT: addi sp, sp, -16
83 ; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
84 ; RV64-NEXT: .Lpcrel_hi2:
85 ; RV64-NEXT: auipc a0, %pcrel_hi(__emutls_v.internal_z)
86 ; RV64-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2)
87 ; RV64-NEXT: call __emutls_get_address
88 ; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
89 ; RV64-NEXT: addi sp, sp, 16
98 ; RV32: .globl __emutls_v.y
100 ; RV32-LABEL: __emutls_v.y:
104 ; RV32-NEXT: .word __emutls_t.y
105 ; RV32: .section .rodata,
106 ; RV32-LABEL: __emutls_t.y:
110 ; RV32-LABEL: __emutls_v.internal_z:
112 ; RV32-NEXT: .word 16
114 ; RV32-NEXT: .word __emutls_t.internal_z
115 ; RV32: .section .rodata,
116 ; RV32-LABEL: __emutls_t.internal_z:
120 ; RV64: .globl __emutls_v.y
122 ; RV64-LABEL: __emutls_v.y:
126 ; RV64-NEXT: .quad __emutls_t.y
127 ; RV64: .section .rodata,
128 ; RV64-LABEL: __emutls_t.y:
132 ; RV64-LABEL: __emutls_v.internal_z:
134 ; RV64-NEXT: .quad 16
136 ; RV64-NEXT: .quad __emutls_t.internal_z
137 ; RV64: .section .rodata,
138 ; RV64-LABEL: __emutls_t.internal_z: