mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
When we delete a dead basic block, see if any of its successors are dead and
delete those as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -194,9 +194,19 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
|
|||||||
WorkList.insert(*II);
|
WorkList.insert(*II);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SmallPtrSet<BasicBlock*, 8>::iterator
|
// Delete the dead blocks and any of their dead successors.
|
||||||
I = WorkList.begin(), E = WorkList.end(); I != E; ++I)
|
while (!WorkList.empty()) {
|
||||||
DeleteDeadBlock(*I);
|
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
|
// Merge pairs of basic blocks with unconditional branches, connected by
|
||||||
// a single edge.
|
// a single edge.
|
||||||
|
Reference in New Issue
Block a user