public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: rridge@csclub.uwaterloo.ca (Ross Ridge)
To: gcc@gcc.gnu.org
Subject: Re: A proposal to align GCC stack
Date: Tue, 18 Dec 2007 04:29:00 -0000	[thread overview]
Message-ID: <20071218042535.3FB1F73CC4@caffeine.csclub.uwaterloo.ca> (raw)

Ye, Joey writes:
>i. STACK_BOUNDARY in bits, which is enforced by hardware, 32 for i386
>and 64 for x86_64. It is the minimum stack boundary. It is fixed.

Strictly speaking by the above definition it would be 8 for i386.
The hardware doesn't force the stack to be 32-bit aligned, it just
performs poorly if it isn't.

>v. INCOMING_STACK_BOUNDARY in bits, which is the stack boundary
>at function entry. If a function is marked with __attribute__
>((force_align_arg_pointer)) or -mstackrealign option is provided,
>INCOMING = STACK_BOUNDARY.  Otherwise, INCOMING == MIN(ABI_STACK_BOUNDARY,
>PREFERRED_STACK_BOUNDARY) because a function can be called via psABI
>externally or called locally with PREFERRED_STACK_BOUNDARY.

This section doesn't make sense to me.  The force_align_arg_pointer
attribute and -mstackrealign assume that the ABI is being
followed, while the -fpreferred-stack-boundary option effectively
changes the ABI.  According your defintions, I would think
that INCOMING should be ABI_STACK_BOUNDARY in the first case,
and MAX(ABI_STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) in the second.
(Or just PREFERRED_STACK_BOUNDARY because a boundary less than the ABI's
should be rejected during command line processing.)

>vi. REQUIRED_STACK_ALIGNMENT in bits, which is stack alignment required
>by local variables and calling other function. REQUIRED_STACK_ALIGNMENT
>== MAX(LOCAL_STACK_BOUNDARY,PREFERRED_STACK_BOUNDARY) in case of a
>non-leaf function. For a leaf function, REQUIRED_STACK_ALIGNMENT ==
>LOCAL_STACK_BOUNDARY.

Hmm... I think you should define STACK_BOUNDARY as the minimum
alignment that ABI requires the stack pointer to keep at all times.
ABI_STACK_BOUNDARY should be defined as the stack alignment the
ABI requires at function entry.  In that case a leaf function's
REQUIRED_STACK_ALIGMENT should be MAX(LOCAL_STACK_BOUNDARY,
STACK_BOUNDARY).

>Because I386 PIC requires BX as GOT pointer and I386 may use AX, DX
>and CX as parameter passing registers, there are limited candidates for
>this proposal to choose. Current proposal suggests EDI, because it won't
>conflict with i386 PIC or regparm.

Could you pick a call-clobbered register in cases where one is availale?

>//  Reserve two stack slots and save return address 
>//  and previous frame pointer into them. By
>//  pointing new ebp to them, we build a pseudo 
>//  stack for unwinding

Hmmm... I don't know much about the DWARF unwind information, but
couldn't it handle this case without creating the "pseudo frame"?
Or at least be extended so it could?

					Ross Ridge

             reply	other threads:[~2007-12-18  4:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-18  4:29 Ross Ridge [this message]
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
  -- 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-19  1:00 Ross Ridge
2007-12-19  1:53 ` Ye, Joey
2007-12-19  2:07 ` H.J. Lu
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: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=20071218042535.3FB1F73CC4@caffeine.csclub.uwaterloo.ca \
    --to=rridge@csclub.uwaterloo.ca \
    --cc=gcc@gcc.gnu.org \
    /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).