re PR target/77759 (ICE in function_arg_record_value on nested empty class)
authorJames Clarke <jrtc27@jrtc27.com>
Thu, 6 Oct 2016 10:28:23 +0000 (10:28 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 6 Oct 2016 10:28:23 +0000 (10:28 +0000)
PR target/77759
* config/sparc/sparc.c (classify_data_t): Remove int_regs field.
(classify_registers): Don't set it
(function_arg_slotno): Don't initialize and test it.  Tidy up.

Co-Authored-By: Eric Botcazou <ebotcazou@adacore.com>
From-SVN: r240830

gcc/ChangeLog
gcc/config/sparc/sparc.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr77759.C [new file with mode: 0644]

index b7e7a6d..5fd5c7a 100644 (file)
@@ -1,3 +1,11 @@
+2016-10-06  James Clarke  <jrtc27@jrtc27.com>
+            Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR target/77759
+       * config/sparc/sparc.c (classify_data_t): Remove int_regs field.
+       (classify_registers): Don't set it
+       (function_arg_slotno): Don't initialize and test it.  Tidy up.
+
 2016-10-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77839
index c622b66..c1c196b 100644 (file)
@@ -6294,7 +6294,6 @@ traverse_record_type (const_tree type, bool named, T *data,
 
 typedef struct
 {
-  bool int_regs;       /* true if field eligible to int registers.  */
   bool fp_regs;                /* true if field eligible to FP registers.  */
   bool fp_regs_in_first_word;  /* true if such field in first word.  */
 } classify_data_t;
@@ -6311,8 +6310,6 @@ classify_registers (const_tree, HOST_WIDE_INT bitpos, bool fp,
       if (bitpos < BITS_PER_WORD)
        data->fp_regs_in_first_word = true;
     }
-  else
-    data->int_regs = true;
 }
 
 /* Compute the slot number to pass an argument in.
@@ -6439,23 +6436,25 @@ function_arg_slotno (const struct sparc_args *cum, machine_mode mode,
 
          if (TREE_CODE (type) == RECORD_TYPE)
            {
-             classify_data_t data = { false, false, false };
+             classify_data_t data = { false, false };
              traverse_record_type<classify_data_t, classify_registers>
                (type, named, &data);
 
-             /* If all slots are filled except for the last one, but there
-                is no FP field in the first word, then must pass on stack.  */
-             if (data.fp_regs
-                 && !data.fp_regs_in_first_word
-                 && slotno >= SPARC_FP_ARG_MAX - 1)
-               return -1;
-
-             /* If there are only int args and all int slots are filled,
-                then must pass on stack.  */
-             if (!data.fp_regs
-                 && data.int_regs
-                 && slotno >= SPARC_INT_ARG_MAX)
-               return -1;
+             if (data.fp_regs)
+               {
+                 /* If all FP slots are filled except for the last one and
+                    there is no FP field in the first word, then must pass
+                    on stack.  */
+                 if (slotno >= SPARC_FP_ARG_MAX - 1
+                     && !data.fp_regs_in_first_word)
+                   return -1;
+               }
+             else
+               {
+                 /* If all int slots are filled, then must pass on stack.  */
+                 if (slotno >= SPARC_INT_ARG_MAX)
+                   return -1;
+               }
            }
 
          /* PREGNO isn't set since both int and FP regs can be used.  */
index 0f24a75..0858846 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-06  James Clarke  <jrtc27@jrtc27.com>
+            Eric Botcazou  <ebotcazou@adacore.com>
+
+       * g++.dg/other/pr77759.C: New test.
+
 2016-10-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/77839
diff --git a/gcc/testsuite/g++.dg/other/pr77759.C b/gcc/testsuite/g++.dg/other/pr77759.C
new file mode 100644 (file)
index 0000000..71bee65
--- /dev/null
@@ -0,0 +1,21 @@
+// PR target/77759
+// This ICEd in the 64-bit SPARC back-end because of the nested empty struct.
+
+// { dg-do compile }
+
+struct empty {};
+
+struct pair_empty
+{
+   struct empty a;
+   struct empty b;
+};
+
+extern void foo (int slot0, int slot1, int slot2, int slot3, int slot4,
+                int slot5, struct pair_empty pair);
+
+void bar (void)
+{
+  struct pair_empty pair;
+  foo (0, 0, 0, 0, 0, 0, pair);
+}