This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: forcing tail/sibling call optimization
- To: dewar at gnat dot com (Robert Dewar)
- Subject: Re: forcing tail/sibling call optimization
- From: Jeffrey A Law <law at redhat dot com>
- Date: Mon, 27 Nov 2000 08:58:33 -0700
- cc: fjh at cs dot mu dot oz dot au, gcc at gcc dot gnu dot org
- Reply-To: law at redhat dot com
In message <20001126161445.8878634D82@nile.gnat.com>you write:
> The formal definition seems quite reasonable here, but I must say
> I dislike the syntax, and it is unnecessarily provocative, since
> this really is not semantically a goto at all (e.g. the formal
> denmotational semantics would have nothing to do with the semantics
> of goto). Why not something like "tail return" or perhaps better
> simply a compiler directive.
>
> The real point here is that the semantics is identical to return. What
> the declaration (in whatever form it exists) is doing is to say that
> the semanjtics of execution will be undefined if there are any subsequent
> references to local variables of the caller. That's *all* that needs to
> be said semantically.
>
> In Ada, one would provide this capability by simply having a pragma
> e.g. pragma Tail_Return; which has no effect on the semantics of the
> program if it is correct.
Instead of tagging the return itself, couldn't we use an attribute which
would (in effect) tell the optimizer that any tail call in the function
is safe to optimize? Yes, we lose the ability to specify that a specific
call site is safe to optimize, but we don't have to invent yet another
GCC extension of dubious value.
jeff