Stack Frame Problem

Ian Lance Taylor ian@airs.com
Thu Jan 13 15:17:00 GMT 2005


Peter Bühler <p1buehle@hsr.ch> writes:

> I'm working at a highschool in Rapperswil, Switzerland. We teach students on
> informatics and therefore there is a need we can explain why things works as
> they do. No we got a serious problem explaining, why passing parameters over
> stack is handled different on the i386 and the i686 compiled C-code. In i386
> parameters are pushed to lower adresses than the stack pointer, on i686
> parameters are moved to higher adresses than the stack pointer.

I'm sure you know this, but, to be clear, this is not an ABI change.
The parameters are still presented to the called function in the same
order.  It is just a change in how the parameters are put onto the
stack.

This behaviour can be controlled using the options
-maccumulate-outgoing-args and -mpush-args.  See the documentation.

The compiler will default to -maccumulate-outgoing-args (i.e.,
allocate space on the stack and store the parameter values by moving
them into place) on Athlon, K8, Pentium 4, Nocona, and Pentium Pro
(i686).

I believe that the advantage of -maccumulating-outgoing-args on some
CPUs is the increased ability to freely schedule instructions.  The
patch which added this can be found here:
    http://gcc.gnu.org/ml/gcc-patches/2001-06/msg00792.html
and Jan reports that it led to better results on the spec2000
performance tests.

I would not expect this change to be an improvement for a small
program.  It would only show up in functions that were sufficiently
complex for the scheduling improvements to be visible.

Hope this helps.

Ian



More information about the Gcc mailing list