public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Installed] Patch to fix sh handling of PIC save slots
@ 2002-11-18  4:40 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2002-11-18  4:40 UTC (permalink / raw)
  To: gcc-patches

This patch fixes a bug in which the PIC register might be
saved when no slot had been allocated to it.

Tested on sh64-elf.  Approved by Alex off-list.

Richard


	* config/sh/sh.c (calc_live_regs): Update check for PIC liveness
	in compact code.

Index: config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v
retrieving revision 1.178
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.178 sh.c
*** config/sh/sh.c	4 Nov 2002 16:57:10 -0000	1.178
--- config/sh/sh.c	15 Nov 2002 13:21:43 -0000
*************** calc_live_regs (count_ptr, live_regs_mas
*** 4442,4448 ****
  	     && reg != RETURN_ADDRESS_POINTER_REGNUM
  	     && reg != T_REG && reg != GBR_REG)
  	  : (/* Only push those regs which are used and need to be saved.  */
! 	     regs_ever_live[reg] && ! call_used_regs[reg]))
  	{
  	  live_regs_mask[reg / 32] |= 1 << (reg % 32);
  	  count += GET_MODE_SIZE (REGISTER_NATURAL_MODE (reg));
--- 4433,4443 ----
  	     && reg != RETURN_ADDRESS_POINTER_REGNUM
  	     && reg != T_REG && reg != GBR_REG)
  	  : (/* Only push those regs which are used and need to be saved.  */
! 	     (TARGET_SHCOMPACT
! 	      && flag_pic
! 	      && current_function_args_info.call_cookie
! 	      && reg == PIC_OFFSET_TABLE_REGNUM)
! 	     || (regs_ever_live[reg] && ! call_used_regs[reg])))
  	{
  	  live_regs_mask[reg / 32] |= 1 << (reg % 32);
  	  count += GET_MODE_SIZE (REGISTER_NATURAL_MODE (reg));
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/gcc.c-torture/execute/20021118-1.c	Fri Nov 15 13:21:22 2002
***************
*** 0 ****
--- 1,15 ----
+ struct s { int f[4]; };
+ 
+ int foo (struct s s, int x1, int x2, int x3, int x4, int x5, int x6, int x7)
+ {
+   return s.f[3] + x7;
+ }
+ 
+ int main ()
+ {
+   struct s s = { 1, 2, 3, 4 };
+ 
+   if (foo (s, 100, 200, 300, 400, 500, 600, 700) != 704)
+     abort ();
+   exit (0);
+ }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-18 12:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18  4:40 [Installed] Patch to fix sh handling of PIC save slots Richard Sandiford

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