diff options
author | Jeremy Morse <jeremy.morse.llvm@gmail.com> | 2019-09-02 12:28:36 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse.llvm@gmail.com> | 2019-09-02 12:28:36 +0000 |
commit | 22493f66f168cf3cf8512e42b4ffb32f3f30b949 (patch) | |
tree | d1bbcfeebaf3ab31989303cfba7f3cbf2c4d764f /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 9bc338b89ec02cdb87d54ef9d431544c52b7774a (diff) | |
download | bcm5719-llvm-22493f66f168cf3cf8512e42b4ffb32f3f30b949.tar.gz bcm5719-llvm-22493f66f168cf3cf8512e42b4ffb32f3f30b949.zip |
[DebugInfo] LiveDebugValues: correctly discriminate kinds of variable locations
The missing line added by this patch ensures that only spilt variable
locations are candidates for being restored from the stack. Otherwise,
register or constant-value information can be interpreted as a spill
location, through a union.
The added regression test replicates a scenario where this occurs: the
stack load from [rsp] causes the register-location DBG_VALUE to be
"restored" to rsi, when it should be left alone. See PR43058 for details.
Un x-fail a test that was suffering from this from a previous patch.
Differential Revision: https://reviews.llvm.org/D66895
llvm-svn: 370648
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 7316148e4c0..779f6086b8c 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -2119,7 +2119,21 @@ void MachineInstr::collectDebugValues( void MachineInstr::changeDebugValuesDefReg(Register Reg) { // Collect matching debug values. SmallVector<MachineInstr *, 2> DbgValues; - collectDebugValues(DbgValues); + + if (!getOperand(0).isReg()) + return; + + unsigned DefReg = getOperand(0).getReg(); + auto *MRI = getRegInfo(); + for (auto &MO : MRI->use_operands(DefReg)) { + auto *DI = MO.getParent(); + if (!DI->isDebugValue()) + continue; + if (DI->getOperand(0).isReg() && + DI->getOperand(0).getReg() == DefReg){ + DbgValues.push_back(DI); + } + } // Propagate Reg to debug value instructions. for (auto *DBI : DbgValues) |