[gcc r15-1291] libstdc++: Optimize std::add_rvalue_reference compilation performance

Ken Matsui kmatsui@gcc.gnu.org
Thu Jun 13 14:00:35 GMT 2024


https://gcc.gnu.org/g:3f3eb16743a126ebe6d200ad0091495b6f11962a

commit r15-1291-g3f3eb16743a126ebe6d200ad0091495b6f11962a
Author: Ken Matsui <kmatsui@gcc.gnu.org>
Date:   Thu Feb 15 00:49:55 2024 -0800

    libstdc++: Optimize std::add_rvalue_reference compilation performance
    
    This patch optimizes the compilation performance of
    std::add_rvalue_reference by dispatching to the new
    __add_rvalue_reference built-in trait.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/type_traits (__add_rval_ref_t): Use
            __add_rvalue_reference built-in trait.
    
    Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
    Reviewed-by: Patrick Palka <ppalka@redhat.com>
    Reviewed-by: Jonathan Wakely <jwakely@redhat.com>

Diff:
---
 libstdc++-v3/include/std/type_traits | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 79983ea980a1..a31de2ee4abb 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1184,6 +1184,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /// @cond undocumented
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference)
+  template<typename _Tp>
+    using __add_rval_ref_t = __add_rvalue_reference(_Tp);
+#else
   template<typename _Tp, typename = void>
     struct __add_rvalue_reference_helper
     { using type = _Tp; };
@@ -1194,6 +1198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type;
+#endif
   /// @endcond
 
   /// is_move_constructible


More information about the Gcc-cvs mailing list