public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zadeck at naturalbridge dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/32431] ICE in df_refs_verify, at df-scan.c:4066
Date: Thu, 21 Jun 2007 12:29:00 -0000	[thread overview]
Message-ID: <20070621122906.6593.qmail@sourceware.org> (raw)
In-Reply-To: <bug-32431-12574@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from zadeck at naturalbridge dot com  2007-06-21 12:29 -------
Subject: Re:  ICE in df_refs_verify, at df-scan.c:4066

rask at sygehus dot dk wrote:
> ------- Comment #1 from rask at sygehus dot dk  2007-06-20 16:58 -------
> Created an attachment (id=13747)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13747&action=view)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13747&action=view)
> Preprocessed testcase
>
>
>   
:ADDPATCH MIDDLE-END:

The underlying problem is that the later phases of compilation on the
m68hc11 create shared rtl.  The reorg phase needs df and also needs the
rtl to be unshared. This causes problems because the unsharing process
changes insns in ways that mess up df's scanning information.

There are two ways to solve this problem:

1) Go in and fix the places that create shared rtl in this back end.
2) Make the rtl unsharing df-ready.

I chose plan (2) because I know how to do this and do not know how to do
(1).
The astute middle end/gwp maintainer may say that (1) is the right thing
to do and so the sharing police (namely honza) should investigate this
pr.  If that is the proper plan of action, then this patch may go into
the trash.

I tested this on x86-64 which does call unshare_all_rtl_again (from
ifcvt) to verify that this does not cause any problems and it does fix
the immediate bug here. 

Ok for trunk?

Kenny


2007-06-21  Kenneth Zadeck <zadeck@naturalbridge.com>

        PR middle-end/32431
    * emit-rtl.c (unshare_all_rtl_in_chain): Now rescans insns and
    notes if unsharing happens.
    (copy_rtx_if_shared_1): Returns true if sharing was found.
    config/m68hc11/m68hc11.c: (m68hc11_reorg): Move reinitialization
    of cfg to before unsharing rtl.

Index: emit-rtl.c
===================================================================
--- emit-rtl.c  (revision 125916)
+++ emit-rtl.c  (working copy)
@@ -184,7 +184,7 @@ static int reg_attrs_htab_eq (const void
 static reg_attrs *get_reg_attrs (tree, int);
 static tree component_ref_for_mem_expr (tree);
 static rtx gen_const_vector (enum machine_mode, int);
-static void copy_rtx_if_shared_1 (rtx *orig);
+static bool copy_rtx_if_shared_1 (rtx *orig);

 /* Probability of the conditional branch currently proceeded by try_split.
    Set to -1 otherwise.  */
@@ -2350,8 +2350,20 @@ unshare_all_rtl_in_chain (rtx insn)
   for (; insn; insn = NEXT_INSN (insn))
     if (INSN_P (insn))
       {
-       PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
-       REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
+       rtx orig = PATTERN (insn);
+
+        if (copy_rtx_if_shared_1 (&orig))
+         {
+           PATTERN (insn) = orig;
+           df_insn_rescan (insn);
+         }
+
+       orig = REG_NOTES (insn);
+       if (copy_rtx_if_shared_1 (&orig))
+         {
+           REG_NOTES (insn) = orig;
+           df_notes_rescan (insn);
+         }
       }
 }

@@ -2383,10 +2395,11 @@ copy_rtx_if_shared (rtx orig)
   return orig;
 }

-/* Mark *ORIG1 as in use, and set it to a copy of it if it was already in
-   use.  Recursively does the same for subexpressions.  */
+/* Mark *ORIG1 as in use, and set it to a copy of it if it was already
+   in use.  Recursively does the same for subexpressions.  Return true
+   if copies were made.  */

