From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 24E0A385840C; Mon, 4 Oct 2021 06:29:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24E0A385840C From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102285] New flag -ftrivial-auto-var-init=zero causes crash in pr82421.c Date: Mon, 04 Oct 2021 06:29:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: qinzhao at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Mon, 04 Oct 2021 06:29:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102285 --- Comment #20 from rguenther at suse dot de --- On Fri, 1 Oct 2021, qinzhao at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102285 >=20 > --- Comment #18 from qinzhao at gcc dot gnu.org --- > (In reply to Richard Biener from comment #13) > > We could try sth like the following which should cover this testcase and > > also hopefully doesn't break anything else. > >=20 > > diff --git a/gcc/expr.c b/gcc/expr.c > > index e0bcbccd905..ab3b5b26c20 100644 > > --- a/gcc/expr.c > > +++ b/gcc/expr.c > > @@ -5322,7 +5322,7 @@ non_mem_decl_p (tree base) > > /* Returns true if REF refers to an object that does not > > reside in memory and has non-BLKmode. */ > >=20=20 > > -static inline bool > > +bool > > mem_ref_refers_to_non_mem_p (tree ref) > > { > > tree base; > > diff --git a/gcc/expr.h b/gcc/expr.h > > index 94a85b40dca..85650e96834 100644 > > --- a/gcc/expr.h > > +++ b/gcc/expr.h > > @@ -346,4 +346,6 @@ extern void expand_operands (tree, tree, rtx, rtx*,= rtx*, > > /* Return an rtx for the size in bytes of the value of an expr. */ > > extern rtx expr_size (tree); > >=20=20 > > +extern bool mem_ref_refers_to_non_mem_p (tree ref); > > + > > #endif /* GCC_EXPR_H */ > > diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c > > index 8312d08aab2..c1d23dfd21e 100644 > > --- a/gcc/internal-fn.c > > +++ b/gcc/internal-fn.c > > @@ -3015,8 +3015,10 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt) > > reg_lhs =3D true; > > else > > { > > - rtx tem =3D expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); > > - reg_lhs =3D !MEM_P (tem); > > + tree lhs_base =3D lhs; > > + while (handled_component_p (lhs_base)) > > + lhs_base =3D TREE_OPERAND (lhs_base, 0); > > + reg_lhs =3D mem_refers_to_non_mem_p (lhs_base); > > } > >=20=20 > > if (!reg_lhs) >=20 > I tried the above patch, it even doesn't work for this testing case.=20 > After the patch, this call to .DEFERRED_INIT will be expanded through REG= path, > however, the existing problem in the LHS IR broke the "expand_assignment"= too.=20 > so I see. > , I still think that the root cause is the IR for LHS of the following=20 call > to .DEFERRED_INIT is not correct: > > MEM[(int[0:D.1993] *)&fb.3] =3D .DEFERRED_INIT (16, 2, 1); >=20 > the LHS is: MEM[(int[0:D.1993] *)&fb.3] >=20 > this is the MEM_REF, whose base address is a ADDR_EXPR of a VAR_DECL, how= ever, > this VAR_DECL is not addressable, will be in REG. this is conflicting: ho= w can > a variable that in a REG be address taken? It doesn't have its address taken - the ADDR_EXPR is artificial when at the base of a MEM_REF. Let me thake this bug then.=