diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h index 7580ac2dc5889..4a39889e534a0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h @@ -50,11 +50,8 @@ inline typename T::Type atomic_load( __sync_synchronize(); } } else { - // 64-bit load on 32-bit platform. - // Gross, but simple and reliable. - // Assume that it is not in read-only memory. - v = __sync_fetch_and_add( - const_cast(&a->val_dont_use), 0); + __atomic_load(const_cast(&a->val_dont_use), &v, + __ATOMIC_SEQ_CST); } return v; } @@ -79,16 +76,7 @@ inline void atomic_store(volatile T *a, typename T::Type v, memory_order mo) { __sync_synchronize(); } } else { - // 64-bit store on 32-bit platform. - // Gross, but simple and reliable. - typename T::Type cmp = a->val_dont_use; - typename T::Type cur; - for (;;) { - cur = __sync_val_compare_and_swap(&a->val_dont_use, cmp, v); - if (cur == cmp || cur == v) - break; - cmp = cur; - } + __atomic_store(&a->val_dont_use, &v, __ATOMIC_SEQ_CST); } }