Skip to content

Commit 81cb742

Browse files
committed
Ensure that ptrauth subtarget feature is checked for ptrauth-returns
1 parent 52afe42 commit 81cb742

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,9 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
15111511
// If we're saving LR, sign it first.
15121512
if (shouldAuthenticateLR(MF)) {
15131513
if (LLVM_UNLIKELY(!Subtarget.hasPAuth()))
1514-
report_fatal_error("arm64e LR authentication requires ptrauth");
1514+
report_fatal_error(
1515+
StringRef(Subtarget.isTargetMachO() ? "arm64e" : "aarch64") +
1516+
" LR authentication requires ptrauth");
15151517
for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) {
15161518
if (Info.getReg() != AArch64::LR)
15171519
continue;
@@ -2051,7 +2053,9 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF,
20512053
auto InsertAuthLROnExit = make_scope_exit([&]() {
20522054
if (shouldAuthenticateLR(MF)) {
20532055
if (LLVM_UNLIKELY(!Subtarget.hasPAuth()))
2054-
report_fatal_error("arm64e LR authentication requires ptrauth");
2056+
report_fatal_error(
2057+
StringRef(Subtarget.isTargetMachO() ? "arm64e" : "aarch64") +
2058+
" LR authentication requires ptrauth");
20552059
for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) {
20562060
if (Info.getReg() != AArch64::LR)
20572061
continue;

llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-lowering-err.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,21 @@ define i8* @foo() #0 {
5252
@g_weak.ptrauth = private constant { i8*, i32, i64, i64 } { i8* bitcast (i32* @g_weak to i8*), i32 0, i64 0, i64 0 }, section "llvm.ptrauth"
5353

5454
attributes #0 = { "ptrauth-calls" "target-cpu"="generic" }
55+
56+
;--- ptrauth-returns.ll
57+
58+
; RUN: not --crash llc -mtriple aarch64-elf ptrauth-returns.ll 2>&1 | \
59+
; RUN: FileCheck ptrauth-returns.ll
60+
61+
; CHECK: LLVM ERROR: aarch64 LR authentication requires ptrauth
62+
63+
define i32 @bar() #0 {
64+
ret i32 42
65+
}
66+
67+
define i32 @foo() {
68+
%tmp = call i32 @bar()
69+
ret i32 %tmp
70+
}
71+
72+
attributes #0 = { "ptrauth-returns" "target-cpu"="generic" }

0 commit comments

Comments
 (0)