back

by uecker·6d ago·view on hn ↗
It is usually assumed that it does not control the callee and the jump has to preserve the calling convention for a call.
1 comments
If it doesn't control both then TCO is impossible, because the stack will grow with each recursive step, as it's just performing a normal call.
Have your mind blown: https://godbolt.org/z/xnn3PPxvW
Extremely specific example is uncompelling.
It is a simple counterexample to your incorrect statement.
It's still impossible in the general case, where not all arguments are passable by registers.
You are right that there are cases where it is not possible. But it also works when arguments are not passed in registers. The condition then is that there are less stack slots used than in the caller.

https://godbolt.org/z/M4Eqzh3YE

It's possible for calling conventions where the callee is responsible for stack cleanup before return.