[llvm] [llvm][aarch64] Mark PAuth_LR PACSym offset adrp+add's as FrameDestroy (PR #190439)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 17:55:35 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Jon Roelofs (jroelofs)
<details>
<summary>Changes</summary>
These only really make sense in epilogues where we're preparing to tear down the frame and authenticate a pc-diversified LR, so mark them as part of the elilogue with FrameDestroy.
---
Patch is 37.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/190439.diff
3 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64PointerAuth.cpp (+16-11)
- (added) llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr-mir.ll (+550)
- (modified) llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll (+2)
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
index fe50b97e9b832..fdaa92b650a2a 100644
--- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
+++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
@@ -60,16 +60,19 @@ FunctionPass *llvm::createAArch64PointerAuthPass() {
char AArch64PointerAuthLegacy::ID = 0;
-static void emitPACSymOffsetIntoX16(const TargetInstrInfo &TII,
- MachineBasicBlock &MBB,
- MachineBasicBlock::iterator I, DebugLoc DL,
- MCSymbol *PACSym) {
- BuildMI(MBB, I, DL, TII.get(AArch64::ADRP), AArch64::X16)
- .addSym(PACSym, AArch64II::MO_PAGE);
- BuildMI(MBB, I, DL, TII.get(AArch64::ADDXri), AArch64::X16)
- .addReg(AArch64::X16)
+static void emitEpiloguePACSymOffsetIntoReg(const TargetInstrInfo &TII,
+ MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator I,
+ DebugLoc DL, MCSymbol *PACSym,
+ Register Reg) {
+ BuildMI(MBB, I, DL, TII.get(AArch64::ADRP), Reg)
+ .addSym(PACSym, AArch64II::MO_PAGE)
+ .setMIFlag(MachineInstr::FrameDestroy);
+ BuildMI(MBB, I, DL, TII.get(AArch64::ADDXri), Reg)
+ .addReg(Reg)
.addSym(PACSym, AArch64II::MO_PAGEOFF | AArch64II::MO_NC)
- .addImm(0);
+ .addImm(0)
+ .setMIFlag(MachineInstr::FrameDestroy);
}
static void emitPACCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
@@ -175,7 +178,8 @@ void AArch64PointerAuthImpl::authenticateLR(
.setMIFlag(MachineInstr::FrameDestroy);
} else {
if (MFnI->branchProtectionPAuthLR()) {
- emitPACSymOffsetIntoX16(*TII, MBB, MBBI, DL, PACSym);
+ emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym,
+ AArch64::X16);
BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
.setMIFlag(MachineInstr::FrameDestroy);
}
@@ -194,7 +198,8 @@ void AArch64PointerAuthImpl::authenticateLR(
.setMIFlag(MachineInstr::FrameDestroy);
} else {
if (MFnI->branchProtectionPAuthLR()) {
- emitPACSymOffsetIntoX16(*TII, MBB, MBBI, DL, PACSym);
+ emitEpiloguePACSymOffsetIntoReg(*TII, MBB, MBBI, DL, PACSym,
+ AArch64::X16);
BuildMI(MBB, MBBI, DL, TII->get(AArch64::PACM))
.setMIFlag(MachineInstr::FrameDestroy);
emitPACCFI(MBB, MBBI, MachineInstr::FrameDestroy, EmitAsyncCFI);
diff --git a/llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr-mir.ll b/llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr-mir.ll
new file mode 100644
index 0000000000000..f6e7e618f9a0f
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr-mir.ll
@@ -0,0 +1,550 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+
+; RUN: llc -mtriple=aarch64 -stop-after=aarch64-ptrauth < %s | FileCheck --check-prefixes=CHECK-MIR,COMPAT-MIR %s
+; RUN: llc -mtriple=aarch64 -stop-after=aarch64-ptrauth -mattr=v8.3a < %s | FileCheck --check-prefixes=CHECK-MIR,V83A-MIR %s
+; RUN: llc -mtriple=aarch64 -stop-after=aarch64-ptrauth -mattr=v9a -mattr=pauth-lr < %s | FileCheck --check-prefixes=PAUTHLR-MIR %s
+
+; See also: sign-return-address-pauth-lr.ll
+
+define i32 @leaf(i32 %x) "branch-protection-pauth-lr" {
+ ; CHECK-MIR-LABEL: name: leaf
+ ; CHECK-MIR: bb.0 (%ir-block.0):
+ ; CHECK-MIR-NEXT: liveins: $w0
+ ; CHECK-MIR-NEXT: {{ $}}
+ ; CHECK-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; PAUTHLR-MIR-LABEL: name: leaf
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ret i32 %x
+}
+
+define i32 @leaf_sign_none(i32 %x) "branch-protection-pauth-lr" {
+ ; CHECK-MIR-LABEL: name: leaf_sign_none
+ ; CHECK-MIR: bb.0 (%ir-block.0):
+ ; CHECK-MIR-NEXT: liveins: $w0
+ ; CHECK-MIR-NEXT: {{ $}}
+ ; CHECK-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; PAUTHLR-MIR-LABEL: name: leaf_sign_none
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ret i32 %x
+}
+
+define i32 @leaf_sign_non_leaf(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {
+ ; CHECK-MIR-LABEL: name: leaf_sign_non_leaf
+ ; CHECK-MIR: bb.0 (%ir-block.0):
+ ; CHECK-MIR-NEXT: liveins: $w0
+ ; CHECK-MIR-NEXT: {{ $}}
+ ; CHECK-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; PAUTHLR-MIR-LABEL: name: leaf_sign_non_leaf
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ret i32 %x
+}
+
+define i32 @leaf_sign_all(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" {
+ ; COMPAT-MIR-LABEL: name: leaf_sign_all
+ ; COMPAT-MIR: bb.0 (%ir-block.0):
+ ; COMPAT-MIR-NEXT: liveins: $w0
+ ; COMPAT-MIR-NEXT: {{ $}}
+ ; COMPAT-MIR-NEXT: frame-setup PACM
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; COMPAT-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; COMPAT-MIR-NEXT: frame-destroy PACM
+ ; COMPAT-MIR-NEXT: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp
+ ; COMPAT-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; V83A-MIR-LABEL: name: leaf_sign_all
+ ; V83A-MIR: bb.0 (%ir-block.0):
+ ; V83A-MIR-NEXT: liveins: $w0
+ ; V83A-MIR-NEXT: {{ $}}
+ ; V83A-MIR-NEXT: frame-setup PACM
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; V83A-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; V83A-MIR-NEXT: frame-destroy PACM
+ ; V83A-MIR-NEXT: frame-destroy RETAA implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ ;
+ ; PAUTHLR-MIR-LABEL: name: leaf_sign_all
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; PAUTHLR-MIR-NEXT: frame-setup PACIASPPC implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; PAUTHLR-MIR-NEXT: frame-destroy RETAASPPCi <mcsymbol >, implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ ret i32 %x
+}
+
+define i64 @leaf_clobbers_lr(i64 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {
+ ; COMPAT-MIR-LABEL: name: leaf_clobbers_lr
+ ; COMPAT-MIR: bb.0 (%ir-block.0):
+ ; COMPAT-MIR-NEXT: liveins: $x0, $lr
+ ; COMPAT-MIR-NEXT: {{ $}}
+ ; COMPAT-MIR-NEXT: frame-setup PACM
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; COMPAT-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; COMPAT-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; COMPAT-MIR-NEXT: INLINEASM &"mov x30, $0", 1 /* sideeffect attdialect */, 3866633 /* reguse:GPR64common */, renamable $x0, 12 /* clobber */, implicit-def dead early-clobber $lr
+ ; COMPAT-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; COMPAT-MIR-NEXT: frame-destroy PACM
+ ; COMPAT-MIR-NEXT: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp
+ ; COMPAT-MIR-NEXT: RET undef $lr, implicit killed $x0
+ ;
+ ; V83A-MIR-LABEL: name: leaf_clobbers_lr
+ ; V83A-MIR: bb.0 (%ir-block.0):
+ ; V83A-MIR-NEXT: liveins: $x0, $lr
+ ; V83A-MIR-NEXT: {{ $}}
+ ; V83A-MIR-NEXT: frame-setup PACM
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; V83A-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; V83A-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; V83A-MIR-NEXT: INLINEASM &"mov x30, $0", 1 /* sideeffect attdialect */, 3866633 /* reguse:GPR64common */, renamable $x0, 12 /* clobber */, implicit-def dead early-clobber $lr
+ ; V83A-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; V83A-MIR-NEXT: frame-destroy PACM
+ ; V83A-MIR-NEXT: frame-destroy RETAA implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ ;
+ ; PAUTHLR-MIR-LABEL: name: leaf_clobbers_lr
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $x0, $lr
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; PAUTHLR-MIR-NEXT: frame-setup PACIASPPC implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; PAUTHLR-MIR-NEXT: INLINEASM &"mov x30, $0", 1 /* sideeffect attdialect */, 3866633 /* reguse:GPR64common */, renamable $x0, 12 /* clobber */, implicit-def dead early-clobber $lr
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-destroy RETAASPPCi <mcsymbol >, implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1
+ ret i64 %x
+}
+
+declare i32 @foo(i32)
+
+define i32 @non_leaf_sign_all(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="all" {
+ ; COMPAT-MIR-LABEL: name: non_leaf_sign_all
+ ; COMPAT-MIR: bb.0 (%ir-block.0):
+ ; COMPAT-MIR-NEXT: liveins: $w0, $lr
+ ; COMPAT-MIR-NEXT: {{ $}}
+ ; COMPAT-MIR-NEXT: frame-setup PACM
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; COMPAT-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; COMPAT-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; COMPAT-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; COMPAT-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; COMPAT-MIR-NEXT: frame-destroy PACM
+ ; COMPAT-MIR-NEXT: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp
+ ; COMPAT-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; V83A-MIR-LABEL: name: non_leaf_sign_all
+ ; V83A-MIR: bb.0 (%ir-block.0):
+ ; V83A-MIR-NEXT: liveins: $w0, $lr
+ ; V83A-MIR-NEXT: {{ $}}
+ ; V83A-MIR-NEXT: frame-setup PACM
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; V83A-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; V83A-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; V83A-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; V83A-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; V83A-MIR-NEXT: frame-destroy PACM
+ ; V83A-MIR-NEXT: frame-destroy RETAA implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ ;
+ ; PAUTHLR-MIR-LABEL: name: non_leaf_sign_all
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0, $lr
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; PAUTHLR-MIR-NEXT: frame-setup PACIASPPC implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; PAUTHLR-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-destroy RETAASPPCi <mcsymbol >, implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ %call = call i32 @foo(i32 %x)
+ ret i32 %call
+}
+
+define i32 @non_leaf_sign_non_leaf(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" {
+ ; COMPAT-MIR-LABEL: name: non_leaf_sign_non_leaf
+ ; COMPAT-MIR: bb.0 (%ir-block.0):
+ ; COMPAT-MIR-NEXT: liveins: $w0, $lr
+ ; COMPAT-MIR-NEXT: {{ $}}
+ ; COMPAT-MIR-NEXT: frame-setup PACM
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; COMPAT-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; COMPAT-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; COMPAT-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; COMPAT-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; COMPAT-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; COMPAT-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; COMPAT-MIR-NEXT: frame-destroy PACM
+ ; COMPAT-MIR-NEXT: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp
+ ; COMPAT-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; V83A-MIR-LABEL: name: non_leaf_sign_non_leaf
+ ; V83A-MIR: bb.0 (%ir-block.0):
+ ; V83A-MIR-NEXT: liveins: $w0, $lr
+ ; V83A-MIR-NEXT: {{ $}}
+ ; V83A-MIR-NEXT: frame-setup PACM
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; V83A-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; V83A-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; V83A-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; V83A-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; V83A-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; V83A-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; V83A-MIR-NEXT: frame-destroy PACM
+ ; V83A-MIR-NEXT: frame-destroy RETAA implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ ;
+ ; PAUTHLR-MIR-LABEL: name: non_leaf_sign_non_leaf
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0, $lr
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; PAUTHLR-MIR-NEXT: frame-setup PACIASPPC implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; PAUTHLR-MIR-NEXT: BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; PAUTHLR-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; PAUTHLR-MIR-NEXT: frame-destroy RETAASPPCi <mcsymbol >, implicit $lr, implicit $sp, implicit-def $lr, implicit killed $lr, implicit $sp
+ %call = call i32 @foo(i32 %x)
+ ret i32 %call
+}
+
+define i32 @non_leaf_scs(i32 %x) "branch-protection-pauth-lr" "sign-return-address"="non-leaf" shadowcallstack "target-features"="+v8.3a,+reserve-x18" {
+ ; CHECK-MIR-LABEL: name: non_leaf_scs
+ ; CHECK-MIR: bb.0 (%ir-block.0):
+ ; CHECK-MIR-NEXT: liveins: $w0, $lr, $x18
+ ; CHECK-MIR-NEXT: {{ $}}
+ ; CHECK-MIR-NEXT: frame-setup PACM
+ ; CHECK-MIR-NEXT: frame-setup CFI_INSTRUCTION negate_ra_sign_state_with_pc
+ ; CHECK-MIR-NEXT: frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp, pre-instr-symbol <mcsymbol >
+ ; CHECK-MIR-NEXT: early-clobber $x18 = frame-setup STRXpost $lr, $x18, 8
+ ; CHECK-MIR-NEXT: frame-setup CFI_INSTRUCTION escape 0x16, 0x12, 0x02, 0x82, 0x78
+ ; CHECK-MIR-NEXT: early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.0)
+ ; CHECK-MIR-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ ; CHECK-MIR-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -16
+ ; CHECK-MIR-NEXT: BL @foo, csr_aarch64_aapcs_scs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
+ ; CHECK-MIR-NEXT: early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.0)
+ ; CHECK-MIR-NEXT: early-clobber $x18, $lr = frame-destroy LDRXpre $x18, -8
+ ; CHECK-MIR-NEXT: $x16 = frame-destroy ADRP target-flags(aarch64-page) <mcsymbol >
+ ; CHECK-MIR-NEXT: $x16 = frame-destroy ADDXri $x16, target-flags(aarch64-pageoff, aarch64-nc) <mcsymbol >, 0
+ ; CHECK-MIR-NEXT: frame-destroy PACM
+ ; CHECK-MIR-NEXT: frame-destroy AUTIASP implicit-def $lr, implicit $lr, implicit $sp
+ ; CHECK-MIR-NEXT: RET undef $lr, implicit killed $w0
+ ;
+ ; PAUTHLR-MIR-LABEL: name: non_leaf_scs
+ ; PAUTHLR-MIR: bb.0 (%ir-block.0):
+ ; PAUTHLR-MIR-NEXT: liveins: $w0, $lr, $x18
+ ; PAUTHLR-MIR-NEXT: {{ $}}
+ ; PAUTHLR-MIR-NEXT: frame-setup CFI_INSTRUCTION neg...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/190439
More information about the llvm-commits
mailing list