summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-23 22:54:34 +0000
committerChris Lattner <sabre@nondot.org>2003-08-23 22:54:34 +0000
commit44bb541c011bcae84759ed194ec7cb4139775fcb (patch)
tree526a54ce90310936949ff477b6c1ea387d62bde1 /lib
parent4d34adad6778ac232c8bf0a9d41cd5c20faed153 (diff)
downloadllvm-44bb541c011bcae84759ed194ec7cb4139775fcb.tar.gz
llvm-44bb541c011bcae84759ed194ec7cb4139775fcb.tar.bz2
llvm-44bb541c011bcae84759ed194ec7cb4139775fcb.tar.xz
Fix bug: LowerSwitch/2003-08-23-EmptySwitch.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index c0e9e0dcd3..73ce2f77f9 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -63,6 +63,13 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) {
// 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) {
+ CurBlock->getInstList().push_back(new BranchInst(SI->getDefaultDest()));
+ delete SI;
+ return;
+ }
+
// Expand comparisons for all of the non-default cases...
for (unsigned i = 2, e = SI->getNumOperands(); i != e; i += 2) {
// Insert a new basic block after the current one...