From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 98A7C3857C6A; Fri, 19 Nov 2021 12:46:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98A7C3857C6A From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 12:46:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103328 --- Comment #12 from Richard Biener --- 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 blo= cks, 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=20 struct _ZNSt11server_impl8io_fiberEN12_GLOBAL__N_114append_requestE.Frame= * _Coro_frameptr; bool _Coro_promise_live; bool _Coro_gro_live; { Scope block #0=20 } } 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); /* 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) =3D=3D gimple_seq_last (body) && gimple_code (gimple_seq_first_stmt (body)) =3D=3D GIMPLE_B= IND); + hash_set blocks; + collect_subblocks (&blocks, DECL_INITIAL (current_function_decl)); + for (auto i =3D blocks.begin (); i !=3D blocks.end (); ++i) + TREE_USED (*i) =3D 0; + memset (&data, 0, sizeof (data)); data.block =3D DECL_INITIAL (current_function_decl); BLOCK_SUBBLOCKS (data.block) =3D NULL_TREE; @@ -165,6 +171,17 @@ lower_function_body (void) =3D blocks_nreverse (BLOCK_SUBBLOCKS (data.block)); clear_block_marks (data.block); + + hash_set blocks_after; + collect_subblocks (&blocks_after, DECL_INITIAL (current_function_decl)); + for (auto i =3D blocks.begin (); i !=3D blocks.end (); ++i) + if (TREE_USED (*i) && !blocks_after.contains (*i)) + gcc_unreachable (); + for (auto i =3D blocks_after.begin (); i !=3D 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 =3D gsi_stmt (*gsi); gimple_set_block (stmt, data->block); + TREE_USED (data->block) =3D 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, v= oid *data) /* Insert all subblocks of BLOCK into BLOCKS and recurse. */ -static void +void collect_subblocks (hash_set *blocks, tree block) { tree t;=