This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
sub-optimal stack alignment with __builtin_alloca()
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gbenson at redhat dot com
- Cc: gcc at gcc dot gnu dot org, geoffk at apple dot com
- Date: Fri, 21 Dec 2007 15:16:17 -0200
- Subject: sub-optimal stack alignment with __builtin_alloca()
WRT http://gbenson.livejournal.com/2007/12/21/
I see where the problem is. GCC is being overzealous because of a
default that was local to one file was made global on 2003-10-07, and
this changed the behavior of the #if statement in explow.c's
allocate_dynamic_stack_space():
#if defined (STACK_DYNAMIC_OFFSET) || defined (STACK_POINTER_OFFSET)
#define MUST_ALIGN 1
#else
#define MUST_ALIGN (PREFERRED_STACK_BOUNDARY < BIGGEST_ALIGNMENT)
#endif
Unfortunately, STACK_POINTER_OFFSET isn't a preprocessor constant on
all ports. We could change the above to:
#if defined (STACK_DYNAMIC_OFFSET)
#define MUST_ALIGN 1
#else
#define MUST_ALIGN (STACK_POINTER_OFFSET || PREFERRED_STACK_BOUNDARY < BIGGEST_ALIGNMENT)
#endif
but on at least one port (pa), STACK_POINTER_OFFSET depends on the
size of the outgoing arguments of a function, which we don't
necessarily know yet at the point we expand alloca builtins. For pa,
it's never zero, but for other ports it might be, and then this would
break.
Thoughts, anyone?
BTW, function.c still provides a no-longer-necessary default for
STACK_POINTER_OFFSET.
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}