[llvm] [InstrRef] Preserve debug instr num in aarch64-ldst-opt. (PR #136009)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 08:32:28 PDT 2025


================
@@ -965,6 +965,40 @@ static void updateDefinedRegisters(MachineInstr &MI, LiveRegUnits &Units,
       Units.addReg(MOP.getReg());
 }
 
+/// Find the DBG_INSTR_REF instruction that references the \p InstrNum
+static std::optional<MachineInstr *> findDebugInstrRef(MachineBasicBlock *MBB,
+                                                       unsigned InstrNum) {
+
+  for (auto &MI : *MBB) {
+    if (MI.isDebugRef())
+      if (MI.getOperand(2).getInstrRefInstrIndex() == InstrNum)
----------------
jmorse wrote:

While it's a fixed location it could also be a symbolic constant; I think the true reason it's a hardcoded offset is because it recently changed when @SLTozer made everything variadic. No reason why we couldn't firm it up now. Previously it was at operand index zero, and `getOperand(0)` is more or less an idiom in the backend.

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


More information about the llvm-commits mailing list