This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about -mpreferred-stack-boundary
- To: "Andreas Jaeger" <aj at suse dot de>,"gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Subject: Re: Question about -mpreferred-stack-boundary
- From: "Geert Bosch" <bosch at gnat dot com>
- Date: Sat, 03 Feb 2001 08:39:46 -0500
- Cc: "Jens Wallner" <wallner at ims dot uni-hannover dot de>
- Reply-To: "Geert Bosch" <bosch at gnat dot com>
On 03 Feb 2001 11:37:35 +0100, Andreas Jaeger wrote:
Who has to align the stack for calls to a function - the caller or the
callee? In other words: Does this mean that the stack has to be
aligned before calling a function? Or does it have to be aligned when
entering a function?
From the description you quote it seems that the stack will stay
properly aligned if it was aligned to start with. This is done by
ensuring that when function A calls B, the stack-pointer will
be a multiple of the alignment lower than it was when A was called.
What I would think we'd need in addition is the ability to align
a particular stack-frame more than the alignment we assume for
the stack (by default 4 bytes on x86). This way, one could use
types with stricter alignment-requirements than the stack.
In Ada for example, we have to disallow any attempt to specify an
alignment greater than 4 bytes, as we cannot *guarantee* that all
objects will be properly aligned. It would be great if GCC could
recognize that a certain stack-frame contains variables with a stricter
alignment than the stack-alignment and aligns its stack frame.
Of course, this does not help at all for variables passed by value,
which is what one can never guarantee on i386 because of the ABI.
To solve this problem one would always pass objects with, for example,
a 16-byte alignment requirement by reference. Especially with upcoming
support for SSE instructions I think that enabling higher alignments
would be a good thing.
-Geert