[PATCH] D40385: [mips][compiler-rt] Provide 64bit atomic add and sub
Simon Dardis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 23 02:12:17 PST 2017
sdardis created this revision.
Herald added subscribers: arichardson, kubamracek.
r318733 introduced a build failure for native MIPS32 systems for xray due
to the lack of __sync_fetch_and_add / __syn_fetch_and_sub support. This patch
extends the existing support providing atomics so that xray can be
successfully built.
Repository:
rL LLVM
https://reviews.llvm.org/D40385
Files:
lib/sanitizer_common/sanitizer_atomic_clang.h
Index: lib/sanitizer_common/sanitizer_atomic_clang.h
===================================================================
--- lib/sanitizer_common/sanitizer_atomic_clang.h
+++ lib/sanitizer_common/sanitizer_atomic_clang.h
@@ -48,14 +48,30 @@
typename T::Type v, memory_order mo) {
(void)mo;
DCHECK(!((uptr)a % sizeof(*a)));
+#if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32
+ typedef typename T::Type Type;
+ if (sizeof(*a) == 8) {
+ Type volatile *val_ptr = const_cast<Type volatile *>(&a->val_dont_use);
+ return __mips_sync_fetch_and_add<u64>(
+ reinterpret_cast<u64 volatile *>(val_ptr), (u64)v);
+ }
+#endif
return __sync_fetch_and_add(&a->val_dont_use, v);
}
template<typename T>
INLINE typename T::Type atomic_fetch_sub(volatile T *a,
typename T::Type v, memory_order mo) {
(void)mo;
DCHECK(!((uptr)a % sizeof(*a)));
+#if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32
+ typedef typename T::Type Type;
+ if (sizeof(*a) == 8) {
+ Type volatile *val_ptr = const_cast<Type volatile *>(&a->val_dont_use);
+ return __mips_sync_fetch_and_add<u64>(
+ reinterpret_cast<u64 volatile *>(val_ptr), -((u64)(v)));
+ }
+#endif
return __sync_fetch_and_add(&a->val_dont_use, -v);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40385.124052.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171123/3226c65c/attachment.bin>
More information about the llvm-commits
mailing list