forked from OSchip/llvm-project
When we delete a dead basic block, see if any of its successors are dead and
delete those as well. llvm-svn: 168829
This commit is contained in:
parent
9bbc8da517
commit
f3614fd8e2
|
@ -194,9 +194,19 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
|
|||
WorkList.insert(*II);
|
||||
}
|
||||
|
||||
for (SmallPtrSet<BasicBlock*, 8>::iterator
|
||||
I = WorkList.begin(), E = WorkList.end(); I != E; ++I)
|
||||
DeleteDeadBlock(*I);
|
||||
// Delete the dead blocks and any of their dead successors.
|
||||
while (!WorkList.empty()) {
|
||||
BasicBlock *BB = *WorkList.begin();
|
||||
WorkList.erase(BB);
|
||||
SmallVector<BasicBlock*, 2> Successors(succ_begin(BB), succ_end(BB));
|
||||
|
||||
DeleteDeadBlock(BB);
|
||||
|
||||
for (SmallVectorImpl<BasicBlock*>::iterator
|
||||
II = Successors.begin(), IE = Successors.end(); II != IE; ++II)
|
||||
if (pred_begin(*II) == pred_end(*II))
|
||||
WorkList.insert(*II);
|
||||
}
|
||||
|
||||
// Merge pairs of basic blocks with unconditional branches, connected by
|
||||
// a single edge.
|
||||
|
|
Loading…
Reference in New Issue