aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.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/Writer/BitcodeWriter.cpp
parentdb3467f8d4a98bf17f87726be3ac9b82242a49ae (diff)
downloadllvm-ad0ea2d430f8bcd0b7f6730fa48f918638876055.zip
llvm-ad0ea2d430f8bcd0b7f6730fa48f918638876055.tar.gz
llvm-ad0ea2d430f8bcd0b7f6730fa48f918638876055.tar.bz2
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/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp37
1 files changed, 11 insertions, 26 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 6bf2712..9249c70 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -147,8 +147,6 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
Abbv = new BitCodeAbbrev();
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_FUNCTION));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
- Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
- Log2_32_Ceil(VE.getParamAttrs().size()+1)));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
Log2_32_Ceil(VE.getTypes().size()+1)));
@@ -206,10 +204,9 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
case Type::FunctionTyID: {
const FunctionType *FT = cast<FunctionType>(T);
- // FUNCTION: [isvararg, attrid, retty, paramty x N]
+ // FUNCTION: [isvararg, retty, paramty x N]
Code = bitc::TYPE_CODE_FUNCTION;
TypeVals.push_back(FT->isVarArg());
- TypeVals.push_back(VE.getParamAttrID(FT->getParamAttrs()));
TypeVals.push_back(VE.getTypeID(FT->getReturnType()));
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
TypeVals.push_back(VE.getTypeID(FT->getParamType(i)));
@@ -383,18 +380,13 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
// Emit the function proto information.
for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F) {
- // FUNCTION: [type, callingconv, isproto, linkage, alignment, section,
- // visibility]
+ // FUNCTION: [type, callingconv, isproto, paramattr,
+ // linkage, alignment, section, visibility]
Vals.push_back(VE.getTypeID(F->getType()));
Vals.push_back(F->getCallingConv());
Vals.push_back(F->isDeclaration());
Vals.push_back(getEncodedLinkage(F));
-
- // Note: we emit the param attr ID number for the function type of this
- // function. In the future, we intend for attrs to be properties of
- // functions, instead of on the type. This is to support this future work.
- Vals.push_back(VE.getParamAttrID(F->getFunctionType()->getParamAttrs()));
-
+ Vals.push_back(VE.getParamAttrID(F->getParamAttrs()));
Vals.push_back(Log2_32(F->getAlignment())+1);
Vals.push_back(F->hasSection() ? SectionMap[F->getSection()] : 0);
Vals.push_back(getEncodedVisibility(F));
@@ -760,12 +752,9 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
Code = bitc::FUNC_CODE_INST_INVOKE;
- // Note: we emit the param attr ID number for the function type of this
- // function. In the future, we intend for attrs to be properties of
- // functions, instead of on the type. This is to support this future work.
- Vals.push_back(VE.getParamAttrID(FTy->getParamAttrs()));
-
- Vals.push_back(cast<InvokeInst>(I).getCallingConv());
+ const InvokeInst *II = cast<InvokeInst>(&I);
+ Vals.push_back(VE.getParamAttrID(II->getParamAttrs()));
+ Vals.push_back(II->getCallingConv());
Vals.push_back(VE.getValueID(I.getOperand(1))); // normal dest
Vals.push_back(VE.getValueID(I.getOperand(2))); // unwind dest
PushValueAndType(I.getOperand(0), InstID, Vals, VE); // callee
@@ -837,14 +826,10 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Code = bitc::FUNC_CODE_INST_CALL;
- // Note: we emit the param attr ID number for the function type of this
- // function. In the future, we intend for attrs to be properties of
- // functions, instead of on the type. This is to support this future work.
- Vals.push_back(VE.getParamAttrID(FTy->getParamAttrs()));
-
- Vals.push_back((cast<CallInst>(I).getCallingConv() << 1) |
- unsigned(cast<CallInst>(I).isTailCall()));
- PushValueAndType(I.getOperand(0), InstID, Vals, VE); // Callee
+ const CallInst *CI = cast<CallInst>(&I);
+ Vals.push_back(VE.getParamAttrID(CI->getParamAttrs()));
+ Vals.push_back((CI->getCallingConv() << 1) | unsigned(CI->isTailCall()));
+ PushValueAndType(CI->getOperand(0), InstID, Vals, VE); // Callee
// Emit value #'s for the fixed parameters.
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)