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
|
; RUN: llc -mtriple=aarch64-unknown-linux-gnu -mattr=+pauth -relocation-model=pic \
; RUN: -verify-machineinstrs < %s | FileCheck %s
; RUN: llc -mtriple=aarch64-unknown-linux-gnu -mattr=+pauth -relocation-model=pic \
; RUN: -filetype=obj < %s | llvm-readelf -r -s - | FileCheck --check-prefix=CHECK-OBJ %s
; RUN: not --crash llc -mtriple=aarch64-unknown-linux-gnu -mattr=+pauth -relocation-model=pic \
; RUN: -global-isel=1 < %s 2>&1 | FileCheck --check-prefix=CHECK-ERR %s
@general_dynamic_var = external thread_local global i32
define i32 @test_generaldynamic() {
; CHECK-LABEL: test_generaldynamic:
%val = load i32, ptr @general_dynamic_var
ret i32 %val
; CHECK: adrp x[[TLSDESC_HI:[0-9]+]], :tlsdesc_auth:general_dynamic_var
; CHECK-NEXT: ldr x16, [x[[TLSDESC_HI]], :tlsdesc_auth_lo12:general_dynamic_var]
; CHECK-NEXT: add x0, x[[TLSDESC_HI]], :tlsdesc_auth_lo12:general_dynamic_var
; CHECK-NEXT: blraa x16, x0
; CHECK-NEXT: mrs x[[TPIDR:[0-9]+]], TPIDR_EL0
; CHECK-NEXT: ldr w0, [x[[TPIDR]], x0]
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_LD64_LO12
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADD_LO12
; CHECK-OBJ-NOT: R_AARCH64_TLSDESC_CALL
; CHECK-ERR: LLVM ERROR: cannot select: %1:gpr64sp(p0) = G_GLOBAL_VALUE @general_dynamic_var (in function: test_generaldynamic)
}
define ptr @test_generaldynamic_addr() {
; CHECK-LABEL: test_generaldynamic_addr:
ret ptr @general_dynamic_var
; CHECK: adrp x[[TLSDESC_HI:[0-9]+]], :tlsdesc_auth:general_dynamic_var
; CHECK-NEXT: ldr x16, [x[[TLSDESC_HI]], :tlsdesc_auth_lo12:general_dynamic_var]
; CHECK-NEXT: add x0, x[[TLSDESC_HI]], :tlsdesc_auth_lo12:general_dynamic_var
; CHECK-NEXT: blraa x16, x0
; CHECK-NEXT: mrs [[TP:x[0-9]+]], TPIDR_EL0
; CHECK-NEXT: add x0, [[TP]], x0
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_LD64_LO12
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADD_LO12
; CHECK-OBJ-NOT: R_AARCH64_TLSDESC_CALL
}
;; Note: with signed TLSDESC, general dynamic model is always used,
;; even when local dynamic is requested.
@local_dynamic_var = external thread_local(localdynamic) global i32
define i32 @test_localdynamic() {
; CHECK-LABEL: test_localdynamic:
%val = load i32, ptr @local_dynamic_var
ret i32 %val
; CHECK: adrp x[[TLSDESC_HI:[0-9]+]], :tlsdesc_auth:local_dynamic_var
; CHECK-NEXT: ldr x16, [x[[TLSDESC_HI]], :tlsdesc_auth_lo12:local_dynamic_var]
; CHECK-NEXT: add x0, x[[TLSDESC_HI]], :tlsdesc_auth_lo12:local_dynamic_var
; CHECK-NEXT: blraa x16, x0
; CHECK-NEXT: mrs x[[TPIDR:[0-9]+]], TPIDR_EL0
; CHECK-NEXT: ldr w0, [x[[TPIDR]], x0]
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_LD64_LO12
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADD_LO12
; CHECK-OBJ-NOT: R_AARCH64_TLSDESC_CALL
}
define ptr @test_localdynamic_addr() {
; CHECK-LABEL: test_localdynamic_addr:
ret ptr @local_dynamic_var
; CHECK: adrp x[[TLSDESC_HI:[0-9]+]], :tlsdesc_auth:local_dynamic_var
; CHECK-NEXT: ldr x16, [x[[TLSDESC_HI]], :tlsdesc_auth_lo12:local_dynamic_var]
; CHECK-NEXT: add x0, x[[TLSDESC_HI]], :tlsdesc_auth_lo12:local_dynamic_var
; CHECK-NEXT: blraa x16, x0
; CHECK-NEXT: mrs x[[TPIDR:[0-9]+]], TPIDR_EL0
; CHECK-NEXT: add x0, x[[TPIDR]], x0
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_LD64_LO12
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADD_LO12
; CHECK-OBJ-NOT: R_AARCH64_TLSDESC_CALL
}
@extern_weak_var = extern_weak thread_local global i32
define i32 @test_extern_weak() {
; CHECK-LABEL: test_extern_weak:
%val = load i32, ptr @extern_weak_var
ret i32 %val
; CHECK: adrp x[[TLSDESC_HI:[0-9]+]], :tlsdesc_auth:extern_weak_var
; CHECK-NEXT: ldr x16, [x[[TLSDESC_HI]], :tlsdesc_auth_lo12:extern_weak_var]
; CHECK-NEXT: add x0, x[[TLSDESC_HI]], :tlsdesc_auth_lo12:extern_weak_var
; CHECK-NEXT: blraa x16, x0
; CHECK-NEXT: mrs x[[TPIDR:[0-9]+]], TPIDR_EL0
; CHECK-NEXT: ldr w0, [x[[TPIDR]], x0]
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADR_PAGE21
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_LD64_LO12
; CHECK-OBJ: R_AARCH64_AUTH_TLSDESC_ADD_LO12
; CHECK-OBJ-NOT: R_AARCH64_TLSDESC_CALL
; CHECK-OBJ: 0000000000000000 0 TLS WEAK DEFAULT UND extern_weak_var
}
!llvm.module.flags = !{!0}
!0 = !{i32 8, !"ptrauth-elf-got", i32 1}
|