Fix bug: LowerSwitch/2003-08-23-EmptySwitch.ll
authorChris Lattner <sabre@nondot.org>
Sat, 23 Aug 2003 22:54:34 +0000 (22:54 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 23 Aug 2003 22:54:34 +0000 (22:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LowerSwitch.cpp

index c0e9e0dcd33ee973c17e2cb5a8f24351589eec84..73ce2f77f92b4be0bbc77b6a5f8a6d1bd2ac6247 100644 (file)
@@ -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...