[libcxx-commits] [libcxx] [libc++] Annotate barrier functions that are defined in the dylib (PR #148542)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 13 10:54:20 PDT 2025


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

This can improve code gen slightly.


>From 25638e03fdc6c197755c5b2a8e6ae7111e44de3d Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 13 Jul 2025 19:53:49 +0200
Subject: [PATCH] [libc++] Annotate barrier functions that are defined in the
 dylib

---
 libcxx/include/barrier | 14 ++++++++------
 libcxx/src/barrier.cpp |  7 ++++---
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 00e196963f11c..fb40757a73fb6 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -97,19 +97,21 @@ using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t;
 
 class __barrier_algorithm_base;
 
-_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base*
-__construct_barrier_algorithm_base(ptrdiff_t& __expected);
+[[__gnu__::__returns_nonnull__, __gnu__::__malloc__]] _LIBCPP_AVAILABILITY_SYNC
+    _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base*
+    __construct_barrier_algorithm_base(ptrdiff_t& __expected);
 
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool
-__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept;
+__arrive_barrier_algorithm_base([[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier,
+                                __barrier_phase_t __old_phase) noexcept;
 
-_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
-__destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept;
+_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(
+    [[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier) noexcept;
 
 template <class _CompletionF>
 class __barrier_base {
   ptrdiff_t __expected_;
-  unique_ptr<__barrier_algorithm_base, void (*)(__barrier_algorithm_base*)> __base_;
+  unique_ptr<__barrier_algorithm_base, void (*)(_LIBCPP_NOESCAPE __barrier_algorithm_base*)> __base_;
   atomic<ptrdiff_t> __expected_adjustment_;
   _CompletionF __completion_;
   atomic<__barrier_phase_t> __phase_;
diff --git a/libcxx/src/barrier.cpp b/libcxx/src/barrier.cpp
index 868f1bfbaffc2..72c29b49ada39 100644
--- a/libcxx/src/barrier.cpp
+++ b/libcxx/src/barrier.cpp
@@ -60,11 +60,12 @@ class __barrier_algorithm_base {
 _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected) {
   return new __barrier_algorithm_base(__expected);
 }
-_LIBCPP_EXPORTED_FROM_ABI bool
-__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept {
+_LIBCPP_EXPORTED_FROM_ABI bool __arrive_barrier_algorithm_base(
+    _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept {
   return __barrier->__arrive(__old_phase);
 }
-_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept {
+_LIBCPP_EXPORTED_FROM_ABI void
+__destroy_barrier_algorithm_base(_LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier) noexcept {
   delete __barrier;
 }
 



More information about the libcxx-commits mailing list