public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl@lucon.org>
To: Ross Ridge <rridge@csclub.uwaterloo.ca>
Cc: gcc@gcc.gnu.org
Subject: Re: A proposal to align GCC stack
Date: Wed, 19 Dec 2007 02:07:00 -0000	[thread overview]
Message-ID: <20071219015833.GA15046@lucon.org> (raw)
In-Reply-To: <20071218233126.3EA1973D2A@caffeine.csclub.uwaterloo.ca>

On Tue, Dec 18, 2007 at 06:31:26PM -0500, Ross Ridge wrote:
> Ross Ridge wrote:
> > The -fpreferrred-stack-boundary flag currently generates code that
> > assumes the stack aligned to the preferred alignment on function entry.
> > If you assume a worse incoming alignment you'll be aligning the stack
> > unnecessarily and generating code that this flag doesn't require.
> 
> H.J. Lu writes:
> > That is how we get into trouble in the first place. The only place I
> > think of where you can guarantee everything is compiled with the same
> > -fpreferrred-stack-boundary is kernel. Our proposal will align stack
> > only when needed. PREFERRED_STACK_BOUNDARY > ABI_STACK_BOUNDARY will
> > generate a largr stack unnecessarily.
> 
> I'm currently using -fpreferred-stack-boundary without any trouble.

BTW, it is -mpreferred-stack-boundary. What value did you use for
-mpreferred-stack-boundary? The x86 backend defaults to 16byte.
The x86-64 psABI specifies 16byte stack alignment. But the ia32 psABI
only specifies 4byte stack alignment. That means that the object
files generated by gcc may be incompatible with libs or objects
compiled by other ia32 psABI confirming compilers.

> Your proposal would in fact generate code to align stack when it's not
> necessary.  This would change the behaviour of -fpreferred-stack-boundary,
> hurting performance and that's unacceptable to me.
> 
> >> Ok, if people are using this flag to change the alignment to something
> >> smaller than used by the standard ABI, then INCOMING should be
> >> MAX(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY).
> >
> > On x86-64, ABI_STACK_BOUNDARY is 16byte, but the Linux kernel may
> > want to use 8 byte for PREFERRED_STACK_BOUNDARY. INCOMING will
> > be MIN(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) == 8 byte.

A typo, I meant "INCOMING will be MIN(ABI_STACK_BOUNDARY,
PREFERRED_STACK_BOUNDARY) == 8".

> 
> Using MAX(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) also equals 8 in that
> case and preserves the behaviour -fpreferred-stack-boundary in every case.

STACK_BOUNDARY is the minimum stack boundary. MAX(STACK_BOUNDARY,
PREFERRED_STACK_BOUNDARY) == PREFERRED_STACK_BOUNDARY. So the question is
if we should assume INCOMING == PREFERRED_STACK_BOUNDARY in all cases:

Pros:
  1. Keep the current behaviour of -mpreferred-stack-boundary.

Cons:
  1. The generated code is incompatible with the other object files.

I guess we can live with that.


H.J.

  parent reply	other threads:[~2007-12-19  1:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-19  1:00 Ross Ridge
2007-12-19  1:53 ` Ye, Joey
2007-12-19  2:07 ` H.J. Lu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-12-19 11:52 Ross Ridge
2007-12-19 10:06 Ross Ridge
2007-12-19 15:32 ` H.J. Lu
2007-12-19  9:13 Ross Ridge
2007-12-19 14:30 ` H.J. Lu
2007-12-19  3:51 Ross Ridge
2007-12-19 10:33 ` Andrew Pinski
2007-12-20  9:32   ` Ye, Joey
2007-12-20  9:11 ` Ye, Joey
2008-03-20 20:18 ` Ye, Joey
2007-12-19  1:46 Ross Ridge
2007-12-18 23:31 Ross Ridge
2007-12-19  1:25 ` Robert Dewar
2007-12-19  2:18 ` H.J. Lu
2007-12-18 11:55 Ross Ridge
2007-12-18 16:14 ` H.J. Lu
2007-12-18  4:29 Ross Ridge
2007-12-18  6:15 ` H.J. Lu
2007-12-18  7:50   ` Ye, Joey
2007-12-18 13:52 ` Daniel Jacobowitz
2007-12-18 18:05   ` H.J. Lu
2007-12-18 14:41 ` Robert Dewar
2007-12-18  4:25 Ye, Joey
2007-12-21 20:25 ` Christian Schüler

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=20071219015833.GA15046@lucon.org \
    --to=hjl@lucon.org \
    --cc=gcc@gcc.gnu.org \
    --cc=rridge@csclub.uwaterloo.ca \
    /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).