1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -relocation-model=pic < %s \
; RUN: | FileCheck -check-prefix=RV32-PIC %s
; RUN: llc -mtriple=riscv32 -relocation-model=pic < %s -enable-tlsdesc \
; RUN: | FileCheck -check-prefix=RV32-PIC-TLSDESC %s
; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s \
; RUN: | FileCheck -check-prefix=RV64-PIC %s
; RUN: llc -mtriple=riscv64 -relocation-model=pic -enable-tlsdesc < %s \
; RUN: | FileCheck -check-prefix=RV64-PIC-TLSDESC %s
; RUN: llc -mtriple=riscv32 < %s | FileCheck -check-prefix=RV32-NOPIC %s
; RUN: llc -mtriple=riscv32 < %s -enable-tlsdesc | FileCheck -check-prefix=RV32-NOPIC-TLSDESC %s
; RUN: llc -mtriple=riscv64 < %s | FileCheck -check-prefix=RV64-NOPIC %s
; RUN: llc -mtriple=riscv64 < %s -enable-tlsdesc | FileCheck -check-prefix=RV64-NOPIC-TLSDESC %s
; Check that TLS symbols are lowered correctly based on the specified
; model. Make sure they're external to avoid them all being optimised to Local
; Exec for the executable.
@unspecified = external thread_local global i32
@ld = external thread_local(localdynamic) global i32
@ie = external thread_local(initialexec) global i32
@le = external thread_local(localexec) global i32
; No model specified
define ptr @f1() nounwind {
; RV32-PIC-LABEL: f1:
; RV32-PIC: # %bb.0: # %entry
; RV32-PIC-NEXT: addi sp, sp, -16
; RV32-PIC-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
; RV32-PIC-NEXT: .Lpcrel_hi0:
; RV32-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(unspecified)
; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0)
; RV32-PIC-NEXT: call __tls_get_addr
; RV32-PIC-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
; RV32-PIC-NEXT: addi sp, sp, 16
; RV32-PIC-NEXT: ret
;
; RV64-PIC-LABEL: f1:
; RV64-PIC: # %bb.0: # %entry
; RV64-PIC-NEXT: addi sp, sp, -16
; RV64-PIC-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
; RV64-PIC-NEXT: .Lpcrel_hi0:
; RV64-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(unspecified)
; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0)
; RV64-PIC-NEXT: call __tls_get_addr
; RV64-PIC-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
; RV64-PIC-NEXT: addi sp, sp, 16
; RV64-PIC-NEXT: ret
;
; RV32-NOPIC-LABEL: f1:
; RV32-NOPIC: # %bb.0: # %entry
; RV32-NOPIC-NEXT: .Lpcrel_hi0:
; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified)
; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV32-NOPIC-NEXT: add a0, a0, tp
; RV32-NOPIC-NEXT: ret
;
; RV64-NOPIC-LABEL: f1:
; RV64-NOPIC: # %bb.0: # %entry
; RV64-NOPIC-NEXT: .Lpcrel_hi0:
; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified)
; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV64-NOPIC-NEXT: add a0, a0, tp
; RV64-NOPIC-NEXT: ret
;
; RV32-PIC-TLSDESC-LABEL: f1:
; RV32-PIC-TLSDESC: # %bb.0: # %entry
; RV32-PIC-TLSDESC-NEXT: .Ltlsdesc_hi0:
; RV32-PIC-TLSDESC-NEXT: auipc a0, %tlsdesc_hi(unspecified)
; RV32-PIC-TLSDESC-NEXT: lw a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0)
; RV32-PIC-TLSDESC-NEXT: addi a0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0)
; RV32-PIC-TLSDESC-NEXT: jalr t0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0)
; RV32-PIC-TLSDESC-NEXT: add a0, a0, tp
; RV32-PIC-TLSDESC-NEXT: ret
;
; RV64-PIC-TLSDESC-LABEL: f1:
; RV64-PIC-TLSDESC: # %bb.0: # %entry
; RV64-PIC-TLSDESC-NEXT: .Ltlsdesc_hi0:
; RV64-PIC-TLSDESC-NEXT: auipc a0, %tlsdesc_hi(unspecified)
; RV64-PIC-TLSDESC-NEXT: ld a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0)
; RV64-PIC-TLSDESC-NEXT: addi a0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0)
; RV64-PIC-TLSDESC-NEXT: jalr t0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0)
; RV64-PIC-TLSDESC-NEXT: add a0, a0, tp
; RV64-PIC-TLSDESC-NEXT: ret
;
; RV32-NOPIC-TLSDESC-LABEL: f1:
; RV32-NOPIC-TLSDESC: # %bb.0: # %entry
; RV32-NOPIC-TLSDESC-NEXT: .Lpcrel_hi0:
; RV32-NOPIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified)
; RV32-NOPIC-TLSDESC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV32-NOPIC-TLSDESC-NEXT: add a0, a0, tp
; RV32-NOPIC-TLSDESC-NEXT: ret
;
; RV64-NOPIC-TLSDESC-LABEL: f1:
; RV64-NOPIC-TLSDESC: # %bb.0: # %entry
; RV64-NOPIC-TLSDESC-NEXT: .Lpcrel_hi0:
; RV64-NOPIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified)
; RV64-NOPIC-TLSDESC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV64-NOPIC-TLSDESC-NEXT: add a0, a0, tp
; RV64-NOPIC-TLSDESC-NEXT: ret
entry:
ret ptr @unspecified
}
; localdynamic specified
define ptr @f2() nounwind {
; RV32-PIC-LABEL: f2:
; RV32-PIC: # %bb.0: # %entry
; RV32-PIC-NEXT: addi sp, sp, -16
; RV32-PIC-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
; RV32-PIC-NEXT: .Lpcrel_hi1:
; RV32-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(ld)
; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1)
; RV32-PIC-NEXT: call __tls_get_addr
; RV32-PIC-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
; RV32-PIC-NEXT: addi sp, sp, 16
; RV32-PIC-NEXT: ret
;
; RV64-PIC-LABEL: f2:
; RV64-PIC: # %bb.0: # %entry
; RV64-PIC-NEXT: addi sp, sp, -16
; RV64-PIC-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
; RV64-PIC-NEXT: .Lpcrel_hi1:
; RV64-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(ld)
; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1)
; RV64-PIC-NEXT: call __tls_get_addr
; RV64-PIC-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
; RV64-PIC-NEXT: addi sp, sp, 16
; RV64-PIC-NEXT: ret
;
; RV32-NOPIC-LABEL: f2:
; RV32-NOPIC: # %bb.0: # %entry
; RV32-NOPIC-NEXT: .Lpcrel_hi1:
; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ld)
; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi1)(a0)
; RV32-NOPIC-NEXT: add a0, a0, tp
; RV32-NOPIC-NEXT: ret
;
; RV64-NOPIC-LABEL: f2:
; RV64-NOPIC: # %bb.0: # %entry
; RV64-NOPIC-NEXT: .Lpcrel_hi1:
; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ld)
; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi1)(a0)
; RV64-NOPIC-NEXT: add a0, a0, tp
; RV64-NOPIC-NEXT: ret
entry:
ret ptr @ld
}
; initialexec specified
define ptr @f3() nounwind {
; RV32-PIC-LABEL: f3:
; RV32-PIC: # %bb.0: # %entry
; RV32-PIC-NEXT: .Lpcrel_hi2:
; RV32-PIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV32-PIC-NEXT: add a0, a0, tp
; RV32-PIC-NEXT: ret
;
; RV64-PIC-LABEL: f3:
; RV64-PIC: # %bb.0: # %entry
; RV64-PIC-NEXT: .Lpcrel_hi2:
; RV64-PIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV64-PIC-NEXT: add a0, a0, tp
; RV64-PIC-NEXT: ret
;
; RV32-NOPIC-LABEL: f3:
; RV32-NOPIC: # %bb.0: # %entry
; RV32-NOPIC-NEXT: .Lpcrel_hi2:
; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV32-NOPIC-NEXT: add a0, a0, tp
; RV32-NOPIC-NEXT: ret
;
; RV64-NOPIC-LABEL: f3:
; RV64-NOPIC: # %bb.0: # %entry
; RV64-NOPIC-NEXT: .Lpcrel_hi2:
; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV64-NOPIC-NEXT: add a0, a0, tp
; RV64-NOPIC-NEXT: ret
;
; RV32-PIC-TLSDESC-LABEL: f3:
; RV32-PIC-TLSDESC: # %bb.0: # %entry
; RV32-PIC-TLSDESC-NEXT: .Lpcrel_hi0:
; RV32-PIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV32-PIC-TLSDESC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV32-PIC-TLSDESC-NEXT: add a0, a0, tp
; RV32-PIC-TLSDESC-NEXT: ret
;
; RV64-PIC-TLSDESC-LABEL: f3:
; RV64-PIC-TLSDESC: # %bb.0: # %entry
; RV64-PIC-TLSDESC-NEXT: .Lpcrel_hi0:
; RV64-PIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV64-PIC-TLSDESC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
; RV64-PIC-TLSDESC-NEXT: add a0, a0, tp
; RV64-PIC-TLSDESC-NEXT: ret
;
; RV32-NOPIC-TLSDESC-LABEL: f3:
; RV32-NOPIC-TLSDESC: # %bb.0: # %entry
; RV32-NOPIC-TLSDESC-NEXT: .Lpcrel_hi2:
; RV32-NOPIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV32-NOPIC-TLSDESC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV32-NOPIC-TLSDESC-NEXT: add a0, a0, tp
; RV32-NOPIC-TLSDESC-NEXT: ret
;
; RV64-NOPIC-TLSDESC-LABEL: f3:
; RV64-NOPIC-TLSDESC: # %bb.0: # %entry
; RV64-NOPIC-TLSDESC-NEXT: .Lpcrel_hi2:
; RV64-NOPIC-TLSDESC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie)
; RV64-NOPIC-TLSDESC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0)
; RV64-NOPIC-TLSDESC-NEXT: add a0, a0, tp
; RV64-NOPIC-TLSDESC-NEXT: ret
entry:
ret ptr @ie
}
; localexec specified
define ptr @f4() nounwind {
; RV32-PIC-LABEL: f4:
; RV32-PIC: # %bb.0: # %entry
; RV32-PIC-NEXT: lui a0, %tprel_hi(le)
; RV32-PIC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV32-PIC-NEXT: addi a0, a0, %tprel_lo(le)
; RV32-PIC-NEXT: ret
;
; RV64-PIC-LABEL: f4:
; RV64-PIC: # %bb.0: # %entry
; RV64-PIC-NEXT: lui a0, %tprel_hi(le)
; RV64-PIC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV64-PIC-NEXT: addi a0, a0, %tprel_lo(le)
; RV64-PIC-NEXT: ret
;
; RV32-NOPIC-LABEL: f4:
; RV32-NOPIC: # %bb.0: # %entry
; RV32-NOPIC-NEXT: lui a0, %tprel_hi(le)
; RV32-NOPIC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV32-NOPIC-NEXT: addi a0, a0, %tprel_lo(le)
; RV32-NOPIC-NEXT: ret
;
; RV64-NOPIC-LABEL: f4:
; RV64-NOPIC: # %bb.0: # %entry
; RV64-NOPIC-NEXT: lui a0, %tprel_hi(le)
; RV64-NOPIC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV64-NOPIC-NEXT: addi a0, a0, %tprel_lo(le)
; RV64-NOPIC-NEXT: ret
;
; RV32-PIC-TLSDESC-LABEL: f4:
; RV32-PIC-TLSDESC: # %bb.0: # %entry
; RV32-PIC-TLSDESC-NEXT: lui a0, %tprel_hi(le)
; RV32-PIC-TLSDESC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV32-PIC-TLSDESC-NEXT: addi a0, a0, %tprel_lo(le)
; RV32-PIC-TLSDESC-NEXT: ret
;
; RV64-PIC-TLSDESC-LABEL: f4:
; RV64-PIC-TLSDESC: # %bb.0: # %entry
; RV64-PIC-TLSDESC-NEXT: lui a0, %tprel_hi(le)
; RV64-PIC-TLSDESC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV64-PIC-TLSDESC-NEXT: addi a0, a0, %tprel_lo(le)
; RV64-PIC-TLSDESC-NEXT: ret
;
; RV32-NOPIC-TLSDESC-LABEL: f4:
; RV32-NOPIC-TLSDESC: # %bb.0: # %entry
; RV32-NOPIC-TLSDESC-NEXT: lui a0, %tprel_hi(le)
; RV32-NOPIC-TLSDESC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV32-NOPIC-TLSDESC-NEXT: addi a0, a0, %tprel_lo(le)
; RV32-NOPIC-TLSDESC-NEXT: ret
;
; RV64-NOPIC-TLSDESC-LABEL: f4:
; RV64-NOPIC-TLSDESC: # %bb.0: # %entry
; RV64-NOPIC-TLSDESC-NEXT: lui a0, %tprel_hi(le)
; RV64-NOPIC-TLSDESC-NEXT: add a0, a0, tp, %tprel_add(le)
; RV64-NOPIC-TLSDESC-NEXT: addi a0, a0, %tprel_lo(le)
; RV64-NOPIC-TLSDESC-NEXT: ret
entry:
ret ptr @le
}
|