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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81593 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index fcaa49e..c63dab1 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -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