proper tail recursion for gcc

Richard Henderson rth@cygnus.com
Thu Jul 20 12:12:00 GMT 2000


On Thu, Jul 20, 2000 at 11:21:51AM +0000, Mark Probst wrote:
> i was referring to exactly this optimization. at least on the alpha,
> for example, only calls to static functions are optimized, which is
> not very helpful if you need separate compilation.

This is required by the calling conventions.

Given foo calls bar calls baz, if baz function is in a different file
than bar, it might use a different $gp value.  If baz uses a different
$gp value, then the $gp value on return to foo will be incorrect and
foo may crash.

There is no way around this, except foreknowledge that bar and baz
use the same $gp value.  And that may only be guaranteed by putting
the functions in the same translation unit.



r~


More information about the Gcc mailing list