[llvm-commits] [llvm-gcc-4.2] r49170 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-convert.cpp llvm-types.cpp

Devang Patel dpatel at apple.com
Thu Apr 3 09:48:09 PDT 2008


Author: dpatel
Date: Thu Apr  3 11:48:09 2008
New Revision: 49170

URL: http://llvm.org/viewvc/llvm-project?rev=49170&view=rev
Log:
Use appropriate function tree node while checking aggregate_value_p(). current_function_decl may not be appropriate in all cases.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-abi.h
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=49170&r1=49169&r2=49170&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Thu Apr  3 11:48:09 2008
@@ -102,9 +102,9 @@
 
 // isAggregateFunctionParam - Return true if the specified GCC type 
 // satisfies function.c:aggregate_value_p()
-static bool isAggregateFunctionParam(tree type) {
+static bool isAggregateFunctionParam(tree type, tree fndecl) {
   if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST
-      && !aggregate_value_p(type, current_function_decl))
+      && !aggregate_value_p(type, fndecl))
     return true;
   return false;
 }
@@ -267,7 +267,7 @@
   /// return type. It potentially breaks down the argument and invokes methods
   /// on the client that indicate how its pieces should be handled.  This
   /// handles things like returning structures via hidden parameters.
-  void HandleReturnType(tree type, bool isBuiltin) {
+  void HandleReturnType(tree type, tree fn, bool isBuiltin) {
     const Type *Ty = ConvertType(type);
     if (Ty->getTypeID() == Type::VectorTyID) {
       // Vector handling is weird on x86.  In particular builtin and
@@ -283,7 +283,7 @@
     } else if (Ty->isFirstClassType() || Ty == Type::VoidTy) {
       // Return scalar values normally.
       C.HandleScalarResult(Ty);
-    } else if (isAggregateFunctionParam(type)
+    } else if (isAggregateFunctionParam(type, fn)
                && LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(type)) {
       tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type);
       if (SingleElt && TYPE_SIZE(SingleElt) && 

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49170&r1=49169&r2=49170&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Apr  3 11:48:09 2008
@@ -661,7 +661,7 @@
   TheLLVMABI<FunctionPrologArgumentConversion> ABIConverter(Client);
 
   // Handle the DECL_RESULT.
-  ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)),
+  ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl,
                                 DECL_BUILT_IN(FnDecl));
 
   // Prepend the static chain (if any) to the list of arguments.
@@ -2542,7 +2542,8 @@
   TheLLVMABI<FunctionCallArgumentConversion> ABIConverter(Client);
 
   // Handle the result, including struct returns.
-  ABIConverter.HandleReturnType(TREE_TYPE(exp),
+  ABIConverter.HandleReturnType(TREE_TYPE(exp), 
+                                fndecl ? fndecl : TREE_OPERAND (exp, 0),
                                 fndecl ? DECL_BUILT_IN(fndecl) : false);
 
   // Pass the static chain, if any, as the first parameter.

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49170&r1=49169&r2=49170&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Thu Apr  3 11:48:09 2008
@@ -1042,7 +1042,7 @@
   TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
   
   // Builtins are always prototyped, so this isn't one.
-  ABIConverter.HandleReturnType(ReturnType, false);
+  ABIConverter.HandleReturnType(ReturnType, current_function_decl, false);
 
   SmallVector<ParamAttrsWithIndex, 8> Attrs;
 
@@ -1093,7 +1093,7 @@
   FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/);
   TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
   
-  ABIConverter.HandleReturnType(TREE_TYPE(type), 
+  ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl,
                                 decl ? DECL_BUILT_IN(decl) : false);
   
   // Allow the target to set the CC for things like fastcall etc.





More information about the llvm-commits mailing list