diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-03-09 03:09:36 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-03-09 03:09:36 +0000 |
commit | aca747a34ad7dcb5f6fd5ff64fb1e171b7ca7166 (patch) | |
tree | a4c10187fe9dc300e9692dfb2a3610aff55f19e0 /clang | |
parent | 1d4000ba5075c873e752968282e91037cbd606a2 (diff) | |
download | bcm5719-llvm-aca747a34ad7dcb5f6fd5ff64fb1e171b7ca7166.tar.gz bcm5719-llvm-aca747a34ad7dcb5f6fd5ff64fb1e171b7ca7166.zip |
Propagate calling convention information to function declarations and CallInst
instructions.
llvm-svn: 48077
Diffstat (limited to 'clang')
-rw-r--r-- | clang/CodeGen/CGExpr.cpp | 12 | ||||
-rw-r--r-- | clang/CodeGen/CodeGenModule.cpp | 10 |
2 files changed, 15 insertions, 7 deletions
diff --git a/clang/CodeGen/CGExpr.cpp b/clang/CodeGen/CGExpr.cpp index 879f29ab60a..932a5c5da8b 100644 --- a/clang/CodeGen/CGExpr.cpp +++ b/clang/CodeGen/CGExpr.cpp @@ -595,9 +595,11 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, } } - llvm::Value *V = Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size()); - if (V->getType() != llvm::Type::VoidTy) - V->setName("call"); + llvm::CallInst *CI = Builder.CreateCall(Callee,&Args[0],&Args[0]+Args.size()); + if (const llvm::Function *F = dyn_cast<llvm::Function>(Callee)) + CI->setCallingConv(F->getCallingConv()); + if (CI->getType() != llvm::Type::VoidTy) + CI->setName("call"); else if (ResultType->isComplexType()) return RValue::getComplex(LoadComplexFromAddr(Args[0], false)); else if (hasAggregateLLVMType(ResultType)) @@ -606,8 +608,8 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, else { // void return. assert(ResultType->isVoidType() && "Should only have a void expr here"); - V = 0; + CI = 0; } - return RValue::get(V); + return RValue::get(CI); } diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp index d2b60475250..0b39ca44378 100644 --- a/clang/CodeGen/CodeGenModule.cpp +++ b/clang/CodeGen/CodeGenModule.cpp @@ -18,6 +18,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/TargetInfo.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -87,8 +88,13 @@ llvm::Constant *CodeGenModule::GetAddrOfFunctionDecl(const FunctionDecl *D, // If it doesn't already exist, just create and return an entry. if (F == 0) { // FIXME: param attributes for sext/zext etc. - return Entry = new llvm::Function(FTy, llvm::Function::ExternalLinkage, - D->getName(), &getModule()); + F = new llvm::Function(FTy, llvm::Function::ExternalLinkage, D->getName(), + &getModule()); + + // Set the appropriate calling convention for the Function. + if (D->getAttr<FastCallAttr>()) + F->setCallingConv(llvm::CallingConv::Fast); + return Entry = F; } // If the pointer type matches, just return it. |