The Gambit Scheme->C compiler has an option to generate more efficient code if it knows that all tail and sibling calls in the generated C code will be optimized. If gcc does not, however, optimize a tail or sibling call, the generated C code may be incorrect (depending on circumstances).

So I would like to add a warning enabled by -Wdisabled-optimization so that if -foptimize-sibling-calls is given and a tail or sibling call is not optimized, then a warning is triggered.

I don't quite know where to place the warning. It would be good if there were one piece of code to identify all tail and sibling calls, and then another piece that decides whether the optimization can be performed.

I see code in gcc/tree-tailcall.cc

suitable_for_tail_opt_p
suitable_for_tail_call_opt_p

which are called by

tree_optimize_tail_calls_1

which takes an argument

opt_tailcalls

and it's called in one place with opt_tailcalls true and in another place with opt_tailcalls false.

So I'm losing the plot here.

There is other code dealing with tail calls in gcc/calls.cc I don't seem to understand at all.

Any advice?

Brad

Reply via email to