public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/103328] [11/12 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1921 since r11-7419-g0f161cc8494cf728
Date: Fri, 19 Nov 2021 12:46:43 +0000	[thread overview]
Message-ID: <bug-103328-4-aTTtePSDPx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103328-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
Basically with lower_gimple_bind we re-wire the BLOCK tree to match the
GIMPLE_BLOCK IL nesting.  Whatever gets "unreachable" in that process is
"lost".
The following shows this, but it seems it is expected that we lose some blocks,
just not that we lose used ones (so I use TREE_USED to mark
the blocks we record in stmts and only check those).  Interestingly then
it doesn't trigger.  Instead it looks like the BIND_EXPR tree contains
BLOCKs not in the initial BLOCK tree!?

{ Scope block #0 
  struct _ZNSt11server_impl8io_fiberEN12_GLOBAL__N_114append_requestE.Frame *
_Coro_frameptr;
  bool _Coro_promise_live;
  bool _Coro_gro_live;

  { Scope block #0 

  }

}

for example.

diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 7d9b3df2ffb..b0ae15f0368 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -77,6 +77,7 @@ static void lower_gimple_return (gimple_stmt_iterator *,
struct lower_data *);
 static void lower_builtin_setjmp (gimple_stmt_iterator *);
 static void lower_builtin_posix_memalign (gimple_stmt_iterator *);

+extern void collect_subblocks (hash_set<tree> *, tree);

 /* Lower the body of current_function_decl from High GIMPLE into Low
    GIMPLE.  */
@@ -96,6 +97,11 @@ lower_function_body (void)
   gcc_assert (gimple_seq_first (body) == gimple_seq_last (body)
              && gimple_code (gimple_seq_first_stmt (body)) == GIMPLE_BIND);

+  hash_set<tree> blocks;
+  collect_subblocks (&blocks, DECL_INITIAL (current_function_decl));
+  for (auto i = blocks.begin (); i != blocks.end (); ++i)
+    TREE_USED (*i) = 0;
+
   memset (&data, 0, sizeof (data));
   data.block = DECL_INITIAL (current_function_decl);
   BLOCK_SUBBLOCKS (data.block) = NULL_TREE;
@@ -165,6 +171,17 @@ lower_function_body (void)
     = blocks_nreverse (BLOCK_SUBBLOCKS (data.block));

   clear_block_marks (data.block);
+
+  hash_set<tree> blocks_after;
+  collect_subblocks (&blocks_after, DECL_INITIAL (current_function_decl));
+  for (auto i = blocks.begin (); i != blocks.end (); ++i)
+    if (TREE_USED (*i) && !blocks_after.contains (*i))
+      gcc_unreachable ();
+  for (auto i = blocks_after.begin (); i != blocks_after.end (); ++i)
+    if (!blocks.contains (*i))
+      gcc_unreachable ();
+
+
   data.return_statements.release ();
   return 0;
 }
@@ -248,6 +265,7 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data
*data)
   gimple *stmt = gsi_stmt (*gsi);

   gimple_set_block (stmt, data->block);
+  TREE_USED (data->block) = 1;

   switch (gimple_code (stmt))
     {
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index cde606e1a40..719941dea42 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5396,7 +5396,7 @@ verify_expr_location (tree *tp, int *walk_subtrees, void
*data)

 /* Insert all subblocks of BLOCK into BLOCKS and recurse.  */

-static void
+void
 collect_subblocks (hash_set<tree> *blocks, tree block)
 {
   tree t;

  parent reply	other threads:[~2021-11-19 12:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  9:56 [Bug c++/103328] New: IC in remap_gimple_stmt, at tree-inline.c:1921 avi@cloudius-systems.com
2021-11-19 10:41 ` [Bug c++/103328] ICE " rguenth at gcc dot gnu.org
2021-11-19 10:41 ` rguenth at gcc dot gnu.org
2021-11-19 11:07 ` [Bug c++/103328] [11/12 Regression] ICE in remap_gimple_stmt, at tree-inline.c:1921 since r11-7419-g0f161cc8494cf728 marxin at gcc dot gnu.org
2021-11-19 11:26 ` jakub at gcc dot gnu.org
2021-11-19 11:57 ` avi@cloudius-systems.com
2021-11-19 12:03 ` avi@cloudius-systems.com
2021-11-19 12:07 ` jakub at gcc dot gnu.org
2021-11-19 12:10 ` avi@cloudius-systems.com
2021-11-19 12:11 ` avi@cloudius-systems.com
2021-11-19 12:20 ` avi@cloudius-systems.com
2021-11-19 12:28 ` rguenth at gcc dot gnu.org
2021-11-19 12:46 ` rguenth at gcc dot gnu.org [this message]
2021-11-19 12:48 ` rguenth at gcc dot gnu.org
2021-11-19 13:42 ` rguenth at gcc dot gnu.org
2021-11-19 13:59 ` iains at gcc dot gnu.org
2021-11-19 14:05 ` rguenth at gcc dot gnu.org
2021-11-20 11:15 ` avi@cloudius-systems.com
2022-01-17 12:55 ` rguenth at gcc dot gnu.org
2022-02-26 17:17 ` piotr.grabowski at scylladb dot com
2022-03-11  2:14 ` gcc at bmevers dot de
2022-03-11 16:40 ` gcc at bmevers dot de
2022-03-15 15:29 ` avi at scylladb dot com
2022-03-22 14:48 ` [Bug c++/103328] [11/12 Regression] ICE in remap_gimple_stmt with coroutines " avi at scylladb dot com
2022-04-03 10:28 ` cvs-commit at gcc dot gnu.org
2022-04-04 15:05 ` avi at scylladb dot com
2022-04-07 12:04 ` [Bug c++/103328] [11 " cvs-commit at gcc dot gnu.org
2022-04-07 12:06 ` rguenth at gcc dot gnu.org
2022-04-07 14:42 ` avi at scylladb dot com

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-103328-4-aTTtePSDPx@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).