Use ETForest instead of DominatorTree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2007-04-18 04:55:33 +00:00
parent ee6dcaf906
commit ca2563d2d8

View File

@ -68,7 +68,7 @@ public:
// can be marked live that wouldn't necessarily be otherwise. // can be marked live that wouldn't necessarily be otherwise.
AU.addRequired<UnifyFunctionExitNodes>(); AU.addRequired<UnifyFunctionExitNodes>();
AU.addRequired<AliasAnalysis>(); AU.addRequired<AliasAnalysis>();
AU.addRequired<PostDominatorTree>(); AU.addRequired<PostETForest>();
AU.addRequired<PostDominanceFrontier>(); AU.addRequired<PostDominanceFrontier>();
} }
@ -246,8 +246,8 @@ bool ADCE::doADCE() {
// have any post-dominance information, thus we cannot perform our // have any post-dominance information, thus we cannot perform our
// transformations safely. // transformations safely.
// //
PostDominatorTree &DT = getAnalysis<PostDominatorTree>(); PostETForest &ET = getAnalysis<PostETForest>();
if (DT[&Func->getEntryBlock()] == 0) { if (ET.getNodeForBlock(&Func->getEntryBlock()) == 0) {
WorkList.clear(); WorkList.clear();
return MadeChanges; return MadeChanges;
} }
@ -258,7 +258,7 @@ bool ADCE::doADCE() {
// function which unwinds, exits or has side-effects, we don't want to delete // function which unwinds, exits or has side-effects, we don't want to delete
// the infinite loop or those blocks leading up to it. // the infinite loop or those blocks leading up to it.
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I) for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
if (DT[I] == 0 && ReachableBBs.count(I)) if (ET.getNodeForBlock(I) == 0 && ReachableBBs.count(I))
for (pred_iterator PI = pred_begin(I), E = pred_end(I); PI != E; ++PI) for (pred_iterator PI = pred_begin(I), E = pred_end(I); PI != E; ++PI)
markInstructionLive((*PI)->getTerminator()); markInstructionLive((*PI)->getTerminator());
@ -383,16 +383,16 @@ bool ADCE::doADCE() {
// postdominator that is alive, and the last postdominator that is // postdominator that is alive, and the last postdominator that is
// dead... // dead...
// //
PostDominatorTree::Node *LastNode = DT[TI->getSuccessor(i)]; BasicBlock *LastDead = TI->getSuccessor(i);
PostDominatorTree::Node *NextNode = 0; BasicBlock *NextAlive = 0;
if (LastNode) { if (LastDead) {
NextNode = LastNode->getIDom(); NextAlive = ET.getIDom(LastDead);
while (!AliveBlocks.count(NextNode->getBlock())) { while (!AliveBlocks.count(NextAlive)) {
LastNode = NextNode; LastDead = NextAlive;
NextNode = NextNode->getIDom(); NextAlive = ET.getIDom(NextAlive);
if (NextNode == 0) { if (NextAlive == 0) {
LastNode = 0; LastDead = 0;
break; break;
} }
} }
@ -406,7 +406,7 @@ bool ADCE::doADCE() {
// drawback of ADCE, so in the future if we choose to revisit the // drawback of ADCE, so in the future if we choose to revisit the
// decision, this is where it should be. // decision, this is where it should be.
// //
if (LastNode == 0) { // No postdominator! if (LastDead == 0) { // No postdominator!
if (!isa<InvokeInst>(TI)) { if (!isa<InvokeInst>(TI)) {
// Call RemoveSuccessor to transmogrify the terminator instruction // Call RemoveSuccessor to transmogrify the terminator instruction
// to not contain the outgoing branch, or to create a new // to not contain the outgoing branch, or to create a new
@ -427,10 +427,6 @@ bool ADCE::doADCE() {
} }
} else { } else {
// Get the basic blocks that we need...
BasicBlock *LastDead = LastNode->getBlock();
BasicBlock *NextAlive = NextNode->getBlock();
// Make the conditional branch now go to the next alive block... // Make the conditional branch now go to the next alive block...
TI->getSuccessor(i)->removePredecessor(BB); TI->getSuccessor(i)->removePredecessor(BB);
TI->setSuccessor(i, NextAlive); TI->setSuccessor(i, NextAlive);