From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CA22A39484B4; Mon, 1 Feb 2021 19:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA22A39484B4 From: "hubicka at ucw dot cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98925] Extend modref to handle return slot optimization Date: Mon, 01 Feb 2021 19:11:17 +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: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at ucw dot cz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hubicka 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, 01 Feb 2021 19:11:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98925 --- Comment #1 from Jan Hubicka --- > If I don't overstimate modref and alias analysis destructor should disa= ppear > completely in the example below (from https://gcc.gnu.org/PR98499#c4): >=20 > struct string { > char * _M_buf; > // local store > char _M_local_buf[16]; >=20 > __attribute__((noinline)) string() : _M_buf(_M_local_buf) {} >=20 > ~string() { > if (_M_buf !=3D _M_local_buf) > __builtin_trap(); > } >=20 > string(const string &__str); // no copies > }; To see that _M_buf =3D=3D _M_local_buf at the destruction time would require tracking the aggregate alue from the inlinined constructor to destructor which is something fitting to ipa-prop. Modref can helip in case _M_buf is initialized to NULL. In that case the address of return value would be non-escaping and we could optimize the if condition to true (is we did incorrectly before). I have WIP patch for this and will discuss with Martin Jambor the jump functions for return values. Thanks! Honza=