This is the mail archive of the gcc@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]

Re: forcing tail/sibling call optimization


On 27 Nov 2000, Andi Kleen wrote:

> Jeffrey A Law <law@redhat.com> writes:
> >   > 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.
> 
> Problem I see with that is diagnostics again: e.g. someone depends on a 
> particular call being a tail call and not allocating new storage. With a 
> "tail call statement" gcc could easily give a warning or even an error
> when the compiler is not able to satisfy that requirement. With the function
> wide attribute it would be much harder to enforce it. Every call could
> possible be a tail call depending on rather complex, machine dependent rules.
> How would you generate the "not a tail call" warning without getting lots
> of false positives? With an explicit statement it is clear what to do. 

Even an explicit statement doesn't help you because even if it doesn't warn
when compiling for one machine, it might still warn on another machine, or
with a different version of the compiler.

IMHO we shouldn't encourage users to rely on gcc being able to optimize
tail calls.  It's a nice optimization, but if a program relies on it for
correctness, that program is broken.


Bernd


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