[libcxx-commits] [libcxx] [libc++] Mark __{emplace, push}_back_slow_path as noinline (PR #94379)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 4 09:54:12 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/94379

These are almost ceratinly intended to not be inlined. This significantly reduces code size when `push_back` and `emplace_back` are used heavily.

Fixes #94360


>From 5348436c10cf895cf682953cbd31c0a62f678fdd Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 4 Jun 2024 18:49:06 +0200
Subject: [PATCH] [libc++] Mark __{emplace,push}_back_slow_path as noinline

---
 libcxx/include/vector | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/vector b/libcxx/include/vector
index cbfc2cefa1fd9..c542b3e70cdd1 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -844,10 +844,11 @@ private:
   }
 
   template <class _Up>
-  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __push_back_slow_path(_Up&& __x);
+  _LIBCPP_NOINLINE _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __push_back_slow_path(_Up&& __x);
 
   template <class... _Args>
-  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args);
+  _LIBCPP_NOINLINE _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer
+  __emplace_back_slow_path(_Args&&... __args);
 
   // The following functions are no-ops outside of AddressSanitizer mode.
   // We call annotations for every allocator, unless explicitly disabled.



More information about the libcxx-commits mailing list