[PATCH] D118024: [sanitizer_common] Use atomic builtin in sanitizer_atomic_clang.h
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 29 13:53:31 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG067650fd12fc: [sanitizer_common] Use atomic builtin in sanitizer_atomic_clang.h (authored by ro).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118024/new/
https://reviews.llvm.org/D118024
Files:
compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
Index: compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
@@ -74,13 +74,12 @@
inline bool atomic_compare_exchange_strong(volatile T *a, typename T::Type *cmp,
typename T::Type xchg,
memory_order mo) {
- typedef typename T::Type Type;
- Type cmpv = *cmp;
- Type prev;
- prev = __sync_val_compare_and_swap(&a->val_dont_use, cmpv, xchg);
- if (prev == cmpv) return true;
- *cmp = prev;
- return false;
+ // Transitioned from __sync_val_compare_and_swap to support targets like
+ // SPARC V8 that cannot inline atomic cmpxchg. __atomic_compare_exchange
+ // can then be resolved from libatomic. __ATOMIC_SEQ_CST is used to best
+ // match the __sync builtin memory order.
+ return __atomic_compare_exchange(&a->val_dont_use, cmp, &xchg, false,
+ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}
template<typename T>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118024.404303.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220129/957e6703/attachment.bin>
More information about the llvm-commits
mailing list