tsan: add failure memory order to atomic compare exchange functions

llvm-svn: 168518
This commit is contained in:
Dmitry Vyukov 2012-11-23 15:51:45 +00:00
parent f22c697f58
commit 195eda9922
2 changed files with 48 additions and 39 deletions

View File

@ -198,7 +198,8 @@ static T AtomicFetchXor(ThreadState *thr, uptr pc, volatile T *a, T v,
template<typename T> template<typename T>
static bool AtomicCAS(ThreadState *thr, uptr pc, static bool AtomicCAS(ThreadState *thr, uptr pc,
volatile T *a, T *c, T v, morder mo) { volatile T *a, T *c, T v, morder mo, morder fmo) {
(void)fmo;
if (IsReleaseOrder(mo)) if (IsReleaseOrder(mo))
Release(thr, pc, (uptr)a); Release(thr, pc, (uptr)a);
T cc = *c; T cc = *c;
@ -213,8 +214,8 @@ static bool AtomicCAS(ThreadState *thr, uptr pc,
template<typename T> template<typename T>
static T AtomicCAS(ThreadState *thr, uptr pc, static T AtomicCAS(ThreadState *thr, uptr pc,
volatile T *a, T c, T v, morder mo) { volatile T *a, T c, T v, morder mo, morder fmo) {
AtomicCAS(thr, pc, a, &c, v, mo); AtomicCAS(thr, pc, a, &c, v, mo, fmo);
return c; return c;
} }
@ -351,62 +352,62 @@ a64 __tsan_atomic64_fetch_xor(volatile a64 *a, a64 v, morder mo) {
} }
int __tsan_atomic8_compare_exchange_strong(volatile a8 *a, a8 *c, a8 v, int __tsan_atomic8_compare_exchange_strong(volatile a8 *a, a8 *c, a8 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic16_compare_exchange_strong(volatile a16 *a, a16 *c, a16 v, int __tsan_atomic16_compare_exchange_strong(volatile a16 *a, a16 *c, a16 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic32_compare_exchange_strong(volatile a32 *a, a32 *c, a32 v, int __tsan_atomic32_compare_exchange_strong(volatile a32 *a, a32 *c, a32 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic64_compare_exchange_strong(volatile a64 *a, a64 *c, a64 v, int __tsan_atomic64_compare_exchange_strong(volatile a64 *a, a64 *c, a64 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic8_compare_exchange_weak(volatile a8 *a, a8 *c, a8 v, int __tsan_atomic8_compare_exchange_weak(volatile a8 *a, a8 *c, a8 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic16_compare_exchange_weak(volatile a16 *a, a16 *c, a16 v, int __tsan_atomic16_compare_exchange_weak(volatile a16 *a, a16 *c, a16 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic32_compare_exchange_weak(volatile a32 *a, a32 *c, a32 v, int __tsan_atomic32_compare_exchange_weak(volatile a32 *a, a32 *c, a32 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
int __tsan_atomic64_compare_exchange_weak(volatile a64 *a, a64 *c, a64 v, int __tsan_atomic64_compare_exchange_weak(volatile a64 *a, a64 *c, a64 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
a8 __tsan_atomic8_compare_exchange_val(volatile a8 *a, a8 c, a8 v, a8 __tsan_atomic8_compare_exchange_val(volatile a8 *a, a8 c, a8 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
a16 __tsan_atomic16_compare_exchange_val(volatile a16 *a, a16 c, a16 v, a16 __tsan_atomic16_compare_exchange_val(volatile a16 *a, a16 c, a16 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
a32 __tsan_atomic32_compare_exchange_val(volatile a32 *a, a32 c, a32 v, a32 __tsan_atomic32_compare_exchange_val(volatile a32 *a, a32 c, a32 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
a64 __tsan_atomic64_compare_exchange_val(volatile a64 *a, a64 c, a64 v, a64 __tsan_atomic64_compare_exchange_val(volatile a64 *a, a64 c, a64 v,
morder mo) { morder mo, morder fmo) {
SCOPED_ATOMIC(CAS, a, c, v, mo); SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
} }
void __tsan_atomic_thread_fence(morder mo) { void __tsan_atomic_thread_fence(morder mo) {

View File

@ -106,35 +106,43 @@ __tsan_atomic64 __tsan_atomic64_fetch_xor(volatile __tsan_atomic64 *a,
__tsan_atomic64 v, __tsan_memory_order mo); __tsan_atomic64 v, __tsan_memory_order mo);
int __tsan_atomic8_compare_exchange_weak(volatile __tsan_atomic8 *a, int __tsan_atomic8_compare_exchange_weak(volatile __tsan_atomic8 *a,
__tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo); __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic16_compare_exchange_weak(volatile __tsan_atomic16 *a, int __tsan_atomic16_compare_exchange_weak(volatile __tsan_atomic16 *a,
__tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo); __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic32_compare_exchange_weak(volatile __tsan_atomic32 *a, int __tsan_atomic32_compare_exchange_weak(volatile __tsan_atomic32 *a,
__tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo); __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic64_compare_exchange_weak(volatile __tsan_atomic64 *a, int __tsan_atomic64_compare_exchange_weak(volatile __tsan_atomic64 *a,
__tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo); __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic8_compare_exchange_strong(volatile __tsan_atomic8 *a, int __tsan_atomic8_compare_exchange_strong(volatile __tsan_atomic8 *a,
__tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo); __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic16_compare_exchange_strong(volatile __tsan_atomic16 *a, int __tsan_atomic16_compare_exchange_strong(volatile __tsan_atomic16 *a,
__tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo); __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic32_compare_exchange_strong(volatile __tsan_atomic32 *a, int __tsan_atomic32_compare_exchange_strong(volatile __tsan_atomic32 *a,
__tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo); __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
int __tsan_atomic64_compare_exchange_strong(volatile __tsan_atomic64 *a, int __tsan_atomic64_compare_exchange_strong(volatile __tsan_atomic64 *a,
__tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo); __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo,
__tsan_memory_order fail_mo);
__tsan_atomic8 __tsan_atomic8_compare_exchange_val( __tsan_atomic8 __tsan_atomic8_compare_exchange_val(
volatile __tsan_atomic8 *a, __tsan_atomic8 c, __tsan_atomic8 v, volatile __tsan_atomic8 *a, __tsan_atomic8 c, __tsan_atomic8 v,
__tsan_memory_order mo); __tsan_memory_order mo, __tsan_memory_order fail_mo);
__tsan_atomic16 __tsan_atomic16_compare_exchange_val( __tsan_atomic16 __tsan_atomic16_compare_exchange_val(
volatile __tsan_atomic16 *a, __tsan_atomic16 c, __tsan_atomic16 v, volatile __tsan_atomic16 *a, __tsan_atomic16 c, __tsan_atomic16 v,
__tsan_memory_order mo); __tsan_memory_order mo, __tsan_memory_order fail_mo);
__tsan_atomic32 __tsan_atomic32_compare_exchange_val( __tsan_atomic32 __tsan_atomic32_compare_exchange_val(
volatile __tsan_atomic32 *a, __tsan_atomic32 c, __tsan_atomic32 v, volatile __tsan_atomic32 *a, __tsan_atomic32 c, __tsan_atomic32 v,
__tsan_memory_order mo); __tsan_memory_order mo, __tsan_memory_order fail_mo);
__tsan_atomic64 __tsan_atomic64_compare_exchange_val( __tsan_atomic64 __tsan_atomic64_compare_exchange_val(
volatile __tsan_atomic64 *a, __tsan_atomic64 c, __tsan_atomic64 v, volatile __tsan_atomic64 *a, __tsan_atomic64 c, __tsan_atomic64 v,
__tsan_memory_order mo); __tsan_memory_order mo, __tsan_memory_order fail_mo);
void __tsan_atomic_thread_fence(__tsan_memory_order mo); void __tsan_atomic_thread_fence(__tsan_memory_order mo);
void __tsan_atomic_signal_fence(__tsan_memory_order mo); void __tsan_atomic_signal_fence(__tsan_memory_order mo);