[compiler-rt] r274634 - [asan Win64] Implement atomic_compare_exchange_strong for 8 bit
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 09:44:13 PDT 2016
On Wed, Jul 6, 2016 at 9:33 AM, Etienne Bergeron via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: etienneb
> Date: Wed Jul 6 11:33:57 2016
> New Revision: 274634
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274634&view=rev
> Log:
> [asan Win64] Implement atomic_compare_exchange_strong for 8 bit
>
> Patch by: Wei Wang
> Differential Revision: http://reviews.llvm.org/D21950
>
>
> Modified:
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_atomic_msvc.h
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_atomic_msvc.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_atomic_msvc.h?rev=274634&r1=274633&r2=274634&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_atomic_msvc.h
> (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_atomic_msvc.h Wed
> Jul 6 11:33:57 2016
> @@ -33,6 +33,10 @@ extern "C" long _InterlockedExchange(
> extern "C" long _InterlockedExchangeAdd( // NOLINT
> long volatile * Addend, long Value); // NOLINT
> #pragma intrinsic(_InterlockedExchangeAdd)
> +extern "C" char _InterlockedCompareExchange8( // NOLINT
> + char volatile *Destination, // NOLINT
> + char Exchange, char Comparand); // NOLINT
> +#pragma intrinsic(_InterlockedCompareExchange8)
> extern "C" short _InterlockedCompareExchange16( // NOLINT
> short volatile *Destination, // NOLINT
> short Exchange, short Comparand); // NOLINT
> @@ -175,15 +179,13 @@ INLINE bool atomic_compare_exchange_stro
> u8 *cmp,
> u8 xchgv,
> memory_order mo) {
> -#ifdef _WIN64
> - // TODO(wwchrome): Implement same functionality without inline asm.
> - // Inline asm not supported in Win64.
> - __debugbreak();
> - return false;
> -#else
> (void)mo;
> DCHECK(!((uptr)a % sizeof(*a)));
> u8 cmpv = *cmp;
> +#ifdef _WIN64
> + u8 prev = (u8)_InterlockedCompareExchange8(
> + (volatile char*)&a->val_dont_use, (char)xchgv, (char)cmpv);
> +#else
> u8 prev;
> __asm {
> mov al, cmpv
> @@ -192,11 +194,11 @@ INLINE bool atomic_compare_exchange_stro
> lock cmpxchg [ecx], dl
> mov prev, al
> }
>
Could we have used _InterlockedCompareExchange8 on the #else path as well?
> +#endif
> if (prev == cmpv)
> return true;
> *cmp = prev;
> return false;
> -#endif
> }
>
> INLINE bool atomic_compare_exchange_strong(volatile atomic_uintptr_t *a,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160706/02a68303/attachment.html>
More information about the llvm-commits
mailing list