This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
CFT: Fix PR 25636
- From: Bernd Schmidt <bernds_cb1 at t-online dot de>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Date: Wed, 15 Feb 2006 00:06:26 +0100
- Subject: CFT: Fix PR 25636
This is a follow-on problem to PR 15248, which involved reload creating
writes to read-only memory locations when using equivalences made with
REG_EQUIV notes.
The problem isn't entirely fixed by the previous patch. We miscompile
gcc's opts.c; we have
(set (reg A) (mem (symbol_ref "something")))
[...]
(set (reg B) (reg A)) (REG_EQUAL (mem (symbol_ref "something")))
Both A and B get REG_EQUIV notes, but the second SET isn't marked as an
equivalencing insn, because it fails to pass a rtx_equal_p test that
compares the SET_SRC and the REG_EQUAL note. As a result, the insn
isn't deleted by reload, and gets turned into
(set (mem ...) (reg A))
which is wrong if the mem is readonly and useless otherwise.
I can't see any good reason for having that particular rtx_equal_p test.
Just marking everything that has a REG_EQUAL note as an initializing
insn should work fine, and the patch below has bootstrapped and
regtested ok on i686-linux. I wouldn't mind seeing people test it on
other machines, though. Eric, a sparc bootstrap for the previous patch
showed up some different code paths - would you mind giving this new
patch a spin? Anyone else with a spare machine is also invited to test.
Bernd
Index: local-alloc.c
===================================================================
--- local-alloc.c (revision 110366)
+++ local-alloc.c (working copy)
@@ -1,6 +1,7 @@
/* Allocate registers within a basic block, for GNU compiler.
Copyright (C) 1987, 1988, 1991, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+ Inc.
This file is part of GCC.
@@ -962,8 +963,7 @@ update_equiv_regs (void)
/* If we haven't done so, record for reload that this is an
equivalencing insn. */
- if (!reg_equiv[regno].is_arg_equivalence
- && (!MEM_P (x) || rtx_equal_p (src, x)))
+ if (!reg_equiv[regno].is_arg_equivalence)
reg_equiv_init[regno]
= gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv_init[regno]);