summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-10-13 16:15:31 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-10-13 16:15:31 +0000
commit2f6dfc7d0b6bb82ee561dc919218aef4fe651509 (patch)
treeb4e34ec48a16a8e99d0a100869889213bc619556 /llvm/lib
parentecd15d7f6c93e56183f28678989f4465028c195c (diff)
downloadbcm5719-llvm-2f6dfc7d0b6bb82ee561dc919218aef4fe651509.tar.gz
bcm5719-llvm-2f6dfc7d0b6bb82ee561dc919218aef4fe651509.zip
Allow for loops in LiveIntervals::pruneValue().
It is possible that the live range of the value being pruned loops back into the kill MBB where the search started. When that happens, make sure that the beginning of KillMBB is also pruned. Instead of starting a DFS at KillMBB and skipping the root of the search, start a DFS at each KillMBB successor, and allow the search to loop back to KillMBB. This fixes PR14078. llvm-svn: 165872
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/LiveIntervalAnalysis.cpp61
1 files changed, 32 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
index 2ea9056f0a5..8daac469543 100644
--- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -761,38 +761,41 @@ void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill,
LI->removeRange(Kill, MBBEnd);
if (EndPoints) EndPoints->push_back(MBBEnd);
- // Find all blocks that are reachable from MBB without leaving VNI's live
- // range.
- for (df_iterator<MachineBasicBlock*>
- I = df_begin(KillMBB), E = df_end(KillMBB); I != E;) {
- MachineBasicBlock *MBB = *I;
- // KillMBB itself was already handled.
- if (MBB == KillMBB) {
- ++I;
- continue;
- }
+ // Find all blocks that are reachable from KillMBB without leaving VNI's live
+ // range. It is possible that KillMBB itself is reachable, so start a DFS
+ // from each successor.
+ typedef SmallPtrSet<MachineBasicBlock*, 9> VisitedTy;
+ VisitedTy Visited;
+ for (MachineBasicBlock::succ_iterator
+ SuccI = KillMBB->succ_begin(), SuccE = KillMBB->succ_end();
+ SuccI != SuccE; ++SuccI) {
+ for (df_ext_iterator<MachineBasicBlock*, VisitedTy>
+ I = df_ext_begin(*SuccI, Visited), E = df_ext_end(*SuccI, Visited);
+ I != E;) {
+ MachineBasicBlock *MBB = *I;
+
+ // Check if VNI is live in to MBB.
+ tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB);
+ LiveRangeQuery LRQ(*LI, MBBStart);
+ if (LRQ.valueIn() != VNI) {
+ // This block isn't part of the VNI live range. Prune the search.
+ I.skipChildren();
+ continue;
+ }
- // Check if VNI is live in to MBB.
- tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB);
- LiveRangeQuery LRQ(*LI, MBBStart);
- if (LRQ.valueIn() != VNI) {
- // This block isn't part of the VNI live range. Prune the search.
- I.skipChildren();
- continue;
- }
+ // Prune the search if VNI is killed in MBB.
+ if (LRQ.endPoint() < MBBEnd) {
+ LI->removeRange(MBBStart, LRQ.endPoint());
+ if (EndPoints) EndPoints->push_back(LRQ.endPoint());
+ I.skipChildren();
+ continue;
+ }
- // Prune the search if VNI is killed in MBB.
- if (LRQ.endPoint() < MBBEnd) {
- LI->removeRange(MBBStart, LRQ.endPoint());
- if (EndPoints) EndPoints->push_back(LRQ.endPoint());
- I.skipChildren();
- continue;
+ // VNI is live through MBB.
+ LI->removeRange(MBBStart, MBBEnd);
+ if (EndPoints) EndPoints->push_back(MBBEnd);
+ ++I;
}
-
- // VNI is live through MBB.
- LI->removeRange(MBBStart, MBBEnd);
- if (EndPoints) EndPoints->push_back(MBBEnd);
- ++I;
}
}
OpenPOWER on IntegriCloud