[PATCH] D36071: [builtins] Use _Interlocked* intrinsics for atomics on MSVC

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 01:23:33 PDT 2017


mstorsjo added inline comments.


================
Comment at: lib/builtins/emutls.c:219
 #else
-    return (uintptr_t) _load_be_u32(ptr);
+    return _InterlockedAdd64(ptr, 0);
+#endif
----------------
X64 doesn't have `Add64`, but have got `Or64_np`. ARM (and according to MSVC 2017's `intrin.h`, ARM64 as well) have got `Add64` though.


================
Comment at: lib/builtins/emutls.c:231
 #else
-    _store_be_u32(ptr, val);
+    _InterlockedExchange(ptr, val);
 #endif
----------------
`_InterlockedExchangePointer` would ideally work on both 32 and 64 bit, but in MSVC 2013 for X86, this fails due to some kludge in MSVC's `intrin.h`.


https://reviews.llvm.org/D36071





More information about the llvm-commits mailing list