Bug 10907 - [IA64] gcc violates the ia64 ABI
Summary: [IA64] gcc violates the ia64 ABI
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3
: P2 critical
Target Milestone: 3.3.1
Assignee: Richard Henderson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-05-21 16:00 UTC by H.J. Lu
Modified: 2003-07-25 23:25 UTC (History)
1 user (show)

See Also:
Host:
Target: ia64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-05-31 09:26:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2003-05-21 16:00:56 UTC
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.
Comment 1 Andrew Pinski 2003-07-05 03:14:06 UTC
I think the check in pa might be able to be copied into the ia64 sources.
Comment 2 CVS Commits 2003-07-16 23:46:54 UTC
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

Comment 3 CVS Commits 2003-07-17 16:33:31 UTC
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

Comment 4 Richard Henderson 2003-07-17 16:34:39 UTC
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01733.html