From b2f24c85c8b21cd649d11da2eb8c65079d3f21b7 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 22 Jan 2004 09:15:50 +0000 Subject: [PATCH] sparc.c (function_arg_record_value_1): Fix computation of the number of integer registers required. * config/sparc/sparc.c (function_arg_record_value_1): Fix computation of the number of integer registers required. From-SVN: r76339 --- gcc/ChangeLog | 5 +++++ gcc/config/sparc/sparc.c | 7 +++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/struct-by-value-2.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/struct-by-value-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80af02b0ee4..5c01e68bda4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-01-22 Olivier Hainque + + * config/sparc/sparc.c (function_arg_record_value_1): Fix + computation of the number of integer registers required. + 2004-01-21 Kazu Hirata * config/i386/i386.md: Simplify certain comparisons of diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 6002a5d7300..d3eb9986ed5 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -5039,10 +5039,13 @@ function_arg_record_value_1 (tree type, HOST_WIDE_INT startbitpos, { 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 433533fa825..9d8d1fb01bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-01-22 Eric Botcazou + + * gcc.dg/struct-by-value-2.c: New test. + 2004-01-21 Andrew Pinski PR target/13785 diff --git a/gcc/testsuite/gcc.dg/struct-by-value-2.c b/gcc/testsuite/gcc.dg/struct-by-value-2.c new file mode 100644 index 00000000000..8d5d0bb01c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/struct-by-value-2.c @@ -0,0 +1,15 @@ +/* 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; }; + +extern void foo(struct S); + +void bar(void) +{ + struct S s; + foo(s); +} -- 2.30.2