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

Chris Lattner lattner at cs.uiuc.edu
Sat Mar 13 22:15:12 PST 2004


Changes in directory llvm/lib/Transforms/Scalar:

LowerSwitch.cpp updated: 1.11 -> 1.12

---
Log message:

Do not create empty basic blocks when the lowerswitch pass expects blocks to
be non-empty!  This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll


---
Diffs of the changes:  (+2 -5)

Index: llvm/lib/Transforms/Scalar/LowerSwitch.cpp
diff -u llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.11 llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.12
--- llvm/lib/Transforms/Scalar/LowerSwitch.cpp:1.11	Wed Feb 25 09:15:04 2004
+++ llvm/lib/Transforms/Scalar/LowerSwitch.cpp	Sat Mar 13 22:14:31 2004
@@ -181,13 +181,10 @@
   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 @@
   new BranchInst(SwitchBlock, OrigBlock);
 
   // We are now done with the switch instruction, delete it.
-  delete SI;
+  CurBlock->getInstList().erase(SI);
 }





More information about the llvm-commits mailing list