Change CodeGenModule::ConstructTypeAttributes to return the calling convention
to use, and allow the ABI implementation to override the calling convention.

llvm-svn: 81593
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ae7a8b1..5dfc4bc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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())