summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LowerSwitch.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-14 04:14:31 +0000
committerChris Lattner <sabre@nondot.org>2004-03-14 04:14:31 +0000
commitbf9eaddfb0642e49bc2f3835765a9782ff48c76e (patch)
tree7937ce71262e2212e55ea010ddfa5af6169d744e /lib/Transforms/Utils/LowerSwitch.cpp
parent6cc83750b8c4eaadabae405240d06d6d70fb8ef8 (diff)
downloadllvm-bf9eaddfb0642e49bc2f3835765a9782ff48c76e.tar.gz
llvm-bf9eaddfb0642e49bc2f3835765a9782ff48c76e.tar.bz2
llvm-bf9eaddfb0642e49bc2f3835765a9782ff48c76e.tar.xz
Do not create empty basic blocks when the lowerswitch pass expects blocks to
be non-empty! This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerSwitch.cpp')
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index 2238d7b388..653d9ffa47 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -181,13 +181,10 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
Value *Val = SI->getOperand(0); // The value we are switching on...
BasicBlock* Default = SI->getDefaultDest();
- // Unlink the switch instruction from it's block.
- CurBlock->getInstList().remove(SI);
-
// If there is only the default destination, don't bother with the code below.
if (SI->getNumOperands() == 2) {
new BranchInst(SI->getDefaultDest(), CurBlock);
- delete SI;
+ CurBlock->getInstList().erase(SI);
return;
}
@@ -222,5 +219,5 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
new BranchInst(SwitchBlock, OrigBlock);
// We are now done with the switch instruction, delete it.
- delete SI;
+ CurBlock->getInstList().erase(SI);
}