diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-05-04 17:00:46 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-05-04 17:00:46 +0000 | 
| commit | 9490849028350f5e06be00559af3d968bc7ad99c (patch) | |
| tree | 40d90148a6c91deed869e7e159105b6cd570682f | |
| parent | 1190a4de0b5c242f27bce068593aef9bb0fb614e (diff) | |
| download | bcm5719-llvm-9490849028350f5e06be00559af3d968bc7ad99c.tar.gz bcm5719-llvm-9490849028350f5e06be00559af3d968bc7ad99c.zip | |
Do not mark instructions in unreachable sections of the function as live.
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx
llvm-svn: 13349
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ADCE.cpp | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 3423fdd4929..98f8bed5160 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -215,8 +215,10 @@ bool ADCE::doADCE() {    // 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 @@ bool ADCE::doADCE() {      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! | 

