> > Yes maybe the checks could be all moved, but that's a much larger 
> > project.
> 
> Hmm.  I count six tests in about 25 lines of code in 
> tree-tailcall.cc:suitable_for_tail_opt_p and suitable_for_tail_call_opt_p.
There are more checks in find_tail_calls. The logic is fairly spread
out. Some of it is needed to determine if it is valid.

> 
> Are you perhaps worrying about the sibcall discovery itself (i.e. much of 
> find_tail_calls)? Why would that be needed for musttail?  Is that 
> attribute sometimes applied to calls that aren't in fact sibcall-able?

The rules the compilers use for this are hard to understand for
programmers.  So that's the whole point of the attribute. If they miss some 
subtle 
requirement they get a compile time error instead of a stack overflow at
runtime.

So yes it has to do all the checks.

> 
> One thing I'm worried about is the need for a new sibcall pass at O0 just 
> for sibcall discovery.  find_tail_calls isn't cheap, because it computes 
> live local variables for the whole function, potentially being quadratic.

The live local variables computation is only done when there are actual
suitable tail calls. And the new -O0 variant only does it for musttail, nothing
else. So by default it is just a BB backwards walk until it sees a BB with 
enough edges to give up.


-Andi

Reply via email to