public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/90259] ICE: verify_flow_info failed (error: missing REG_EH_REGION note at the end of bb 4)
Date: Wed, 02 Nov 2022 09:24:24 +0000	[thread overview]
Message-ID: <bug-90259-4-rG4qB0EUTG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-90259-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90259

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |linkw at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #7 from Kewen Lin <linkw at gcc dot gnu.org> ---
The function copyprop_hardreg_forward_1 of pass cprop_hardreg has the code:

      /* Detect obviously dead sets (via REG_UNUSED notes) and remove them.  */
      if (set
          && !RTX_FRAME_RELATED_P (insn)
          && NONJUMP_INSN_P (insn)
          && !may_trap_p (set)
          && find_reg_note (insn, REG_UNUSED, SET_DEST (set))
          && !side_effects_p (SET_SRC (set))
          && !side_effects_p (SET_DEST (set)))
        {
          bool last = insn == BB_END (bb);
          delete_insn (insn);
          if (last)
            break;
          continue;
        }

it removes the insn 109

(insn 109 117 79 6 (set (reg:DF 33 1 [orig:134+8 ] [134])
        (mem:DF (plus:SI (reg/f:SI 31 31)
                (const_int 40 [0x28])) [11  S8 A64])) "pr90259_test.cc":5:53
584 {*movdf_hardfloat32}
     (expr_list:REG_UNUSED (reg:DF 33 1 [orig:134+8 ] [134])
        (expr_list:REG_EH_REGION (const_int 2 [0x2])
            (nil))))

as DF 33 is unused and it meets the above conditions. The case can pass if we
purge dead edges after this removal, such as the below diff. But I need more
investigation to see if we can purge these kinds of dead edges when they are
created (it should make more senses).

=======

diff --git a/gcc/regcprop.cc b/gcc/regcprop.cc
index ce9d32a4fb7..afcfc0bf252 100644
--- a/gcc/regcprop.cc
+++ b/gcc/regcprop.cc
@@ -36,6 +36,7 @@
 #include "cfgrtl.h"
 #include "target.h"
 #include "function-abi.h"
+#include "cfgcleanup.h"

 /* The following code does forward propagation of hard register copies.
    The object is to eliminate as many dependencies as possible, so that
@@ -74,6 +75,7 @@ struct value_data
   struct value_data_entry e[FIRST_PSEUDO_REGISTER];
   unsigned int max_value_regs;
   unsigned int n_debug_insn_changes;
+  bool need_purge_dead_edge;
 };

 static object_allocator<queued_debug_insn_change>
queued_debug_insn_change_pool
@@ -818,7 +820,11 @@ copyprop_hardreg_forward_1 (basic_block bb, struct
value_data *vd)
          bool last = insn == BB_END (bb);
          delete_insn (insn);
          if (last)
-           break;
+           {
+             if (find_reg_note (insn, REG_EH_REGION, NULL_RTX))
+               vd->need_purge_dead_edge = true;
+             break;
+           }
          continue;
        }

@@ -1405,6 +1411,7 @@ pass_cprop_hardreg::execute (function *fun)

   FOR_EACH_BB_FN (bb, fun)
     {
+      all_vd[bb->index].need_purge_dead_edge = false;
       if (cprop_hardreg_bb (bb, all_vd, visited))
        curr->safe_push (bb->index);
       if (all_vd[bb->index].n_debug_insn_changes)
@@ -1444,6 +1451,10 @@ pass_cprop_hardreg::execute (function *fun)
       std::swap (curr, next);
     }

+  FOR_EACH_BB_FN (bb, fun)
+    if (all_vd[bb->index].need_purge_dead_edge)
+      purge_dead_edges (bb);
+
   free (all_vd);
   return 0;
 }

  parent reply	other threads:[~2022-11-02  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-90259-4@http.gcc.gnu.org/bugzilla/>
2022-10-19  4:02 ` asolokha at gmx dot com
2022-10-27  6:30 ` linkw at gcc dot gnu.org
2022-10-27  7:44 ` asolokha at gmx dot com
2022-10-27 14:43 ` pinskia at gcc dot gnu.org
2022-11-01  7:19 ` linkw at gcc dot gnu.org
2022-11-01  7:56 ` asolokha at gmx dot com
2022-11-01  8:16 ` linkw at gcc dot gnu.org
2022-11-02  9:24 ` linkw at gcc dot gnu.org [this message]
2022-11-16  2:26 ` cvs-commit at gcc dot gnu.org
2022-11-17  2:28 ` linkw at gcc dot gnu.org
2023-05-14 22:44 ` pinskia at gcc dot gnu.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=bug-90259-4-rG4qB0EUTG@http.gcc.gnu.org/bugzilla/ \
    --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).