From 90ea78edba19cb531890b2944760263338bdcdf5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Feb 2004 16:09:21 +0000 Subject: If a block is made dead, make sure to promptly remove it. llvm-svn: 11799 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/Transforms/Utils') 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(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. -- cgit v1.2.3