tail calls in const functions?

Jan Hubicka hubicka@atrey.karlin.mff.cuni.cz
Thu Mar 23 14:20: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.
OK.
I was bringing this issue mainly because I was unsure whther we want to read it
again or not.  In the example I gave the caller was storing value "1" twice to
the same position once for first function, later for the second.  I was unsure
whther we would not want to implement later pass that will eliminate the second
sture.

With const fuctions modifying their arguemnt area we will have to hack
this future pass for such special case.

Honza

> jeff


More information about the Gcc mailing list