Make sure that we always grow a multiple of 2 operands.
authorChris Lattner <sabre@nondot.org>
Sat, 29 Jan 2005 01:05:12 +0000 (01:05 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 29 Jan 2005 01:05:12 +0000 (01:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19902 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Instructions.cpp

index e936fafa229b8cd578d8cd17d40f40fbec0acfbe..4bbe64a12855c26b9ddf2dbc5f15b0118f4b4e8e 100644 (file)
@@ -948,6 +948,7 @@ void SwitchInst::addCase(Constant *OnVal, BasicBlock *Dest) {
   if (OpNo+2 > ReservedSpace)
     resizeOperands(0);  // Get more space!
   // Initialize some new operands.
+  assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
   NumOperands = OpNo+2;
   OperandList[OpNo].init(OnVal, this);
   OperandList[OpNo+1].init(Dest, this);
@@ -989,14 +990,14 @@ void SwitchInst::removeCase(unsigned idx) {
 ///
 void SwitchInst::resizeOperands(unsigned NumOps) {
   if (NumOps == 0) {
-    NumOps = (getNumOperands())*3/2;
+    NumOps = getNumOperands()/2*6;
   } else if (NumOps*2 > NumOperands) {
     // No resize needed.
     if (ReservedSpace >= NumOps) return;
   } else if (NumOps == NumOperands) {
     if (ReservedSpace == NumOps) return;
   } else {
-    return;        
+    return;
   }
 
   ReservedSpace = NumOps;