This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((aligned(16)) on x86
- To: "Ryan T. Sammartino" <ryants at home dot com>
- Subject: Re: __attribute__((aligned(16)) on x86
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 29 Jul 2001 01:56:34 -0300
- Cc: gcc at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <20010630161223.A11962@home.com><ord76mn524.fsf@guarana.lsd.ic.unicamp.br><20010728020356.A978@home.com>
On Jul 28, 2001, "Ryan T. Sammartino" <ryants@home.com> wrote:
> I'm afraid I don't see the connection between glibc and
> __attribute__((aligned())).
> When I have something on the stack that is aligned to a certain
> boundary, I expect the compiler to do something like:
> sub 8, %esp
> and -16, %esp
> add 4, %esp
> <now put variables on the stack>
AFAIK, GCC doesn't do anything like this. It *maintains* the stack
aligned to a certain ABI-specified alignment, but it doesn't introduce
additional alignment. Therefore, if the start-up code doesn't get the
stack aligned as specified in the ABI GCC is following, it will remain
unaligned throughout the execution of the application.
Doing it this way is a matter of efficiency: by only modifying the
stack pointer such that it remains aligned means you can save some
`and's and `add's.
> Aligning the stack is no good, since if I do something like:
> char c;
> vector v1;
> my vector will be misaligned by sizeof(char).
Nope; GCC knows how the stack must be aligned, and it will add padding
to stack frames to make sure the stack pointer remains aligned.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me