[PATCH] D14811: [tsan] Handle dispatch_once on OS X
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 19 02:05:33 PST 2015
dvyukov added a comment.
LGTM with nits
================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:30
@@ +29,3 @@
+// GCD's dispatch_once implementation contains a fast path that contains an
+// intentionally racy read and it's inlined into user's code. Furthermore, this
+// fast path doesn't establish a proper happens-before relations between the
----------------
I can't imagine how undefined behavior can be intentional. Also, whether it is intentional or not is irrelevant here. So just drop "intentionally".
================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:45
@@ +44,3 @@
+ SCOPED_TSAN_INTERCEPTOR(dispatch_once, predicate, block);
+ atomic_uint32_t *a = static_cast<atomic_uint32_t*>((void *)predicate);
+ u32 v = atomic_load(a, memory_order_acquire);
----------------
C++ and C cast chained look weird. Do either just C cast, or just reinterpret_cast.
================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:65
@@ +64,3 @@
+ SCOPED_TSAN_INTERCEPTOR(dispatch_once_f, predicate, context, function);
+ WRAP(dispatch_once)(predicate, ^{ function(context); });
+}
----------------
For my education: how do these blocks work? Are they allocated with malloc, and then atomically reference-counted?
http://reviews.llvm.org/D14811
More information about the llvm-commits
mailing list