summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocGreedy.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-26 22:33:12 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-26 22:33:12 +0000
commit9f4b893b84d9c2b56aa2abc3c96ce1e5ccc465e5 (patch)
treec5bf2921106ae502b478c1373c07131d93d855c1 /lib/CodeGen/RegAllocGreedy.cpp
parentd5c7f7cb5e15a7382cd163cb191db898510226c8 (diff)
downloadllvm-9f4b893b84d9c2b56aa2abc3c96ce1e5ccc465e5.tar.gz
llvm-9f4b893b84d9c2b56aa2abc3c96ce1e5ccc465e5.tar.bz2
llvm-9f4b893b84d9c2b56aa2abc3c96ce1e5ccc465e5.tar.xz
Add a safe-guard against repeated splitting for some rare cases.
The number of blocks covered by a live range must be strictly decreasing when splitting, otherwise we can't allow repeated splitting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130249 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocGreedy.cpp')
-rw-r--r--lib/CodeGen/RegAllocGreedy.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp
index b150582da6..d57bc88a13 100644
--- a/lib/CodeGen/RegAllocGreedy.cpp
+++ b/lib/CodeGen/RegAllocGreedy.cpp
@@ -921,6 +921,7 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg,
SmallVector<unsigned, 8> IntvMap;
SE->finish(&IntvMap);
LRStage.resize(MRI->getNumVirtRegs());
+ unsigned OrigBlocks = SA->getNumThroughBlocks() + SA->getUseBlocks().size();
// Sort out the new intervals created by splitting. We get four kinds:
// - Remainder intervals should not be split again.
@@ -941,9 +942,20 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg,
continue;
}
- // Other intervals are treated as new. This includes the main interval,
- // local intervals created for blocks with multiple uses, and anything
- // created by DCE.
+ // Main interval. Allow repeated splitting as long as the number of live
+ // blocks is strictly decreasing.
+ if (IntvMap[i] == MainIntv) {
+ if (SA->countLiveBlocks(LREdit.get(i)) >= OrigBlocks) {
+ DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks
+ << " blocks as original.\n");
+ // Don't allow repeated splitting as a safe guard against looping.
+ LRStage[Reg] = RS_Global;
+ }
+ continue;
+ }
+
+ // Other intervals are treated as new. This includes local intervals created
+ // for blocks with multiple uses, and anything created by DCE.
}
if (VerifyEnabled)