[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerSwitch.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Aug 23 17:55:01 PDT 2003


Changes in directory llvm/lib/Transforms/Scalar:

LowerSwitch.cpp updated: 1.3 -> 1.4

---
Log message:

Fix bug: LowerSwitch/2003-08-23-EmptySwitch.ll


---
Diffs of the changes:

Index: llvm/lib/Transforms/Scalar/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.3 llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.4
--- llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.3	Wed Aug 13 13:18:15 2003
+++ llvm/lib/Transforms/Scalar/LowerSwitch.cpp	Sat Aug 23 17:54:34 2003
@@ -63,6 +63,13 @@
   // 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...





More information about the llvm-commits mailing list