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. For extern void foo (); void bar (void) { foo (); } With "gcc -S -O2 x.c", I got .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# gp is not preserved.
I think the check in pa might be able to be copied into the ia64 sources.
Subject: Bug 10907 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: rth@gcc.gnu.org 2003-07-16 23:46:45 Modified files: gcc : ChangeLog gcc/config/ia64: ia64.c Log message: PR target/10907 * config/ia64/ia64.c (ia64_epilogue_uses): GP is live at end even with !TARGET_CONST_GP. (ia64_function_ok_for_sibcall): Reject non-local functions. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.665&r2=1.16114.2.666 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.198.2.8&r2=1.198.2.9
Subject: Bug 10907 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2003-07-17 16:33:23 Modified files: gcc : ChangeLog gcc/config/ia64: ia64.c Log message: PR target/10907 * config/ia64/ia64.c (ia64_epilogue_uses): GP is live at end even with !TARGET_CONST_GP. (ia64_function_ok_for_sibcall): Reject non-local functions. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.540&r2=2.541 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&r1=1.236&r2=1.237
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01733.html
Subject: Bug 10907 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-rhl8-branch Changes by: jakub@gcc.gnu.org 2003-07-18 11:22:54 Modified files: gcc : ChangeLog Makefile.in calls.c gcc/config/ia64: ia64.c ia64.h Log message: PR target/10907 * config/ia64/ia64.c (ia64_epilogue_uses): GP is live at end even with !TARGET_CONST_GP. * config/ia64/ia64.h (FUNCTION_OK_FOR_SIBCALL): Define. * calls.c: Include target.h. * Makefile.in (calls.o): Depend on $(TARGET_H). Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.13152.2.657.2.27.2.147&r2=1.13152.2.657.2.27.2.148 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/Makefile.in.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.830.2.15.4.11&r2=1.830.2.15.4.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/calls.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.221.2.2.8.6&r2=1.221.2.2.8.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.139.2.15.8.8&r2=1.139.2.15.8.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.99.2.8.8.4&r2=1.99.2.8.8.5