From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9592B385B833; Mon, 23 Mar 2020 23:16:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9592B385B833 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585005406; bh=NB4gl8Yh7IGPiEN+Lr5kmasPDy48py2b647JWIEhJwk=; h=From:To:Subject:Date:From; b=xGlMO6Rdb2SCkJO/yS97YCNsAc/vhfsTbzQTMfHozduG868yja8EHMOztrltMD0TF RqGvUCPS31cfOzr/FjPqeE8lz6jaq2B7MZxemFo6XX4g/mMkfPl2+5Y1805+o/Usuh 7ajFfZR7iVhutt35PqkKiaR4vLJ+PMRzLH6bvN0Q= From: "richard-gccbugzilla at metafoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94295] New: use __builtin_operator_new and __builtin_operator_delete when available Date: Mon, 23 Mar 2020 23:16:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: richard-gccbugzilla at metafoo dot co.uk X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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, 23 Mar 2020 23:16:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94295 Bug ID: 94295 Summary: use __builtin_operator_new and __builtin_operator_delete when available Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: richard-gccbugzilla at metafoo dot co.uk Target Milestone: --- See https://bugs.llvm.org/show_bug.cgi?id=3D45287 for some background. The C++ language rules do not permit optimization (eg, deletion) of direct calls to 'operator new' and 'operator delete'. libstdc++ uses such calls to implement std::allocator: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/ext/= new_allocator.h#L112 As a consequence, allocations performed by libstdc++'s containers are not optimizable. Clang provides a pair of builtin functions to work around this issue: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-operator-new-an= d-builtin-operator-delete __builtin_operator_new(args) is equivalent to ::operator new(args) except t= hat it permits optimizations. __builtin_operator_delete(args) is equivalent to ::operator delete(args) ex= cept that it permits optimizations. You can detect support for these builtins with #ifdef __has_builtin #if __has_builtin(__builtin_operator_new) >=3D 201802L // ... #endif #endif (Note that __has_builtin(...) returned 1 for an older version of the builti= ns that didn't support placement forms, and so couldn't be used for aligned allocation and sized delete. It's probably not worth your time dealing with those.) This bug requests that libstdc++ uses these builtins when available. (Separately, it'd be great if GCC considered supporting them too.)=