[compiler-rt] r358316 - [TSan][libdispatch] Move libdispatch tests out of Darwin folder

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 16:07:00 PDT 2019


Author: yln
Date: Fri Apr 12 16:07:00 2019
New Revision: 358316

URL: http://llvm.org/viewvc/llvm-project?rev=358316&view=rev
Log:
[TSan][libdispatch] Move libdispatch tests out of Darwin folder

The libdispatch tests are now not tied to Darwin anymore. Move them to
their own platform-independent folder.

Added:
    compiler-rt/trunk/test/tsan/libdispatch/after.c
    compiler-rt/trunk/test/tsan/libdispatch/async-norace.c
    compiler-rt/trunk/test/tsan/libdispatch/async-race.c
    compiler-rt/trunk/test/tsan/libdispatch/barrier-race.c
    compiler-rt/trunk/test/tsan/libdispatch/barrier.c
    compiler-rt/trunk/test/tsan/libdispatch/blocks.c
    compiler-rt/trunk/test/tsan/libdispatch/fd.c
    compiler-rt/trunk/test/tsan/libdispatch/groups-norace.c
    compiler-rt/trunk/test/tsan/libdispatch/io-barrier-race.c
    compiler-rt/trunk/test/tsan/libdispatch/io-barrier.c
    compiler-rt/trunk/test/tsan/libdispatch/io-cleanup.c
    compiler-rt/trunk/test/tsan/libdispatch/io-race.c
    compiler-rt/trunk/test/tsan/libdispatch/io.c
    compiler-rt/trunk/test/tsan/libdispatch/serial-queue-norace.c
    compiler-rt/trunk/test/tsan/libdispatch/source-cancel.c
    compiler-rt/trunk/test/tsan/libdispatch/source-cancel2.c
    compiler-rt/trunk/test/tsan/libdispatch/source-event.c
    compiler-rt/trunk/test/tsan/libdispatch/source-event2.c
    compiler-rt/trunk/test/tsan/libdispatch/source-registration.c
    compiler-rt/trunk/test/tsan/libdispatch/source-registration2.c
    compiler-rt/trunk/test/tsan/libdispatch/sync-norace.c
    compiler-rt/trunk/test/tsan/libdispatch/sync-race.c
    compiler-rt/trunk/test/tsan/libdispatch/target-queue-norace.c
