This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: tail calls in const functions?
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: tail calls in const functions?
- From: Jan Hubicka <hubicka at atrey dot karlin dot mff dot cuni dot cz>
- Date: Thu, 23 Mar 2000 23:20:03 +0100
- Cc: Jakub Jelinek <jakub at redhat dot com>, egcs at egcs dot cygnus dot com
- References: <20000323154300.D2277@atrey.karlin.mff.cuni.cz> <16624.953830896@upchuck>
>
> 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