[compiler-rt] [scudo] Add missing thread-safety analysis annotations. (PR #68072)

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 00:29:11 PDT 2023


https://github.com/legrosbuffle created https://github.com/llvm/llvm-project/pull/68072

This avoids new warnings from `-Wthread-safety` after https://github.com/llvm/llvm-project/pull/67776, see https://github.com/llvm/llvm-project/pull/67795.

Note that this are not really useful since thread safety analysis is disabled anyway here: llvm-project/compiler-rt/lib/scudo/standalone/tsd_exclusive.h:172

>From bee8776a08f1c0008e15b4babd613de377bb7c8b Mon Sep 17 00:00:00 2001
From: Clement Courbet <courbet at google.com>
Date: Tue, 3 Oct 2023 09:23:59 +0200
Subject: [PATCH] [scudo] Add missing thread-safety analysis annotations.

This avoids new warnings from `-Wthread-safety` after https://github.com/llvm/llvm-project/pull/67776, see
https://github.com/llvm/llvm-project/pull/67795.

Note that this are not really useful since thread safety analysis is disabled anyway here:
llvm-project/compiler-rt/lib/scudo/standalone/tsd_exclusive.h:172
---
 compiler-rt/lib/scudo/standalone/tsd.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/tsd.h b/compiler-rt/lib/scudo/standalone/tsd.h
index f4fa545de5e0468..d41142a2cf014e6 100644
--- a/compiler-rt/lib/scudo/standalone/tsd.h
+++ b/compiler-rt/lib/scudo/standalone/tsd.h
@@ -53,7 +53,7 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
   inline void unlock() NO_THREAD_SAFETY_ANALYSIS { Mutex.unlock(); }
   inline uptr getPrecedence() { return atomic_load_relaxed(&Precedence); }
 
-  void commitBack(Allocator *Instance) ASSERT_CAPABILITY(Mutex) {
+  void commitBack(Allocator *Instance) ASSERT_CAPABILITY(Mutex) REQUIRES(Mutex) {
     Instance->commitBack(this);
   }
 
@@ -66,11 +66,11 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
   // TODO(chiahungduan): Ideally, we want to do `Mutex.assertHeld` but acquiring
   // TSD doesn't always require holding the lock. Add this assertion while the
   // lock is always acquired.
-  typename Allocator::CacheT &getCache() ASSERT_CAPABILITY(Mutex) {
+  typename Allocator::CacheT &getCache() ASSERT_CAPABILITY(Mutex) REQUIRES(Mutex) {
     return Cache;
   }
   typename Allocator::QuarantineCacheT &getQuarantineCache()
-      ASSERT_CAPABILITY(Mutex) {
+      ASSERT_CAPABILITY(Mutex) REQUIRES(Mutex) {
     return QuarantineCache;
   }
 



More information about the llvm-commits mailing list