summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-11-27 13:23:08 +0000
committerDuncan Sands <baldrick@free.fr>2007-11-27 13:23:08 +0000
commitad0ea2d430f8bcd0b7f6730fa48f918638876055 (patch)
treebdf884ebc407bc280fbf081907724f9b2311c07d /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentdb3467f8d4a98bf17f87726be3ac9b82242a49ae (diff)
downloadbcm5719-llvm-ad0ea2d430f8bcd0b7f6730fa48f918638876055.tar.gz
bcm5719-llvm-ad0ea2d430f8bcd0b7f6730fa48f918638876055.zip
Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions and function calls. This is an updated and slightly corrected version of Reid Spencer's original patch. The only known problem is that auto-upgrading of bitcode files doesn't seem to work properly (see test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully a bitcode guru (who might that be? :) ) will fix it. llvm-svn: 44359
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 119a583358e..93542f3dad0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -329,15 +329,15 @@ bool BitcodeReader::ParseTypeTable() {
ResultTy = PointerType::get(getTypeByID(Record[0], true));
break;
case bitc::TYPE_CODE_FUNCTION: {
- // FUNCTION: [vararg, attrid, retty, paramty x N]
- if (Record.size() < 3)
+ // FUNCTION: [vararg, retty, paramty x N]
+ if (Record.size() < 2)
return Error("Invalid FUNCTION type record");
std::vector<const Type*> ArgTys;
- for (unsigned i = 3, e = Record.size(); i != e; ++i)
+ for (unsigned i = 2, e = Record.size(); i != e; ++i)
ArgTys.push_back(getTypeByID(Record[i], true));
- ResultTy = FunctionType::get(getTypeByID(Record[2], true), ArgTys,
- Record[0], getParamAttrs(Record[1]));
+ ResultTy = FunctionType::get(getTypeByID(Record[1], true), ArgTys,
+ Record[0]);
break;
}
case bitc::TYPE_CODE_STRUCT: { // STRUCT: [ispacked, eltty x N]
@@ -1033,9 +1033,8 @@ bool BitcodeReader::ParseModule(const std::string &ModuleID) {
Func->setCallingConv(Record[1]);
bool isProto = Record[2];
Func->setLinkage(GetDecodedLinkage(Record[3]));
-
- assert(Func->getFunctionType()->getParamAttrs() ==
- getParamAttrs(Record[4]));
+ const ParamAttrsList *PAL = getParamAttrs(Record[4]);
+ Func->setParamAttrs(PAL);
Func->setAlignment((1 << Record[5]) >> 1);
if (Record[6]) {
@@ -1360,8 +1359,10 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
break;
}
- case bitc::FUNC_CODE_INST_INVOKE: { // INVOKE: [cc,fnty, op0,op1,op2, ...]
+ case bitc::FUNC_CODE_INST_INVOKE: {
+ // INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...]
if (Record.size() < 4) return Error("Invalid INVOKE record");
+ const ParamAttrsList *PAL = getParamAttrs(Record[0]);
unsigned CCInfo = Record[1];
BasicBlock *NormalBB = getBasicBlock(Record[2]);
BasicBlock *UnwindBB = getBasicBlock(Record[3]);
@@ -1380,8 +1381,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
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)));
@@ -1403,6 +1402,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = new InvokeInst(Callee, NormalBB, UnwindBB, Ops.begin(), Ops.end());
cast<InvokeInst>(I)->setCallingConv(CCInfo);
+ cast<InvokeInst>(I)->setParamAttrs(PAL);
break;
}
case bitc::FUNC_CODE_INST_UNWIND: // UNWIND
@@ -1482,10 +1482,12 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = new StoreInst(Val, Ptr, Record[OpNum+1], (1 << Record[OpNum]) >> 1);
break;
}
- case bitc::FUNC_CODE_INST_CALL: { // CALL: [cc, fnty, fnid, arg0, arg1...]
- if (Record.size() < 2)
+ case bitc::FUNC_CODE_INST_CALL: {
+ // CALL: [paramattrs, cc, fnty, fnid, arg0, arg1...]
+ if (Record.size() < 3)
return Error("Invalid CALL record");
+ const ParamAttrsList *PAL = getParamAttrs(Record[0]);
unsigned CCInfo = Record[1];
unsigned OpNum = 2;
@@ -1499,8 +1501,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
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) {
@@ -1527,6 +1527,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = new CallInst(Callee, Args.begin(), Args.end());
cast<CallInst>(I)->setCallingConv(CCInfo>>1);
cast<CallInst>(I)->setTailCall(CCInfo & 1);
+ cast<CallInst>(I)->setParamAttrs(PAL);
break;
}
case bitc::FUNC_CODE_INST_VAARG: { // VAARG: [valistty, valist, instty]
OpenPOWER on IntegriCloud