[llvm] [AArch64][BTI] Add BTI at EH entries. (PR #155308)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 13:59:24 PDT 2025
================
@@ -143,11 +161,33 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall,
MBBI->getOpcode() == AArch64::PACIBSP))
return;
- if (HasWinCFI && MBBI->getFlag(MachineInstr::FrameSetup)) {
+ // If there's already a HINT at the insertion point, handle BTI safely.
+ if (MBBI != MBB.end() && MBBI->getOpcode() == AArch64::HINT) {
+ // Only "upgrade" if it is actually a BTI HINT (base 32). Otherwise,
+ // fall through and insert a BTI before this non-BTI hint, so the
+ // first executed instruction is BTI/PAC as required by enforcement.
+ if (MBBI->getOperand(0).isImm()) {
+ int64_t Imm = MBBI->getOperand(0).getImm();
+ if ((Imm & ~int64_t(BTIMask)) == BTIBase) {
+ unsigned Have = unsigned(Imm) & BTIMask;
----------------
efriedma-quic wrote:
Is this code actually reachable? As far as I can tell, no other pass actually generates BTI instructions, so we should never find one.
https://github.com/llvm/llvm-project/pull/155308
More information about the llvm-commits
mailing list