This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: vax call pattern updates
- To: Michael Sokolov <msokolov at ivan dot Harhan dot ORG>
- Subject: Re: vax call pattern updates
- From: Richard Henderson <rth at redhat dot com>
- Date: Sun, 14 Jan 2001 18:40:10 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- References: <0101142127.AA01648@ivan.Harhan.ORG>
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~