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]
Other format: [Raw text]

caller-save.c patch for invalid rtl sharing


I have added this patch to gcc mainline to fix an rtl sharing problem reported by Daniel Bayer on the gcc list. See the thread
http://gcc.gnu.org/ml/gcc/2004-02/msg00674.html


caller-save emits mems with shared addresses, one gets reloaded, and then the rest appear to be valid because the addresses were shared. However, the address got reloaded into a call-clobbered register, and hence the restore after the call gets garbage for the address.

This was tested with an x86-linux bootstrap and regression test, excluding Ada because I stupidly forgot to build the ada runtime. There were no regressions.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
2004-02-17  James E Wilson  <wilson@specifixinc.com>

	* caller-save.c (insert_restore): Pass mem through copy_rtx.
	(insert_save): Likewise.

Index: caller-save.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/caller-save.c,v
retrieving revision 1.62
diff -p -r1.62 caller-save.c
*** caller-save.c	4 Feb 2004 19:15:16 -0000	1.62
--- caller-save.c	17 Feb 2004 19:29:36 -0000
*************** insert_restore (struct insn_chain *chain
*** 685,690 ****
--- 685,692 ----
        && save_mode [regno] != GET_MODE (mem)
        && numregs == (unsigned int) hard_regno_nregs[regno][save_mode [regno]])
      mem = adjust_address (mem, save_mode[regno], 0);
+   else
+     mem = copy_rtx (mem);
    pat = gen_rtx_SET (VOIDmode,
  		     gen_rtx_REG (GET_MODE (mem),
  				  regno), mem);
*************** insert_save (struct insn_chain *chain, i
*** 757,762 ****
--- 759,766 ----
        && save_mode [regno] != GET_MODE (mem)
        && numregs == (unsigned int) hard_regno_nregs[regno][save_mode [regno]])
      mem = adjust_address (mem, save_mode[regno], 0);
+   else
+     mem = copy_rtx (mem);
    pat = gen_rtx_SET (VOIDmode, mem,
  		     gen_rtx_REG (GET_MODE (mem),
  				  regno));

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