[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue May 4 12:01:29 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
ADCE.cpp updated: 1.76 -> 1.77
---
Log message:
Do not mark instructions in unreachable sections of the function as live.
This fixes PR332: http://llvm.cs.uiuc.edu/PR332 and ADCE/2004-05-04-UnreachableBlock.llx
---
Diffs of the changes: (+5 -2)
Index: llvm/lib/Transforms/Scalar/ADCE.cpp
diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.76 llvm/lib/Transforms/Scalar/ADCE.cpp:1.77
--- llvm/lib/Transforms/Scalar/ADCE.cpp:1.76 Sat Apr 10 13:06:21 2004
+++ llvm/lib/Transforms/Scalar/ADCE.cpp Tue May 4 12:00:46 2004
@@ -215,8 +215,10 @@
// instructions live in basic blocks that are unreachable. These blocks will
// be eliminated later, along with the instructions inside.
//
- for (df_iterator<Function*> BBI = df_begin(Func), BBE = df_end(Func);
- BBI != BBE; ++BBI) {
+ std::set<BasicBlock*> ReachableBBs;
+ for (df_ext_iterator<BasicBlock*>
+ BBI = df_ext_begin(&Func->front(), ReachableBBs),
+ BBE = df_ext_end(&Func->front(), ReachableBBs); BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
Instruction *I = II++;
@@ -279,6 +281,7 @@
WorkList.pop_back();
BasicBlock *BB = I->getParent();
+ if (!ReachableBBs.count(BB)) continue;
if (!AliveBlocks.count(BB)) { // Basic block not alive yet...
AliveBlocks.insert(BB); // Block is now ALIVE!
markBlockAlive(BB); // Make it so now!
More information about the llvm-commits
mailing list