This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] erroneous use of int_size_in_bytes by m32r RETURN_IN_MEMORY


Debugging compile/20010605-1.c on m32r-elf, the failure is because
int_size_in_bytes returns -1 and m32r.h's RETURN_IN_MEMORY doesn't handle
this.  Browsing the tree I see other ports that define RETURN_IN_MEMORY as
a simple check for (int_size_in_bytes (TYPE) > some_number).

// e.g. from stormy16.h
#define RETURN_IN_MEMORY(TYPE) \
  (int_size_in_bytes (TYPE) > UNITS_PER_WORD * NUM_ARGUMENT_REGISTERS)

And sure enough, building xstormy16-elf yields a cc1 that
fails compile/20010605-1.c (with a bit of effort).
At first it didn't fail.  That's because stormy16.h doesn't
define DEFAULT_PCC_STRUCT_RETURN so cc1 uses the default of 1
which causes aggregate_value_p to return 1 like it should.
However, if I pass -fno-pcc-struct-return, xstormy16-elf fails the
same way m32r-elf does:

20010605-1.c: In function `retframe_block':
20010605-1.c:10: internal compiler error: in hard_function_value, at explow.c:1668

Seems like the obvious fix is to also test for int_size_in_bytes < 0.
Both the arm and ia64 ports do this.  Hence the following patch for m32r:

2003-06-12  Doug Evans  <dje@sebabeach.org>

	* config/m32r/m32r-protos.h (m32r_return_in_memory): Declare.
	* config/m32r/m32r.c (m32r_return_in_memory): New fn.
	* config/m32r/m32r.h (RETURN_IN_MEMORY): Call it.

Index: config/m32r/m32r-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m32r/m32r-protos.h,v
retrieving revision 1.15
diff -u -p -r1.15 m32r-protos.h
--- config/m32r/m32r-protos.h	10 Jun 2003 16:30:47 -0000	1.15
+++ config/m32r/m32r-protos.h	12 Jun 2003 07:53:51 -0000
@@ -93,6 +93,7 @@ extern int    reg_or_zero_operand       
 
 #ifdef TREE_CODE
 extern struct rtx_def * m32r_va_arg		PARAMS ((tree, tree));
+extern int m32r_return_in_memory		PARAMS ((tree));
 #endif /* TREE_CODE */
 #endif /* RTX_CODE */
 
Index: config/m32r/m32r.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m32r/m32r.c,v
retrieving revision 1.66
diff -u -p -r1.66 m32r.c
--- config/m32r/m32r.c	10 Jun 2003 16:30:47 -0000	1.66
+++ config/m32r/m32r.c	12 Jun 2003 07:53:52 -0000
@@ -1002,6 +1002,19 @@ large_insn_p (op, mode)
   return get_attr_length (op) != 2;
 }
 
+/* Return non-zero if TYPE must be returned in memory.  */
+
+int
+m32r_return_in_memory (type)
+     tree type;
+{
+  int size = int_size_in_bytes (type);
+
+  if (size < 0 || size > 8)
+    return 1;
+
+  return 0;
+}
 
 /* Comparisons.  */
 
Index: config/m32r/m32r.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m32r/m32r.h,v
retrieving revision 1.85
diff -u -p -r1.85 m32r.h
--- config/m32r/m32r.h	11 Jun 2003 17:52:40 -0000	1.85
+++ config/m32r/m32r.h	12 Jun 2003 07:53:53 -0000
@@ -1210,8 +1210,7 @@ M32R_STACK_ALIGN (current_function_outgo
    to return the function value in memory, just as large structures are
    always returned.  Here TYPE will be a C expression of type `tree',
    representing the data type of the value.  */
-#define RETURN_IN_MEMORY(TYPE) \
-(int_size_in_bytes (TYPE) > 8)
+#define RETURN_IN_MEMORY(TYPE) m32r_return_in_memory (TYPE)
 
 /* Tell GCC to use RETURN_IN_MEMORY.  */
 #define DEFAULT_PCC_STRUCT_RETURN 0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]