[compiler-rt] 6c1d74d - sanitizer_common: don't use [[no_unique_address]]
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 23 01:55:45 PDT 2021
Author: Dmitry Vyukov
Date: 2021-07-23T10:55:40+02:00
New Revision: 6c1d74d5eda2a8e21e1037eb1b2015cb58683a12
URL: https://github.com/llvm/llvm-project/commit/6c1d74d5eda2a8e21e1037eb1b2015cb58683a12
DIFF: https://github.com/llvm/llvm-project/commit/6c1d74d5eda2a8e21e1037eb1b2015cb58683a12.diff
LOG: sanitizer_common: don't use [[no_unique_address]]
https://lab.llvm.org/buildbot#builders/112/builds/7881
https://lab.llvm.org/buildbot#builders/121/builds/9907
https://lab.llvm.org/buildbot#builders/105/builds/12770
../../sanitizer_common/sanitizer_mutex.h:288:38: error:
'no_unique_address' attribute directive ignored [-Werror=attributes]
[[no_unique_address]] CheckedMutex checked_;
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D106637
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h b/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
index a78eb4a7f996..cbd1c25eb69f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
@@ -149,12 +149,15 @@ class CheckedMutex {
};
// Reader-writer mutex.
-class MUTEX Mutex {
+// Derive from CheckedMutex for the purposes of EBO.
+// We could make it a field marked with [[no_unique_address]],
+// but this attribute is not supported by some older compilers.
+class MUTEX Mutex : CheckedMutex {
public:
- constexpr Mutex(MutexType type = MutexUnchecked) : checked_(type) {}
+ constexpr Mutex(MutexType type = MutexUnchecked) : CheckedMutex(type) {}
void Lock() ACQUIRE() {
- checked_.Lock();
+ CheckedMutex::Lock();
u64 reset_mask = ~0ull;
u64 state = atomic_load_relaxed(&state_);
const uptr kMaxSpinIters = 1500;
@@ -200,7 +203,7 @@ class MUTEX Mutex {
}
void Unlock() RELEASE() {
- checked_.Unlock();
+ CheckedMutex::Unlock();
bool wake_writer;
u64 wake_readers;
u64 new_state;
@@ -229,7 +232,7 @@ class MUTEX Mutex {
}
void ReadLock() ACQUIRE_SHARED() {
- checked_.Lock();
+ CheckedMutex::Lock();
bool locked;
u64 new_state;
u64 state = atomic_load_relaxed(&state_);
@@ -250,7 +253,7 @@ class MUTEX Mutex {
}
void ReadUnlock() RELEASE_SHARED() {
- checked_.Unlock();
+ CheckedMutex::Unlock();
bool wake;
u64 new_state;
u64 state = atomic_load_relaxed(&state_);
@@ -285,7 +288,6 @@ class MUTEX Mutex {
}
private:
- [[no_unique_address]] CheckedMutex checked_;
atomic_uint64_t state_ = {0};
Semaphore writers_;
Semaphore readers_;
More information about the llvm-commits
mailing list