[cfe-commits] r81593 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGCall.h CodeGenModule.cpp CodeGenModule.h
Daniel Dunbar
daniel at zuster.org
Fri Sep 11 17:59:20 PDT 2009
Author: ddunbar
Date: Fri Sep 11 19:59:20 2009
New Revision: 81593
URL: http://llvm.org/viewvc/llvm-project?rev=81593&view=rev
Log:
Change CodeGenModule::ConstructTypeAttributes to return the calling convention
to use, and allow the ABI implementation to override the calling convention.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=81593&r1=81592&r2=81593&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Sep 11 19:59:20 2009
@@ -156,7 +156,8 @@
CGFunctionInfo::CGFunctionInfo(unsigned _CallingConvention,
QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys)
- : CallingConvention(_CallingConvention)
+ : CallingConvention(_CallingConvention),
+ EffectiveCallingConvention(_CallingConvention)
{
NumArgs = ArgTys.size();
Args = new ArgInfo[1 + NumArgs];
@@ -404,10 +405,13 @@
void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
const Decl *TargetDecl,
- AttributeListType &PAL) {
+ AttributeListType &PAL,
+ unsigned &CallingConv) {
unsigned FuncAttrs = 0;
unsigned RetAttrs = 0;
+ CallingConv = FI.getEffectiveCallingConvention();
+
// FIXME: handle sseregparm someday...
if (TargetDecl) {
if (TargetDecl->hasAttr<NoThrowAttr>())
@@ -835,8 +839,9 @@
llvm::BasicBlock *InvokeDest = getInvokeDest();
+ unsigned CallingConv;
CodeGen::AttributeListType AttributeList;
- CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList);
+ CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList, CallingConv);
llvm::AttrListPtr Attrs = llvm::AttrListPtr::get(AttributeList.begin(),
AttributeList.end());
@@ -851,9 +856,7 @@
}
CS.setAttributes(Attrs);
- llvm::CallingConv::ID CC =
- static_cast<llvm::CallingConv::ID>(CallInfo.getCallingConvention());
- CS.setCallingConv(CC);
+ CS.setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
// If the call doesn't return, finish the basic block and clear the
// insertion point; this allows the rest of IRgen to discard
Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=81593&r1=81592&r2=81593&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Fri Sep 11 19:59:20 2009
@@ -60,9 +60,14 @@
ABIArgInfo info;
};
- /// The LLVM::CallingConv to use for this function.
+ /// The LLVM::CallingConv to use for this function (as specified by the
+ /// user).
unsigned CallingConvention;
+ /// The LLVM::CallingConv to actually use for this function, which may
+ /// depend on the ABI.
+ unsigned EffectiveCallingConvention;
+
unsigned NumArgs;
ArgInfo *Args;
@@ -82,8 +87,19 @@
unsigned arg_size() const { return NumArgs; }
+ /// getCallingConvention - Return the user specified calling
+ /// convention.
unsigned getCallingConvention() const { return CallingConvention; }
+ /// getEffectiveCallingConvention - Return the actual calling convention to
+ /// use, which may depend on the ABI.
+ unsigned getEffectiveCallingConvention() const {
+ return EffectiveCallingConvention;
+ }
+ void setEffectiveCallingConvention(unsigned Value) {
+ EffectiveCallingConvention = Value;
+ }
+
QualType getReturnType() const { return Args[0].type; }
ABIArgInfo &getReturnInfo() { return Args[0].info; }
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=81593&r1=81592&r2=81593&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Sep 11 19:59:20 2009
@@ -337,15 +337,12 @@
void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
const CGFunctionInfo &Info,
llvm::Function *F) {
+ unsigned CallingConv;
AttributeListType AttributeList;
- ConstructAttributeList(Info, D, AttributeList);
-
+ ConstructAttributeList(Info, D, AttributeList, CallingConv);
F->setAttributes(llvm::AttrListPtr::get(AttributeList.begin(),
- AttributeList.size()));
-
- llvm::CallingConv::ID CC =
- static_cast<llvm::CallingConv::ID>(Info.getCallingConvention());
- F->setCallingConv(CC);
+ AttributeList.size()));
+ F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
}
void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
@@ -1101,8 +1098,8 @@
ArgList.clear();
if (NewCall->getType() != llvm::Type::getVoidTy(Old->getContext()))
NewCall->takeName(CI);
- NewCall->setCallingConv(CI->getCallingConv());
NewCall->setAttributes(CI->getAttributes());
+ NewCall->setCallingConv(CI->getCallingConv());
// Finally, remove the old call, replacing any uses with the new one.
if (!CI->use_empty())
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=81593&r1=81592&r2=81593&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Sep 11 19:59:20 2009
@@ -384,9 +384,19 @@
/// as a return type.
bool ReturnTypeUsesSret(const CGFunctionInfo &FI);
+ /// ConstructAttributeList - Get the LLVM attributes and calling convention to
+ /// use for a particular function type.
+ ///
+ /// \param Info - The function type information.
+ /// \param TargetDecl - The decl these attributes are being constructed
+ /// for. If supplied the attributes applied to this decl may contribute to the
+ /// function attributes and calling convention.
+ /// \param PAL [out] - On return, the attribute list to use.
+ /// \param CallingConv [out] - On return, the LLVM calling convention to use.
void ConstructAttributeList(const CGFunctionInfo &Info,
const Decl *TargetDecl,
- AttributeListType &PAL);
+ AttributeListType &PAL,
+ unsigned &CallingConv);
const char *getMangledName(const GlobalDecl &D);
More information about the cfe-commits
mailing list