This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Fix PR rtl-optimization/33732
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>, Paolo Bonzini <bonzini at gnu dot org>, Seongbae Park <seongbae dot park at gmail dot com>, Kenneth Zadeck <zadeck at naturalbridge dot com>, John David Anglin <dave dot anglin at nrc dot ca>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Nov 2007 23:16:11 +0100
- Subject: Re: [RFC] Fix PR rtl-optimization/33732
- References: <200711051115.45052.ebotcazou@libertysurf.fr> <20071106131915.GD17368@sygehus.dk> <20071107203532.GG17368@sygehus.dk>
On Wed, Nov 07, 2007 at 09:35:32PM +0100, Rask Ingemann Lambertsen wrote:
> This happens because in df-scan.c at line 2676 (df_ref_record()) we have
>
> for (i = regno; i < endregno; i++)
> {
> ref = df_ref_create_structure (collection_rec, regno_reg_rtx[i], loc,
> bb, insn, ref_type, ref_flags);
>
> with regno = 22 and endregno = 23 with loc pointing to the
> (subreg:SI (reg:DI 21) 4) expression. df_ref_create_structure() will then set
> DF_REF_REG(ref) to regno_reg_rtx[22] and point DF_REF_LOC(ref) to the
> (subreg:SI (reg:DI 21) 4) expression. This goes wrong in df-problems.c at line 2832
> (df_note_bb_compute()), where we have
>
> rtx reg = (DF_REF_LOC (use))
> ? *DF_REF_REAL_LOC (use) : DF_REF_REG (use);
> old_dead_notes = df_set_note (REG_DEAD, insn, old_dead_notes, reg);
>
> #ifdef REG_DEAD_DEBUGGING
> df_print_note ("adding 4: ", insn, REG_NOTES (insn));
>
> and so dig into the subreg expression and find and use (reg:DI 21) instead
> of (reg:SI 22) for the REG_DEAD note.
>
> I can see a few ways to fix this:
>
> 1) Pass NULL for LOC to df_ref_create_structure().
> 2) Pass ®no_reg_rtx[i] for LOC to df_ref_create_structure().
> 3) Don't use DF_REF_REAL_LOC(use) if it looks like a bad idea.
>
> Comments? I tried option 3) and it seems to work:
I suppose df_create_unused_note() is also affected?
FWIW, I'm going to test this patch, but I can't any PA-RISC testing.
Index: /home/rask/cvssrc/owcc-gcc/gcc/df-problems.c
===================================================================
--- /home/rask/cvssrc/owcc-gcc/gcc/df-problems.c (revision 129849)
+++ /home/rask/cvssrc/owcc-gcc/gcc/df-problems.c (working copy)
@@ -2636,7 +2636,10 @@ df_create_unused_note (rtx insn, rtx old
|| bitmap_bit_p (artificial_uses, dregno)
|| df_ignore_stack_reg (dregno)))
{
- rtx reg = (DF_REF_LOC (def))
+ rtx reg = (DF_REF_LOC (def)
+ && (GET_MODE (*DF_REF_REAL_LOC (def))
+ == GET_MODE (DF_REF_REG (def))
+ || !HARD_REGISTER_P (*DF_REF_REAL_LOC (def))))
? *DF_REF_REAL_LOC (def): DF_REF_REG (def);
old = df_set_note (REG_UNUSED, insn, old, reg);
#ifdef REG_DEAD_DEBUGGING
@@ -2829,7 +2832,10 @@ df_note_bb_compute (unsigned int bb_inde
&& (!(DF_REF_FLAGS (use) & DF_REF_READ_WRITE))
&& (!df_ignore_stack_reg (uregno)))
{
- rtx reg = (DF_REF_LOC (use))
+ rtx reg = (DF_REF_LOC (use)
+ && (GET_MODE (*DF_REF_REAL_LOC (use))
+ == GET_MODE (DF_REF_REG (use))
+ || !HARD_REGISTER_P (*DF_REF_REAL_LOC (use))))
? *DF_REF_REAL_LOC (use) : DF_REF_REG (use);
old_dead_notes = df_set_note (REG_DEAD, insn, old_dead_notes, reg);
Index: /home/rask/cvssrc/owcc-gcc/gcc/reload1.c
===================================================================
--- /home/rask/cvssrc/owcc-gcc/gcc/reload1.c (revision 129849)
+++ /home/rask/cvssrc/owcc-gcc/gcc/reload1.c (working copy)
@@ -891,6 +891,19 @@ reload (rtx first, int global)
for (i = LAST_VIRTUAL_REGISTER + 1; i < max_regno; i++)
alter_reg (i, -1);
+ /* Update REG_DEAD and REG_UNUSED notes. */
+ df_finish_pass (true);
+ df_note_add_problem ();
+ df_scan_alloc (NULL);
+ df_scan_blocks ();
+ df_analyze ();
+
+ /* There is just too much going on in the register allocators to
+ keep things up to date. At the end we have to rescan anyway
+ because things change when the reload_completed flag is set.
+ So we just turn off scanning and we will rescan by hand. */
+ df_set_flags (DF_NO_INSN_RESCAN);
+
/* If we have some registers we think can be eliminated, scan all insns to
see if there is an insn that sets one of these registers to something
other than itself plus a constant. If so, the register cannot be
--
Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year