Skip to content

Commit

Permalink
[tsan] Annotate function parameters with attribute 'noescape'.
Browse files Browse the repository at this point in the history
This commit annotates the block parameters of the following functions
declared in compiler-rt with 'noescape':

- dispatch_sync
- dispatch_barrier_sync
- dispatch_once
- dispatch_apply

This is needed to commit the patch that adds support for 'noescape' in
clang (see https://reviews.llvm.org/D32210) since these functions are
annotated with 'noescape' in the SDK header files.

Differential Revision: https://reviews.llvm.org/D32210

llvm-svn: 313929
  • Loading branch information
ahatanaka committed Sep 21, 2017
1 parent 0aa02c0 commit 475a38f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc
Expand Up @@ -177,7 +177,8 @@ static void invoke_and_release_block(void *param) {
}

#define DISPATCH_INTERCEPT_SYNC_B(name, barrier) \
TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, dispatch_block_t block) { \
TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, \
DISPATCH_NOESCAPE dispatch_block_t block) { \
SCOPED_TSAN_INTERCEPTOR(name, q, block); \
SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START(); \
dispatch_block_t heap_block = Block_copy(block); \
Expand Down Expand Up @@ -267,7 +268,7 @@ TSAN_INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when,
// need to undefine the macro.
#undef dispatch_once
TSAN_INTERCEPTOR(void, dispatch_once, dispatch_once_t *predicate,
dispatch_block_t block) {
DISPATCH_NOESCAPE dispatch_block_t block) {
SCOPED_INTERCEPTOR_RAW(dispatch_once, predicate, block);
atomic_uint32_t *a = reinterpret_cast<atomic_uint32_t *>(predicate);
u32 v = atomic_load(a, memory_order_acquire);
Expand Down Expand Up @@ -477,7 +478,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler_f,
}

TSAN_INTERCEPTOR(void, dispatch_apply, size_t iterations,
dispatch_queue_t queue, void (^block)(size_t)) {
dispatch_queue_t queue,
DISPATCH_NOESCAPE void (^block)(size_t)) {
SCOPED_TSAN_INTERCEPTOR(dispatch_apply, iterations, queue, block);

void *parent_to_child_sync = nullptr;
Expand Down

0 comments on commit 475a38f

Please sign in to comment.