diff options
author | Mikael Holmen <mikael.holmen@ericsson.com> | 2018-06-21 07:02:46 +0000 |
---|---|---|
committer | Mikael Holmen <mikael.holmen@ericsson.com> | 2018-06-21 07:02:46 +0000 |
commit | 57b33f6aac852d6f8d154d574b05b7689afc8e2b (patch) | |
tree | 727ba14af974501aee0c6922bc9fe7ec8c39f6bc /llvm/lib/CodeGen/LiveDebugVariables.cpp | |
parent | 76df3d61a394d06549264b22e3015fcc52201a6f (diff) | |
download | bcm5719-llvm-57b33f6aac852d6f8d154d574b05b7689afc8e2b.tar.gz bcm5719-llvm-57b33f6aac852d6f8d154d574b05b7689afc8e2b.zip |
[DebugInfo] Keep DBG_VALUE undef in LiveDebugVariables
Summary:
Fixes PR36579.
For cases where we had e.g.
DBG_VALUE 42
[...]
DBG_VALUE undef
LiveDebugVariables would discard all undef DBG_VALUEs and then it would
look like the variable had the value 42 throughout the rest of the
function, which is incorrect.
With this patch we don't remove all undef DBG_VALUEs in LiveDebugVariables
so they will be kept after register allocation just like other DBG_VALUEs
which will yield more correct debug information.
Reviewers: aprantl
Reviewed By: aprantl
Subscribers: bjope, Ka-Ka, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D48277
llvm-svn: 335205
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugVariables.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index 91c5e8565c0..0b6867cfbd8 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -224,7 +224,12 @@ public: return L1; } - /// getLocationNo - Return the location number that matches Loc. + /// Return the location number that matches Loc. + /// + /// For undef values we always return location number UndefLocNo without + /// inserting anything in locations. Since locations is a vector and the + /// location number is the position in the vector and UndefLocNo is ~0, + /// we would need a very big vector to put the value at the right position. unsigned getLocationNo(const MachineOperand &LocMO) { if (LocMO.isReg()) { if (LocMO.getReg() == 0) @@ -761,13 +766,6 @@ void UserValue::computeIntervals(MachineRegisterInfo &MRI, // function). } - // Erase all the undefs. - for (LocMap::iterator I = locInts.begin(); I.valid();) - if (I.value().isUndef()) - I.erase(); - else - ++I; - // The computed intervals may extend beyond the range of the debug // location's lexical scope. In this case, splitting of an interval // can result in an interval outside of the scope being created, @@ -990,7 +988,9 @@ UserValue::splitLocation(unsigned OldLocNo, ArrayRef<unsigned> NewRegs, << LocMapI.stop() << ")\n"); LocMapI.erase(); } else { - if (v.locNo() > OldLocNo) + // Undef values always have location number UndefLocNo, so don't change + // locNo in that case. See getLocationNo(). + if (!v.isUndef() && v.locNo() > OldLocNo) LocMapI.setValueUnchecked(v.changeLocNo(v.locNo() - 1)); ++LocMapI; } @@ -1099,6 +1099,10 @@ void UserValue::rewriteLocations(VirtRegMap &VRM, const TargetRegisterInfo &TRI, // physical register. for (LocMap::iterator I = locInts.begin(); I.valid(); ++I) { DbgValueLocation Loc = I.value(); + // Undef values don't exist in locations (and thus not in LocNoMap either) + // so skip over them. See getLocationNo(). + if (Loc.isUndef()) + continue; unsigned NewLocNo = LocNoMap[Loc.locNo()]; I.setValueUnchecked(Loc.changeLocNo(NewLocNo)); I.setStart(I.start()); @@ -1163,7 +1167,15 @@ void UserValue::insertDebugValue(MachineBasicBlock *MBB, SlotIndex StartIdx, // Only search within the current MBB. StopIdx = (MBBEndIdx < StopIdx) ? MBBEndIdx : StopIdx; MachineBasicBlock::iterator I = findInsertLocation(MBB, StartIdx, LIS); - MachineOperand &MO = locations[Loc.locNo()]; + // Undef values don't exist in locations so create new "noreg" register MOs + // for them. See getLocationNo(). + MachineOperand MO = !Loc.isUndef() ? + locations[Loc.locNo()] : + MachineOperand::CreateReg(/* Reg */ 0, /* isDef */ false, /* isImp */ false, + /* isKill */ false, /* isDead */ false, + /* isUndef */ false, /* isEarlyClobber */ false, + /* SubReg */ 0, /* isDebug */ true); + ++NumInsertedDebugValues; assert(cast<DILocalVariable>(Variable) |