diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2021-07-20 10:43:21 +0100 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2021-07-20 11:45:13 +0100 |
commit | 241f3e386cd2ce176ac32a957732664ad69b6144 (patch) | |
tree | 029ac9f5c051e604f697d111501106c04c4c7d2a /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 9ced84de0916ca521c6bbf888db9db9b26e487d0 (diff) | |
download | llvm-241f3e386cd2ce176ac32a957732664ad69b6144.zip llvm-241f3e386cd2ce176ac32a957732664ad69b6144.tar.gz llvm-241f3e386cd2ce176ac32a957732664ad69b6144.tar.bz2 |
[DebugInfo][InstrRef] Fix a broken substitution method, add test coverage
This patch fixes a clearly-broken function that I absent-mindedly bodged
many months ago.
Over in D85749 I landed the substituteDebugValuesForInst, that creates
substitution records for all the def operands from one debug-labelled
instruction to the new one. Unfortunately it would crash if the two
instructions had different numbers of operands; I tried to fix this in
537f0fbe82 by adding a "max operand" parameter to the method, but then
didn't actually change the loop bound to take account of this. It passed
all the tests because.... well there wasn't any real test coverage of this
method.
This patch fixes up the loop to be bounded by the MaxOperand bound; and
adds test coverage for the x86-fixup-LEAs calls to this method, so that
it's actually tested.
Differential Revision: https://reviews.llvm.org/D105820
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index d26f581..72e5870 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -990,7 +990,7 @@ void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old, // 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) { + for (unsigned int I = 0; I < MaxOperand; ++I) { const auto &OldMO = Old.getOperand(I); auto &NewMO = New.getOperand(I); (void)NewMO; |