diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2020-10-21 14:28:28 +0100 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2020-10-21 14:45:55 +0100 |
commit | 537f0fbe82049b8d5b6c700ecc4ab166c350b0c6 (patch) | |
tree | d838342da8d76942c71e8ec3c918fdc4234d437c /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 1bcec29afb321976cdcaa632ee6a47567dd651a7 (diff) | |
download | llvm-537f0fbe82049b8d5b6c700ecc4ab166c350b0c6.zip llvm-537f0fbe82049b8d5b6c700ecc4ab166c350b0c6.tar.gz llvm-537f0fbe82049b8d5b6c700ecc4ab166c350b0c6.tar.bz2 |
[DebugInfo] Follow up c521e44defb5 with an API improvement
As mentioned post-commit in D85749, the 'substituteDebugValuesForInst'
method added in c521e44defb5 would be better off with a limit on the
number of operands to substitute. This handles the common case of
"substitute the first operand between these two differing instructions",
or possibly up to N first operands.
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 2568448..a7edc27 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -955,7 +955,8 @@ void MachineFunction::makeDebugValueSubstitution(DebugInstrOperandPair A, } void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old, - MachineInstr &New) { + MachineInstr &New, + unsigned MaxOperand) { // If the Old instruction wasn't tracked at all, there is no work to do. unsigned OldInstrNum = Old.peekDebugInstrNum(); if (!OldInstrNum) @@ -965,12 +966,16 @@ void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old, // Avoid creating new instr numbers unless we create a new substitution. // While this has no functional effect, it risks confusing someone reading // MIR output. + // Examine all the operands, or the first N specified by the caller. + MaxOperand = std::min(MaxOperand, Old.getNumOperands()); for (unsigned int I = 0; I < Old.getNumOperands(); ++I) { const auto &OldMO = Old.getOperand(I); + auto &NewMO = New.getOperand(I); + (void)NewMO; if (!OldMO.isReg() || !OldMO.isDef()) continue; - assert(Old.getOperand(I).isDef()); + assert(NewMO.isDef()); unsigned NewInstrNum = New.getDebugInstrNum(); makeDebugValueSubstitution(std::make_pair(OldInstrNum, I), |