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 12:09:58AM +0200, Andreas Schwab wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> |> 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?
> 
> I don't see where's the problem.  If a function does not use a
> call-clobbered register there is no need for saving/restoring it.  It's
> the duty of the caller to do it.

gp is a special register in the ia64 ABI:

On page 5-2 in Itanium Software Conventions and Runtime Architecture
Guide, there are

...
a. On entry to a procedure, gp is guaranteed valide for that procedure.
b. At any direct procedure call, gp must be valid (for the caller). This
guarantees that an import stub (see Section 8.4.1) can access the linkage
table.
c. Any procedure call (indirect or direct) may modify gp - unless the call
is known to be local to the load module.
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').

The effect of the rules is that gp must be treated as scratch register
at the point of call (i.e., it must be saved by the caller), and it must
be preserved from entry to exit.

Since bar () may modify gp, at the return of foo, gp must be valid for foo
even if foo doesn't use gp at all. Did I miss something here?


H.J.


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