public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* x86_64 argument passing fix
@ 2002-08-11  5:43 Jan Hubicka
  2002-08-14  2:46 ` Gwenole Beauchesne
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2002-08-11  5:43 UTC (permalink / raw)
  To: gcc-patches, rth

Hi,
the offset of nested structure fields is computed wrong.  I am
installing the patch to mainline and queueing for 3.2.1. It affects only
the x86_64 specific code but has been bootstrapped on i386.

Sat Aug 10 19:56:31 CEST 2002  Jan Hubicka  <jh@suse.cz>

	* i386.c (classify_argument): Fix computing of field's offsets.

*** i386.c.old	Sat Aug 10 18:58:35 2002
--- i386.c	Sat Aug 10 18:58:38 2002
*************** classify_argument (mode, type, classes, 
*** 1634,1640 ****
  		     return 0;
  		   for (i = 0; i < num; i++)
  		     {
! 		       int pos = (offset + bit_offset) / 8 / 8;
  		       classes[i + pos] =
  			 merge_classes (subclasses[i], classes[i + pos]);
  		     }
--- 1634,1640 ----
  		     return 0;
  		   for (i = 0; i < num; i++)
  		     {
! 		       int pos = (offset + (bit_offset % 64)) / 8 / 8;
  		       classes[i + pos] =
  			 merge_classes (subclasses[i], classes[i + pos]);
  		     }
*************** classify_argument (mode, type, classes, 
*** 1671,1677 ****
  		      for (i = 0; i < num; i++)
  			{
  			  int pos =
! 			    (int_bit_position (field) + bit_offset) / 8 / 8;
  			  classes[i + pos] =
  			    merge_classes (subclasses[i], classes[i + pos]);
  			}
--- 1671,1677 ----
  		      for (i = 0; i < num; i++)
  			{
  			  int pos =
! 			    (int_bit_position (field) + (bit_offset % 64)) / 8 / 8;
  			  classes[i + pos] =
  			    merge_classes (subclasses[i], classes[i + pos]);
  			}
*************** classify_argument (mode, type, classes, 
*** 1717,1723 ****
  
  		   num = classify_argument (TYPE_MODE (type),
  					    type, subclasses,
! 					    (offset + bit_offset) % 256);
  		   if (!num)
  		     return 0;
  		   for (i = 0; i < num; i++)
--- 1717,1723 ----
  
  		   num = classify_argument (TYPE_MODE (type),
  					    type, subclasses,
! 					    (offset + (bit_offset % 64)) % 256);
  		   if (!num)
  		     return 0;
  		   for (i = 0; i < num; i++)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: x86_64 argument passing fix
  2002-08-11  5:43 x86_64 argument passing fix Jan Hubicka
@ 2002-08-14  2:46 ` Gwenole Beauchesne
  0 siblings, 0 replies; 2+ messages in thread
From: Gwenole Beauchesne @ 2002-08-14  2:46 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, rth

On Sun, 11 Aug 2002, Jan Hubicka wrote:

> the offset of nested structure fields is computed wrong.  I am
> installing the patch to mainline and queueing for 3.2.1. It affects only
> the x86_64 specific code but has been bootstrapped on i386.

As a reminder, both cases of PR target/7559 are hereunder:

2002-08-10  Gwenole Beauchesne  <gbeauchesne@mandrakesoft.com>

	PR target/7559
	* testsuite/gcc.c-torture/execute/20020810-1.c: New test.

--- gcc-3.2/gcc/testsuite/gcc.c-torture/execute/20020810-1.c.x86_64-struct-args	2002-08-13 10:59:50.000000000 +0200
+++ gcc-3.2/gcc/testsuite/gcc.c-torture/execute/20020810-1.c	2002-08-13 11:03:23.000000000 +0200
@@ -0,0 +1,38 @@
+/* PR target/7559
+   This testcase was miscompiled on x86-64, because classify_argument
+   wrongly computed the offset of nested structure fields.  */
+
+extern void abort (void);
+
+struct A
+{
+  long x;
+};
+
+struct R
+{
+  struct A a, b;
+};
+
+struct R R = { 100, 200 };
+
+void f (struct R r)
+{
+  if (r.a.x != R.a.x || r.b.x != R.b.x)
+    abort ();
+}
+
+struct R g (void)
+{
+  return R;
+}
+
+int main (void)
+{
+  struct R r;
+  f(R);
+  r = g();
+  if (r.a.x != R.a.x || r.b.x != R.b.x)
+    abort ();
+  return 0;
+}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-14  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-11  5:43 x86_64 argument passing fix Jan Hubicka
2002-08-14  2:46 ` Gwenole Beauchesne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).