aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-29 01:05:12 +0000
committerChris Lattner <sabre@nondot.org>2005-01-29 01:05:12 +0000
commit1f377fcaadb6fc5914759d84ad68eb9297510bf2 (patch)
treedcfb717fca11f2156fa5211e822f165d5754717b /lib/VMCore/Instructions.cpp
parent204fcaea41057bed5183f6a925d5b8903b19b962 (diff)
Make sure that we always grow a multiple of 2 operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r--lib/VMCore/Instructions.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index e936fafa22..4bbe64a128 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -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;