This PR is about an ICE on SPARC 32-bit with -freg-struct-return.  I didn't 
know that this option was supported on this architecture but apparently it 
was, at least in the 3.x series, so the attached patchlet fixes the ICE.

Tested on SPARC/Solaris (including compat testing), applied on all branches.


2015-11-09  Eric Botcazou  <ebotca...@adacore.com>

        PR target/57845
        * config/sparc/sparc.c (sparc_function_value_1): In 32-bit mode, do
        not promote the mode for aggregate types.


2015-11-09  Eric Botcazou  <ebotca...@adacore.com>

        * gcc.target/sparc/sparc-ret.c: Rename to...
        * gcc.target/sparc/sparc-ret-1.c: ...this.
        * gcc.target/sparc/sparc-ret-2.c: New test.

-- 
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 230016)
+++ config/sparc/sparc.c	(working copy)
@@ -7329,9 +7329,10 @@ sparc_function_value_1 (const_tree type,
 	mode = word_mode;
     }
 
-  /* We should only have pointer and integer types at this point.  This must
-     match sparc_promote_function_mode.  */
+  /* We should only have pointer and integer types at this point, except with
+     -freg-struct-return.  This must match sparc_promote_function_mode.  */
   else if (TARGET_ARCH32
+	   && !(type && AGGREGATE_TYPE_P (type))
 	   && mclass == MODE_INT
 	   && GET_MODE_SIZE (mode) < UNITS_PER_WORD)
     mode = word_mode;
/* PR target/57845 */

/* { dg-do compile } */
/* { dg-options "-freg-struct-return" } */

struct S { short int i; };

struct S foo (short int i)
{
  struct S s;
  s.i = i;
  return s;
}

Reply via email to