diff options
author | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
commit | f5588dc4ec43da1e4423e5ff2394669c0f000350 (patch) | |
tree | 843dfcaeb8f6c99de930a32020148b563005c2fd /lib/VMCore/Instructions.cpp | |
parent | 4b97e6dc76fe49155a0da53e3df3eef153729d0f (diff) | |
download | external_llvm-f5588dc4ec43da1e4423e5ff2394669c0f000350.zip external_llvm-f5588dc4ec43da1e4423e5ff2394669c0f000350.tar.gz external_llvm-f5588dc4ec43da1e4423e5ff2394669c0f000350.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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 6bee186..7226f66 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -35,6 +35,18 @@ void CallSite::setCallingConv(unsigned CC) { else cast<InvokeInst>(I)->setCallingConv(CC); } +const ParamAttrsList* CallSite::getParamAttrs() const { + if (CallInst *CI = dyn_cast<CallInst>(I)) + return CI->getParamAttrs(); + else + return cast<InvokeInst>(I)->getParamAttrs(); +} +void CallSite::setParamAttrs(const ParamAttrsList *PAL) { + if (CallInst *CI = dyn_cast<CallInst>(I)) + CI->setParamAttrs(PAL); + else + cast<InvokeInst>(I)->setParamAttrs(PAL); +} @@ -341,8 +353,9 @@ CallInst::CallInst(Value *Func, const std::string &Name, CallInst::CallInst(const CallInst &CI) : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()], - CI.getNumOperands()) { - ParamAttrs = 0; + CI.getNumOperands()), + ParamAttrs(0) { + setParamAttrs(CI.getParamAttrs()); SubclassData = CI.SubclassData; Use *OL = OperandList; Use *InOL = CI.OperandList; @@ -350,7 +363,10 @@ CallInst::CallInst(const CallInst &CI) OL[i].init(InOL[i], this); } -void CallInst::setParamAttrs(ParamAttrsList *newAttrs) { +void CallInst::setParamAttrs(const ParamAttrsList *newAttrs) { + if (ParamAttrs == newAttrs) + return; + if (ParamAttrs) ParamAttrs->dropRef(); @@ -360,6 +376,12 @@ void CallInst::setParamAttrs(ParamAttrsList *newAttrs) { ParamAttrs = newAttrs; } +bool CallInst::isStructReturn() const { + if (ParamAttrs) + return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet); + return false; +} + //===----------------------------------------------------------------------===// // InvokeInst Implementation //===----------------------------------------------------------------------===// @@ -397,8 +419,9 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, InvokeInst::InvokeInst(const InvokeInst &II) : TerminatorInst(II.getType(), Instruction::Invoke, - new Use[II.getNumOperands()], II.getNumOperands()) { - ParamAttrs = 0; + new Use[II.getNumOperands()], II.getNumOperands()), + ParamAttrs(0) { + setParamAttrs(II.getParamAttrs()); SubclassData = II.SubclassData; Use *OL = OperandList, *InOL = II.OperandList; for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i) @@ -415,7 +438,10 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { return setSuccessor(idx, B); } -void InvokeInst::setParamAttrs(ParamAttrsList *newAttrs) { +void InvokeInst::setParamAttrs(const ParamAttrsList *newAttrs) { + if (ParamAttrs == newAttrs) + return; + if (ParamAttrs) ParamAttrs->dropRef(); @@ -425,6 +451,12 @@ void InvokeInst::setParamAttrs(ParamAttrsList *newAttrs) { ParamAttrs = newAttrs; } +bool InvokeInst::isStructReturn() const { + if (ParamAttrs) + return ParamAttrs->paramHasAttr(1, ParamAttr::StructRet); + return false; +} + //===----------------------------------------------------------------------===// // ReturnInst Implementation //===----------------------------------------------------------------------===// |