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

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 17 17:38:54 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)
+        return &MI;
+  }
+  return std::nullopt;
+}
+
+/// Set the correct debug-instr-number and the operand index in case of a merge.
----------------
adrian-prantl wrote:

In fact, this function doesn't seem to do anything specific to merges, so not give it a generic name that describes the abstract operation that it does (finding an instrref for a number and setting the instrnum to that)?

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


More information about the llvm-commits mailing list