This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[SPARC] Fix corner cases with aggregates in 64-bit mode
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 6 Nov 2004 18:38:14 +0100
- Subject: [SPARC] Fix corner cases with aggregates in 64-bit mode
Hello,
These were exposed as 3 groups of ICEs by Jakub's struct-layout-1 testsuite.
The ChangeLog entry is self-explanatory I think.
Bootstrapped/regtested/compat-tested against 3.4.2 on sparc64-sun-solaris2.9
and sparc-sun-solaris2.8, applied to mainline.
2004-11-06 ?Eric Botcazou ?<ebotcazou@libertysurf.fr>
* config/sparc/sparc.c (function_arg_record_value_1): Skip
fields with zero length.
(function_arg_record_value_2): Likewise.
(function_arg_record_value_3): Use smallest_mode_for_size
instead of mode_for_size.
(function_arg_union_value): Return naked register for unions
with zero length.
--
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.340
diff -u -p -r1.340 sparc.c
--- config/sparc/sparc.c 6 Nov 2004 17:06:05 -0000 1.340
+++ config/sparc/sparc.c 6 Nov 2004 17:29:50 -0000
@@ -5262,9 +5262,14 @@ function_arg_record_value_1 (tree type,
{
HOST_WIDE_INT bitpos = startbitpos;
- if (DECL_SIZE (field) != 0
- && host_integerp (bit_position (field), 1))
- bitpos += int_bit_position (field);
+ if (DECL_SIZE (field) != 0)
+ {
+ if (integer_zerop (DECL_SIZE (field)))
+ continue;
+
+ if (host_integerp (bit_position (field), 1))
+ bitpos += int_bit_position (field);
+ }
/* ??? FIXME: else assume zero offset. */
@@ -5355,8 +5360,8 @@ function_arg_record_value_3 (HOST_WIDE_I
at the moment but may wish to revisit. */
if (intoffset % BITS_PER_WORD != 0)
- mode = mode_for_size (BITS_PER_WORD - intoffset % BITS_PER_WORD,
- MODE_INT, 0);
+ mode = smallest_mode_for_size (BITS_PER_WORD - intoffset % BITS_PER_WORD,
+ MODE_INT);
else
mode = word_mode;
@@ -5405,9 +5410,14 @@ function_arg_record_value_2 (tree type,
{
HOST_WIDE_INT bitpos = startbitpos;
- if (DECL_SIZE (field) != 0
- && host_integerp (bit_position (field), 1))
- bitpos += int_bit_position (field);
+ if (DECL_SIZE (field) != 0)
+ {
+ if (integer_zerop (DECL_SIZE (field)))
+ continue;
+
+ if (host_integerp (bit_position (field), 1))
+ bitpos += int_bit_position (field);
+ }
/* ??? FIXME: else assume zero offset. */
@@ -5588,6 +5598,10 @@ function_arg_union_value (int size, enum
int nwords = ROUND_ADVANCE (size), i;
rtx regs;
+ /* See comment in previous function for empty structures. */
+ if (nwords == 0)
+ return gen_rtx_REG (mode, regno);
+
regs = gen_rtx_PARALLEL (mode, rtvec_alloc (nwords));
for (i = 0; i < nwords; i++)