Update DBG_VALUE register operand during LiveInterval operations
Summary:
Handling of DBG_VALUE in ConnectedVNInfoEqClasses::Distribute() was fixed in
PR16110. However DBG_VALUE register operands are not getting updated. This
patch properly resolves the value location.
Reviewers: MatzeB, vsk
Reviewed By: MatzeB
Subscribers: kparzysz, thegameg, vsk, MatzeB, dschuff, sbc100, jgravelle-google, aheejin, sunfish, llvm-commits
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D48994
llvm-svn: 340310
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 83dd982..2340b6a 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -1310,17 +1310,17 @@
MachineOperand &MO = *RI;
MachineInstr *MI = RI->getParent();
++RI;
- // DBG_VALUE instructions don't have slot indexes, so get the index of the
- // instruction before them.
- // Normally, DBG_VALUE instructions are removed before this function is
- // called, but it is not a requirement.
- SlotIndex Idx;
- if (MI->isDebugValue())
- Idx = LIS.getSlotIndexes()->getIndexBefore(*MI);
- else
- Idx = LIS.getInstructionIndex(*MI);
- LiveQueryResult LRQ = LI.Query(Idx);
- const VNInfo *VNI = MO.readsReg() ? LRQ.valueIn() : LRQ.valueDefined();
+ const VNInfo *VNI;
+ if (MI->isDebugValue()) {
+ // DBG_VALUE instructions don't have slot indexes, so get the index of
+ // the instruction before them. The value is defined there too.
+ SlotIndex Idx = LIS.getSlotIndexes()->getIndexBefore(*MI);
+ VNI = LI.Query(Idx).valueOut();
+ } else {
+ SlotIndex Idx = LIS.getInstructionIndex(*MI);
+ LiveQueryResult LRQ = LI.Query(Idx);
+ VNI = MO.readsReg() ? LRQ.valueIn() : LRQ.valueDefined();
+ }
// In the case of an <undef> use that isn't tied to any def, VNI will be
// NULL. If the use is tied to a def, VNI will be the defined value.
if (!VNI)