If a block is made dead, make sure to promptly remove it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-02-24 16:09:21 +00:00
parent 0d6c5b6489
commit 8e509dd5e8

View File

@ -512,6 +512,14 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
Preds.pop_back();
}
// If this block is now dead, remove it.
if (pred_begin(BB) == pred_end(BB)) {
// We know there are no successors, so just nuke the block.
M->getBasicBlockList().erase(BB);
return true;
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->begin())) {
// If the only instruction in this block is a switch instruction, see if we
// can fold the switch instruction into a switch in a predecessor block.