Summary: This substitution expands to the appropriate minimum deployment target flag where thread local storage (TLS) was first introduced on Darwin platforms. For all other platforms the substitution expands to an empty string. E.g. for macOS the substitution expands to `-mmacosx-version-min=10.12` This patch adds support for the substitution (and future substitutions) by doing a minor refactor and then uses the substitution in the relevant TSan tests. rdar://problem/59568956 Reviewers: yln, kubamracek, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D74802
42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
// RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
|
|
// RUN: %deflake %run %t | FileCheck %s
|
|
#include "test.h"
|
|
|
|
int Global;
|
|
__thread int huge[1024*1024];
|
|
|
|
void *Thread1(void *x) {
|
|
barrier_wait(&barrier);
|
|
Global++;
|
|
return NULL;
|
|
}
|
|
|
|
void *Thread2(void *x) {
|
|
pthread_mutex_t *mtx = new pthread_mutex_t;
|
|
pthread_mutex_init(mtx, 0);
|
|
pthread_mutex_lock(mtx);
|
|
Global--;
|
|
pthread_mutex_unlock(mtx);
|
|
pthread_mutex_destroy(mtx);
|
|
delete mtx;
|
|
barrier_wait(&barrier);
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
barrier_init(&barrier, 2);
|
|
pthread_t t[2];
|
|
pthread_create(&t[0], NULL, Thread1, NULL);
|
|
pthread_create(&t[1], NULL, Thread2, NULL);
|
|
pthread_join(t[0], NULL);
|
|
pthread_join(t[1], NULL);
|
|
}
|
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|
|
// CHECK: Write of size 4 at {{.*}} by thread T1:
|
|
// CHECK: Previous write of size 4 at {{.*}} by thread T2
|
|
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
|
// CHECK: Mutex [[M1]] is already destroyed
|
|
// CHECK-NOT: Mutex {{.*}} created at
|
|
|