Re: backend question

"Fergus Henderson" <>
1 Dec 2002 22:41:08 -0500

          From comp.compilers

Related articles
[11 earlier articles]
Re: backend question (2002-11-24)
Re: backend question (Mark) (2002-11-24)
Re: backend question (Nick Maclaren) (2002-11-24)
Re: backend question (Joachim Durchholz) (2002-11-24)
Re: backend question (Nick Maclaren) (2002-11-26)
Re: backend question (Fergus Henderson) (2002-12-01)
Re: backend question (Fergus Henderson) (2002-12-01)
Re: backend question (Nick Maclaren) (2002-12-03)
Re: backend question (2002-12-07)
Backend Question (Suman Karumuri) (2005-10-07)
Re: Backend Question (George Neuner) (2005-10-08)
| List of all articles for this month |

From: "Fergus Henderson" <>
Newsgroups: comp.compilers
Date: 1 Dec 2002 22:41:08 -0500
Organization: Computer Science, University of Melbourne
References: 02-11-063 02-11-078 02-11-099 02-11-104 02-11-129 02-11-151 02-11-160
Keywords: optimize, C
Posted-Date: 01 Dec 2002 22:41:07 EST

"Nick Maclaren" <> writes:

>"Joachim Durchholz" <> writes:
>|> felix wrote:
>|> > On the other hand several people seem to work towards providing TCO
>|> > for GCC (I just read one or two papers, though - I don't know what the
>|> > current state of affairs is).
>|> Last time I heard anything, its state was "it works but the
>|> opportunities for actually applying the optimization are quite rare". It
>|> was a long list of requirements that the C function should fulfill.
>|> The one keyword that stuck with me was setjmp/longjmp, but that was just
>|> one entry in a far-too-long-for-my-taste list of potential TCO inhibitors.
>Unless I have missed something fundamental, that restriction is only
>to the use of setjmp in a function being optimised to remove its
>return. Not a big deal. There is a much nastier one to do with never
>passing the address of a local variable to an external function.

At least with that one it is possible to work around it, by changing
the generated C code so that all such local variables are put inside a
local scope, and all tail calls are done by first using a "goto" to
jump outside that scope, and then doing the tail call. But this would
get very messy.

The worst restriction, IMHO, is that GCC's tail call optimization doesn't
work for position independant code.

However, there have been some improvements. For example, Andreas
Bauer has been doing some work on tail calls in GCC; with the support
of other GCC developers he has recently been able to put in place the
infrastructure needed to do tail call optimization for calls via
function pointers, and has implemented this for x86.
Fergus Henderson <> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <> | -- the last words of T. S. Garp.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.