[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 22 20:13:01 PST 2003
Changes in directory llvm/lib/Transforms/Scalar:
ADCE.cpp updated: 1.48 -> 1.49
---
Log message:
Fix bug: ADCE/2003-01-22-PredecessorProblem.ll
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/ADCE.cpp
diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.48 llvm/lib/Transforms/Scalar/ADCE.cpp:1.49
--- llvm/lib/Transforms/Scalar/ADCE.cpp:1.48 Tue Oct 1 17:38:40 2002
+++ llvm/lib/Transforms/Scalar/ADCE.cpp Wed Jan 22 20:12:18 2003
@@ -331,10 +331,17 @@
}
}
- // Loop over all of the basic blocks in the function, dropping references of
- // the dead basic blocks
+ // We make changes if there are any dead blocks in the function...
+ if (unsigned NumDeadBlocks = Func->size() - AliveBlocks.size()) {
+ MadeChanges = true;
+ NumBlockRemoved += NumDeadBlocks;
+ }
+
+ // Loop over all of the basic blocks in the function, removing control flow
+ // edges to live blocks (also eliminating any entries in PHI functions in
+ // referenced blocks).
//
- for (Function::iterator BB = Func->begin(), E = Func->end(); BB != E; ++BB) {
+ for (Function::iterator BB = Func->begin(), E = Func->end(); BB != E; ++BB)
if (!AliveBlocks.count(BB)) {
// Remove all outgoing edges from this basic block and convert the
// terminator into a return instruction.
@@ -354,12 +361,16 @@
BB->getInstList().push_back(new ReturnInst(RetTy != Type::VoidTy ?
Constant::getNullValue(RetTy) : 0));
}
+ }
+
+ // Loop over all of the basic blocks in the function, dropping references of
+ // the dead basic blocks. We must do this after the previous step to avoid
+ // dropping references to PHIs which still have entries...
+ //
+ for (Function::iterator BB = Func->begin(), E = Func->end(); BB != E; ++BB)
+ if (!AliveBlocks.count(BB))
BB->dropAllReferences();
- ++NumBlockRemoved;
- MadeChanges = true;
- }
- }
// Now loop through all of the blocks and delete the dead ones. We can safely
// do this now because we know that there are no references to dead blocks
More information about the llvm-commits
mailing list