• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
2; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-RELOC %s
3
4@initial_exec_var = external thread_local(initialexec) global i32
5
6define i32 @test_initial_exec() {
7; CHECK-LABEL: test_initial_exec:
8  %val = load i32, i32* @initial_exec_var
9
10; CHECK: adrp x[[GOTADDR:[0-9]+]], :gottprel:initial_exec_var
11; CHECK: ldr x[[TP_OFFSET:[0-9]+]], [x[[GOTADDR]], :gottprel_lo12:initial_exec_var]
12; CHECK: mrs x[[TP:[0-9]+]], TPIDR_EL0
13; CHECK: ldr w0, [x[[TP]], x[[TP_OFFSET]]]
14
15; CHECK-RELOC: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
16; CHECK-RELOC: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
17
18  ret i32 %val
19}
20
21define i32* @test_initial_exec_addr() {
22; CHECK-LABEL: test_initial_exec_addr:
23  ret i32* @initial_exec_var
24
25; CHECK: adrp x[[GOTADDR:[0-9]+]], :gottprel:initial_exec_var
26; CHECK: ldr [[TP_OFFSET:x[0-9]+]], [x[[GOTADDR]], :gottprel_lo12:initial_exec_var]
27; CHECK: mrs [[TP:x[0-9]+]], TPIDR_EL0
28; CHECK: add x0, [[TP]], [[TP_OFFSET]]
29
30; CHECK-RELOC: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
31; CHECK-RELOC: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
32
33}
34
35@local_exec_var = thread_local(localexec) global i32 0
36
37define i32 @test_local_exec() {
38; CHECK-LABEL: test_local_exec:
39  %val = load i32, i32* @local_exec_var
40
41; CHECK: mrs x[[R1:[0-9]+]], TPIDR_EL0
42; CHECK: add x[[R2:[0-9]+]], x[[R1]], :tprel_hi12:local_exec_var
43; CHECK: add x[[R3:[0-9]+]], x[[R2]], :tprel_lo12_nc:local_exec_var
44; CHECK: ldr w0, [x[[R3]]]
45
46; CHECK-RELOC: R_AARCH64_TLSLE_ADD_TPREL_HI12
47; CHECK-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12_NC
48  ret i32 %val
49}
50
51define i32* @test_local_exec_addr() {
52; CHECK-LABEL: test_local_exec_addr:
53  ret i32* @local_exec_var
54
55; CHECK: mrs x[[R1:[0-9]+]], TPIDR_EL0
56; CHECK: add x[[R2:[0-9]+]], x[[R1]], :tprel_hi12:local_exec_var
57; CHECK: add x0, x[[R2]], :tprel_lo12_nc:local_exec_var
58; CHECK: ret
59
60; CHECK-RELOC: R_AARCH64_TLSLE_ADD_TPREL_HI12
61; CHECK-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12_NC
62}
63