aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-08 05:38:01 +0000
committerChris Lattner <sabre@nondot.org>2007-05-08 05:38:01 +0000
commit4c0a6d660ee83a4b18490d566a0a15bbf6e1d9d1 (patch)
tree3f706cbe7f437787581c4238848286c7153be41f /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent2357362805695919bf323c9074c94d3024e8cff3 (diff)
downloadllvm-4c0a6d660ee83a4b18490d566a0a15bbf6e1d9d1.zip
llvm-4c0a6d660ee83a4b18490d566a0a15bbf6e1d9d1.tar.gz
llvm-4c0a6d660ee83a4b18490d566a0a15bbf6e1d9d1.tar.bz2
Make a preemptive bitcode format change to support PR1146. This lets us do
pr1146 in llvm 2.1 without ugly code to emulate old behavior. This should be merged into the 2.0 release branch. llvm-svn: 36928
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 34c8383..1ea7633 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -386,6 +386,12 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
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(Log2_32(F->getAlignment())+1);
Vals.push_back(F->hasSection() ? SectionMap[F->getSection()] : 0);
Vals.push_back(getEncodedVisibility(F));
@@ -736,15 +742,21 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Vals.push_back(VE.getValueID(I.getOperand(i)));
break;
case Instruction::Invoke: {
+ const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
+ 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());
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
// Emit value #'s for the fixed parameters.
- const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
- const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
Vals.push_back(VE.getValueID(I.getOperand(i+3))); // fixed param.
@@ -806,14 +818,21 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Vals.push_back(cast<StoreInst>(I).isVolatile());
break;
case Instruction::Call: {
+ const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
+ const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
+
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
// Emit value #'s for the fixed parameters.
- const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
- const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
Vals.push_back(VE.getValueID(I.getOperand(i+1))); // fixed param.