[llvm-commits] CVS: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Chris Lattner
sabre at nondot.org
Mon May 7 22:38:25 PDT 2007
Changes in directory llvm/lib/Bitcode/Reader:
BitcodeReader.cpp updated: 1.47 -> 1.48
---
Log message:
Make a preemptive bitcode format change to support PR1146: http://llvm.org/PR1146 . This lets us do
pr1146: http://llvm.org/PR1146 in llvm 2.1 without ugly code to emulate old behavior. This should
be merged into the 2.0 release branch.
---
Diffs of the changes: (+25 -16)
BitcodeReader.cpp | 41 +++++++++++++++++++++++++----------------
1 files changed, 25 insertions(+), 16 deletions(-)
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.47 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.48
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.47 Sun May 6 14:27:46 2007
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Tue May 8 00:38:01 2007
@@ -985,10 +985,10 @@
GlobalInits.push_back(std::make_pair(NewGV, InitID-1));
break;
}
- // FUNCTION: [type, callingconv, isproto, linkage, alignment, section,
- // visibility]
+ // FUNCTION: [type, callingconv, isproto, linkage, paramattr,
+ // alignment, section, visibility]
case bitc::MODULE_CODE_FUNCTION: {
- if (Record.size() < 7)
+ if (Record.size() < 8)
return Error("Invalid MODULE_CODE_FUNCTION record");
const Type *Ty = getTypeByID(Record[0]);
if (!isa<PointerType>(Ty))
@@ -1004,13 +1004,17 @@
Func->setCallingConv(Record[1]);
bool isProto = Record[2];
Func->setLinkage(GetDecodedLinkage(Record[3]));
- Func->setAlignment((1 << Record[4]) >> 1);
- if (Record[5]) {
- if (Record[5]-1 >= SectionTable.size())
+
+ assert(Func->getFunctionType()->getParamAttrs() ==
+ getParamAttrs(Record[4]));
+
+ Func->setAlignment((1 << Record[5]) >> 1);
+ if (Record[6]) {
+ if (Record[6]-1 >= SectionTable.size())
return Error("Invalid section ID");
- Func->setSection(SectionTable[Record[5]-1]);
+ Func->setSection(SectionTable[Record[6]-1]);
}
- Func->setVisibility(GetDecodedVisibility(Record[6]));
+ Func->setVisibility(GetDecodedVisibility(Record[7]));
ValueList.push_back(Func);
@@ -1364,12 +1368,12 @@
}
case bitc::FUNC_CODE_INST_INVOKE: { // INVOKE: [cc,fnty, op0,op1,op2, ...]
- if (Record.size() < 3) return Error("Invalid INVOKE record");
- unsigned CCInfo = Record[0];
- BasicBlock *NormalBB = getBasicBlock(Record[1]);
- BasicBlock *UnwindBB = getBasicBlock(Record[2]);
+ if (Record.size() < 4) return Error("Invalid INVOKE record");
+ unsigned CCInfo = Record[1];
+ BasicBlock *NormalBB = getBasicBlock(Record[2]);
+ BasicBlock *UnwindBB = getBasicBlock(Record[3]);
- unsigned OpNum = 3;
+ unsigned OpNum = 4;
Value *Callee;
if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
return Error("Invalid INVOKE record");
@@ -1383,6 +1387,8 @@
Record.size() < OpNum+FTy->getNumParams())
return Error("Invalid INVOKE record");
+ assert(FTy->getParamAttrs() == getParamAttrs(Record[0]));
+
SmallVector<Value*, 16> Ops;
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
Ops.push_back(getFnValueByID(Record[OpNum], FTy->getParamType(i)));
@@ -1484,11 +1490,12 @@
break;
}
case bitc::FUNC_CODE_INST_CALL: { // CALL: [cc, fnty, fnid, arg0, arg1...]
- if (Record.size() < 1)
+ if (Record.size() < 2)
return Error("Invalid CALL record");
- unsigned CCInfo = Record[0];
- unsigned OpNum = 1;
+ unsigned CCInfo = Record[1];
+
+ unsigned OpNum = 2;
Value *Callee;
if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
return Error("Invalid CALL record");
@@ -1499,6 +1506,8 @@
if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
return Error("Invalid CALL record");
+ assert(FTy->getParamAttrs() == getParamAttrs(Record[0]));
+
SmallVector<Value*, 16> Args;
// Read the fixed params.
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
More information about the llvm-commits
mailing list