1; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs < %s | FileCheck %s 2; RUN: llc -mtriple=aarch64-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: test_initial_exec: 8 %val = load 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: 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(initialexec) global i32 0 36 37define i32 @test_local_exec() { 38; CHECK: test_local_exec: 39 %val = load i32* @local_exec_var 40 41; CHECK: movz [[TP_OFFSET:x[0-9]+]], #:tprel_g1:local_exec_var 42; CHECK: movk [[TP_OFFSET]], #:tprel_g0_nc:local_exec_var 43; CHECK: mrs x[[TP:[0-9]+]], tpidr_el0 44; CHECK: ldr w0, [x[[TP]], [[TP_OFFSET]]] 45 46; CHECK-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1 47; CHECK-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 48 49 ret i32 %val 50} 51 52define i32* @test_local_exec_addr() { 53; CHECK: test_local_exec_addr: 54 ret i32* @local_exec_var 55 56; CHECK: movz [[TP_OFFSET:x[0-9]+]], #:tprel_g1:local_exec_var 57; CHECK: movk [[TP_OFFSET]], #:tprel_g0_nc:local_exec_var 58; CHECK: mrs [[TP:x[0-9]+]], tpidr_el0 59; CHECK: add x0, [[TP]], [[TP_OFFSET]] 60 61; CHECK-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1 62; CHECK-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 63} 64