Skip to content

Commit 8c2472c

Browse files
committed
Misc improvements
1 parent 248ab08 commit 8c2472c

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
114114
if (!MFI->shouldSignReturnAddress(MF))
115115
return NumBytes;
116116

117-
auto &STI = MF->getSubtarget<AArch64Subtarget>();
117+
const auto &STI = MF->getSubtarget<AArch64Subtarget>();
118118
auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
119119
NumBytes += AArch64PAuth::getCheckerSizeInBytes(Method);
120120
return NumBytes;

llvm/lib/Target/AArch64/AArch64InstrInfo.td

+4-4
Original file line numberDiff line numberDiff line change
@@ -1972,16 +1972,16 @@ let Predicates = [HasPAuth] in {
19721972

19731973
let Predicates = [TailCallAny] in
19741974
def : Pat<(AArch64authtcret tcGPR64:$dst, (i32 timm:$FPDiff), (i32 timm:$Key),
1975-
(i64 timm:$Disc), tcGPR64:$AddrDisc),
1975+
(i64 timm:$Disc), tcGPRnotx16x17:$AddrDisc),
19761976
(AUTH_TCRETURN tcGPR64:$dst, imm:$FPDiff, imm:$Key, imm:$Disc,
1977-
tcGPR64:$AddrDisc)>;
1977+
tcGPRnotx16x17:$AddrDisc)>;
19781978

19791979
let Predicates = [TailCallX16X17] in
19801980
def : Pat<(AArch64authtcret tcGPRx16x17:$dst, (i32 timm:$FPDiff),
19811981
(i32 timm:$Key), (i64 timm:$Disc),
1982-
tcGPR64:$AddrDisc),
1982+
tcGPRnotx16x17:$AddrDisc),
19831983
(AUTH_TCRETURN_BTI tcGPRx16x17:$dst, imm:$FPDiff, imm:$Key,
1984-
imm:$Disc, tcGPR64:$AddrDisc)>;
1984+
imm:$Disc, tcGPRnotx16x17:$AddrDisc)>;
19851985
}
19861986

19871987
// v9.5-A pointer authentication extensions

llvm/lib/Target/AArch64/AArch64PointerAuth.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ enum class AuthCheckMethod {
8686
};
8787

8888
#define AUTH_CHECK_METHOD_CL_VALUES_COMMON \
89-
clEnumValN(AArch64PAuth::AuthCheckMethod::None, "none", \
90-
"Do not check authenticated address"), \
89+
clEnumValN(AArch64PAuth::AuthCheckMethod::None, "none", \
90+
"Do not check authenticated address"), \
9191
clEnumValN(AArch64PAuth::AuthCheckMethod::DummyLoad, "load", \
9292
"Perform dummy load from authenticated address"), \
93-
clEnumValN(AArch64PAuth::AuthCheckMethod::HighBitsNoTBI, \
94-
"high-bits-notbi", \
95-
"Compare bits 62 and 61 of address (TBI should be disabled)")
93+
clEnumValN( \
94+
AArch64PAuth::AuthCheckMethod::HighBitsNoTBI, "high-bits-notbi", \
95+
"Compare bits 62 and 61 of address (TBI should be disabled)"), \
96+
clEnumValN(AArch64PAuth::AuthCheckMethod::XPAC, "xpac", \
97+
"Compare with the result of XPAC (requires Armv8.3-a)")
9698

9799
#define AUTH_CHECK_METHOD_CL_VALUES_LR \
98100
AUTH_CHECK_METHOD_CL_VALUES_COMMON, \

llvm/test/CodeGen/AArch64/sign-return-address-tailcall.ll

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=high-bits-notbi < %s | FileCheck -DAUTIASP="hint #29" --check-prefixes=COMMON,BITS-NOTBI,BRK %s
44
; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac-hint < %s | FileCheck -DAUTIASP="hint #29" -DXPACLRI="hint #7" --check-prefixes=COMMON,XPAC,BRK %s
55
; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac-hint -mattr=v8.3a < %s | FileCheck -DAUTIASP="autiasp" -DXPACLRI="xpaclri" --check-prefixes=COMMON,XPAC,BRK %s
6+
; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac -mattr=v8.3a < %s | FileCheck -DAUTIASP="autiasp" --check-prefixes=COMMON,XPAC83,BRK %s
67

78
define i32 @tailcall_direct() "sign-return-address"="non-leaf" {
89
; COMMON-LABEL: tailcall_direct:
@@ -21,6 +22,11 @@ define i32 @tailcall_direct() "sign-return-address"="non-leaf" {
2122
; XPAC-NEXT: cmp x30, x16
2223
; XPAC-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
2324
;
25+
; XPAC83-NEXT: mov x16, x30
26+
; XPAC83-NEXT: xpaci x16
27+
; XPAC83-NEXT: cmp x30, x16
28+
; XPAC83-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
29+
;
2430
; BRK-NEXT: brk #0xc470
2531
; BRK-NEXT: .[[GOOD]]:
2632
; COMMON-NEXT: b callee
@@ -46,6 +52,11 @@ define i32 @tailcall_indirect(ptr %fptr) "sign-return-address"="non-leaf" {
4652
; XPAC-NEXT: cmp x30, x16
4753
; XPAC-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
4854
;
55+
; XPAC83-NEXT: mov x16, x30
56+
; XPAC83-NEXT: xpaci x16
57+
; XPAC83-NEXT: cmp x30, x16
58+
; XPAC83-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
59+
;
4960
; BRK-NEXT: brk #0xc470
5061
; BRK-NEXT: .[[GOOD]]:
5162
; COMMON-NEXT: br x0
@@ -87,6 +98,11 @@ define i32 @tailcall_direct_noframe_sign_all() "sign-return-address"="all" {
8798
; XPAC-NEXT: cmp x30, x16
8899
; XPAC-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
89100
;
101+
; XPAC83-NEXT: mov x16, x30
102+
; XPAC83-NEXT: xpaci x16
103+
; XPAC83-NEXT: cmp x30, x16
104+
; XPAC83-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
105+
;
90106
; BRK-NEXT: brk #0xc470
91107
; BRK-NEXT: .[[GOOD]]:
92108
; COMMON-NEXT: b callee
@@ -111,6 +127,11 @@ define i32 @tailcall_indirect_noframe_sign_all(ptr %fptr) "sign-return-address"=
111127
; XPAC-NEXT: cmp x30, x16
112128
; XPAC-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
113129
;
130+
; XPAC83-NEXT: mov x16, x30
131+
; XPAC83-NEXT: xpaci x16
132+
; XPAC83-NEXT: cmp x30, x16
133+
; XPAC83-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
134+
;
114135
; BRK-NEXT: brk #0xc470
115136
; BRK-NEXT: .[[GOOD]]:
116137
; COMMON-NEXT: br x0
@@ -148,6 +169,11 @@ define i32 @tailcall_two_branches(i1 %0) "sign-return-address"="all" {
148169
; XPAC-NEXT: cmp x30, x16
149170
; XPAC-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
150171
;
172+
; XPAC83-NEXT: mov x16, x30
173+
; XPAC83-NEXT: xpaci x16
174+
; XPAC83-NEXT: cmp x30, x16
175+
; XPAC83-NEXT: b.eq .[[GOOD:Lauth_success[_0-9]+]]
176+
;
151177
; BRK-NEXT: brk #0xc470
152178
; BRK-NEXT: .[[GOOD]]:
153179
; COMMON-NEXT: b callee

0 commit comments

Comments
 (0)