[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 08:27:04 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
----------------
marsupial wrote:
> mstorsjo wrote:
> > 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.
> The docs for these functions say it returns the original value.
> Should be fine as 0 is added/ored, but a comment explaining the situation may be wise.
Sure, I can add that. Does my approach look sensible otherwise? Do you think I should add inline comments about the gotchas in different versions as motivation for each of them?


https://reviews.llvm.org/D36071





More information about the llvm-commits mailing list