summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-24 16:09:21 +0000
committerChris Lattner <sabre@nondot.org>2004-02-24 16:09:21 +0000
commit90ea78edba19cb531890b2944760263338bdcdf5 (patch)
tree38da9e578a68ad50b1615f655406cc770e1418a0 /llvm/lib/Transforms
parent1dd872ce9439743854a11d0f9c7179d5abafb95e (diff)
downloadbcm5719-llvm-90ea78edba19cb531890b2944760263338bdcdf5.tar.gz
bcm5719-llvm-90ea78edba19cb531890b2944760263338bdcdf5.zip
If a block is made dead, make sure to promptly remove it.
llvm-svn: 11799
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 15124003d24..ca59276f2b7 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud