This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [GCC 3.0] Bad regression, binary size
In article <20010709144855.B10117@redhat.com> you write:
>On Sun, Jul 08, 2001 at 02:28:04PM -0700, Linus Torvalds wrote:
>> You can fix it in three easy-ish steps (famous last words):
>
>Oh, no. You can't get away that easily.
>
>> - make a "align frame pointer prologue" (which is not that different
>> from the existing one - one extra "and")
>
>Not quite -- you have to play games to get a proper pointer
>to the argument list so that you can do your step 3.
Ehh, what's wrong with just
pushl %ebp
movl %esp,%ebp
subl $needed+16,%esp
andl $-15,%esp
which is just one instruction longer than the current regular frame
prologue, and leaves you with a aligned stack pointer AND a perfectly
good way to get to the argument frame (the frame pointer).
Sure, if people use "alloca()" or other fancy stuff (variable-sized
automatic variables etc), then you might need an extra instruction or
two to actually align the stack. How common is that? That case does need
some extra work, I agree.
>> - load all alignment-wanting arguments into pseudos in the prologue
>> after aliging the frame pointer (and let the normal spill code spill
>> them if required - now they are aligned or are cached in registers).
>
>Which might work ok for small numbers of arguments, but
>is going to be excruciating when someone passes in 30
>arguments, or worse, passes a structure by value.
Anyway, there's a simpler approach for that: when passing in values that
need alignment, we align the stack in the caller. That way you know
that your frame is always as aligned as it can be, AND the callee has
the additional knowledge that because it was passed in a FP value it
doesn't need to do the extra alignment itself.
So the only reason to ever do the above alignment stuff is
- you haven't been passed in a aligned value, but you need to spill
one, or you need to call one with one on the stack.
Statistics, anyone? I bet heavy FP code has FP arguments, which means
that the stack needs alignment very seldom indeed. Same is probably true
for XMM etc too.
Linus