Propagate calling convention information to function declarations and CallInst
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48077 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index 879f29a..932a5c5 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -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);
 }