aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/PreAllocSplitting.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-10-28 00:47:49 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-10-28 00:47:49 +0000
commitf62ce370a48e1621af7934e668c215b8109cddb7 (patch)
treedd23fbfca63b2a9f71c96c6d5b8de65636580b40 /lib/CodeGen/PreAllocSplitting.cpp
parente649778b555465fd25811daef98f6ddbc9efd378 (diff)
downloadexternal_llvm-f62ce370a48e1621af7934e668c215b8109cddb7.zip
external_llvm-f62ce370a48e1621af7934e668c215b8109cddb7.tar.gz
external_llvm-f62ce370a48e1621af7934e668c215b8109cddb7.tar.bz2
Avoid putting a split past the end of the live range; always shrink wrap live interval in the barrier mbb.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PreAllocSplitting.cpp')
-rw-r--r--lib/CodeGen/PreAllocSplitting.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index f3a3ac3..5c1c223 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -109,7 +109,7 @@ namespace {
SmallPtrSet<MachineInstr*, 4>&, unsigned&);
MachineBasicBlock::iterator
- findRestorePoint(MachineBasicBlock*, MachineInstr*,
+ findRestorePoint(MachineBasicBlock*, MachineInstr*, unsigned,
SmallPtrSet<MachineInstr*, 4>&, unsigned&);
void RecordSplit(unsigned, unsigned, unsigned, int);
@@ -203,12 +203,15 @@ PreAllocSplitting::findSpillPoint(MachineBasicBlock *MBB, MachineInstr *MI,
/// found.
MachineBasicBlock::iterator
PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI,
+ unsigned LastIdx,
SmallPtrSet<MachineInstr*, 4> &RefsInMBB,
unsigned &RestoreIndex) {
MachineBasicBlock::iterator Pt = MBB->end();
+ unsigned EndIdx = LIs->getMBBEndIdx(MBB);
- // Go bottom up if RefsInMBB is empty.
- if (RefsInMBB.empty()) {
+ // Go bottom up if RefsInMBB is empty and the end of the mbb isn't beyond
+ // the last index in the live range.
+ if (RefsInMBB.empty() && LastIdx >= EndIdx) {
MachineBasicBlock::iterator MII = MBB->end();
MachineBasicBlock::iterator EndPt = MI;
do {
@@ -224,8 +227,12 @@ PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI,
} else {
MachineBasicBlock::iterator MII = MI;
MII = ++MII;
+ // FIXME: Limit the number of instructions to examine to reduce
+ // compile time?
while (MII != MBB->end()) {
unsigned Index = LIs->getInstructionIndex(MII);
+ if (Index > LastIdx)
+ break;
unsigned Gap = LIs->findGapBeforeInstr(Index);
if (Gap) {
Pt = MII;
@@ -438,13 +445,15 @@ PreAllocSplitting::ShrinkWrapLiveInterval(VNInfo *ValNo, MachineBasicBlock *MBB,
// If live interval is live in another successor path, then we can't process
// this block. But we may able to do so after all the successors have been
// processed.
- for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
- SE = MBB->succ_end(); SI != SE; ++SI) {
- MachineBasicBlock *SMBB = *SI;
- if (SMBB == SuccMBB)
- continue;
- if (CurrLI->liveAt(LIs->getMBBStartIdx(SMBB)))
- return;
+ if (MBB != BarrierMBB) {
+ for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
+ SE = MBB->succ_end(); SI != SE; ++SI) {
+ MachineBasicBlock *SMBB = *SI;
+ if (SMBB == SuccMBB)
+ continue;
+ if (CurrLI->liveAt(LIs->getMBBStartIdx(SMBB)))
+ return;
+ }
}
Visited.insert(MBB);
@@ -536,7 +545,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) {
// Find a point to restore the value after the barrier.
unsigned RestoreIndex;
MachineBasicBlock::iterator RestorePt =
- findRestorePoint(BarrierMBB, Barrier, RefsInMBB, RestoreIndex);
+ findRestorePoint(BarrierMBB, Barrier, LR->end, RefsInMBB, RestoreIndex);
if (RestorePt == BarrierMBB->end())
return false;