This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: problem with call clobbered regs
Daniel Bayer wrote:
It seems that the plus-rtx in both insns is a pointer to the same
memory. I inserted a copy_rtx() in insert_restore() and insert_save()
and now it works. The patch is attached.
Yes, this is invalid rtl sharing, and we need copy_rtx calls to fix it.
Since adjust_address calls copy_rtx already, I suggest the following
patch.
--
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));