aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/PreAllocSplitting.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-01-29 08:22:06 +0000
committerOwen Anderson <resistor@mac.com>2009-01-29 08:22:06 +0000
commitc70f0a93bded74d6c5906a01b49035b8880f9613 (patch)
tree691a720364e1b1efd2053b7543de8786e5a35ade /lib/CodeGen/PreAllocSplitting.cpp
parentf97d61244fd710c9e3ef8c1c07e61018a69b602f (diff)
downloadexternal_llvm-c70f0a93bded74d6c5906a01b49035b8880f9613.zip
external_llvm-c70f0a93bded74d6c5906a01b49035b8880f9613.tar.gz
external_llvm-c70f0a93bded74d6c5906a01b49035b8880f9613.tar.bz2
Fix an issue where restores could be inserted after a terminator instruction,
and an iterator invalidation issue. FreeBench/pifft no longer miscompiles with these fixes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PreAllocSplitting.cpp')
-rw-r--r--lib/CodeGen/PreAllocSplitting.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index 44819aa..4dc8b82 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -277,7 +277,7 @@ PreAllocSplitting::findRestorePoint(MachineBasicBlock *MBB, MachineInstr *MI,
MII = ++MII;
// FIXME: Limit the number of instructions to examine to reduce
// compile time?
- while (MII != MBB->end()) {
+ while (MII != MBB->getFirstTerminator()) {
unsigned Index = LIs->getInstructionIndex(MII);
if (Index > LastIdx)
break;
@@ -486,7 +486,8 @@ VNInfo* PreAllocSplitting::PerformPHIConstruction(
IncomingVNs.begin(), E = IncomingVNs.end(); I != E; ++I) {
I->second->hasPHIKill = true;
unsigned KillIndex = LIs->getMBBEndIdx(I->first);
- LI->addKill(I->second, KillIndex);
+ if (!LiveInterval::isKill(I->second, KillIndex))
+ LI->addKill(I->second, KillIndex);
}
unsigned EndIndex = 0;
@@ -1118,6 +1119,7 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
LIs->RemoveMachineInstrFromMaps(DefMI);
(*LI)->removeValNo(CurrVN);
DefMI->eraseFromParent();
+ VNUseCount.erase(CurrVN);
NumDeadSpills++;
changed = true;
continue;
@@ -1176,11 +1178,15 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
VNUseCount[CurrVN].begin(), IE = VNUseCount[CurrVN].end();
II != IE; ++II) {
for (DenseMap<VNInfo*, SmallPtrSet<MachineInstr*, 4> >::iterator
- VI = VNUseCount.begin(), VE = VNUseCount.end(); VI != VE; ++VI)
- VI->second.erase(*II);
+ VNI = VNUseCount.begin(), VNE = VNUseCount.end(); VNI != VNE;
+ ++VNI)
+ if (VNI->first != CurrVN)
+ VNI->second.erase(*II);
LIs->RemoveMachineInstrFromMaps(*II);
(*II)->eraseFromParent();
}
+
+ VNUseCount.erase(CurrVN);
for (DenseMap<VNInfo*, SmallPtrSet<MachineInstr*, 4> >::iterator
VI = VNUseCount.begin(), VE = VNUseCount.end(); VI != VE; ++VI)
@@ -1204,6 +1210,8 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
(*UI)->eraseFromParent();
}
+ VNUseCount.erase(CurrVN);
+
LIs->RemoveMachineInstrFromMaps(DefMI);
(*LI)->removeValNo(CurrVN);
DefMI->eraseFromParent();