From 7f9de06cc411501aaefd9157ae97998150720910 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sun, 20 Mar 2011 19:46:23 +0000 Subject: [PATCH] Process all dead defs after rematerializing during splitting. llvm-svn: 127973 --- lib/CodeGen/SplitKit.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index c0f4adf0779..b69a3078ac9 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -789,30 +789,23 @@ void SplitEditor::rewriteAssigned(bool ExtendRanges) { void SplitEditor::deleteRematVictims() { SmallVector Dead; - for (LiveInterval::const_vni_iterator I = Edit->getParent().vni_begin(), - E = Edit->getParent().vni_end(); I != E; ++I) { - const VNInfo *VNI = *I; - // Was VNI rematted anywhere? - if (VNI->isUnused() || VNI->isPHIDef() || !Edit->didRematerialize(VNI)) - continue; - unsigned RegIdx = RegAssign.lookup(VNI->def); - LiveInterval *LI = Edit->get(RegIdx); - LiveInterval::const_iterator LII = LI->FindLiveRangeContaining(VNI->def); - assert(LII != LI->end() && "Missing live range for rematted def"); + for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I){ + LiveInterval *LI = *I; + for (LiveInterval::const_iterator LII = LI->begin(), LIE = LI->end(); + LII != LIE; ++LII) { + // Dead defs end at the store slot. + if (LII->end != LII->valno->def.getNextSlot()) + continue; + MachineInstr *MI = LIS.getInstructionFromIndex(LII->valno->def); + assert(MI && "Missing instruction for dead def"); + MI->addRegisterDead(LI->reg, &TRI); - // Is this a dead def? - if (LII->end != VNI->def.getNextSlot()) - continue; + if (!MI->allDefsAreDead()) + continue; - MachineInstr *MI = LIS.getInstructionFromIndex(VNI->def); - assert(MI && "Missing instruction for dead def"); - MI->addRegisterDead(LI->reg, &TRI); - - if (!MI->allDefsAreDead()) - continue; - - DEBUG(dbgs() << "All defs dead: " << *MI); - Dead.push_back(MI); + DEBUG(dbgs() << "All defs dead: " << *MI); + Dead.push_back(MI); + } } if (Dead.empty())