[llvm] [LFI][AArch64] Add rewrites for control flow (PR #192602)

Zachary Yedidia via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 12:53:48 PDT 2026


================
@@ -51,3 +51,14 @@ bool MCLFIRewriter::mayModifyRegister(const MCInst &Inst,
                                       MCRegister Reg) const {
   return InstInfo->get(Inst.getOpcode()).hasDefOfPhysReg(Inst, Reg, *RegInfo);
 }
+
+bool MCLFIRewriter::explicitlyModifiesRegister(const MCInst &Inst,
+                                               MCRegister Reg) const {
+  const MCInstrDesc &Desc = InstInfo->get(Inst.getOpcode());
+  for (unsigned I = 0, E = Desc.getNumDefs(); I != E; ++I) {
+    if (Desc.operands()[I].OperandType == MCOI::OPERAND_REGISTER &&
+        RegInfo->isSubRegisterEq(Reg, Inst.getOperand(I).getReg()))
+      return true;
+  }
----------------
zyedidia wrote:

It can't directly be used here -- `hasDefOfPhysReg` is used above in the `mayModifyRegister` function but it includes implicit defs, which we are trying to avoid in this function (so that for example `bl` doesn't cause a guard on LR).

https://github.com/llvm/llvm-project/pull/192602


More information about the llvm-commits mailing list