On Tue, Dec 18, 2007 at 06:31:26PM -0500, Ross Ridge wrote: > Ross Ridge wrote: > > 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. > > H.J. Lu writes: > > 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. > > I'm currently using -fpreferred-stack-boundary without any trouble.
BTW, it is -mpreferred-stack-boundary. What value did you use for -mpreferred-stack-boundary? The x86 backend defaults to 16byte. The x86-64 psABI specifies 16byte stack alignment. But the ia32 psABI only specifies 4byte stack alignment. That means that the object files generated by gcc may be incompatible with libs or objects compiled by other ia32 psABI confirming compilers. > Your proposal would in fact generate code to align stack when it's not > necessary. This would change the behaviour of -fpreferred-stack-boundary, > hurting performance and that's unacceptable to me. > > >> 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. A typo, I meant "INCOMING will be MIN(ABI_STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) == 8". > > Using MAX(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) also equals 8 in that > case and preserves the behaviour -fpreferred-stack-boundary in every case. STACK_BOUNDARY is the minimum stack boundary. MAX(STACK_BOUNDARY, PREFERRED_STACK_BOUNDARY) == PREFERRED_STACK_BOUNDARY. So the question is if we should assume INCOMING == PREFERRED_STACK_BOUNDARY in all cases: Pros: 1. Keep the current behaviour of -mpreferred-stack-boundary. Cons: 1. The generated code is incompatible with the other object files. I guess we can live with that. H.J.