This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix structure return on SPARC64
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Jan 2004 09:51:20 +0100
- Subject: [PATCH] Fix structure return on SPARC64
Hi,
The compiler dies on a sanity check when returning the following structure:
struct S {
float f1;
int i1;
int i2;
float f2;
};
The back-end uses several functions to compute the (complex) layout of
structure on SPARC64 and one of them disagrees with the others. And it is
wrong.
The patch has been in the ACT tree for some time. It was bootstrapped and
regtested on sparc64-sun-solaris2.9 (except Ada and libgcj) yesterday, and
compat-regtested against the Sun ONE Studio 8 compiler.
Olivier requested that a third pair of eyes be present, so it would be nice
if another SPARC maintainer took a quick look. I'd like to apply it to the
3.4 branch too, because it is needed for the complete fix to another ABI
problem, PR target/13559.
2004-01-20 Olivier Hainque <hainque@act-europe.fr>
* config/sparc/sparc.c (function_arg_record_value_1): Fix computation
of the number of integer registers required. Inspired from what's done
in other function_arg_record_value cases.
2004-01-20 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/struct-ret-3.c: New test.
--
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.271
diff -u -p -r1.271 sparc.c
--- config/sparc/sparc.c 10 Dec 2003 15:25:41 -0000 1.271
+++ config/sparc/sparc.c 19 Jan 2004 12:58:46 -0000
@@ -5039,10 +5039,13 @@ function_arg_record_value_1 (tree type,
{
if (parms->intoffset != -1)
{
+ unsigned int startbit, endbit;
int intslots, this_slotno;
- intslots = (bitpos - parms->intoffset + BITS_PER_WORD - 1)
- / BITS_PER_WORD;
+ startbit = parms->intoffset & -BITS_PER_WORD;
+ endbit = (bitpos + BITS_PER_WORD - 1) & -BITS_PER_WORD;
+
+ intslots = (endbit - startbit) / BITS_PER_WORD;
this_slotno = parms->slotno + parms->intoffset
/ BITS_PER_WORD;
/* This testcase caused a sanity check to abort on SPARC64
because of a discrepancy between two functions involved
in the calculation of structure layout. */
/* { dg-do compile } */
struct S { float f1; int i1; int i2; float f2; };
struct S foo(void)
{
struct S s;
return s;
}