public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH: PR target/34001: Incorrect x86 fastcall behavior
@ 2007-11-09 17:32 H.J. Lu
  2007-11-09 18:23 ` Richard Guenther
  2007-11-16 11:01 ` Ye, Joey
  0 siblings, 2 replies; 20+ messages in thread
From: H.J. Lu @ 2007-11-09 17:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: jh, ubizjak

From

http://msdn2.microsoft.com/en-us/library/6xa169sk(VS.80).aspx

"The first two DWORD or smaller arguments are passed in ECX and EDX
registers; all other arguments are passed right to left."

But it isn't clear if it applies to structure/union. We tested all MS
compilers we have and verified that the above doesn't apply to
structure/union.  To make fastcall compatible with MS compilers, we
should only put scalar arguments in ECX and EDX.



H.J.
---
2007-11-09  H.J. Lu  <hongjiu.lu@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-06 19:52:12.000000000 -0800
+++ gcc/config/i386/i386.c	2007-11-08 11:48:38.000000000 -0800
@@ -4233,8 +4233,10 @@ 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.  */
-	  if (cum->fastcall)
+	     smaller arguments to ECX and EDX if it isn't an
+	     aggregate type .  */
+	  if (cum->fastcall
+	      && (!type || !AGGREGATE_TYPE_P (type)))
 	    {
 	      if (mode == BLKmode || mode == DImode)
 	        break;

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: PATCH: PR target/34001: Incorrect x86 fastcall behavior
@ 2007-11-13 14:14 Ross Ridge
  0 siblings, 0 replies; 20+ messages in thread
From: Ross Ridge @ 2007-11-13 14:14 UTC (permalink / raw)
  To: gcc-patches

Mark Mitchell writes:
> Why?  I don't have a strong opinion, and, in any case, this issue is
> something for the x86 maintainers to determine.  But what's the virtue
> in changing the GCC ABI for GNU/Linux (or any other non-Windows OS)
> applications?  Especially in a way that makes it use a less efficient
> calling sequence?

I can only see two reasons why fastcall would've been used on non-Windows
OS.  One is for compatibility with assembler or object code that was
originally written for Windows.  The other is in code that should've
used the more efficient regparam(3) attribute.  Changing the behavior
of fastcall to be compatible with Microsoft's compiler shouldn't cause
problems in the first case.  In the second case I think code that would
break would be very rare, probably non-existant.  Code like this would
have to use the fastcall attribute in a function that both takes a small
aggregate by value and could be called from a function compiled with a
different version of GCC.

						Ross Ridge

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

end of thread, other threads:[~2007-11-28  1:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-09 17:32 PATCH: PR target/34001: Incorrect x86 fastcall behavior 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
2007-11-13 14:14 Ross Ridge

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).