Skip to content

Commit 82c16f8

Browse files
committed
Simplify
1 parent cbbe61c commit 82c16f8

File tree

3 files changed

+116
-120
lines changed

3 files changed

+116
-120
lines changed

compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ int setcontext(const ucontext_t *ucp);
4040

4141
namespace __tsan {
4242

43-
// The non-barrier versions of OSAtomic* functions are semantically
44-
// morder::relaxed, but the two variants (e.g. OSAtomicAdd32 and
45-
// OSAtomicAdd32Barrier) are actually aliases of each other, and we cannot have
46-
// different interceptors for them, because they're actually the same function.
47-
// Thus, we have to stay conservative and treat the non-barrier versions as
48-
// morder::acq_rel.
49-
static constexpr morder kMacOrderBarrier = morder::acq_rel;
50-
static constexpr morder kMacOrderNonBarrier = morder::acq_rel;
51-
static constexpr morder kMacFailureOrder = morder::relaxed;
43+
// The non-barrier versions of OSAtomic* functions are semantically mo_relaxed,
44+
// but the two variants (e.g. OSAtomicAdd32 and OSAtomicAdd32Barrier) are
45+
// actually aliases of each other, and we cannot have different interceptors for
46+
// them, because they're actually the same function. Thus, we have to stay
47+
// conservative and treat the non-barrier versions as mo_acq_rel.
48+
static constexpr morder kMacOrderBarrier = mo_acq_rel;
49+
static constexpr morder kMacOrderNonBarrier = mo_acq_rel;
50+
static constexpr morder kMacFailureOrder = mo_relaxed;
5251

5352
# define OSATOMIC_INTERCEPTOR(return_t, t, tsan_t, f, tsan_atomic_f, mo) \
5453
TSAN_INTERCEPTOR(return_t, f, t x, volatile t *ptr) { \
@@ -465,7 +464,7 @@ struct fake_shared_weak_count {
465464
// Shared and weak pointers in C++ maintain reference counts via atomics in
466465
// libc++.dylib, which are TSan-invisible, and this leads to false positives in
467466
// destructor code. These interceptors re-implements the whole functions so that
468-
// the morder::acq_rel semantics of the atomic decrement are visible.
467+
// the mo_acq_rel semantics of the atomic decrement are visible.
469468
//
470469
// Unfortunately, the interceptors cannot simply Acquire/Release some sync
471470
// object and call the original function, because it would have a race between
@@ -480,11 +479,11 @@ STDCXX_INTERCEPTOR(void, _ZNSt3__119__shared_weak_count16__release_sharedEv,
480479

481480
SCOPED_TSAN_INTERCEPTOR(_ZNSt3__119__shared_weak_count16__release_sharedEv,
482481
o);
483-
if (__tsan_atomic64_fetch_add(&o->shared_owners, -1, morder::release) == 0) {
482+
if (__tsan_atomic64_fetch_add(&o->shared_owners, -1, mo_release) == 0) {
484483
Acquire(thr, pc, (uptr)&o->shared_owners);
485484
o->on_zero_shared();
486-
if (__tsan_atomic64_fetch_add(&o->shared_weak_owners, -1,
487-
morder::release) == 0) {
485+
if (__tsan_atomic64_fetch_add(&o->shared_weak_owners, -1, mo_release) ==
486+
0) {
488487
Acquire(thr, pc, (uptr)&o->shared_weak_owners);
489488
o->on_zero_shared_weak();
490489
}
@@ -497,7 +496,7 @@ STDCXX_INTERCEPTOR(bool, _ZNSt3__114__shared_count16__release_sharedEv,
497496
return REAL(_ZNSt3__114__shared_count16__release_sharedEv)(o);
498497

499498
SCOPED_TSAN_INTERCEPTOR(_ZNSt3__114__shared_count16__release_sharedEv, o);
500-
if (__tsan_atomic64_fetch_add(&o->shared_owners, -1, morder::release) == 0) {
499+
if (__tsan_atomic64_fetch_add(&o->shared_owners, -1, mo_release) == 0) {
501500
Acquire(thr, pc, (uptr)&o->shared_owners);
502501
o->on_zero_shared();
503502
return true;

compiler-rt/lib/tsan/rtl/tsan_interface.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ __extension__ typedef __int128 a128;
219219

220220
// Part of ABI, do not change.
221221
// https://github.com/llvm/llvm-project/blob/main/libcxx/include/atomic
222-
enum class morder : int {
223-
relaxed,
224-
consume,
225-
acquire,
226-
release,
227-
acq_rel,
228-
seq_cst
229-
};
222+
typedef enum {
223+
mo_relaxed,
224+
mo_consume,
225+
mo_acquire,
226+
mo_release,
227+
mo_acq_rel,
228+
mo_seq_cst
229+
} morder;
230230

231231
struct ThreadState;
232232

0 commit comments

Comments
 (0)