This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: vax call pattern updates


On Sun, Jan 14, 2001 at 01:28:58PM -0800, Michael Sokolov wrote:
> But is this actually enforced, or is there any chance that under different
> optimisation levels or whatnot the middle end could pick call because
> it's more efficient?

No, this is enforced.  RETURN_POPS_ARGS is an assertion that
the function that we are calling *will* pop the stack.

The fact that this must be is clearer with the i386 "stdcall" calling
convention used on windows.  In that case the function that we are
calling ends in a "ret $N" instruction that pops N bytes while returning
to the caller.  This number is hard-coded into the callee, and there
is no way the call can affect whether or how much will be popped.

> func1(expr1, expr2);
> func2(expr1, expr2);
> 
> If the optimiser knows that func1 can't change expr1 or expr2, it could push
> the arguments once, call func1 without popping the stack, and then call func2
> with the same arguments. I believe GCC does this optimisation on other
> architectures (please correct me if I'm wrong).

GCC never does this optimization.  Those stack slots are considered
call clobbered.  Even by "constant" functions, which may reuse those
stack slots for register spills.


r~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]