public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Does gcc violate the ia64 ABI?
@ 2003-05-17 18:58 John David Anglin
  2003-05-17 20:43 ` H. J. Lu
  0 siblings, 1 reply; 25+ messages in thread
From: John David Anglin @ 2003-05-17 18:58 UTC (permalink / raw)
  To: gcc, rth, schwab, hjl

> 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.

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
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.

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.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: Does gcc violate the ia64 ABI?
@ 2003-05-16 23:37 John David Anglin
  0 siblings, 0 replies; 25+ messages in thread
From: John David Anglin @ 2003-05-16 23:37 UTC (permalink / raw)
  To: gcc; +Cc: hjl

> The problem is gcc doesn't save/store gp across call. According to the
> ia64 ABI, callee can change gp and gp must be saved/restore by caller
> across calls. It is on page 5-2 in the Itanium Software Conventions
> and Runtime Architecture Guide. Am I right?
> 
> # gcc -O2 -S x.c
> 
> H.J.
> --x.c-
> extern void foo ();
>  
>  void
>  bar (void)
>  {
>    foo ();
>  }

As on the PA, I don't believe there is a need to always save and restore
gp.  gp isn't used in bar.  The caller of bar will restore gp if it
uses gp after calling bar.  If bar called foo twice, then gp should
be saved and restored across the first call to foo.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Does gcc violate the ia64 ABI?
@ 2003-05-16 21:55 H. J. Lu
  2003-05-16 22:10 ` Andreas Schwab
  0 siblings, 1 reply; 25+ messages in thread
From: H. J. Lu @ 2003-05-16 21:55 UTC (permalink / raw)
  To: gcc

I will open a bug in gcc bugzilla when conversion is done. In the
meantime, I opened

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=91056

The problem is gcc doesn't save/store gp across call. According to the
ia64 ABI, callee can change gp and gp must be saved/restore by caller
across calls. It is on page 5-2 in the Itanium Software Conventions
and Runtime Architecture Guide. Am I right?

# gcc -O2 -S x.c

H.J.
--x.c-
extern void foo ();
 
void
bar (void)
{
  foo ();
}
--x.s-
        .file   "x.c"
        .pred.safe_across_calls p1-p5,p16-p63
        .text
        .align 16
        .global bar#
        .proc bar#
bar:
        .prologue
        .body
        .bbb
        nop 0
        nop 0
        br.sptk.many foo#
        ;;
        break.f 0
        ;;
        .endp bar#
        .ident  "GCC: (GNU) 3.2.3 20030422 (Red Hat Linux 3.2.3-3)"

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2003-05-21  2:06 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-17 18:58 Does gcc violate the ia64 ABI? John David Anglin
2003-05-17 20:43 ` H. J. Lu
2003-05-17 23:27   ` John David Anglin
2003-05-17 23:45     ` H. J. Lu
2003-05-18  3:22       ` John David Anglin
2003-05-18  4:10         ` H. J. Lu
2003-05-18 23:00           ` John David Anglin
2003-05-19  3:08             ` Fergus Henderson
2003-05-19  6:18               ` Richard Henderson
2003-05-19 15:00                 ` H. J. Lu
2003-05-19 15:06                   ` Jakub Jelinek
2003-05-19 15:27                     ` H. J. Lu
2003-05-19 20:43                       ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2003-05-16 23:37 John David Anglin
2003-05-16 21:55 H. J. Lu
2003-05-16 22:10 ` Andreas Schwab
2003-05-16 22:27   ` H. J. Lu
2003-05-17  0:50     ` Richard Henderson
2003-05-17  5:52       ` H. J. Lu
2003-05-17 18:58         ` Richard Henderson
2003-05-17 22:02           ` H. J. Lu
2003-05-18  0:08             ` Richard Henderson
2003-05-18  3:10               ` H. J. Lu
2003-05-20 23:21               ` H. J. Lu
2003-05-21  3:22                 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).