1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

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:
Bill Wendling 2012-11-28 23:23:48 +00:00
parent 94185797ca
commit 176de1b36b

View File

@ -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.