Better support for tailcalls

Markus Pizka
Tue Feb 8 06:28:00 GMT 2000

David Starner wrote:

> On Thu, Feb 03, 2000 at 10:04:16PM +0000, Markus Pizka wrote:
> > Hello,
> >
> > to support the implementation of new front ends for gcc (especially
> > functional languages) I am highly
> > interested in integrating a fully general tailcall feature into gcc.
> Cool. Considering my grant proposal for adding a Scheme frontend to
> GCC, this could come in very useful.

there are a quite a lot of people feeling the same way ... but hardly any

> > I wonder, has anyone succeeded, yet or is there a partial implementation
> > that could be used as a starting point?
> fgrep -ir recursive gcc-cvs | fgrep -i tail | wc
> 10  97  766

> Look in flow.c and stmt.c.

the current support for tailcall elimination is very limited as it is
restricted to
self-recursion of non-void functions only!
(correct me if I am wrong)

> > As a first step, I think it would be sufficient if the gcc back end
> > would not automatically detect
> > tailcalls but only provide a mechanism to transform a tail call
> > specified by the front end
> Why? Personally, I was planning on doing it (if I had to) in tree,
> as that should have all the information necessary. I don't see
> what you'd gain by having each frontend try to interpret it.

agreed. As I said, this would be a first step. Automatic detection could
be added later. The reason is, that there are languages (such as C--)
which provide and explicit tail call concept. That is a tail call - let's
say a non-local goto with arguments - is specified in the program.
To implement this concept it would be helpful to be able to explicitly
a tailcall instead of a call expression which is (hopefully) optimized into
a tail call. To me, the automatic detection and application of the tail call
mechanism is an additional feature build on top of the pure mechanism.


More information about the Gcc mailing list