This is the mail archive of the gcc-patches@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]

SH PIC prologue/epilogue fixes


The first part of this patch fixes gcc.dg/noncompile/930714-1.c with
`-fPIC -m4 -O[1-3]'.  I don't have a testcase that would trigger the
latent bug fixed by the second part of the patch, but it was blatantly
wrong.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/sh/sh.c (sh_expand_prologue): Mark GOTaddr2picreg as
	MAYBE_DEAD.
	(sh_expand_epilogue): Take d the PIC register into account when
	computing the frame size.

Index: gcc/config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.62
diff -u -p -r1.62 sh.c
--- gcc/config/sh/sh.c 2000/09/07 22:24:33 1.62
+++ gcc/config/sh/sh.c 2000/09/16 12:25:24
@@ -3950,7 +3950,17 @@ sh_expand_prologue ()
 
   if (flag_pic && (current_function_uses_pic_offset_table
 		   || regs_ever_live[PIC_OFFSET_TABLE_REGNUM]))
-    emit_insn (gen_GOTaddr2picreg ());
+    {
+      rtx insn = get_last_insn ();
+      rtx insn_end = emit_insn (gen_GOTaddr2picreg ());
+      while (insn != insn_end)
+	{
+	  insn = NEXT_INSN (insn);
+	  REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD,
+						const0_rtx,
+						REG_NOTES (insn));
+	}
+    }
 
   if (target_flags != save_flags)
     emit_insn (gen_toggle_sz ());
@@ -3976,6 +3986,14 @@ sh_expand_epilogue ()
 
   live_regs_mask = calc_live_regs (&d, &live_regs_mask2);
 
+  if (flag_pic && current_function_uses_pic_offset_table)
+    {
+      if ((live_regs_mask & (1 << PIC_OFFSET_TABLE_REGNUM)) != 0)
+	abort ();
+      live_regs_mask |= (1 << PIC_OFFSET_TABLE_REGNUM);
+      d += UNITS_PER_WORD;
+    }
+
   frame_size = rounded_frame_size (d);
 
   if (frame_pointer_needed)
@@ -4003,8 +4021,6 @@ sh_expand_epilogue ()
 
   if (target_flags != save_flags)
     emit_insn (gen_toggle_sz ());
-  if (flag_pic && current_function_uses_pic_offset_table)
-    live_regs_mask |= (1 << PIC_OFFSET_TABLE_REGNUM);
   if (live_regs_mask & (1 << PR_REG))
     pop (PR_REG);
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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