X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FStrongPHIElimination.cpp;h=cdf827d50e6e9b055f4f2119a5fb36cf2f1ba2f4;hb=527c250a9080a5b6cf0053a6215037c3769ff4a0;hp=e5cae2bc723bf14c396f47c380098b5b3d22ecb9;hpb=ddd060ffcfd56ef91eb28ce76a2b0576dfe51129;p=oota-llvm.git diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index e5cae2bc723..cdf827d50e6 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -550,7 +550,12 @@ void StrongPHIElimination::processPHIUnion(MachineInstr* Inst, for (DomForestNode::iterator CI = DFNode->begin(), CE = DFNode->end(); CI != CE; ++CI) { DomForestNode* child = *CI; - + + // If the current node is live-out of the defining block of one of its + // children, insert a copy for it. NOTE: The paper actually calls for + // a more elaborate heuristic for determining whether to insert copies + // for the child or the parent. In the interest of simplicity, we're + // just always choosing the parent. if (isLiveOut(DFNode->getReg(), MRI.getVRegDef(child->getReg())->getParent(), MRI, LV)) { // Insert copies for parent @@ -565,6 +570,9 @@ void StrongPHIElimination::processPHIUnion(MachineInstr* Inst, PHIUnion.erase(SrcReg); } } + + // If a node is live-in to the defining block of one of its children, but + // not live-out, then we need to scan that block for local interferences. } else if (isLiveIn(DFNode->getReg(), MRI.getVRegDef(child->getReg())->getParent(), MRI, LV) || @@ -743,11 +751,17 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) { // FIXME: Insert last-minute copies // Remove PHIs - for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) + std::vector phis; + for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { for (MachineBasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI) if (BI->getOpcode() == TargetInstrInfo::PHI) - BI->eraseFromParent(); + phis.push_back(BI); + } + + for (std::vector::iterator I = phis.begin(), E = phis.end(); + I != E; ++I) + (*I)->eraseFromParent(); return false; }