aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-05-31 19:11:15 +0000
committerDan Gohman <gohman@apple.com>2008-05-31 19:11:15 +0000
commitaa91c1d739629e930071eadefaf70478f829e7c1 (patch)
tree06c7924564550ee0a8b7c4f73ff78d611c77f002 /lib/Bitcode
parentf0bbb440b19963b39a2adcf07c2fb177554d1d9b (diff)
downloadexternal_llvm-aa91c1d739629e930071eadefaf70478f829e7c1.zip
external_llvm-aa91c1d739629e930071eadefaf70478f829e7c1.tar.gz
external_llvm-aa91c1d739629e930071eadefaf70478f829e7c1.tar.bz2
Improved bitcode support for insertvalue/extractvalue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51822 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp4
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp19
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 60767bd..3fc6b17 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -774,7 +774,7 @@ bool BitcodeReader::ParseConstants() {
// 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 @@ bool BitcodeReader::ParseConstants() {
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];
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 376cc05..df644d0 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -738,16 +738,23 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
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);