[llvm] [AArch64][PAC] Fix creating check instructions for BBs without an epilog (PR #92508)
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed May 22 11:57:25 PDT 2024
================
@@ -246,65 +246,56 @@ MachineBasicBlock &llvm::AArch64PAuth::checkAuthenticatedRegister(
default:
break;
case AuthCheckMethod::None:
- return MBB;
+ return;
case AuthCheckMethod::DummyLoad:
BuildMI(MBB, MBBI, DL, TII->get(AArch64::LDRWui), getWRegFromXReg(TmpReg))
.addReg(AuthenticatedReg)
.addImm(0)
.addMemOperand(createCheckMemOperand(MF, Subtarget));
- return MBB;
+ return;
}
// Control flow has to be changed, so arrange new MBBs.
- // At now, at least an AUT* instruction is expected before MBBI
- assert(MBBI != MBB.begin() &&
- "Cannot insert the check at the very beginning of MBB");
- // The block to insert check into.
- MachineBasicBlock *CheckBlock = &MBB;
- // The remaining part of the original MBB that is executed on success.
- MachineBasicBlock *SuccessBlock = MBB.splitAt(*std::prev(MBBI));
-
// The block that explicitly generates a break-point exception on failure.
MachineBasicBlock *BreakBlock =
MF.CreateMachineBasicBlock(MBB.getBasicBlock());
MF.push_back(BreakBlock);
- MBB.splitSuccessor(SuccessBlock, BreakBlock);
+ MBB.addSuccessor(BreakBlock);
- assert(CheckBlock->getFallThrough() == SuccessBlock);
BuildMI(BreakBlock, DL, TII->get(AArch64::BRK)).addImm(BrkImm);
----------------
igorkudrin wrote:
The method only uses `MBBI` as the insertion point. It will still produce correct output even if called for a non-terminal instruction, so semantically such a check is not needed here.
https://github.com/llvm/llvm-project/pull/92508
More information about the llvm-commits
mailing list