diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-24 16:09:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-24 16:09:21 +0000 |
commit | 8e509dd5e81e92a466580ab4022994079952cca9 (patch) | |
tree | 67c654d5a9f89b270586316021eb1e118a9ced3c /lib/Transforms/Utils | |
parent | 0d6c5b6489b9abb634a1506d183ba47f1bf4d1f0 (diff) | |
download | external_llvm-8e509dd5e81e92a466580ab4022994079952cca9.zip external_llvm-8e509dd5e81e92a466580ab4022994079952cca9.tar.gz external_llvm-8e509dd5e81e92a466580ab4022994079952cca9.tar.bz2 |
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
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 1512400..ca59276 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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. |