[cfe-commits] r48077 - in /cfe/trunk/CodeGen: CGExpr.cpp CodeGenModule.cpp

Nate Begeman natebegeman at mac.com
Sat Mar 8 19:09:36 PST 2008


Author: sampo
Date: Sat Mar  8 21:09:36 2008
New Revision: 48077

URL: http://llvm.org/viewvc/llvm-project?rev=48077&view=rev
Log:
Propagate calling convention information to function declarations and CallInst
instructions.

Modified:
    cfe/trunk/CodeGen/CGExpr.cpp
    cfe/trunk/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=48077&r1=48076&r2=48077&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Sat Mar  8 21:09:36 2008
@@ -595,9 +595,11 @@
     }
   }
   
-  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 @@
   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);
 }

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=48077&r1=48076&r2=48077&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Sat Mar  8 21:09:36 2008
@@ -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 @@
   // 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.





More information about the cfe-commits mailing list