From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernd Schmidt To: Andi Kleen Cc: law@redhat.com, gcc@gcc.gnu.org Subject: Re: forcing tail/sibling call optimization Date: Mon, 27 Nov 2000 08:38:00 -0000 Message-id: References: X-SW-Source: 2000-11/msg01179.html On 27 Nov 2000, Andi Kleen wrote: > Jeffrey A Law 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