[llvm-commits] [llvm] r51822 - in /llvm/trunk/lib/Bitcode: Reader/BitcodeReader.cpp Writer/BitcodeWriter.cpp
Dan Gohman
gohman at apple.com
Sat May 31 12:11:15 PDT 2008
Author: djg
Date: Sat May 31 14:11:15 2008
New Revision: 51822
URL: http://llvm.org/viewvc/llvm-project?rev=51822&view=rev
Log:
Improved bitcode support for insertvalue/extractvalue.
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=51822&r1=51821&r2=51822&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat May 31 14:11:15 2008
@@ -774,7 +774,7 @@
// CE_EXTRACTVAL: [opty, opval, n x indices]
const Type *AggTy = getTypeByID(Record[0]);
if (!AggTy || !AggTy->isAggregateType())
- return Error("Invalid CE_INSERTVAL record");
+ return Error("Invalid CE_EXTRACTVAL record");
Constant *Agg = ValueList.getConstantFwdRef(Record[1], AggTy);
SmallVector<unsigned, 4> Indices;
for (unsigned i = 2, e = Record.size(); i != e; ++i) {
@@ -796,7 +796,7 @@
return Error("Invalid CE_INSERTVAL record");
Constant *Agg = ValueList.getConstantFwdRef(Record[1], AggTy);
const Type *ValTy = getTypeByID(Record[2]);
- Constant *Val = ValueList.getConstantFwdRef(Record[2], ValTy);
+ Constant *Val = ValueList.getConstantFwdRef(Record[3], ValTy);
SmallVector<unsigned, 4> Indices;
for (unsigned i = 4, e = Record.size(); i != e; ++i) {
uint64_t Index = Record[i];
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=51822&r1=51821&r2=51822&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Sat May 31 14:11:15 2008
@@ -738,16 +738,23 @@
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
PushValueAndType(I.getOperand(i), InstID, Vals, VE);
break;
- case Instruction::ExtractValue:
+ case Instruction::ExtractValue: {
Code = bitc::FUNC_CODE_INST_EXTRACTVAL;
- for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
- PushValueAndType(I.getOperand(i), InstID, Vals, VE);
+ PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+ const ExtractValueInst *EVI = cast<ExtractValueInst>(&I);
+ for (const unsigned *i = EVI->idx_begin(), *e = EVI->idx_end(); i != e; ++i)
+ Vals.push_back(*i);
break;
- case Instruction::InsertValue:
+ }
+ case Instruction::InsertValue: {
Code = bitc::FUNC_CODE_INST_INSERTVAL;
- for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
- PushValueAndType(I.getOperand(i), InstID, Vals, VE);
+ PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+ PushValueAndType(I.getOperand(1), InstID, Vals, VE);
+ const InsertValueInst *IVI = cast<InsertValueInst>(&I);
+ for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
+ Vals.push_back(*i);
break;
+ }
case Instruction::Select:
Code = bitc::FUNC_CODE_INST_SELECT;
PushValueAndType(I.getOperand(1), InstID, Vals, VE);
More information about the llvm-commits
mailing list