sub-optimal stack alignment with __builtin_alloca()

Alexandre Oliva aoliva@redhat.com
Fri Dec 21 17:31:00 GMT 2007


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}



More information about the Gcc mailing list