[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp
Owen Anderson
resistor at mac.com
Tue Apr 17 21:55:51 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
ADCE.cpp updated: 1.104 -> 1.105
---
Log message:
Use ETForest instead of DominatorTree.
---
Diffs of the changes: (+15 -19)
ADCE.cpp | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
Index: llvm/lib/Transforms/Scalar/ADCE.cpp
diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.104 llvm/lib/Transforms/Scalar/ADCE.cpp:1.105
--- llvm/lib/Transforms/Scalar/ADCE.cpp:1.104 Mon Feb 12 20:10:56 2007
+++ llvm/lib/Transforms/Scalar/ADCE.cpp Tue Apr 17 23:55:33 2007
@@ -68,7 +68,7 @@
// can be marked live that wouldn't necessarily be otherwise.
AU.addRequired<UnifyFunctionExitNodes>();
AU.addRequired<AliasAnalysis>();
- AU.addRequired<PostDominatorTree>();
+ AU.addRequired<PostETForest>();
AU.addRequired<PostDominanceFrontier>();
}
@@ -246,8 +246,8 @@
// have any post-dominance information, thus we cannot perform our
// transformations safely.
//
- PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
- if (DT[&Func->getEntryBlock()] == 0) {
+ PostETForest &ET = getAnalysis<PostETForest>();
+ if (ET.getNodeForBlock(&Func->getEntryBlock()) == 0) {
WorkList.clear();
return MadeChanges;
}
@@ -258,7 +258,7 @@
// function which unwinds, exits or has side-effects, we don't want to delete
// the infinite loop or those blocks leading up to it.
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)
markInstructionLive((*PI)->getTerminator());
@@ -383,16 +383,16 @@
// postdominator that is alive, and the last postdominator that is
// dead...
//
- PostDominatorTree::Node *LastNode = DT[TI->getSuccessor(i)];
- PostDominatorTree::Node *NextNode = 0;
-
- if (LastNode) {
- NextNode = LastNode->getIDom();
- while (!AliveBlocks.count(NextNode->getBlock())) {
- LastNode = NextNode;
- NextNode = NextNode->getIDom();
- if (NextNode == 0) {
- LastNode = 0;
+ BasicBlock *LastDead = TI->getSuccessor(i);
+ BasicBlock *NextAlive = 0;
+
+ if (LastDead) {
+ NextAlive = ET.getIDom(LastDead);
+ while (!AliveBlocks.count(NextAlive)) {
+ LastDead = NextAlive;
+ NextAlive = ET.getIDom(NextAlive);
+ if (NextAlive == 0) {
+ LastDead = 0;
break;
}
}
@@ -406,7 +406,7 @@
// drawback of ADCE, so in the future if we choose to revisit the
// decision, this is where it should be.
//
- if (LastNode == 0) { // No postdominator!
+ if (LastDead == 0) { // No postdominator!
if (!isa<InvokeInst>(TI)) {
// Call RemoveSuccessor to transmogrify the terminator instruction
// to not contain the outgoing branch, or to create a new
@@ -427,10 +427,6 @@
}
} 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...
TI->getSuccessor(i)->removePredecessor(BB);
TI->setSuccessor(i, NextAlive);
More information about the llvm-commits
mailing list