[gcc r15-1290] libstdc++: Optimize std::add_lvalue_reference compilation performance

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


https://gcc.gnu.org/g:13a07c1420b35ac7649f7d8a776b553ec5c26269

commit r15-1290-g13a07c1420b35ac7649f7d8a776b553ec5c26269
Author: Ken Matsui <kmatsui@gcc.gnu.org>
Date:   Wed Feb 14 23:22:57 2024 -0800

    libstdc++: Optimize std::add_lvalue_reference compilation performance
    
    This patch optimizes the compilation performance of
    std::add_lvalue_reference by dispatching to the new
    __add_lvalue_reference built-in trait.
    
    libstdc++-v3/ChangeLog:
    
            * include/std/type_traits (__add_lval_ref_t): Use
            __add_lvalue_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 0ef112926575..79983ea980a1 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1157,6 +1157,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /// @cond undocumented
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_lvalue_reference)
+  template<typename _Tp>
+    using __add_lval_ref_t = __add_lvalue_reference(_Tp);
+#else
   template<typename _Tp, typename = void>
     struct __add_lvalue_reference_helper
     { using type = _Tp; };
@@ -1167,6 +1171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type;
+#endif
   /// @endcond
 
   /// is_copy_constructible


More information about the Gcc-cvs mailing list