Removed:
    compiler-rt/trunk/test/tsan/Darwin/gcd-after.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-async-norace.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-async-race.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-barrier-race.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-barrier.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-blocks.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-fd.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-groups-norace.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier-race.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-io-cleanup.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-io-race.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-io.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-serial-queue-norace.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel2.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-event.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-event2.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration2.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-sync-norace.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-sync-race.mm
    compiler-rt/trunk/test/tsan/Darwin/gcd-target-queue-norace.mm

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-after.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-after.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-after.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-after.mm (removed)
@@ -1,42 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long my_global;
-long my_global2;
-dispatch_semaphore_t done;
-
-void callback(void *context) {
-  my_global2 = 42;
-
-  dispatch_semaphore_signal(done);
-}
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "start\n");
-  done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
-  my_global = 10;
-  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, ^{
-    my_global = 42;
-
-    dispatch_semaphore_signal(done);
-  });
-
-  my_global2 = 10;
-  dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, NULL, &callback);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "done\n");
-  return 0;
-}
-
-// CHECK: start
-// CHECK: done
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-async-norace.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-async-norace.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-async-norace.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-async-norace.mm (removed)
@@ -1,27 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  global = 42;
-  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    global = 43;
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-async-race.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-async-race.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-async-race.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-async-race.mm (removed)
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  print_address("addr=", 1, &global);
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-  barrier_init(&barrier, 2);
-
-  global = 42;
-  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    global = 43;
-    barrier_wait(&barrier);
-  });
-
-  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    barrier_wait(&barrier);
-    global = 44;
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-async-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-barrier-race.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-barrier-race.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-barrier-race.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-barrier-race.mm (removed)
@@ -1,47 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  print_address("addr=", 1, &global);
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-  barrier_init(&barrier, 2);
-
-  dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
-  dispatch_barrier_sync(q, ^{
-    global = 42;
-  });
-
-  dispatch_async(bgq, ^{
-    dispatch_sync(q, ^{
-      global = 43;
-      barrier_wait(&barrier);
-    });
-  });
-
-  dispatch_async(bgq, ^{
-    dispatch_sync(q, ^{
-      barrier_wait(&barrier);
-      global = 44;
-
-      dispatch_semaphore_signal(done);
-    });
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-barrier-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-barrier.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-barrier.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-barrier.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-barrier.mm (removed)
@@ -1,47 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include "../test.h"
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-  barrier_init(&barrier, 2);
-
-  dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-
-  dispatch_async(bgq, ^{
-    dispatch_sync(q, ^{
-      global = 42;
-    });
-    barrier_wait(&barrier);
-  });
-
-  dispatch_async(bgq, ^{
-    barrier_wait(&barrier);
-    dispatch_barrier_sync(q, ^{
-      global = 43;
-    });
-
-    dispatch_async(bgq, ^{
-      barrier_wait(&barrier);
-      global = 44;
-    });
-
-    barrier_wait(&barrier);
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-blocks.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-blocks.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-blocks.mm (removed)
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-#include <assert.h>
-
-int main() {
-  fprintf(stderr, "start\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t background_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-  dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
-  assert(background_q != serial_q);
-
-  dispatch_async(background_q, ^{
-    __block long block_var = 0;
-
-    dispatch_sync(serial_q, ^{
-      block_var = 42;
-    });
-
-    fprintf(stderr, "block_var = %ld\n", block_var);
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "done\n");
-}
-
-// CHECK: start
-// CHECK: block_var = 42
-// CHECK: done
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK-NOT: CHECK failed

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-fd.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-fd.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-fd.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-fd.mm (removed)
@@ -1,62 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-
-  dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
-  dispatch_semaphore_t sem = dispatch_semaphore_create(0);
-
-  const char *path = tempnam(NULL, "libdispatch-fd-");
-
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY,
-      0666, queue, ^(int error) { });
-  dispatch_io_set_high_water(channel, 1);
-
-  char buf[1000];
-  dispatch_data_t data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-
-  my_global++;
-  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      if (done) {
-        dispatch_semaphore_signal(sem);
-      }
-    });
-  });
-
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  dispatch_io_close(channel, 0);
-  channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
-      0, queue, ^(int error) { });
-  dispatch_io_set_high_water(channel, 1);
-
-  my_global++;
-  dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      if (done) {
-        dispatch_semaphore_signal(sem);
-      }
-    });
-  });
-
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-groups-norace.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-groups-norace.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-groups-norace.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-groups-norace.mm (removed)
@@ -1,51 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-  global = 42;
-
-  dispatch_group_t g = dispatch_group_create();
-  dispatch_group_async(g, q, ^{
-    global = 43;
-  });
-  dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
-  global = 44;
-
-  dispatch_group_enter(g);
-  dispatch_async(q, ^{
-    global = 45;
-    dispatch_group_leave(g);
-  });
-  dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
-
-  global = 46;
-
-  dispatch_group_enter(g);
-  dispatch_async(q, ^{
-    global = 47;
-    dispatch_group_leave(g);
-  });
-  dispatch_group_notify(g, q, ^{
-    global = 48;
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier-race.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier-race.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier-race.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier-race.mm (removed)
@@ -1,54 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#import "../test.h"
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-  print_address("addr=", 1, &my_global);
-  barrier_init(&barrier, 2);
-
-  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  sem = dispatch_semaphore_create(0);
-  path = tempnam(NULL, "libdispatch-io-barrier-race-");
-  char buf[1000];
-  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-  
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
-  if (! channel) abort();
-  dispatch_io_set_high_water(channel, 1);
-
-  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    if (error) abort();
-    my_global = 42;
-    barrier_wait(&barrier);
-  });
-
-  dispatch_io_barrier(channel, ^{
-    barrier_wait(&barrier);
-    my_global = 43;
-
-    dispatch_semaphore_signal(sem);
-  });
-
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  dispatch_io_close(channel, 0);
-  
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (gcd-io-barrier-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-io-barrier.mm (removed)
@@ -1,50 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-  
-  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  sem = dispatch_semaphore_create(0);
-  path = tempnam(NULL, "libdispatch-io-barrier");
-  char buf[1000];
-  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-  
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
-  if (! channel) abort();
-  dispatch_io_set_high_water(channel, 1);
-
-  for (int i = 0; i < 1000; i++) {
-    dispatch_io_barrier(channel, ^{
-      my_global = 42;
-    });
-  }
-
-  dispatch_io_barrier(channel, ^{
-    my_global = 43;
-
-    dispatch_semaphore_signal(sem);
-  });
-
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  dispatch_io_close(channel, 0);
-  
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-io-cleanup.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-io-cleanup.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-io-cleanup.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-io-cleanup.mm (removed)
@@ -1,58 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-  
-  dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  dispatch_semaphore_t sem = dispatch_semaphore_create(0);
-  const char *path = tempnam(NULL, "libdispatch-io-cleanup-");
-  dispatch_io_t channel;
-  
-  dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
-  my_global++;
-  channel = dispatch_io_create(DISPATCH_IO_STREAM, fd, queue, ^(int error) {
-    my_global++;
-    dispatch_semaphore_signal(sem);
-  });
-  if (! channel) abort();
-  my_global++;
-  dispatch_io_close(channel, 0);
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  
-  my_global++;
-  channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) {
-    my_global++;
-    dispatch_semaphore_signal(sem);
-  });
-  if (! channel) abort();
-  my_global++;
-  dispatch_io_close(channel, 0);
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  
-  my_global++;
-  dispatch_io_t other_channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
-  channel = dispatch_io_create_with_io(DISPATCH_IO_STREAM, other_channel, queue, ^(int error) {
-    my_global++;
-    dispatch_semaphore_signal(sem);
-  });
-  if (! channel) abort();
-  my_global++;
-  dispatch_io_close(channel, 0);
-  dispatch_io_close(other_channel, 0);
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-io-race.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-io-race.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-io-race.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-io-race.mm (removed)
@@ -1,53 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-// REQUIRES: disabled
-
-#import "../test.h"
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-  print_address("addr=", 1, &my_global);
-  barrier_init(&barrier, 2);
-  
-  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-  sem = dispatch_semaphore_create(0);
-  path = tempnam(NULL, "libdispatch-io-race");
-  char buf[1000];
-  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-  
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
-  if (! channel) abort();
-  dispatch_io_set_high_water(channel, 1);
-  
-  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    my_global = 42;
-    barrier_wait(&barrier);
-  });
-
-  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    barrier_wait(&barrier);
-    my_global = 42;
-
-    dispatch_semaphore_signal(sem);
-  });
-  
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  dispatch_io_close(channel, 0);
-  
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (gcd-io-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-io.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-io.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-io.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-io.mm (removed)
@@ -1,119 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include <dispatch/dispatch.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-dispatch_queue_t queue;
-dispatch_data_t data;
-dispatch_semaphore_t sem;
-const char *path;
-
-long my_global = 0;
-
-void test_dispatch_io_write() {
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
-  if (! channel) abort();
-  dispatch_io_set_high_water(channel, 1);
-  
-  my_global++;
-  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    if (error) abort();
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      if (done) {
-        dispatch_semaphore_signal(sem);
-      }
-    });
-  });
-  
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  dispatch_io_close(channel, 0);
-}
-
-void test_dispatch_write() {
-  dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
-  if (fd == -1) abort();
-  
-  my_global++;
-  dispatch_write(fd, data, queue, ^(dispatch_data_t data, int error) {
-    if (error) abort();
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      
-      dispatch_semaphore_signal(sem);
-    });
-  });
-  
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  close(fd);
-}
-
-void test_dispatch_io_read() {
-  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
-                       0, queue, ^(int error) { });
-  dispatch_io_set_high_water(channel, 1);
-  
-  my_global++;
-  dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
-    if (error) abort();
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      if (done) {
-        dispatch_semaphore_signal(sem);
-      }
-    });
-  });
-  
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  dispatch_io_close(channel, 0);
-}
-
-void test_dispatch_read() {
-  dispatch_fd_t fd = open(path, O_RDONLY, 0);
-  if (fd == -1) abort();
-  
-  my_global++;
-  dispatch_read(fd, SIZE_MAX, queue, ^(dispatch_data_t data, int error) {
-    if (error) abort();
-    my_global++;
-    dispatch_async(queue, ^{
-      my_global++;
-      dispatch_semaphore_signal(sem);
-    });
-  });
-  
-  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
-  my_global++;
-  close(fd);
-}
-
-int main(int argc, const char *argv[]) {
-  fprintf(stderr, "Hello world.\n");
-  
-  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
-  sem = dispatch_semaphore_create(0);
-  path = tempnam(NULL, "libdispatch-io-");
-  char buf[1000];
-  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
-  
-  test_dispatch_io_write();
-  test_dispatch_write();
-  test_dispatch_io_read();
-  test_dispatch_read();
-  
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK: Hello world.
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-serial-queue-norace.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-serial-queue-norace.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-serial-queue-norace.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-serial-queue-norace.mm (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT);
-  dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_SERIAL);
-
-  global = 42;
-  for (int i = 0; i < 10; i++) {
-    dispatch_async(q1, ^{
-      for (int i = 0; i < 100; i++) {
-        dispatch_sync(q2, ^{
-          global++;
-        });
-      }
-    });
-  }
-
-  dispatch_barrier_async(q1, ^{
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel.mm (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main(int argc, const char *argv[]) {
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
-  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
-  global = 42;
-
-  dispatch_source_set_cancel_handler(source, ^{
-    fprintf(stderr, "global = %ld\n", global);
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_resume(source);
-  dispatch_cancel(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel2.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel2.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel2.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-cancel2.mm (removed)
@@ -1,41 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
-  fprintf(stderr, "global = %ld\n", global);
-
-  dispatch_semaphore_signal(done);
-}
-
-int main(int argc, const char *argv[]) {
-  done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
-  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
-  global = 42;
-
-  dispatch_source_set_cancel_handler_f(source, &handler);
-
-  dispatch_resume(source);
-  dispatch_cancel(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-event.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-event.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-event.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-event.mm (removed)
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main(int argc, const char *argv[]) {
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
-  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
-  global = 42;
-
-  dispatch_source_set_event_handler(source, ^{
-    fprintf(stderr, "global = %ld\n", global);
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_resume(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-event2.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-event2.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-event2.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-event2.mm (removed)
@@ -1,40 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
-  fprintf(stderr, "global = %ld\n", global);
-
-  dispatch_semaphore_signal(done);
-}
-
-int main(int argc, const char *argv[]) {
-  done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
-
-  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
-
-  global = 42;
-
-  dispatch_source_set_event_handler_f(source, &handler);
-
-  dispatch_resume(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration.mm (removed)
@@ -1,35 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main(int argc, const char *argv[]) {
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
-
-  global = 42;
-
-  dispatch_source_set_registration_handler(source, ^{
-    fprintf(stderr, "global = %ld\n", global);
-
-    dispatch_semaphore_signal(done);
-  });
-
-  dispatch_resume(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration2.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration2.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration2.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-source-registration2.mm (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-dispatch_semaphore_t done;
-
-void handler(void *arg) {
-  fprintf(stderr, "global = %ld\n", global);
-
-  dispatch_semaphore_signal(done);
-}
-
-int main(int argc, const char *argv[]) {
-  done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t queue =
-      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
-
-  dispatch_source_t source =
-      dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
-
-  global = 42;
-
-  dispatch_source_set_registration_handler_f(source, handler);
-
-  dispatch_resume(source);
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-
-  return 0;
-}
-
-// CHECK: global = 42
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-sync-norace.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-sync-norace.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-sync-norace.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-sync-norace.mm (removed)
@@ -1,37 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-static const long nIter = 1000;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-
-  dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
-
-  global = 42;
-  for (int i = 0; i < nIter; i++) {
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-      dispatch_sync(serial_q, ^{
-        global = i;
-
-        if (i == nIter - 1) {
-          dispatch_semaphore_signal(done);
-        }
-      });
-    });
-  }
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: Done.
-// CHECK-NOT: WARNING: ThreadSanitizer

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-sync-race.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-sync-race.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-sync-race.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-sync-race.mm (removed)
@@ -1,42 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %deflake %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-#include "../test.h"
-
-long global;
-
-int main() {
-  fprintf(stderr, "Hello world.\n");
-  print_address("addr=", 1, &global);
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-  barrier_init(&barrier, 2);
-
-  dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT);
-  dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_CONCURRENT);
-
-  global = 42;
-  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    dispatch_sync(q1, ^{
-      global = 43;
-      barrier_wait(&barrier);
-    });
-  });
-  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    dispatch_sync(q2, ^{
-      barrier_wait(&barrier);
-      global = 44;
-
-      dispatch_semaphore_signal(done);
-    });
-  });
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-}
-
-// CHECK: Hello world.
-// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (gcd-sync-race.mm.tmp+0x{{[0-9,a-f]+}})
-// CHECK: Done.

Removed: compiler-rt/trunk/test/tsan/Darwin/gcd-target-queue-norace.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/gcd-target-queue-norace.mm?rev=358315&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/gcd-target-queue-norace.mm (original)
+++ compiler-rt/trunk/test/tsan/Darwin/gcd-target-queue-norace.mm (removed)
@@ -1,41 +0,0 @@
-// RUN: %clang_tsan %s -o %t
-// RUN: %run %t 2>&1 | FileCheck %s
-
-#include "dispatch/dispatch.h"
-
-#include <stdio.h>
-
-long global;
-
-int main(int argc, const char *argv[]) {
-  dispatch_semaphore_t done = dispatch_semaphore_create(0);
-  dispatch_queue_t target_queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
-  dispatch_queue_t q1 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT);
-  dispatch_queue_t q2 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT);
-  dispatch_set_target_queue(q1, target_queue);
-  dispatch_set_target_queue(q2, target_queue);
-
-  for (int i = 0; i < 100000; i++) {
-    dispatch_async(q1, ^{
-      global++;
-
-      if (global == 200000) {
-        dispatch_semaphore_signal(done);
-      }
-    });
-    dispatch_async(q2, ^{
-      global++;
-
-      if (global == 200000) {
-        dispatch_semaphore_signal(done);
-      }
-    });
-  }
-
-  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
-  fprintf(stderr, "Done.\n");
-  return 0;
-}
-
-// CHECK-NOT: WARNING: ThreadSanitizer
-// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/after.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/after.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/after.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/after.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,42 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long my_global;
+long my_global2;
+dispatch_semaphore_t done;
+
+void callback(void *context) {
+  my_global2 = 42;
+
+  dispatch_semaphore_signal(done);
+}
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "start\n");
+  done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+
+  my_global = 10;
+  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, ^{
+    my_global = 42;
+
+    dispatch_semaphore_signal(done);
+  });
+
+  my_global2 = 10;
+  dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, NULL, &callback);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "done\n");
+  return 0;
+}
+
+// CHECK: start
+// CHECK: done
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/async-norace.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/async-norace.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/async-norace.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/async-norace.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,27 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  global = 42;
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    global = 43;
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/async-race.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/async-race.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/async-race.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/async-race.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,37 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %deflake %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include "../test.h"
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  print_address("addr=", 1, &global);
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+  barrier_init(&barrier, 2);
+
+  global = 42;
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    global = 43;
+    barrier_wait(&barrier);
+  });
+
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    barrier_wait(&barrier);
+    global = 44;
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (async-race.c.tmp+0x{{[0-9,a-f]+}})
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/barrier-race.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/barrier-race.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/barrier-race.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/barrier-race.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,47 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %deflake %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include "../test.h"
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  print_address("addr=", 1, &global);
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+  barrier_init(&barrier, 2);
+
+  dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+
+  dispatch_barrier_sync(q, ^{
+    global = 42;
+  });
+
+  dispatch_async(bgq, ^{
+    dispatch_sync(q, ^{
+      global = 43;
+      barrier_wait(&barrier);
+    });
+  });
+
+  dispatch_async(bgq, ^{
+    dispatch_sync(q, ^{
+      barrier_wait(&barrier);
+      global = 44;
+
+      dispatch_semaphore_signal(done);
+    });
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (barrier-race.c.tmp+0x{{[0-9,a-f]+}})
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/barrier.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/barrier.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/barrier.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/barrier.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,47 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include "../test.h"
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+  barrier_init(&barrier, 2);
+
+  dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  dispatch_queue_t bgq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+
+  dispatch_async(bgq, ^{
+    dispatch_sync(q, ^{
+      global = 42;
+    });
+    barrier_wait(&barrier);
+  });
+
+  dispatch_async(bgq, ^{
+    barrier_wait(&barrier);
+    dispatch_barrier_sync(q, ^{
+      global = 43;
+    });
+
+    dispatch_async(bgq, ^{
+      barrier_wait(&barrier);
+      global = 44;
+    });
+
+    barrier_wait(&barrier);
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/blocks.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/blocks.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/blocks.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/blocks.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,37 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+#include <assert.h>
+
+int main() {
+  fprintf(stderr, "start\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t background_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+  dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
+  assert(background_q != serial_q);
+
+  dispatch_async(background_q, ^{
+    __block long block_var = 0;
+
+    dispatch_sync(serial_q, ^{
+      block_var = 42;
+    });
+
+    fprintf(stderr, "block_var = %ld\n", block_var);
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "done\n");
+}
+
+// CHECK: start
+// CHECK: block_var = 42
+// CHECK: done
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK-NOT: CHECK failed

Added: compiler-rt/trunk/test/tsan/libdispatch/fd.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/fd.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/fd.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/fd.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,62 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+
+#include <stdio.h>
+
+long my_global = 0;
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+
+  dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
+  dispatch_semaphore_t sem = dispatch_semaphore_create(0);
+
+  const char *path = tempnam(NULL, "libdispatch-fd-");
+
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY,
+      0666, queue, ^(int error) { });
+  dispatch_io_set_high_water(channel, 1);
+
+  char buf[1000];
+  dispatch_data_t data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+
+  my_global++;
+  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      if (done) {
+        dispatch_semaphore_signal(sem);
+      }
+    });
+  });
+
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  dispatch_io_close(channel, 0);
+  channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
+      0, queue, ^(int error) { });
+  dispatch_io_set_high_water(channel, 1);
+
+  my_global++;
+  dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      if (done) {
+        dispatch_semaphore_signal(sem);
+      }
+    });
+  });
+
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/groups-norace.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/groups-norace.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/groups-norace.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/groups-norace.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,51 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+  global = 42;
+
+  dispatch_group_t g = dispatch_group_create();
+  dispatch_group_async(g, q, ^{
+    global = 43;
+  });
+  dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
+
+  global = 44;
+
+  dispatch_group_enter(g);
+  dispatch_async(q, ^{
+    global = 45;
+    dispatch_group_leave(g);
+  });
+  dispatch_group_wait(g, DISPATCH_TIME_FOREVER);
+
+  global = 46;
+
+  dispatch_group_enter(g);
+  dispatch_async(q, ^{
+    global = 47;
+    dispatch_group_leave(g);
+  });
+  dispatch_group_notify(g, q, ^{
+    global = 48;
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/io-barrier-race.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/io-barrier-race.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/io-barrier-race.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/io-barrier-race.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,54 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %deflake %run %t 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+
+#import "../test.h"
+
+dispatch_queue_t queue;
+dispatch_data_t data;
+dispatch_semaphore_t sem;
+const char *path;
+
+long my_global = 0;
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+  print_address("addr=", 1, &my_global);
+  barrier_init(&barrier, 2);
+
+  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  sem = dispatch_semaphore_create(0);
+  path = tempnam(NULL, "libdispatch-io-barrier-race-");
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
+  if (! channel) abort();
+  dispatch_io_set_high_water(channel, 1);
+
+  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    if (error) abort();
+    my_global = 42;
+    barrier_wait(&barrier);
+  });
+
+  dispatch_io_barrier(channel, ^{
+    barrier_wait(&barrier);
+    my_global = 43;
+
+    dispatch_semaphore_signal(sem);
+  });
+
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  dispatch_io_close(channel, 0);
+  
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (io-barrier-race.c.tmp+0x{{[0-9,a-f]+}})
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/io-barrier.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/io-barrier.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/io-barrier.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/io-barrier.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,50 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+dispatch_queue_t queue;
+dispatch_data_t data;
+dispatch_semaphore_t sem;
+const char *path;
+
+long my_global = 0;
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+  
+  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  sem = dispatch_semaphore_create(0);
+  path = tempnam(NULL, "libdispatch-io-barrier");
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
+  if (! channel) abort();
+  dispatch_io_set_high_water(channel, 1);
+
+  for (int i = 0; i < 1000; i++) {
+    dispatch_io_barrier(channel, ^{
+      my_global = 42;
+    });
+  }
+
+  dispatch_io_barrier(channel, ^{
+    my_global = 43;
+
+    dispatch_semaphore_signal(sem);
+  });
+
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  dispatch_io_close(channel, 0);
+  
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/io-cleanup.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/io-cleanup.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/io-cleanup.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/io-cleanup.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,58 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+long my_global = 0;
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+  
+  dispatch_queue_t queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  dispatch_semaphore_t sem = dispatch_semaphore_create(0);
+  const char *path = tempnam(NULL, "libdispatch-io-cleanup-");
+  dispatch_io_t channel;
+  
+  dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
+  my_global++;
+  channel = dispatch_io_create(DISPATCH_IO_STREAM, fd, queue, ^(int error) {
+    my_global++;
+    dispatch_semaphore_signal(sem);
+  });
+  if (! channel) abort();
+  my_global++;
+  dispatch_io_close(channel, 0);
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  
+  my_global++;
+  channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) {
+    my_global++;
+    dispatch_semaphore_signal(sem);
+  });
+  if (! channel) abort();
+  my_global++;
+  dispatch_io_close(channel, 0);
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  
+  my_global++;
+  dispatch_io_t other_channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
+  channel = dispatch_io_create_with_io(DISPATCH_IO_STREAM, other_channel, queue, ^(int error) {
+    my_global++;
+    dispatch_semaphore_signal(sem);
+  });
+  if (! channel) abort();
+  my_global++;
+  dispatch_io_close(channel, 0);
+  dispatch_io_close(other_channel, 0);
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/io-race.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/io-race.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/io-race.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/io-race.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,55 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %deflake %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: disabled
+
+#include <dispatch/dispatch.h>
+
+#include "../test.h"
+
+dispatch_queue_t queue;
+dispatch_data_t data;
+dispatch_semaphore_t sem;
+const char *path;
+
+long my_global = 0;
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+  print_address("addr=", 1, &my_global);
+  barrier_init(&barrier, 2);
+  
+  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+  sem = dispatch_semaphore_create(0);
+  path = tempnam(NULL, "libdispatch-io-race");
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
+  if (! channel) abort();
+  dispatch_io_set_high_water(channel, 1);
+  
+  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    my_global = 42;
+    barrier_wait(&barrier);
+  });
+
+  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    barrier_wait(&barrier);
+    my_global = 42;
+
+    dispatch_semaphore_signal(sem);
+  });
+  
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  dispatch_io_close(channel, 0);
+  
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'my_global' {{(of size 8 )?}}at [[ADDR]] (io-race.c.tmp+0x{{[0-9,a-f]+}})
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/io.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/io.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/io.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/io.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,119 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <dispatch/dispatch.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+dispatch_queue_t queue;
+dispatch_data_t data;
+dispatch_semaphore_t sem;
+const char *path;
+
+long my_global = 0;
+
+void test_dispatch_io_write() {
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_CREAT | O_WRONLY, 0666, queue, ^(int error) { });
+  if (! channel) abort();
+  dispatch_io_set_high_water(channel, 1);
+  
+  my_global++;
+  dispatch_io_write(channel, 0, data, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    if (error) abort();
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      if (done) {
+        dispatch_semaphore_signal(sem);
+      }
+    });
+  });
+  
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  dispatch_io_close(channel, 0);
+}
+
+void test_dispatch_write() {
+  dispatch_fd_t fd = open(path, O_CREAT | O_WRONLY, 0666);
+  if (fd == -1) abort();
+  
+  my_global++;
+  dispatch_write(fd, data, queue, ^(dispatch_data_t data, int error) {
+    if (error) abort();
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      
+      dispatch_semaphore_signal(sem);
+    });
+  });
+  
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  close(fd);
+}
+
+void test_dispatch_io_read() {
+  dispatch_io_t channel = dispatch_io_create_with_path(DISPATCH_IO_STREAM, path, O_RDONLY,
+                       0, queue, ^(int error) { });
+  dispatch_io_set_high_water(channel, 1);
+  
+  my_global++;
+  dispatch_io_read(channel, 0, SIZE_MAX, queue, ^(bool done, dispatch_data_t remainingData, int error) {
+    if (error) abort();
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      if (done) {
+        dispatch_semaphore_signal(sem);
+      }
+    });
+  });
+  
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  dispatch_io_close(channel, 0);
+}
+
+void test_dispatch_read() {
+  dispatch_fd_t fd = open(path, O_RDONLY, 0);
+  if (fd == -1) abort();
+  
+  my_global++;
+  dispatch_read(fd, SIZE_MAX, queue, ^(dispatch_data_t data, int error) {
+    if (error) abort();
+    my_global++;
+    dispatch_async(queue, ^{
+      my_global++;
+      dispatch_semaphore_signal(sem);
+    });
+  });
+  
+  dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+  my_global++;
+  close(fd);
+}
+
+int main(int argc, const char *argv[]) {
+  fprintf(stderr, "Hello world.\n");
+  
+  queue = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
+  sem = dispatch_semaphore_create(0);
+  path = tempnam(NULL, "libdispatch-io-");
+  char buf[1000];
+  data = dispatch_data_create(buf, sizeof(buf), NULL, DISPATCH_DATA_DESTRUCTOR_DEFAULT);
+  
+  test_dispatch_io_write();
+  test_dispatch_write();
+  test_dispatch_io_read();
+  test_dispatch_read();
+  
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK: Hello world.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/serial-queue-norace.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/serial-queue-norace.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/serial-queue-norace.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/serial-queue-norace.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,38 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT);
+  dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_SERIAL);
+
+  global = 42;
+  for (int i = 0; i < 10; i++) {
+    dispatch_async(q1, ^{
+      for (int i = 0; i < 100; i++) {
+        dispatch_sync(q2, ^{
+          global++;
+        });
+      }
+    });
+  }
+
+  dispatch_barrier_async(q1, ^{
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-cancel.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-cancel.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-cancel.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-cancel.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,38 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main(int argc, const char *argv[]) {
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
+
+  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
+
+  global = 42;
+
+  dispatch_source_set_cancel_handler(source, ^{
+    fprintf(stderr, "global = %ld\n", global);
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_resume(source);
+  dispatch_cancel(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-cancel2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-cancel2.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-cancel2.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-cancel2.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,41 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+dispatch_semaphore_t done;
+
+void handler(void *arg) {
+  fprintf(stderr, "global = %ld\n", global);
+
+  dispatch_semaphore_signal(done);
+}
+
+int main(int argc, const char *argv[]) {
+  done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
+
+  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
+
+  global = 42;
+
+  dispatch_source_set_cancel_handler_f(source, &handler);
+
+  dispatch_resume(source);
+  dispatch_cancel(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-event.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-event.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-event.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-event.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,37 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main(int argc, const char *argv[]) {
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
+
+  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
+
+  global = 42;
+
+  dispatch_source_set_event_handler(source, ^{
+    fprintf(stderr, "global = %ld\n", global);
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_resume(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-event2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-event2.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-event2.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-event2.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,40 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+dispatch_semaphore_t done;
+
+void handler(void *arg) {
+  fprintf(stderr, "global = %ld\n", global);
+
+  dispatch_semaphore_signal(done);
+}
+
+int main(int argc, const char *argv[]) {
+  done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
+
+  dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
+
+  global = 42;
+
+  dispatch_source_set_event_handler_f(source, &handler);
+
+  dispatch_resume(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-registration.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-registration.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-registration.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-registration.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,35 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main(int argc, const char *argv[]) {
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
+
+  global = 42;
+
+  dispatch_source_set_registration_handler(source, ^{
+    fprintf(stderr, "global = %ld\n", global);
+
+    dispatch_semaphore_signal(done);
+  });
+
+  dispatch_resume(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/source-registration2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/source-registration2.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/source-registration2.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/source-registration2.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,38 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+dispatch_semaphore_t done;
+
+void handler(void *arg) {
+  fprintf(stderr, "global = %ld\n", global);
+
+  dispatch_semaphore_signal(done);
+}
+
+int main(int argc, const char *argv[]) {
+  done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t queue =
+      dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
+
+  dispatch_source_t source =
+      dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, queue);
+
+  global = 42;
+
+  dispatch_source_set_registration_handler_f(source, handler);
+
+  dispatch_resume(source);
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+
+  return 0;
+}
+
+// CHECK: global = 42
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/sync-norace.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/sync-norace.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/sync-norace.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/sync-norace.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,37 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+static const long nIter = 1000;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+
+  dispatch_queue_t serial_q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
+
+  global = 42;
+  for (int i = 0; i < nIter; i++) {
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+      dispatch_sync(serial_q, ^{
+        global = i;
+
+        if (i == nIter - 1) {
+          dispatch_semaphore_signal(done);
+        }
+      });
+    });
+  }
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer

Added: compiler-rt/trunk/test/tsan/libdispatch/sync-race.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/sync-race.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/sync-race.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/sync-race.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,42 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %deflake %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+#include "../test.h"
+
+long global;
+
+int main() {
+  fprintf(stderr, "Hello world.\n");
+  print_address("addr=", 1, &global);
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+  barrier_init(&barrier, 2);
+
+  dispatch_queue_t q1 = dispatch_queue_create("my.queue1", DISPATCH_QUEUE_CONCURRENT);
+  dispatch_queue_t q2 = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_CONCURRENT);
+
+  global = 42;
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    dispatch_sync(q1, ^{
+      global = 43;
+      barrier_wait(&barrier);
+    });
+  });
+  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    dispatch_sync(q2, ^{
+      barrier_wait(&barrier);
+      global = 44;
+
+      dispatch_semaphore_signal(done);
+    });
+  });
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+}
+
+// CHECK: Hello world.
+// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'global' {{(of size 8 )?}}at [[ADDR]] (sync-race.c.tmp+0x{{[0-9,a-f]+}})
+// CHECK: Done.

Added: compiler-rt/trunk/test/tsan/libdispatch/target-queue-norace.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/libdispatch/target-queue-norace.c?rev=358316&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/libdispatch/target-queue-norace.c (added)
+++ compiler-rt/trunk/test/tsan/libdispatch/target-queue-norace.c Fri Apr 12 16:07:00 2019
@@ -0,0 +1,41 @@
+// RUN: %clang_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
+
+long global;
+
+int main(int argc, const char *argv[]) {
+  dispatch_semaphore_t done = dispatch_semaphore_create(0);
+  dispatch_queue_t target_queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
+  dispatch_queue_t q1 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT);
+  dispatch_queue_t q2 = dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT);
+  dispatch_set_target_queue(q1, target_queue);
+  dispatch_set_target_queue(q2, target_queue);
+
+  for (int i = 0; i < 100000; i++) {
+    dispatch_async(q1, ^{
+      global++;
+
+      if (global == 200000) {
+        dispatch_semaphore_signal(done);
+      }
+    });
+    dispatch_async(q2, ^{
+      global++;
+
+      if (global == 200000) {
+        dispatch_semaphore_signal(done);
+      }
+    });
+  }
+
+  dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+  fprintf(stderr, "Done.\n");
+  return 0;
+}
+
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK: Done.




More information about the llvm-commits mailing list