summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_libdispatch_mac.cc
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2016-05-19 15:31:42 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2016-05-19 15:31:42 +0000
commita6b9e9785cef543eafa96d30c421a89175dce54c (patch)
treecea0a72736f9ed98879e902236511ed18acb0340 /lib/tsan/rtl/tsan_libdispatch_mac.cc
parenta4313de1d6cc10dfaad540f1efec2ab1ccb2ad0d (diff)
[tsan] Add support for GCD's dispatch_after and dispatch_after_f
We're missing interceptors for dispatch_after and dispatch_after_f. Let's add them to avoid false positives. Added a test case. Differential Revision: http://reviews.llvm.org/D20426 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_libdispatch_mac.cc')
-rw-r--r--lib/tsan/rtl/tsan_libdispatch_mac.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 30e5b4bb0..7f1b8809b 100644
--- a/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc
@@ -184,6 +184,29 @@ DISPATCH_INTERCEPT_SYNC_B(dispatch_barrier_sync)
DISPATCH_INTERCEPT_SYNC_F(dispatch_sync_f)
DISPATCH_INTERCEPT_SYNC_F(dispatch_barrier_sync_f)
+TSAN_INTERCEPTOR(void, dispatch_after, dispatch_time_t when,
+ dispatch_queue_t queue, dispatch_block_t block) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_after, when, queue, block);
+ SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START();
+ dispatch_block_t heap_block = Block_copy(block);
+ SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END();
+ tsan_block_context_t *new_context =
+ AllocContext(thr, pc, queue, heap_block, &invoke_and_release_block);
+ Release(thr, pc, (uptr)new_context);
+ SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START();
+ REAL(dispatch_after_f)(when, queue, new_context, dispatch_callback_wrap);
+ SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END();
+}
+
+TSAN_INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when,
+ dispatch_queue_t queue, void *context,
+ dispatch_function_t work) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_after_f, when, queue, context, work);
+ WRAP(dispatch_after)(when, queue, ^(void) {
+ work(context);
+ });
+}
+
// GCD's dispatch_once implementation has a fast path that contains a racy read
// and it's inlined into user's code. Furthermore, this fast path doesn't
// establish a proper happens-before relations between the initialization and