From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 46D5E3891C07; Thu, 13 Jan 2022 11:10:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46D5E3891C07 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103989] [12 regression] std::optional and bogus -Wmaybe-unitialized at -Og since r12-1992-g6feb628a706e86eb Date: Thu, 13 Jan 2022 11:10:01 +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: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: 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: Thu, 13 Jan 2022 11:10:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103989 --- Comment #5 from Jakub Jelinek --- The reason we warn is that at -Og we don't optimize away the dead code. In uninit2 we have: MEM[(struct _Optional_payload_base *)&D.34851]._M_engaged =3D 0; ... _27 =3D MEM[(const struct _Optional_payload_base &)&D.34851]._M_engaged; if (_27 !=3D 0) goto ; [33.00%] else goto ; [67.00%] [local count: 719407024]: goto ; [100.00%] [local count: 354334800]: MEM[(struct __as_base &)&b] =3D{v} {CLOBBER}; MEM[(struct shared_ptr *)&b] =3D{v} {CLOBBER}; MEM[(struct __shared_ptr *)&b] =3D{v} {CLOBBER}; _30 =3D MEM[(const struct __shared_ptr &)&D.34851]._M_ptr; MEM[(struct __shared_ptr *)&b]._M_ptr =3D _30; MEM[(struct __shared_count *)&b + 8B] =3D{v} {CLOBBER}; _31 =3D MEM[(const struct __shared_count &)&D.34851 + 8]._M_pi; MEM[(struct __shared_count *)&b + 8B]._M_pi =3D _31; and we haven't figured out that bb 3 is all dead, because we store into _M_engaged 0 and bb 3 is done only if _M_engaged is non-zero. -Og runs fre1, but that is too early, fre1 sees MEM[(struct _Optional_payload_base *)&D.34851]._M_engaged =3D 0; D.35431 =3D{v} {CLOBBER}; b =3D{v} {CLOBBER}; MEM[(struct optional *)&b] =3D{v} {CLOBBER}; std::_Optional_base::_Optional_base (&MEM[(struct option= al *)&b].D.34640, &D.34851.D.34640); and _Optional_base isn't inlined there. And -Og doesn't do any FRE or PRE after inlining, unlike e.g. -O1 which has fre3 very soon after inlining. -Og doesn't even do forwprop after inlining.=