This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Installed] Patch to fix sh handling of PIC save slots
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 18 Nov 2002 12:40:05 +0000
- Subject: [Installed] Patch to fix sh handling of PIC save slots
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);
+ }