From 8e509dd5e81e92a466580ab4022994079952cca9 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11799 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/SimplifyCFG.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') 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(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.1