[compiler-rt] cfed8d0 - tsan: rename test Mutex to UserMutex
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 23 00:12:11 PDT 2021
Author: Dmitry Vyukov
Date: 2021-07-23T09:12:05+02:00
New Revision: cfed8d0fafac43b45bbbe6248e1c29b17c91de67
URL: https://github.com/llvm/llvm-project/commit/cfed8d0fafac43b45bbbe6248e1c29b17c91de67
DIFF: https://github.com/llvm/llvm-project/commit/cfed8d0fafac43b45bbbe6248e1c29b17c91de67.diff
LOG: tsan: rename test Mutex to UserMutex
Rename Mutex class in tests to avoid conflicts with sanitizer_common Mutex.
Reviewed By: vitalybuka, melver
Differential Revision: https://reviews.llvm.org/D106547
Added:
Modified:
compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp
compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp
compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp
compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h
compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp
index 36ca9b5e03584..f65aebc02bba4 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_bench.cpp
@@ -89,7 +89,7 @@ TEST(DISABLED_BENCH, FuncCall) {
}
TEST(DISABLED_BENCH, MutexLocal) {
- Mutex m;
+ UserMutex m;
ScopedThread().Create(m);
for (int i = 0; i < 50; i++) {
ScopedThread t;
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp
index 1825c96d7438e..b91aead3dd74e 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_mop.cpp
@@ -65,7 +65,7 @@ TEST(ThreadSanitizer, WriteThenRead) {
}
TEST(ThreadSanitizer, WriteThenLockedRead) {
- Mutex m(Mutex::RW);
+ UserMutex m(UserMutex::RW);
MainThread t0;
t0.Create(m);
MemLoc l;
@@ -84,7 +84,7 @@ TEST(ThreadSanitizer, WriteThenLockedRead) {
}
TEST(ThreadSanitizer, LockedWriteThenRead) {
- Mutex m(Mutex::RW);
+ UserMutex m(UserMutex::RW);
MainThread t0;
t0.Create(m);
MemLoc l;
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp
index dae9c94c339b9..663811ecd760c 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_mutex.cpp
@@ -20,7 +20,7 @@ namespace __tsan {
TEST(ThreadSanitizer, BasicMutex) {
ScopedThread t;
- Mutex m;
+ UserMutex m;
t.Create(m);
t.Lock(m);
@@ -38,7 +38,7 @@ TEST(ThreadSanitizer, BasicMutex) {
TEST(ThreadSanitizer, BasicSpinMutex) {
ScopedThread t;
- Mutex m(Mutex::Spin);
+ UserMutex m(UserMutex::Spin);
t.Create(m);
t.Lock(m);
@@ -56,7 +56,7 @@ TEST(ThreadSanitizer, BasicSpinMutex) {
TEST(ThreadSanitizer, BasicRwMutex) {
ScopedThread t;
- Mutex m(Mutex::RW);
+ UserMutex m(UserMutex::RW);
t.Create(m);
t.Lock(m);
@@ -92,7 +92,7 @@ TEST(ThreadSanitizer, BasicRwMutex) {
}
TEST(ThreadSanitizer, Mutex) {
- Mutex m;
+ UserMutex m;
MainThread t0;
t0.Create(m);
@@ -108,7 +108,7 @@ TEST(ThreadSanitizer, Mutex) {
}
TEST(ThreadSanitizer, SpinMutex) {
- Mutex m(Mutex::Spin);
+ UserMutex m(UserMutex::Spin);
MainThread t0;
t0.Create(m);
@@ -124,7 +124,7 @@ TEST(ThreadSanitizer, SpinMutex) {
}
TEST(ThreadSanitizer, RwMutex) {
- Mutex m(Mutex::RW);
+ UserMutex m(UserMutex::RW);
MainThread t0;
t0.Create(m);
@@ -150,7 +150,7 @@ TEST(ThreadSanitizer, RwMutex) {
TEST(ThreadSanitizer, StaticMutex) {
// Emulates statically initialized mutex.
- Mutex m;
+ UserMutex m;
m.StaticInit();
{
ScopedThread t1, t2;
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h
index df535150a994b..b2d766ad8e9ba 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util.h
@@ -28,7 +28,7 @@ class MemLoc {
void operator = (const MemLoc&);
};
-class Mutex {
+class UserMutex {
public:
enum Type {
Normal,
@@ -40,8 +40,8 @@ class Mutex {
#endif
};
- explicit Mutex(Type type = Normal);
- ~Mutex();
+ explicit UserMutex(Type type = Normal);
+ ~UserMutex();
void Init();
void StaticInit(); // Emulates static initialization (tsan invisible).
@@ -59,8 +59,8 @@ class Mutex {
bool alive_;
const Type type_;
- Mutex(const Mutex&);
- void operator = (const Mutex&);
+ UserMutex(const UserMutex &);
+ void operator=(const UserMutex &);
};
// A thread is started in CTOR and joined in DTOR.
@@ -100,14 +100,14 @@ class ScopedThread {
void Call(void(*pc)());
void Return();
- void Create(const Mutex &m);
- void Destroy(const Mutex &m);
- void Lock(const Mutex &m);
- bool TryLock(const Mutex &m);
- void Unlock(const Mutex &m);
- void ReadLock(const Mutex &m);
- bool TryReadLock(const Mutex &m);
- void ReadUnlock(const Mutex &m);
+ void Create(const UserMutex &m);
+ void Destroy(const UserMutex &m);
+ void Lock(const UserMutex &m);
+ bool TryLock(const UserMutex &m);
+ void Unlock(const UserMutex &m);
+ void ReadLock(const UserMutex &m);
+ bool TryReadLock(const UserMutex &m);
+ void ReadUnlock(const UserMutex &m);
void Memcpy(void *dst, const void *src, int size, bool expect_race = false);
void Memset(void *dst, int val, int size, bool expect_race = false);
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp
index 733e5d282a379..91fed384475ee 100644
--- a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp
+++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cpp
@@ -90,16 +90,11 @@ MemLoc::MemLoc(int offset_from_aligned)
MemLoc::~MemLoc() {
}
-Mutex::Mutex(Type type)
- : alive_()
- , type_(type) {
-}
+UserMutex::UserMutex(Type type) : alive_(), type_(type) {}
-Mutex::~Mutex() {
- CHECK(!alive_);
-}
+UserMutex::~UserMutex() { CHECK(!alive_); }
-void Mutex::Init() {
+void UserMutex::Init() {
CHECK(!alive_);
alive_ = true;
if (type_ == Normal)
@@ -114,7 +109,7 @@ void Mutex::Init() {
CHECK(0);
}
-void Mutex::StaticInit() {
+void UserMutex::StaticInit() {
CHECK(!alive_);
CHECK(type_ == Normal);
alive_ = true;
@@ -122,7 +117,7 @@ void Mutex::StaticInit() {
memcpy(mtx_, &tmp, sizeof(tmp));
}
-void Mutex::Destroy() {
+void UserMutex::Destroy() {
CHECK(alive_);
alive_ = false;
if (type_ == Normal)
@@ -135,7 +130,7 @@ void Mutex::Destroy() {
CHECK_EQ(__interceptor_pthread_rwlock_destroy((pthread_rwlock_t*)mtx_), 0);
}
-void Mutex::Lock() {
+void UserMutex::Lock() {
CHECK(alive_);
if (type_ == Normal)
CHECK_EQ(__interceptor_pthread_mutex_lock((pthread_mutex_t*)mtx_), 0);
@@ -147,7 +142,7 @@ void Mutex::Lock() {
CHECK_EQ(__interceptor_pthread_rwlock_wrlock((pthread_rwlock_t*)mtx_), 0);
}
-bool Mutex::TryLock() {
+bool UserMutex::TryLock() {
CHECK(alive_);
if (type_ == Normal)
return __interceptor_pthread_mutex_trylock((pthread_mutex_t*)mtx_) == 0;
@@ -160,7 +155,7 @@ bool Mutex::TryLock() {
return false;
}
-void Mutex::Unlock() {
+void UserMutex::Unlock() {
CHECK(alive_);
if (type_ == Normal)
CHECK_EQ(__interceptor_pthread_mutex_unlock((pthread_mutex_t*)mtx_), 0);
@@ -172,19 +167,19 @@ void Mutex::Unlock() {
CHECK_EQ(__interceptor_pthread_rwlock_unlock((pthread_rwlock_t*)mtx_), 0);
}
-void Mutex::ReadLock() {
+void UserMutex::ReadLock() {
CHECK(alive_);
CHECK(type_ == RW);
CHECK_EQ(__interceptor_pthread_rwlock_rdlock((pthread_rwlock_t*)mtx_), 0);
}
-bool Mutex::TryReadLock() {
+bool UserMutex::TryReadLock() {
CHECK(alive_);
CHECK(type_ == RW);
return __interceptor_pthread_rwlock_tryrdlock((pthread_rwlock_t*)mtx_) == 0;
}
-void Mutex::ReadUnlock() {
+void UserMutex::ReadUnlock() {
CHECK(alive_);
CHECK(type_ == RW);
CHECK_EQ(__interceptor_pthread_rwlock_unlock((pthread_rwlock_t*)mtx_), 0);
@@ -310,28 +305,28 @@ void ScopedThread::Impl::HandleEvent(Event *ev) {
__tsan_func_exit();
break;
case Event::MUTEX_CREATE:
- static_cast<Mutex*>(ev->ptr)->Init();
+ static_cast<UserMutex *>(ev->ptr)->Init();
break;
case Event::MUTEX_DESTROY:
- static_cast<Mutex*>(ev->ptr)->Destroy();
+ static_cast<UserMutex *>(ev->ptr)->Destroy();
break;
case Event::MUTEX_LOCK:
- static_cast<Mutex*>(ev->ptr)->Lock();
+ static_cast<UserMutex *>(ev->ptr)->Lock();
break;
case Event::MUTEX_TRYLOCK:
- ev->res = static_cast<Mutex*>(ev->ptr)->TryLock();
+ ev->res = static_cast<UserMutex *>(ev->ptr)->TryLock();
break;
case Event::MUTEX_UNLOCK:
- static_cast<Mutex*>(ev->ptr)->Unlock();
+ static_cast<UserMutex *>(ev->ptr)->Unlock();
break;
case Event::MUTEX_READLOCK:
- static_cast<Mutex*>(ev->ptr)->ReadLock();
+ static_cast<UserMutex *>(ev->ptr)->ReadLock();
break;
case Event::MUTEX_TRYREADLOCK:
- ev->res = static_cast<Mutex*>(ev->ptr)->TryReadLock();
+ ev->res = static_cast<UserMutex *>(ev->ptr)->TryReadLock();
break;
case Event::MUTEX_READUNLOCK:
- static_cast<Mutex*>(ev->ptr)->ReadUnlock();
+ static_cast<UserMutex *>(ev->ptr)->ReadUnlock();
break;
case Event::MEMCPY:
__interceptor_memcpy(ev->ptr, (void*)ev->arg, ev->arg2);
@@ -440,44 +435,44 @@ void ScopedThread::Return() {
impl_->send(&event);
}
-void ScopedThread::Create(const Mutex &m) {
+void ScopedThread::Create(const UserMutex &m) {
Event event(Event::MUTEX_CREATE, &m);
impl_->send(&event);
}
-void ScopedThread::Destroy(const Mutex &m) {
+void ScopedThread::Destroy(const UserMutex &m) {
Event event(Event::MUTEX_DESTROY, &m);
impl_->send(&event);
}
-void ScopedThread::Lock(const Mutex &m) {
+void ScopedThread::Lock(const UserMutex &m) {
Event event(Event::MUTEX_LOCK, &m);
impl_->send(&event);
}
-bool ScopedThread::TryLock(const Mutex &m) {
+bool ScopedThread::TryLock(const UserMutex &m) {
Event event(Event::MUTEX_TRYLOCK, &m);
impl_->send(&event);
return event.res;
}
-void ScopedThread::Unlock(const Mutex &m) {
+void ScopedThread::Unlock(const UserMutex &m) {
Event event(Event::MUTEX_UNLOCK, &m);
impl_->send(&event);
}
-void ScopedThread::ReadLock(const Mutex &m) {
+void ScopedThread::ReadLock(const UserMutex &m) {
Event event(Event::MUTEX_READLOCK, &m);
impl_->send(&event);
}
-bool ScopedThread::TryReadLock(const Mutex &m) {
+bool ScopedThread::TryReadLock(const UserMutex &m) {
Event event(Event::MUTEX_TRYREADLOCK, &m);
impl_->send(&event);
return event.res;
}
-void ScopedThread::ReadUnlock(const Mutex &m) {
+void ScopedThread::ReadUnlock(const UserMutex &m) {
Event event(Event::MUTEX_READUNLOCK, &m);
impl_->send(&event);
}
More information about the llvm-commits
mailing list