aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-13 00:10:02 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-13 00:10:02 +0000
commit790366be6dbffc02533e84477757eda096a8f82d (patch)
tree4591aa5ee0ca1827f8016497ebb0c993c53e1634 /lib
parentb61c1cefb2eade2ef9d6929488b7b097c2dcd0ca (diff)
downloadexternal_llvm-790366be6dbffc02533e84477757eda096a8f82d.zip
external_llvm-790366be6dbffc02533e84477757eda096a8f82d.tar.gz
external_llvm-790366be6dbffc02533e84477757eda096a8f82d.tar.bz2
Make sure that GEP indices are only 32 or 64 bits. We're not ready for
indices with other bit sizes yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Bytecode/Writer/Writer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index b7987b2..dab25ca 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -486,9 +486,11 @@ void BytecodeWriter::outputInstructionFormat0(const Instruction *I,
// These should be either 32-bits or 64-bits, however, with bit
// accurate types we just distinguish between less than or equal to
// 32-bits or greater than 32-bits.
- const IntegerType *IdxTy =
- cast<IntegerType>(I->getOperand(Idx)->getType());
- unsigned IdxId = IdxTy->getBitWidth() <= 32 ? 0 : 1;
+ unsigned BitWidth =
+ cast<IntegerType>(I->getOperand(Idx)->getType())->getBitWidth();
+ assert(BitWidth == 32 || BitWidth == 64 &&
+ "Invalid bitwidth for GEP index");
+ unsigned IdxId = BitWidth == 32 ? 0 : 1;
Slot = (Slot << 1) | IdxId;
}
output_vbr(unsigned(Slot));
@@ -737,9 +739,11 @@ void BytecodeWriter::outputInstruction(const Instruction &I) {
// These should be either 32-bits or 64-bits, however, with bit
// accurate types we just distinguish between less than or equal to
// 32-bits or greater than 32-bits.
- const IntegerType *IdxTy =
- cast<IntegerType>(GEP->getOperand(Idx)->getType());
- unsigned IdxId = IdxTy->getBitWidth() <= 32 ? 0 : 1;
+ unsigned BitWidth =
+ cast<IntegerType>(GEP->getOperand(Idx)->getType())->getBitWidth();
+ assert(BitWidth == 32 || BitWidth == 64 &&
+ "Invalid bitwidth for GEP index");
+ unsigned IdxId = BitWidth == 32 ? 0 : 1;
Slots[Idx] = (Slots[Idx] << 1) | IdxId;
if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx];
}