OSDN Git Service

* config/sparc/sparc.c (function_arg_record_value_1): Fix
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2004 09:15:50 +0000 (09:15 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Jan 2004 09:15:50 +0000 (09:15 +0000)
computation of the number of integer registers required.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76339 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/sparc/sparc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/struct-by-value-2.c [new file with mode: 0644]

index 80af02b..5c01e68 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-22  Olivier Hainque  <hainque@act-europe.fr>
+
+       * config/sparc/sparc.c (function_arg_record_value_1): Fix
+       computation of the number of integer registers required.
+
 2004-01-21  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/i386/i386.md: Simplify certain comparisons of
index 6002a5d..d3eb998 100644 (file)
@@ -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;
 
index 433533f..9d8d1fb 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-22  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/struct-by-value-2.c: New test.
+
 2004-01-21  Andrew Pinski  <apinski@apple.com>
 
        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 (file)
index 0000000..8d5d0bb
--- /dev/null
@@ -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);
+}