{"id":2233366,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2233366/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260506085339.325517-2-jwakely@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260506085339.325517-2-jwakely@redhat.com>","date":"2026-05-06T08:48:05","name":"[v2,2/3] libstdc++: Simplify std::shared_ptr internals","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2e1d793df25dfac4c324243cac326a8460341089","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/1.1/people/48004/?format=json","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260506085339.325517-2-jwakely@redhat.com/mbox/","series":[{"id":502950,"url":"http://patchwork.ozlabs.org/api/1.1/series/502950/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=502950","date":"2026-05-06T08:48:05","name":"[v2,1/3] libstdc++: Replace uses of EBO with [[no_unique_address]]","version":2,"mbox":"http://patchwork.ozlabs.org/series/502950/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2233366/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2233366/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=DeP3fKdO;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=DeP3fKdO","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","sourceware.org; arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9WP21yspz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 20:11:02 +1000 (AEST)","from vm01.sourceware.org (localhost [IPv6:::1])\n\tby sourceware.org (Postfix) with ESMTP id 5C72E4BA799A\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  6 May 2026 10:11:00 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id AF0964BA23FA\n for <gcc-patches@gcc.gnu.org>; Wed,  6 May 2026 08:53:46 +0000 (GMT)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-a5zWVBzeO26gPVpVncfgUQ-1; Wed,\n 06 May 2026 04:53:44 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id B8B7D1956096; Wed,  6 May 2026 08:53:43 +0000 (UTC)","from zen.kayari.org (unknown [10.44.32.38])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 81E551801A63; Wed,  6 May 2026 08:53:42 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 5C72E4BA799A","OpenDKIM Filter v2.11.0 sourceware.org AF0964BA23FA"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org AF0964BA23FA","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org AF0964BA23FA","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778057626; cv=none;\n b=A8Fqs4ulrotdkzi4WaFcxZp4Aa1fh8V1SvbFSlpFxH9mj7zcVotIbkwsZ+hW1W59ogqy/fUnRuwsoW1FtafUbJc+X20xz4N4LJMSkTzHnNOpOtAaBQzq3/Yr8jErqkll1rOYuMXsRoihlsWQypHZxKGtdFXN+5D8WmtYwzKD9nk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1778057626; c=relaxed/simple;\n bh=/Wr5MlrL/6zbYA8Llba0sDxUgecoX3gGGvrWSkhD24w=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=Go18GHUe71CD7UNuIamfy9UmPROsX1OiF6U7Cc199Q3PwHyir+VEl3B8BoZrnfefW2O3UPxFB8dZl+jtnulO9CrrbVRWSQsgnHdgXGVEiaBkftgznpm5D8ilStJb5JUYPao28fNmNJxxgyUKJdhdaY7FvtpKLPizi1juxaXc80g=","ARC-Authentication-Results":"i=1; sourceware.org;\n dkim=pass (1024-bit key, unprotected)\n header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=DeP3fKdO","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1778057625;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=1UMTh/tu3k+Tu+wO1jrQP/U9KOZy7t+gOu7ZbhBEFY0=;\n b=DeP3fKdOs3tzQnBkEYH7/xwrAuIksyeWcoy1Uvxg0qm7MYPjqb2E4umma8k5LQ4XDwumLn\n FJHqB/d+ZqcLMPU2mgqU1yUYldThTwj74squLciOR2nsZ6k1RNF8SeqvSPmMwSL3gZAss5\n wH7OKsxiWZ9xVzHMe1x3grAzHRL+dno=","X-MC-Unique":"a5zWVBzeO26gPVpVncfgUQ-1","X-Mimecast-MFC-AGG-ID":"a5zWVBzeO26gPVpVncfgUQ_1778057623","From":"Jonathan Wakely <jwakely@redhat.com>","To":"gcc-patches@gcc.gnu.org,\n\tlibstdc++@gcc.gnu.org","Subject":"[PATCH v2 2/3] libstdc++: Simplify std::shared_ptr internals","Date":"Wed,  6 May 2026 09:48:05 +0100","Message-ID":"<20260506085339.325517-2-jwakely@redhat.com>","In-Reply-To":"<20260506085339.325517-1-jwakely@redhat.com>","References":"<20260506085339.325517-1-jwakely@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"genzqw8tMpdaCYrpk3G76fdfblimFT34uKPoEj0Bfb4_1778057623","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","Content-Transfer-Encoding":"8bit","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Now that we don't use the EBO we can flatten the class layout by\nremoving some _Impl classes.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/out_ptr.h (out_ptr_t::_Impl::~_Impl): Adjust\n\taccess to shared_ptr internals.\n\t* include/bits/shared_ptr_base.h (_Sp_counted_deleter): Remove\n\t_Impl class and replace _M_impl with the data members it\n\tcontained.\n\t(_Sp_counted_ptr_inplace): Likewise.\n---\n\nv2: Use the attribute on the _M_del and _M_alloc members.\n\nTested x86_64-linux.\n\n libstdc++-v3/include/bits/out_ptr.h         |  2 +-\n libstdc++-v3/include/bits/shared_ptr_base.h | 60 ++++++---------------\n 2 files changed, 18 insertions(+), 44 deletions(-)","diff":"diff --git a/libstdc++-v3/include/bits/out_ptr.h b/libstdc++-v3/include/bits/out_ptr.h\nindex cc5a8a3adacb..f5fdc6cf910f 100644\n--- a/libstdc++-v3/include/bits/out_ptr.h\n+++ b/libstdc++-v3/include/bits/out_ptr.h\n@@ -257,7 +257,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t    auto& __pi = _M_smart._M_refcount._M_pi;\n \n \t    if (_Sp __ptr = _M_smart.get())\n-\t      static_cast<_Scd*>(__pi)->_M_impl._M_ptr = __ptr;\n+\t      static_cast<_Scd*>(__pi)->_M_ptr = __ptr;\n \t    else // Destroy the control block manually without invoking deleter.\n \t      std::__exchange(__pi, nullptr)->_M_destroy();\n \t  }\ndiff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h\nindex 3ab73f6e4a0d..01fd57180ecc 100644\n--- a/libstdc++-v3/include/bits/shared_ptr_base.h\n+++ b/libstdc++-v3/include/bits/shared_ptr_base.h\n@@ -547,32 +547,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n   template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp>\n     class _Sp_counted_deleter final : public _Sp_counted_base<_Lp>\n     {\n-      class _Impl\n-      {\n-\t[[__no_unique_address__]] _Sp_ebo_helper<_Deleter> _M_d;\n-\t[[__no_unique_address__]] _Sp_ebo_helper<_Alloc>   _M_a;\n-\n-      public:\n-\t_Impl(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept\n-\t: _M_d{std::move(__d)}, _M_a{__a}, _M_ptr(__p)\n-\t{ }\n-\n-\t_Deleter& _M_del() noexcept { return _M_d._M_obj; }\n-\t_Alloc& _M_alloc() noexcept { return _M_a._M_obj; }\n-\n-\t_Ptr _M_ptr;\n-      };\n-\n     public:\n       using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>;\n \n       // __d(__p) must not throw.\n       _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept\n-      : _M_impl(__p, std::move(__d), _Alloc()) { }\n+      : _M_del{std::move(__d)}, _M_alloc{}, _M_ptr(__p) { }\n \n       // __d(__p) must not throw.\n       _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept\n-      : _M_impl(__p, std::move(__d), __a) { }\n+      : _M_del{std::move(__d)}, _M_alloc{__a}, _M_ptr(__p) { }\n \n #pragma GCC diagnostic push // PR tree-optimization/122197\n #pragma GCC diagnostic ignored \"-Wfree-nonheap-object\"\n@@ -582,12 +566,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \n       virtual void\n       _M_dispose() noexcept\n-      { _M_impl._M_del()(_M_impl._M_ptr); }\n+      { _M_del._M_obj(_M_ptr); }\n \n       virtual void\n       _M_destroy() noexcept\n       {\n-\t__allocator_type __a(_M_impl._M_alloc());\n+\t__allocator_type __a(_M_alloc._M_obj);\n \t__allocated_ptr<__allocator_type> __guard_ptr{ __a, this };\n \tthis->~_Sp_counted_deleter();\n       }\n@@ -598,19 +582,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n #if __cpp_rtti\n \t// _GLIBCXX_RESOLVE_LIB_DEFECTS\n \t// 2400. shared_ptr's get_deleter() should use addressof()\n-        return __ti == typeid(_Deleter)\n-\t  ? std::__addressof(_M_impl._M_del())\n-\t  : nullptr;\n-#else\n-        return nullptr;\n+\tif (__ti == typeid(_Deleter))\n+\t  return std::__addressof(_M_del._M_obj);\n #endif\n+\treturn nullptr;\n       }\n \n     private:\n #ifdef __glibcxx_out_ptr\n       template<typename, typename, typename...> friend class out_ptr_t;\n #endif\n-      _Impl _M_impl;\n+\n+      [[__no_unique_address__]] _Sp_ebo_helper<_Deleter> _M_del;\n+      [[__no_unique_address__]] _Sp_ebo_helper<_Alloc>   _M_alloc;\n+      _Ptr _M_ptr;\n     };\n \n   // helpers for make_shared / allocate_shared\n@@ -640,25 +625,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n   template<typename _Tp, typename _Alloc, _Lock_policy _Lp>\n     class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp>\n     {\n-      class _Impl\n-      {\n-\t[[__no_unique_address__]] _Sp_ebo_helper<_Alloc> _M_a;\n-\n-      public:\n-\texplicit _Impl(_Alloc __a) noexcept : _M_a{std::move(__a)} { }\n-\n-\t_Alloc& _M_alloc() noexcept { return _M_a._M_obj; }\n-\n-\t__gnu_cxx::__aligned_buffer<__remove_cv_t<_Tp>> _M_storage;\n-      };\n-\n     public:\n       using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;\n \n       // Alloc parameter is not a reference so doesn't alias anything in __args\n       template<typename... _Args>\n \t_Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)\n-\t: _M_impl(__a)\n+\t: _M_alloc{__a}\n \t{\n \t  // _GLIBCXX_RESOLVE_LIB_DEFECTS\n \t  // 2070.  allocate_shared should use allocator_traits<A>::construct\n@@ -674,14 +647,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       virtual void\n       _M_dispose() noexcept\n       {\n-\tallocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr());\n+\tallocator_traits<_Alloc>::destroy(_M_alloc._M_obj, _M_ptr());\n       }\n \n       // Override because the allocator needs to know the dynamic type\n       virtual void\n       _M_destroy() noexcept\n       {\n-\t__allocator_type __a(_M_impl._M_alloc());\n+\t__allocator_type __a(_M_alloc._M_obj);\n \t__allocated_ptr<__allocator_type> __guard_ptr{ __a, this };\n \tthis->~_Sp_counted_ptr_inplace();\n       }\n@@ -711,9 +684,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       }\n \n       __remove_cv_t<_Tp>*\n-      _M_ptr() noexcept { return _M_impl._M_storage._M_ptr(); }\n+      _M_ptr() noexcept { return _M_storage._M_ptr(); }\n \n-      _Impl _M_impl;\n+      [[__no_unique_address__]] _Sp_ebo_helper<_Alloc> _M_alloc;\n+      __gnu_cxx::__aligned_buffer<__remove_cv_t<_Tp>> _M_storage;\n     };\n \n #ifdef __glibcxx_smart_ptr_for_overwrite // C++ >= 20 && HOSTED\n","prefixes":["v2","2/3"]}