aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-12-21 20:03:00 +0000
committerAdrian Prantl <aprantl@apple.com>2015-12-21 20:03:00 +0000
commitce8581389b203f67ae0d5d8227bb8662879fe9ce (patch)
tree84ed925c942b9052f5f0a9f5363cbdc9b8135699 /llvm/lib/CodeGen/LiveDebugVariables.cpp
parent6b4454101502d3f5488895f85cc9a813719b703e (diff)
downloadllvm-ce8581389b203f67ae0d5d8227bb8662879fe9ce.zip
llvm-ce8581389b203f67ae0d5d8227bb8662879fe9ce.tar.gz
llvm-ce8581389b203f67ae0d5d8227bb8662879fe9ce.tar.bz2
Fix PR24563 (LiveDebugVariables unconditionally propagates all DBG_VALUEs)
LiveDebugVariables unconditionally propagates all DBG_VALUE down the dominator tree, which happens to work fine if there already is another DBG_VALUE or the DBG_VALUE happends to describe a single-assignment vreg but is otherwise wrong if the DBG_VALUE is coming from only one of the predecessors. In r255759 we introduced a proper data flow analysis scheduled after LiveDebugVariables that correctly propagates DBG_VALUEs across basic block boundaries. With the new pass in place, the incorrect propagation in LiveDebugVariables can be retired witout loosing any of the benefits where LiveDebugVariables happened to do the right thing. llvm-svn: 256188
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugVariables.cpp88
1 files changed, 36 insertions, 52 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 6543287..6dac7db 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -534,65 +534,49 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) {
return Changed;
}
-void UserValue::extendDef(SlotIndex Idx, unsigned LocNo,
- LiveRange *LR, const VNInfo *VNI,
- SmallVectorImpl<SlotIndex> *Kills,
+/// We only propagate DBG_VALUES locally here. LiveDebugValues performs a
+/// data-flow analysis to propagate them beyond basic block boundaries.
+void UserValue::extendDef(SlotIndex Idx, unsigned LocNo, LiveRange *LR,
+ const VNInfo *VNI, SmallVectorImpl<SlotIndex> *Kills,
LiveIntervals &LIS, MachineDominatorTree &MDT,
UserValueScopes &UVS) {
- SmallVector<SlotIndex, 16> Todo;
- Todo.push_back(Idx);
- do {
- SlotIndex Start = Todo.pop_back_val();
- MachineBasicBlock *MBB = LIS.getMBBFromIndex(Start);
- SlotIndex Stop = LIS.getMBBEndIdx(MBB);
- LocMap::iterator I = locInts.find(Start);
-
- // Limit to VNI's live range.
- bool ToEnd = true;
- if (LR && VNI) {
- LiveInterval::Segment *Segment = LR->getSegmentContaining(Start);
- if (!Segment || Segment->valno != VNI) {
- if (Kills)
- Kills->push_back(Start);
- continue;
- }
- if (Segment->end < Stop)
- Stop = Segment->end, ToEnd = false;
- }
-
- // There could already be a short def at Start.
- if (I.valid() && I.start() <= Start) {
- // Stop when meeting a different location or an already extended interval.
- Start = Start.getNextSlot();
- if (I.value() != LocNo || I.stop() != Start)
- continue;
- // This is a one-slot placeholder. Just skip it.
- ++I;
+ SlotIndex Start = Idx;
+ MachineBasicBlock *MBB = LIS.getMBBFromIndex(Start);
+ SlotIndex Stop = LIS.getMBBEndIdx(MBB);
+ LocMap::iterator I = locInts.find(Start);
+
+ // Limit to VNI's live range.
+ bool ToEnd = true;
+ if (LR && VNI) {
+ LiveInterval::Segment *Segment = LR->getSegmentContaining(Start);
+ if (!Segment || Segment->valno != VNI) {
+ if (Kills)
+ Kills->push_back(Start);
+ return;
}
+ if (Segment->end < Stop)
+ Stop = Segment->end, ToEnd = false;
+ }
- // Limited by the next def.
- if (I.valid() && I.start() < Stop)
- Stop = I.start(), ToEnd = false;
- // Limited by VNI's live range.
- else if (!ToEnd && Kills)
- Kills->push_back(Stop);
+ // There could already be a short def at Start.
+ if (I.valid() && I.start() <= Start) {
+ // Stop when meeting a different location or an already extended interval.
+ Start = Start.getNextSlot();
+ if (I.value() != LocNo || I.stop() != Start)
+ return;
+ // This is a one-slot placeholder. Just skip it.
+ ++I;
+ }
- if (Start >= Stop)
- continue;
+ // Limited by the next def.
+ if (I.valid() && I.start() < Stop)
+ Stop = I.start(), ToEnd = false;
+ // Limited by VNI's live range.
+ else if (!ToEnd && Kills)
+ Kills->push_back(Stop);
+ if (Start < Stop)
I.insert(Start, Stop, LocNo);
-
- // If we extended to the MBB end, propagate down the dominator tree.
- if (!ToEnd)
- continue;
- const std::vector<MachineDomTreeNode*> &Children =
- MDT.getNode(MBB)->getChildren();
- for (unsigned i = 0, e = Children.size(); i != e; ++i) {
- MachineBasicBlock *MBB = Children[i]->getBlock();
- if (UVS.dominates(MBB))
- Todo.push_back(LIS.getMBBStartIdx(MBB));
- }
- } while (!Todo.empty());
}
void