From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DFCAA38708B6; Sat, 11 May 2024 16:44:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFCAA38708B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715445852; bh=9wobT1Ns3Z4sxaux4CyMBqlAsd4LzQWaK0MpL8+Hnq0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vAR6yXG9X/oHos3mxQROd/A1PP631vl7Ar1sSBZDUzgGPfh9jOWNmzfIHmwraCHI/ g9jLn+F4sq8NARXcEXY8ZIMWPwDQ/E4N1vXUrMXG+0q2FxEk20uyvj34v85u/a1OYE jBqZ3Bi9L9UrGiwrTANuwiSvTn/HBMaUsAGPOOdc= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109442] Dead local copy of std::vector not removed from function Date: Sat, 11 May 2024 16:44:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109442 --- Comment #20 from Jonathan Wakely --- (In reply to Jan Hubicka from comment #19) > Similar argument can IMO be used for eliding unused memory allocations. It > is kind of up to std::vector implementation on how many > allocations/deallocations it does, right? It's up to std::allocator, which is not required to call operator new every time memory is needed.=20 > So we need a way to annotate the new/delete calls in the standard library= as > safe for such optimizations (i.e. implement clang's > __bulitin_operator_new/delete?) Yes, see PR 110137. > How clang manages to optimize this out without additional hinting? It supports __builtin_operator_{new,delete} and libstdc++ uses that when compiled with clang.=