This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does gcc violate the ia64 ABI?


On Mon, May 19, 2003 at 08:10:23AM -0700, H. J. Lu wrote:
> On Mon, May 19, 2003 at 05:02:00PM +0200, Jakub Jelinek wrote:
> > On Mon, May 19, 2003 at 07:55:40AM -0700, H. J. Lu wrote:
> > > > Only tail calls to provably local functions, apparently.
> > > > I think that's pretty stupid, considering how cheap it is
> > > > to reload the gp...
> > > 
> > > I disagree. Gcc can still do tail calls to external functions as long
> > > as it reloads gp, which gcc is already doing when gp is used after
> > > the call, like in this code
> > > 
> > > ---
> > > extern void bar ();
> > > 
> > > static void
> > > bar1 ()
> > > {
> > >   bar ();
> > > }
> > > 
> > > extern int x;
> > > 
> > > void
> > > foo ()
> > > {
> > >   bar1 ();
> > >   x += 1;
> > > }
> > > ---
> > > 
> > > I think we just need to change the code from
> > > 
> > > 	reload_gp = gp is used after the tail call
> > > 
> > > to
> > > 
> > > 	reload_gp = the tail call is external
> > > 
> > > It may be a win since we won't reload gp for the local call even if
> > > gp is used after the tail call. Besides, you have said reloading gp
> > > is cheap. I don't see fixing gcc will hurt performance.
> > 
> > If bar1 has to reload gp after bar returns, then certainly the call to bar
> > cannot be a tail call (as a tail call returns from bar stright to foo).
> 
> You reload gp when you do tail call expansion in foo, not in bar1.
> But bar1 has to reload gp if it isn't expanded. I don't know if gcc
> has the infrastructure to support that.

You're not making any sense at all.

Either the GP has to be valid for the target after the call
or it doesn't.  If bar1 tail-calls to bar, then the GP isn't
valid for bar1.

Unless you're going to claim that there's a different ABI for
functions called indirectly.  (Though bar1 can't be called by
name from a different TU, it can be called via function pointer.)

And, no matter what, you couldn't tail-call to an external 
routine from a non-static function.



r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]