On Tue, Dec 18, 2007 at 03:39:42AM -0500, Ross Ridge wrote: > >> 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. > > > > That isn't true since some .o files may not be compiled with > > -fpreferred-stack-boundary or with a different value of > > -fpreferred-stack-boundary. > > Like with any ABI changing flag, that's not supported: > > ... Further, every function must be generated such that it keeps > the stack aligned. Thus calling a function compiled with a higher > preferred stack boundary from a function compiled with a lower > preferred stack boundary will most likely misalign the stack. > > The -fpreferrred-stack-boundary flag currently generates code that > assumes the stack aligned to the preferred alignment on function entry. > If you assume a worse incoming alignment you'll be aligning the stack > unnecessarily and generating code that this flag doesn't require.
That is how we get into trouble in the first place. The only place I think of where you can guarantee everything is compiled with the same -fpreferrred-stack-boundary is kernel. Our proposal will align stack only when needed. PREFERRED_STACK_BOUNDARY > ABI_STACK_BOUNDARY will generate a largr stack unnecessarily. We have considered adding a new option, -fincoming-stack-boundary. But we need to consider local/global functions as well as function pointers. If a function can only be called locally, its incoming stack boundary will be PREFERRED_STACK_BOUNDARY. Otherwise, its incoming stack boundary will be MIN(INCOMING_STACK_BOUNDARY, INCOMING_STACK_BOUNDARY,PREFERRED_STACK_BOUNDARY). We aren't sure if its benefit will be worth its complexity. > > > On x86-64, ABI_STACK_BOUNDARY is 16byte, but the Linux kernel may > > want to use 8 byte for PREFERRED_STACK_BOUNDARY. > > Ok, if people are using this flag to change the alignment to something > smaller than used by the standard ABI, then INCOMING should be > MAX(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY). On x86-64, ABI_STACK_BOUNDARY is 16byte, but the Linux kernel may want to use 8 byte for PREFERRED_STACK_BOUNDARY. INCOMING will be MIN(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) == 8 byte. H.J.