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

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 14:03:29 PDT 2025


================
@@ -965,6 +965,28 @@ static void updateDefinedRegisters(MachineInstr &MI, LiveRegUnits &Units,
       Units.addReg(MOP.getReg());
 }
 
+/// This function will add a new entry into the debugValueSubstitutions table
+/// when two instruction have been merged into a new one represented by \p
+/// MergedInstr.
+static void addDebugSubstitutionsToTable(MachineFunction *MF,
+                                         unsigned InstrNumToSet,
+                                         MachineInstr &OriginalInstr,
+                                         MachineInstr &MergedInstr) {
+
+  // Figure out the Operand Index of the destination register of the
+  // OriginalInstr in the new MergedInstr.
+  auto Reg = OriginalInstr.getOperand(0).getReg();
+  unsigned OperandNo = 0;
+  for (auto Op : MergedInstr.operands()) {
+    if (Op.getReg() == Reg)
+      break;
+    OperandNo++;
----------------
adrian-prantl wrote:

Are we okay with this returning a bogus result if there is no Reg operand?

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


More information about the llvm-commits mailing list