From 139dc3c65114ff2497a0391ca7698992eb57f6cd Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 6 Oct 2016 10:28:23 +0000 Subject: [PATCH] re PR target/77759 (ICE in function_arg_record_value on nested empty class) 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 From-SVN: r240830 --- gcc/ChangeLog | 8 +++++++ gcc/config/sparc/sparc.c | 33 ++++++++++++++-------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/pr77759.C | 21 ++++++++++++++++++ 4 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/pr77759.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7e7a6d0f59..5fd5c7a2476 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-10-06 James Clarke + Eric Botcazou + + 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 PR tree-optimization/77839 diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index c622b6674e2..c1c196b5354 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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 (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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f24a758cf2..085884660fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-06 James Clarke + Eric Botcazou + + * g++.dg/other/pr77759.C: New test. + 2016-10-06 Richard Biener 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 index 00000000000..71bee65409a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr77759.C @@ -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); +} -- 2.30.2