This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
caller-save.c patch for invalid rtl sharing
- From: Jim Wilson <wilson at specifixinc dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Daniel Bayer <daniel dot bayer at stud dot uni-rostock dot de>
- Date: Tue, 17 Feb 2004 22:57:40 -0800
- Subject: caller-save.c patch for invalid rtl sharing
- References: <20040211094913.GA12762@nolab.neusy> <402AECB9.3080206@specifixinc.com> <20040212095738.GA4935@nolab.neusy> <402C0CC7.80607@specifixinc.com> <20040213115936.GB4935@nolab.neusy> <20040217141754.GC4935@nolab.neusy>
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));