tail calls in const functions?
Jeffrey A Law
law@cygnus.com
Thu Mar 23 09:09:00 GMT 2000
In message < 20000323154300.D2277@atrey.karlin.mff.cuni.cz >you write:
> > On Thu, Mar 23, 2000 at 03:24:31PM +0100, Jan Hubicka wrote:
> > > Hi
> > > The tail call optimization makes function to modify the stack, that
> > > belongs to the caller. Is this valid for const function?
I would think so -- it's only going to diddle in the parameter area.
One way to think about a const function is does it read/write *state* that
is needed across invocations of the function or which are significant for
the behavior of other code in the program.
In this case we're modifying stack slots that will not be read again anyway;
think of those slots as pass-by-value parameters. We can stomp on the contents
of those slots all we want since we know their value will never be used again.
jeff
More information about the Gcc
mailing list