-static void
+static bool
 copy_rtx_if_shared_1 (rtx *orig1)
 {
   rtx x;
@@ -2396,13 +2409,15 @@ copy_rtx_if_shared_1 (rtx *orig1)
   const char *format_ptr;
   int copied = 0;
   int length;
+  bool changed = false;
+

   /* Repeat is used to turn tail-recursion into iteration.  */
 repeat:
   x = *orig1;

   if (x == 0)
-    return;
+    return changed;

   code = GET_CODE (x);

@@ -2421,15 +2436,15 @@ repeat:
     case CC0:
     case SCRATCH:
       /* SCRATCH must be shared because they represent distinct values.  */
-      return;
+      return changed;
     case CLOBBER:
       if (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER)
-       return;
+       return changed;
       break;

     case CONST:
       if (shared_const_p (x))
-       return;
+       return changed;
       break;

     case INSN:
@@ -2438,7 +2453,7 @@ repeat:
     case NOTE:
     case BARRIER:
       /* The chain of insns is not being copied.  */
-      return;
+      return changed;

     default:
       break;
@@ -2451,6 +2466,7 @@ repeat:
     {
       x = shallow_copy_rtx (x);
       copied = 1;
+      changed = true;
     }
   RTX_FLAG (x, used) = 1;

@@ -2469,7 +2485,7 @@ repeat:
        {
        case 'e':
           if (last_ptr)
-            copy_rtx_if_shared_1 (last_ptr);
+            changed |= copy_rtx_if_shared_1 (last_ptr);
          last_ptr = &XEXP (x, i);
          break;

@@ -2488,7 +2504,7 @@ repeat:
              for (j = 0; j < len; j++)
                 {
                  if (last_ptr)
-                   copy_rtx_if_shared_1 (last_ptr);
+                   changed |= copy_rtx_if_shared_1 (last_ptr);
                   last_ptr = &XVECEXP (x, i, j);
                 }
            }
@@ -2501,7 +2517,7 @@ repeat:
       orig1 = last_ptr;
       goto repeat;
     }
-  return;
+  return changed;
 }

 /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
Index: config/m68hc11/m68hc11.c
===================================================================
--- config/m68hc11/m68hc11.c    (revision 125916)
+++ config/m68hc11/m68hc11.c    (working copy)
@@ -5011,6 +5011,11 @@ m68hc11_reorg (void)
   z_reg = gen_rtx_REG (HImode, HARD_Z_REGNUM);
   first = get_insns ();

+  /* Need to compute the bb_for_insn before splitting when optimizing
+     or else the df_analyze may raise a verify error.  */
+  if (optimize)
+    compute_bb_for_insn ();
+
   /* Some RTX are shared at this point.  This breaks the Z register
      replacement, unshare everything.  */
   unshare_all_rtl_again (first);
@@ -5023,9 +5028,6 @@ m68hc11_reorg (void)
   z_replacement_completed = 1;
   m68hc11_reassign_regs (first);

-  if (optimize)
-    compute_bb_for_insn ();
-
   /* After some splitting, there are some opportunities for CSE pass.
      This happens quite often when 32-bit or above patterns are split.  */
   if (optimize > 0 && split_done)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32431


  parent reply	other threads:[~2007-06-21 12:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 16:57 [Bug target/32431] New: " rask at sygehus dot dk
2007-06-20 16:58 ` [Bug target/32431] " rask at sygehus dot dk
2007-06-21 12:29 ` zadeck at naturalbridge dot com [this message]
2007-06-21 23:13 ` [Bug target/32431] [4.3 Regression] " pinskia at gcc dot gnu dot org
2007-06-29 18:50 ` mmitchel at gcc dot gnu dot org
2007-08-02 19:19 ` zadeck at naturalbridge dot com
2008-01-13 15:16 ` [Bug target/32431] [4.3 Regression][m68hc11] " rguenth at gcc dot gnu dot org
2008-01-13 16:26 ` steven at gcc dot gnu dot org
2008-03-15  0:44 ` [Bug target/32431] [4.3/4.4 " jsm28 at gcc dot gnu dot org
2008-06-06 14:58 ` rguenth at gcc dot gnu dot org
2008-08-27 22:04 ` jsm28 at gcc dot gnu dot org
2009-01-24 10:40 ` rguenth at gcc dot gnu dot org
2009-03-31 13:23 ` [Bug target/32431] [4.3/4.4/4.5 " bonzini at gnu dot org
2009-04-09 10:35 ` bonzini at gnu dot org
2009-08-04 12:36 ` rguenth at gcc dot gnu dot org
2010-05-22 18:19 ` [Bug target/32431] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070621122906.6593.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).