aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-11 22:25:00 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-11 22:25:00 +0000
commit8a9f3fd8bb14a64a31a29bf5cf5376b643218b71 (patch)
treed384738b6222dfc4fbf64beebd6cbabc7826a73f /lib/CodeGen
parentbac7c250c9b098ee3d637c8ed77da62e860d9244 (diff)
Set the calling convention based on the CGFunctionInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGCall.cpp6
-rw-r--r--lib/CodeGen/CGExpr.cpp9
-rw-r--r--lib/CodeGen/CodeGenModule.cpp9
3 files changed, 14 insertions, 10 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 399624d2cf..fcaa49e129 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -851,9 +851,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
}
CS.setAttributes(Attrs);
- if (const llvm::Function *F =
- dyn_cast<llvm::Function>(Callee->stripPointerCasts()))
- CS.setCallingConv(F->getCallingConv());
+ llvm::CallingConv::ID CC =
+ static_cast<llvm::CallingConv::ID>(CallInfo.getCallingConvention());
+ CS.setCallingConv(CC);
// If the call doesn't return, finish the basic block and clear the
// insertion point; this allows the rest of IRgen to discard
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index ba9828c879..33a84036ef 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1386,6 +1386,13 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType,
CallArgList Args;
EmitCallArgs(Args, FnType->getAsFunctionProtoType(), ArgBeg, ArgEnd);
- return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
+ // FIXME: We should not need to do this, it should be part of the function
+ // type.
+ unsigned CallingConvention = 0;
+ if (const llvm::Function *F =
+ dyn_cast<llvm::Function>(Callee->stripPointerCasts()))
+ CallingConvention = F->getCallingConv();
+ return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args,
+ CallingConvention),
Callee, Args, TargetDecl);
}
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 064f3efcc5..00182113f8 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -343,12 +343,9 @@ void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
F->setAttributes(llvm::AttrListPtr::get(AttributeList.begin(),
AttributeList.size()));
- // Set the appropriate calling convention for the Function.
- if (D->hasAttr<FastCallAttr>())
- F->setCallingConv(llvm::CallingConv::X86_FastCall);
-
- if (D->hasAttr<StdCallAttr>())
- F->setCallingConv(llvm::CallingConv::X86_StdCall);
+ llvm::CallingConv::ID CC =
+ static_cast<llvm::CallingConv::ID>(Info.getCallingConvention());
+ F->setCallingConv(CC);
}
void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,