[cfe-commits] r56289 - /cfe/trunk/lib/CodeGen/CGCall.cpp

Daniel Dunbar daniel at zuster.org
Wed Sep 17 13:11:04 PDT 2008


Author: ddunbar
Date: Wed Sep 17 15:11:04 2008
New Revision: 56289

URL: http://llvm.org/viewvc/llvm-project?rev=56289&view=rev
Log:
Drop CodeGenTypes parameter to classifyArgumentType.

Ensure that ABIArgInfo::Default implementation for aggregrate types
is sensible (StructRet on return and ByVal on arguments).

No functionality change.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=56289&r1=56288&r2=56289&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Sep 17 15:11:04 2008
@@ -193,17 +193,33 @@
 }
 
 static ABIArgInfo classifyArgumentType(QualType Ty,
-                                       ASTContext &Context,
-                                       CodeGenTypes &Types) {
+                                       ASTContext &Context) {
   assert(!Ty->isArrayType() && "Array types cannot be passed directly.");
-
-  if (!Types.ConvertType(Ty)->isSingleValueType()) {
+  if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
     return ABIArgInfo::getByVal(0);
   } else {
     return ABIArgInfo::getDefault();
   }
 }
 
+static ABIArgInfo getABIReturnInfo(QualType Ty,
+                                   ASTContext &Context) {
+  ABIArgInfo Info = classifyReturnType(Ty, Context);
+  // Ensure default on aggregate types is StructRet.
+  if (Info.isDefault() && CodeGenFunction::hasAggregateLLVMType(Ty))
+    return ABIArgInfo::getStructRet();
+  return Info;
+}
+
+static ABIArgInfo getABIArgumentInfo(QualType Ty,
+                                     ASTContext &Context) {
+  ABIArgInfo Info = classifyArgumentType(Ty, Context);
+  // Ensure default on aggregate types is ByVal.
+  if (Info.isDefault() && CodeGenFunction::hasAggregateLLVMType(Ty))
+    return ABIArgInfo::getByVal(0);
+  return Info;  
+}
+
 /***/
 
 void CodeGenTypes::GetExpandedTypes(QualType Ty, 
@@ -304,7 +320,7 @@
   const llvm::Type *ResultType = 0;
 
   QualType RetTy = *begin;
-  ABIArgInfo RetAI = classifyReturnType(RetTy, getContext());
+  ABIArgInfo RetAI = getABIReturnInfo(RetTy, getContext());
   switch (RetAI.getKind()) {
   case ABIArgInfo::ByVal:
   case ABIArgInfo::Expand:
@@ -331,7 +347,7 @@
   }
   
   for (++begin; begin != end; ++begin) {
-    ABIArgInfo AI = classifyArgumentType(*begin, getContext(), *this);
+    ABIArgInfo AI = getABIArgumentInfo(*begin, getContext());
     const llvm::Type *Ty = ConvertType(*begin);
     
     switch (AI.getKind()) {
@@ -359,7 +375,7 @@
 }
 
 bool CodeGenModule::ReturnTypeUsesSret(QualType RetTy) {
-  return classifyReturnType(RetTy, getContext()).isStructRet();
+  return getABIReturnInfo(RetTy, getContext()).isStructRet();
 }
 
 void CodeGenModule::ConstructParamAttrList(const Decl *TargetDecl,
@@ -377,7 +393,7 @@
 
   QualType RetTy = *begin;
   unsigned Index = 1;
-  ABIArgInfo RetAI = classifyReturnType(RetTy, getContext());
+  ABIArgInfo RetAI = getABIReturnInfo(RetTy, getContext());
   switch (RetAI.getKind()) {
   case ABIArgInfo::Default:
     if (RetTy->isPromotableIntegerType()) {
@@ -408,7 +424,7 @@
   for (++begin; begin != end; ++begin) {
     QualType ParamType = *begin;
     unsigned ParamAttrs = 0;
-    ABIArgInfo AI = classifyArgumentType(ParamType, getContext(), getTypes());
+    ABIArgInfo AI = getABIArgumentInfo(ParamType, getContext());
     
     switch (AI.getKind()) {
     case ABIArgInfo::StructRet:
@@ -463,7 +479,7 @@
        i != e; ++i) {
     const VarDecl *Arg = i->first;
     QualType Ty = i->second;
-    ABIArgInfo ArgI = classifyArgumentType(Ty, getContext(), CGM.getTypes());
+    ABIArgInfo ArgI = getABIArgumentInfo(Ty, getContext());
 
     switch (ArgI.getKind()) {
     case ABIArgInfo::ByVal: 
@@ -514,7 +530,7 @@
 
   // Functions with no result always return void.
   if (ReturnValue) { 
-    ABIArgInfo RetAI = classifyReturnType(RetTy, getContext());
+    ABIArgInfo RetAI = getABIReturnInfo(RetTy, getContext());
     
     switch (RetAI.getKind()) {
     case ABIArgInfo::StructRet:
@@ -552,7 +568,7 @@
 
   // Handle struct-return functions by passing a pointer to the
   // location that we would like to return into.
-  ABIArgInfo RetAI = classifyReturnType(RetTy, getContext());
+  ABIArgInfo RetAI = getABIReturnInfo(RetTy, getContext());
   switch (RetAI.getKind()) {
   case ABIArgInfo::StructRet:
     // Create a temporary alloca to hold the result of the call. :(
@@ -570,8 +586,7 @@
   
   for (CallArgList::const_iterator I = CallArgs.begin(), E = CallArgs.end(); 
        I != E; ++I) {
-    ABIArgInfo ArgInfo = classifyArgumentType(I->second, getContext(), 
-                                              CGM.getTypes());
+    ABIArgInfo ArgInfo = getABIArgumentInfo(I->second, getContext());
     RValue RV = I->first;
 
     switch (ArgInfo.getKind()) {





More information about the cfe-commits mailing list