[llvm] [InstrRef] Preserve debug instr num in aarch64-ldst-opt. (PR #136009)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 08:08:55 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()) {
----------------
jmorse wrote:
```suggestion
for (const auto &Op : MergedInstr.operands()) {
```
Avoids the risk of copy-constructing a MachineOperand where we can just refer to it.
https://github.com/llvm/llvm-project/pull/136009
More information about the llvm-commits
mailing list