summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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
commitb68659552aa958eac5907c74b7f97a04d78024f8 (patch)
treed93aa594334b593dbf32a355c17f1c727af791eb /llvm/lib
parente7ae4a8cb42392e82d4cc447d63ae3efe3a95cb6 (diff)
downloadbcm5719-llvm-b68659552aa958eac5907c74b7f97a04d78024f8.tar.gz
bcm5719-llvm-b68659552aa958eac5907c74b7f97a04d78024f8.zip
Do not create empty basic blocks when the lowerswitch pass expects blocks to
be non-empty! This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll llvm-svn: 12384
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LowerSwitch.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LowerSwitch.cpp b/llvm/lib/Transforms/Scalar/LowerSwitch.cpp
index 2238d7b388f..653d9ffa47c 100644
--- a/llvm/lib/Transforms/Scalar/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Scalar/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);
}
OpenPOWER on IntegriCloud