From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B62873857C53; Wed, 29 Sep 2021 16:28:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B62873857C53 From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102359] ICE gimplification failed since r12-3433-ga25e0b5e6ac8a77a Date: Wed, 29 Sep 2021 16:28:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: qinzhao at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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: Wed, 29 Sep 2021 16:28:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102359 --- Comment #2 from qinzhao at gcc dot gnu.org --- (In reply to Richard Biener from comment #1) > Confirmed. So we end with '&__closure->__this' which indeed isn't an lva= lue. >=20 > The issue here is that we are initializing the VAR_DECL 'this' but that > has a DECL_VALUE_EXPR expanding to &__closure->__this: >=20 > const struct A * const this [value-expr: &__closure->__this]; >=20 > note the variable is const as well, so emitting a runtime initializer mig= ht > have other issues (like trapping ...), or in this case, not being an lval= ue. >=20 > But note the FE fails to mark the decl as TREE_READONLY - that would be an > easy thing to check (and something we fail to check in > is_var_need_auto_init). Indeed, VAR_DECL "this" is: (gdb) call debug_tree(t) unit-size align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-ty= pe 0x7fffe9461930 fields context full-name "const struct A" needs-constructor X() X(constX&) this=3D(X&) n_parents=3D0 use_template=3D0 interface-unknown pointer_to_this reference_to_this > readonly sizes-gimplified unsigned DI size unit-size align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe947a000> used unsigned read DI t.cpp:4:18 size unit-size align:64 warn_if_not_align:0 context value-expr readonly arg:0 readonly arg:0 arg:0 > arg:1 t.cpp:4:18 start: t.cpp:4:18 finish: t.cpp:4:18>>> It's not marked as "READONLY" by FE.=20 this looks like a FE bug to me.=20 I just feel strange why not marking "this" as "READONLY" hasn't caused any other issue yet? > Thus sth like >=20 > diff --git a/gcc/gimplify.c b/gcc/gimplify.c > index f680292fd91..b2bfab47a2f 100644 > --- a/gcc/gimplify.c > +++ b/gcc/gimplify.c > @@ -1824,7 +1824,9 @@ gimple_add_padding_init_for_auto_var (tree decl, bo= ol > is_vla, > static bool > is_var_need_auto_init (tree decl) > { > - if (auto_var_p (decl) > + if (VAR_P (decl) > + && !TREE_READONLY (decl) > + && auto_var_p (decl) > && (flag_auto_var_init > AUTO_INIT_UNINITIALIZED) > && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl))) > && !is_empty_type (TREE_TYPE (decl))) >=20 > should be needed. If the FE can mark "this" as READONLY, the above will be the reasonable fix= in middle end.=20 should we put this middle end fix in first and then transfer this bug to FE= to fix? >=20 > Jason, any idea?=