public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl@lucon.org>
To: "Ye, Joey" <joey.ye@intel.com>
Cc: jh@suse.cz, ubizjak@gmail.com, gcc-patches@gcc.gnu.org
Subject: Re: PATCH: PR target/34001: Incorrect x86 fastcall behavior
Date: Fri, 16 Nov 2007 16:27:00 -0000	[thread overview]
Message-ID: <20071116135304.GA2801@lucon.org> (raw)
In-Reply-To: <20071116045102.GA26981@lucon.org>

On Thu, Nov 15, 2007 at 08:51:02PM -0800, H.J. Lu wrote:
> On Fri, Nov 16, 2007 at 12:35:47PM +0800, Ye, Joey wrote:
> > HJ,
> > 
> > You patch has a minor problem that fastcall will pass non-scalar integer parameter in EAX/ECX/EDX, which is still imcompatible to MS fastcall. MSVC pass parameter on stack unless it is scalar integer less equal to 32 bits.
> > 
> > With this patch GCC fastcall passes first parameter in EAX when it is not a scalar integer less equal to 32 bits. Check following example and review the patch fixing it:
> > 
> > Here is a patch to fix it:
> > Index: gcc/config/i386/i386.c
> > ===================================================================
> > --- gcc/config/i386/i386.c      (revision 129880)
> > +++ gcc/config/i386/i386.c      (working copy)
> > @@ -4229,9 +4229,12 @@
> >           int regno = cum->regno;
> > 
> >           /* Fastcall allocates the first two DWORD (SImode) or
> > -            smaller arguments to ECX and EDX.  */
> > +            smaller arguments to ECX and EDX if it isn't an
> > +            aggregate type .  */
> >           if (cum->fastcall)
> >             {
> > +             if (type && AGGREGATE_TYPE_P (type))
> > +               break;
> >               if (mode == BLKmode || mode == DImode)
> >                 break;
> >   
> 
> Yes, this version is correct. Thanks.
> 
> 

Here is an equivalent patch.


H.J.
----
2007-11-15  H.J. Lu  <hongjiu.lu@intel.com>
	    Joey Ye <joey.ye@intel.com>

	PR target/34001
	* config/i386/i386.c (function_arg_32): Don't pass aggregate
	arguments in ECX/EDX for fastcall.

--- gcc/config/i386/i386.c.fastcall	2007-11-16 05:41:46.000000000 -0800
+++ gcc/config/i386/i386.c	2007-11-16 05:46:43.000000000 -0800
@@ -4257,10 +4257,12 @@ function_arg_32 (CUMULATIVE_ARGS *cum, e
 	  int regno = cum->regno;
 
 	  /* Fastcall allocates the first two DWORD (SImode) or
-	     smaller arguments to ECX and EDX.  */
+            smaller arguments to ECX and EDX if it isn't an
+            aggregate type .  */
 	  if (cum->fastcall)
 	    {
-	      if (mode == BLKmode || mode == DImode)
+	      if (mode == BLKmode || mode == DImode
+		  || (type && AGGREGATE_TYPE_P (type)))
 	        break;
 
 	      /* ECX not EAX is the first allocated register.  */

  reply	other threads:[~2007-11-16 13:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-09 17:32 H.J. Lu
2007-11-09 18:23 ` Richard Guenther
2007-11-09 21:57   ` H.J. Lu
2007-11-18 13:14     ` Gerald Pfeifer
2007-11-18 15:04       ` H.J. Lu
2007-11-18 15:53         ` Gerald Pfeifer
2007-11-12  1:18   ` Mark Mitchell
2007-11-12  8:00     ` H.J. Lu
2007-11-13 10:56       ` Mark Mitchell
2007-11-13 16:19         ` H.J. Lu
2007-11-13 17:09           ` Mark Mitchell
2007-11-13 20:20             ` H.J. Lu
2007-11-27  7:45               ` H.J. Lu
2007-11-27  9:32                 ` Uros Bizjak
2007-11-28  0:45                   ` Jan Hubicka
2007-11-28 10:38                     ` H.J. Lu
2007-11-16 11:01 ` Ye, Joey
2007-11-16 11:07   ` H.J. Lu
2007-11-16 16:27     ` H.J. Lu [this message]
2007-11-13 14:14 Ross Ridge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071116135304.GA2801@lucon.org \
    --to=hjl@lucon.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jh@suse.cz \
    --cc=joey.ye@intel.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).