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]
Other format: [Raw text]

Re: [tree-ssa] Tail recursion optimisation


On Thu, Oct 16, 2003 at 10:10:43PM -0400, Jason Merrill wrote:
> It seems to me that recursion is the only case which can be interestingly
> handled at the tree level.  Other tail calls just involve popping the
> current frame before the call (right?), which we don't represent at the
> tree level.  Or is there something else you had in mind?

We want to do the analysis to know that the tail call optimization
is possible.  This includes both CFG analysis (same difficulty),
return value tracking (easier), and dataflow analysis of escaping
addresses of local variables (not done at all at present).

We'd set a bit in the call_expr to let rtl expander know that the
tail call is possible.  We'd also allow the front-end to set this
bit, which allows functional languages to tell us that we don't
have to solve data flow problems.

The conversion to tail call might still fail based on argument
layout overlap issues.  This is something we don't have information
about at the tree level.  Only expand_call has that remarkably
complex logic.

At the rtl level we'd get to drop call_placeholder, and not have
to expand the call and its arguments twice and all the problems
that that entails.


r~


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