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 Sat, May 17, 2003 at 02:58:29PM -0400, John David Anglin wrote:
> > On Fri, May 16, 2003 at 05:43:18PM -0700, Richard Henderson wrote:
> > > On Fri, May 16, 2003 at 03:25:08PM -0700, H. J. Lu wrote:
> > > > d. At procedure return, gp must be valid (for the returning prodecure).
> > > > This allows the compiler to optimize calls known to be local (i.e., the
> > > > exceptions to Rule 'c').
> > > 
> > > I was not aware of this clause.  I'd have sworn it wasn't a part
> > > of the ABI at one time...
> > > 
> > > Indeed, if this clause is truely correct, then virtually all of
> > > the tail-call possibilities on ia64 are invalid.  Yes, statics
> > > still can be done, but that's not nearly as frequent.
> > 
> > Gcc can skip gp save/restore across a local call. Right now, gcc
> > saves and restores gp across a local call.
> 
> Your example shows a tail-call to foo.  Gp is obviously valid at the call.
> There is no return in your example, so 'd' doesn't apply.
> 

What did you by "no return"? Where does it go?

> Note that skipping the gp save/restore across a local call is a "compiler"
> optimization.  If you save and restore gp across local calls, then
> it's likely possible to skip the save and restore across the last call in
> a function if gp is not used after the last call, including the return
> path to the caller.  I don't have a good feeling as to which of these

You don't have to save and restore gp as long as you can prove gp is
not changed. It has nothing to do if gp is used or not, according to
the ia64 psABI.

> two optimizations is more beneficial.  I would judge that the latter
> treatment would be in slight violation of the ia64 ABI, but the violation
> would be local to a translation unit.

A violation is a violation. There is no slight violation.

> 
> We currently do the latter optimization on the pa but I am wondering
> if it would be better to skip the gp save/restore across local calls
> instead.
 

 That is safe according to the ia64 psABI.


 H.J.


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