[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jun 16 07:11:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
ADCE.cpp updated: 1.53 -> 1.54
---
Log message:
Fix bug: ADCE/2003-06-11-InvalidCFG.ll
This was because we were deleting large chunks of functions without an exit block, because the post-dominance
information was not useful. This broke crafty and twolf.
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/ADCE.cpp
diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.53 llvm/lib/Transforms/Scalar/ADCE.cpp:1.54
--- llvm/lib/Transforms/Scalar/ADCE.cpp:1.53 Thu May 22 17:00:06 2003
+++ llvm/lib/Transforms/Scalar/ADCE.cpp Mon Jun 16 07:10:45 2003
@@ -166,6 +166,16 @@
}
}
+ // Check to ensure we have an exit node for this CFG. If we don't, we won't
+ // have any post-dominance information, thus we cannot perform our
+ // transformations safely.
+ //
+ PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
+ if (DT[&Func->getEntryNode()] == 0) {
+ WorkList.clear();
+ return MadeChanges;
+ }
+
DEBUG(std::cerr << "Processing work list\n");
// AliveBlocks - Set of basic blocks that we know have instructions that are
@@ -208,19 +218,18 @@
DEBUG(
std::cerr << "Current Function: X = Live\n";
- for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
+ for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I){
+ std::cerr << I->getName() << ":\t"
+ << (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
if (LiveSet.count(BI)) std::cerr << "X ";
std::cerr << *BI;
}
- );
+ });
// Find the first postdominator of the entry node that is alive. Make it the
// new entry node...
//
- PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
-
-
if (AliveBlocks.size() == Func->size()) { // No dead blocks?
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I)
// Loop over all of the instructions in the function, telling dead
More information about the llvm-commits
mailing list