From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 08E183857C56; Fri, 19 Nov 2021 12:28:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08E183857C56 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:28:27 +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:28:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103328 --- Comment #11 from Richard Biener --- The first stmt we complain on remains in the same function. The functions scope tree at the point of complaint is { Scope block #0=20 { Scope block #0 (unused)=20 struct coroutine_handle _Coro_actor_continue; { Scope block #0 (unused)=20 void (*) (struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame *) _Coro_resume_fn [value-expr: frame_ptr->_Coro_resume_fn]; void (*) (struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame *) _Coro_destroy_fn [value-expr: frame_ptr->_Coro_destroy_fn]; struct promise_type _Coro_promise [value-expr: frame_ptr->_Coro_promi= se]; struct coroutine_handle _Coro_self_handle [value-expr: frame_ptr->_Coro_self_handle]; const struct ._anon_5 * const __closure [value-expr: frame_ptr->__closure]; short unsigned int _Coro_resume_index [value-expr: frame_ptr->_Coro_resume_index]; bool _Coro_frame_needs_free [value-expr: frame_ptr->_Coro_frame_needs_free]; bool _Coro_initial_await_resume_called [value-expr: frame_ptr->_Coro_initial_await_resume_called]; { Scope block #0 (unused)=20 struct suspend_never Is [value-expr: frame_ptr->Is_1_1]; } { Scope block #0=20 void resume.6 =3D <<< error >>>; void destroy.6 =3D <<< error >>>; void resume.4 =3D <<< error >>>; void destroy.4 =3D <<< error >>>; void resume.2 =3D <<< error >>>; void destroy.2 =3D <<< error >>>; void coro.delete.frame =3D <<< error >>>; void coro.delete.promise =3D <<< error >>>; void actor.continue.ret =3D <<< error >>>; void actor.suspend.ret =3D <<< error >>>; void actor.begin =3D <<< error >>>; void final.suspend =3D <<< error >>>; const struct tagged_id cid [value-expr: __closure->__cid]; const struct append_request cm [value-expr: __closure->__cm]; struct server_impl * const this [value-expr: __closure->__this]; { Scope block #0 (unused)=20 struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame * _Coro_frameptr; bool _Coro_promise_live; bool _Coro_gro_live; { Scope block #0 (unused)=20 } } } } } } while at the point we lower control flow and set gimple_block it is { Scope block #0=20 { Scope block #0 (unused)=20 struct coroutine_handle _Coro_actor_continue; { Scope block #0 (unused)=20 void (*) (struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame *) _Coro_resume_fn [value-expr: frame_ptr->_Coro_resume_fn]; void (*) (struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame *) _Coro_destroy_fn [value-expr: frame_ptr->_Coro_destroy_fn]; struct promise_type _Coro_promise [value-expr: frame_ptr->_Coro_promi= se]; struct coroutine_handle _Coro_self_handle [value-expr: frame_ptr->_Coro_self_handle]; const struct ._anon_5 * const __closure [value-expr: frame_ptr->__closure]; short unsigned int _Coro_resume_index [value-expr: frame_ptr->_Coro_resume_index]; bool _Coro_frame_needs_free [value-expr: frame_ptr->_Coro_frame_needs_free]; bool _Coro_initial_await_resume_called [value-expr: frame_ptr->_Coro_initial_await_resume_called]; { Scope block #0=20 void resume.6 =3D <<< error >>>; void destroy.6 =3D <<< error >>>; void resume.4 =3D <<< error >>>; void destroy.4 =3D <<< error >>>; void resume.2 =3D <<< error >>>; void destroy.2 =3D <<< error >>>; void coro.delete.frame =3D <<< error >>>; void coro.delete.promise =3D <<< error >>>; void actor.continue.ret =3D <<< error >>>; void actor.suspend.ret =3D <<< error >>>; void actor.begin =3D <<< error >>>; void final.suspend =3D <<< error >>>; const struct tagged_id cid [value-expr: __closure->__cid]; const struct append_request cm [value-expr: __closure->__cm]; struct server_impl * const this [value-expr: __closure->__this]; { Scope block #0=20 struct append_request m [value-expr: frame_ptr->m_2_3]; struct tagged_id id [value-expr: frame_ptr->id_2_3]; { Scope block #0 (unused)=20 struct awaiter Aw0 [value-expr: frame_ptr->Aw0_3_4]; } } } { Scope block #0 (unused)=20 struct suspend_never Is [value-expr: frame_ptr->Is_1_1]; } } } } The block we associate with the stmt is { Scope block #0 (unused)=20 struct awaiter Aw0 [value-expr: frame_ptr->Aw0_3_4]; } it looks like there's mangling of the block tree happening somehow. We run into /* Lower a bind_expr TSI. DATA is passed through the recursion. */ static void lower_gimple_bind (gimple_stmt_iterator *gsi, struct lower_data *data) { tree old_block =3D data->block; gbind *stmt =3D as_a (gsi_stmt (*gsi)); tree new_block =3D gimple_bind_block (stmt); if (new_block) { if (new_block =3D=3D old_block) { /* The outermost block of the original function may not be the outermost statement chain of the gimplified function. So we may see the outermost block just inside the function. */ gcc_assert (new_block =3D=3D DECL_INITIAL (current_function_decl)= ); new_block =3D NULL; } else {=20 /* We do not expect to handle duplicate blocks. */ gcc_assert (!TREE_ASM_WRITTEN (new_block)); TREE_ASM_WRITTEN (new_block) =3D 1; /* Block tree may get clobbered by inlining. Normally this would be fixed in rest_of_decl_compilation using block notes, but since we are not going to emit them, it is up to us. */ BLOCK_CHAIN (new_block) =3D BLOCK_SUBBLOCKS (old_block); BLOCK_SUBBLOCKS (old_block) =3D new_block; BLOCK_SUBBLOCKS (new_block) =3D NULL_TREE; BLOCK_SUPERCONTEXT (new_block) =3D old_block; with BLOCK_CHAIN (new_block) !=3D NULL and lose those blocks. old_block is the outermost block here. It looks like the BIND_EXPR nesting does not match the BLOCK tree nesting and things go wrong from there. The IL looks like { [t.i:533:13] try { [t.i:533:13] { struct _ZZZNSt11server_impl12send_messageISt7variantIJN12_GLOBAL__N_114append_requ= estEEEEEvNS2_8internal9tagged_idINS2_13server_id_tagEEET_ENKUlS9_E_clIS3_EE= DaS9_ENKUlvE_clEv.Frame * _Coro_frameptr; bool _Coro_promise_live; bool _Coro_gro_live; [t.i:533:13] _Coro_frameptr =3D 0B; [t.i:533:13] _Coro_promise_live =3D 0; [t.i:533:13] _Coro_gro_live =3D 0; [t.i:533:13] _1 =3D .CO_FRAME (48, _Coro_frameptr); [t.i:533:13] _Coro_frameptr =3D operator new (_1); [t.i:533:13] try { [t.i:533:13] [t.i:533:13] _Coro_frameptr->_Coro_frame_needs_fre= e =3D 1; [t.i:533:13] [t.i:533:13] _Coro_frameptr->_Coro_resume_fn =3D operator(); [t.i:533:13] [t.i:533:13] _Coro_frameptr->_Coro_destroy_fn =3D operator(); [t.i:533:13] [t.i:533:13] _Coro_frameptr->__closure =3D __closu= re; [t.i:533:13] { [t.i:533:13] _2 =3D [t.i:533:13] &[t.i:533:13] _Coro_frameptr->_Coro_promise; [t.i:533:13] seastar::internal::coroutine_traits_base<>::promise_type::get_return_object (_2); [t.i:533:13] [t.i:533:13] _Coro_frameptr->_Coro_resume_index = =3D 0; [t.i:533:13] std::server_impl::send_message >({anonymous}::server_id, std::variant<{anonymous}::append_request>)::::::o= perator() (_Coro_frameptr); [t.i:533:13] return ; } } catch { [t.i:533:13] catch (NULL) { [t.i:533:13] try { [t.i:533:13] _3 =3D __builtin_eh_pointer (0); [t.i:533:13] __cxa_begin_catch (_3); [t.i:533:13] operator delete (_Coro_frameptr); [t.i:533:13] __cxa_rethrow (); } finally { [t.i:533:13] __cxa_end_catch (); } } } } } catch { <<>> } } IIRC there's no "verification" of IL BIND_EXPR/gimple_block nesting vs. DECL_INITIAL block tree nesting.=