]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR target/69072
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jan 2016 08:06:52 +0000 (08:06 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jan 2016 08:06:52 +0000 (08:06 +0000)
* config/sparc/sparc.c (scan_record_type): Take into account subfields
to compute the PACKED_P predicate.
(function_arg_record_value): Minor tweaks.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232049 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/sparc/sparc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sparc/20160104-1.c [new file with mode: 0644]

index 4e05260070396dbd131ba418588154040794cb99..4b29c224689e9ece790c4be05794bb782b12e5e7 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-04  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR target/69072
+       * config/sparc/sparc.c (scan_record_type): Take into account subfields
+       to compute the PACKED_P predicate.
+       (function_arg_record_value): Minor tweaks.
+
 2016-01-04  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * doc/install.texi (--with-multilib-list): Describe the meaning of the
index 02addbcb5a1ea0cef59679739ea7c294b8921f14..1d00a344095bba51562f5d52162a3b9d97d2ce52 100644 (file)
@@ -6140,30 +6140,28 @@ sparc_strict_argument_naming (cumulative_args_t ca ATTRIBUTE_UNUSED)
       that is eligible for promotion in integer registers.
     - FP_REGS_P: the record contains at least one field or sub-field
       that is eligible for promotion in floating-point registers.
-    - PACKED_P: the record contains at least one field that is packed.
-
-   Sub-fields are not taken into account for the PACKED_P predicate.  */
+    - PACKED_P: the record contains at least one field that is packed.  */
 
 static void
 scan_record_type (const_tree type, int *intregs_p, int *fpregs_p,
                  int *packed_p)
 {
-  tree field;
-
-  for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
+  for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
     {
       if (TREE_CODE (field) == FIELD_DECL)
        {
-         if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE)
-           scan_record_type (TREE_TYPE (field), intregs_p, fpregs_p, 0);
-         else if ((FLOAT_TYPE_P (TREE_TYPE (field))
-                  || TREE_CODE (TREE_TYPE (field)) == VECTOR_TYPE)
+         tree field_type = TREE_TYPE (field);
+
+         if (TREE_CODE (field_type) == RECORD_TYPE)
+           scan_record_type (field_type, intregs_p, fpregs_p, packed_p);
+         else if ((FLOAT_TYPE_P (field_type)
+                  || TREE_CODE (field_type) == VECTOR_TYPE)
                  && TARGET_FPU)
            *fpregs_p = 1;
          else
            *intregs_p = 1;
 
-         if (packed_p && DECL_PACKED (field))
+         if (DECL_PACKED (field))
            *packed_p = 1;
        }
     }
@@ -6647,9 +6645,10 @@ function_arg_record_value (const_tree type, machine_mode mode,
 
       parms.nregs += intslots;
     }
-  nregs = parms.nregs;
 
   /* Allocate the vector and handle some annoying special cases.  */
+  nregs = parms.nregs;
+
   if (nregs == 0)
     {
       /* ??? Empty structure has no value?  Duh?  */
@@ -6661,16 +6660,15 @@ function_arg_record_value (const_tree type, machine_mode mode,
             load.  */
          return gen_rtx_REG (mode, regbase);
        }
-      else
-       {
-         /* ??? C++ has structures with no fields, and yet a size.  Give up
-            for now and pass everything back in integer registers.  */
-         nregs = (typesize + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
-       }
+
+      /* ??? C++ has structures with no fields, and yet a size.  Give up
+        for now and pass everything back in integer registers.  */
+      nregs = (typesize + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
       if (nregs + slotno > SPARC_INT_ARG_MAX)
        nregs = SPARC_INT_ARG_MAX - slotno;
     }
-  gcc_assert (nregs != 0);
+
+  gcc_assert (nregs > 0);
 
   parms.ret = gen_rtx_PARALLEL (mode, rtvec_alloc (parms.stack + nregs));
 
index 91499e3d6aa1e8fab5ae940ab2f1661e61fea156..148ac10dc15c3434a1de7fb15839dea57ec05916 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-04  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.target/sparc/20160104-1.c: New test.
+
 2016-01-03  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/65045
diff --git a/gcc/testsuite/gcc.target/sparc/20160104-1.c b/gcc/testsuite/gcc.target/sparc/20160104-1.c
new file mode 100644 (file)
index 0000000..0cc617a
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR target/69072 */
+/* Reported by Zdenek Sojka <zsojka@seznam.cz> */
+
+/* { dg-do compile } */
+
+typedef struct
+{
+  struct
+  {
+    double d;
+  } __attribute__((packed)) a;
+} S;
+
+void
+foo (S s1, S s2, S s3, S s4, S s5, S s6, S s7)
+{}