[llvm-commits] [dragonegg] r88769 - in /dragonegg/trunk: llvm-abi.h llvm-types.cpp x86/llvm-target.h

Duncan Sands baldrick at free.fr
Sat Nov 14 02:20:46 PST 2009


Author: baldrick
Date: Sat Nov 14 04:20:46 2009
New Revision: 88769

URL: http://llvm.org/viewvc/llvm-project?rev=88769&view=rev
Log:
Port commit 85539 (bwilson) from llvm-gcc:
Fix ARM AAPCS-VFP return of homogeneous aggregates.  Patch by Sandeep Patel.

Modified:
    dragonegg/trunk/llvm-abi.h
    dragonegg/trunk/llvm-types.cpp
    dragonegg/trunk/x86/llvm-target.h

Modified: dragonegg/trunk/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88769&r1=88768&r2=88769&view=diff

==============================================================================
--- dragonegg/trunk/llvm-abi.h (original)
+++ dragonegg/trunk/llvm-abi.h Sat Nov 14 04:20:46 2009
@@ -124,15 +124,24 @@
  false
 #endif
 
+// LLVM_SHOULD_NOT_USE_SHADOW_RETURN - A hook to allow aggregates to be
+// returned in registers.
+#ifndef LLVM_SHOULD_NOT_USE_SHADOW_RETURN
+#define LLVM_SHOULD_NOT_USE_SHADOW_RETURN(X, CC) \
+ false
+#endif
+
 // doNotUseShadowReturn - Return true if the specified GCC type 
 // should not be returned using a pointer to struct parameter. 
-static inline bool doNotUseShadowReturn(tree type, tree fndecl) {
+static inline bool doNotUseShadowReturn(tree type, tree fndecl,
+                                        CallingConv::ID CC) {
   if (!TYPE_SIZE(type))
     return false;
   if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
     return false;
   // LLVM says do not use shadow argument.
-  if (LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(type))
+  if (LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(type) ||
+     LLVM_SHOULD_NOT_USE_SHADOW_RETURN(type, CC))
     return true;
   // GCC says use shadow argument.
   if (aggregate_value_p(type, fndecl))
@@ -394,7 +403,7 @@
     } else if (Ty->isSingleValueType() || Ty->isVoidTy()) {
       // Return scalar values normally.
       C.HandleScalarResult(Ty);
-    } else if (doNotUseShadowReturn(type, fn)) {
+    } else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) {
       tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type);
       if (SingleElt && TYPE_SIZE(SingleElt) && 
           TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST &&
@@ -404,7 +413,8 @@
       } else {
         // Otherwise return as an integer value large enough to hold the entire
         // aggregate.
-        if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type))
+        if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type,
+                                    C.getCallingConv()))
           C.HandleAggregateResultAsAggregate(AggrTy);
         else if (const Type* ScalarTy = 
                     LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(type, &Offset))
@@ -753,7 +763,7 @@
     } else if (Ty->isSingleValueType() || Ty->isVoidTy()) {
       // Return scalar values normally.
       C.HandleScalarResult(Ty);
-    } else if (doNotUseShadowReturn(type, fn)) {
+    } else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) {
       tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type);
       if (SingleElt && TYPE_SIZE(SingleElt) && 
           TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST &&
@@ -763,7 +773,8 @@
       } else {
         // Otherwise return as an integer value large enough to hold the entire
         // aggregate.
-        if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type))
+        if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type,
+                                    C.getCallingConv()))
           C.HandleAggregateResultAsAggregate(AggrTy);
         else if (const Type* ScalarTy = 
                     LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(type, &Offset))

Modified: dragonegg/trunk/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=88769&r1=88768&r2=88769&view=diff

==============================================================================
--- dragonegg/trunk/llvm-types.cpp (original)
+++ dragonegg/trunk/llvm-types.cpp Sat Nov 14 04:20:46 2009
@@ -1024,16 +1024,16 @@
   tree ReturnType = TREE_TYPE(type);
   std::vector<PATypeHolder> ArgTys;
   PATypeHolder RetTy(Type::getVoidTy(Context));
-  
+
   FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/);
   TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
-  
-  // Builtins are always prototyped, so this isn't one.
-  ABIConverter.HandleReturnType(ReturnType, current_function_decl, false);
 
 #ifdef TARGET_ADJUST_LLVM_CC
-    TARGET_ADJUST_LLVM_CC(CallingConv, type);
+  TARGET_ADJUST_LLVM_CC(CallingConv, type);
 #endif
+  
+  // Builtins are always prototyped, so this isn't one.
+  ABIConverter.HandleReturnType(ReturnType, current_function_decl, false);
 
   SmallVector<AttributeWithIndex, 8> Attrs;
 
@@ -1090,15 +1090,15 @@
   bool isVarArg = false;
   FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/);
   TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
-  
-  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.
 #ifdef TARGET_ADJUST_LLVM_CC
   TARGET_ADJUST_LLVM_CC(CallingConv, type);
 #endif
 
+  ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl,
+                                decl ? DECL_BUILT_IN(decl) : false);
+  
   // Compute attributes for return type (and function attributes).
   SmallVector<AttributeWithIndex, 8> Attrs;
   Attributes FnAttributes = Attribute::None;

Modified: dragonegg/trunk/x86/llvm-target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.h?rev=88769&r1=88768&r2=88769&view=diff

==============================================================================
--- dragonegg/trunk/x86/llvm-target.h (original)
+++ dragonegg/trunk/x86/llvm-target.h Sat Nov 14 04:20:46 2009
@@ -137,7 +137,7 @@
 
 /* LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be 
    returned as an aggregate, otherwise return NULL. */
-#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X) \
+#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X, CC) \
   llvm_x86_aggr_type_for_struct_return(X)
 
 extern void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest,





More information about the llvm-commits mailing list