diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -43,11 +43,12 @@ SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress | SanitizerKind::MemTag | SanitizerKind::Memory | SanitizerKind::KernelMemory | SanitizerKind::Leak | - SanitizerKind::Undefined | SanitizerKind::Integer | + SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::Bounds | SanitizerKind::ImplicitConversion | SanitizerKind::Nullability | SanitizerKind::DataFlow | SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink | SanitizerKind::FloatDivideByZero | - SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack; + SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack | + SanitizerKind::Thread; static const SanitizerMask RecoverableByDefault = SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::ImplicitConversion | SanitizerKind::Nullability | diff --git a/clang/test/CodeGen/sanitize-coverage-bounds.c b/clang/test/CodeGen/sanitize-coverage-bounds.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/sanitize-coverage-bounds.c @@ -0,0 +1,29 @@ +// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=bounds -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s + +int x[10]; + +// CHECK-LABEL: define dso_local void @foo( +void foo(int n) { + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: call void @__sanitizer_cov_trace_const_cmp + // CHECK: br + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: br + // CHECK: call void @__sanitizer_cov_trace_const_cmp + // CHECK: br + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: br + if (n) + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: call void @__ubsan_handle_out_of_bounds + // CHECK: br + // CHECK: getelementptr inbounds [10 x i32], [10 x i32]* @x + // CHECK: call void @__sanitizer_cov_trace_const_cmp8 + // CHECK: br + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: store i32 42 + // CHECK: br + x[n] = 42; + + // CHECK: ret void +} diff --git a/clang/test/CodeGen/sanitize-coverage-thread.c b/clang/test/CodeGen/sanitize-coverage-thread.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/sanitize-coverage-thread.c @@ -0,0 +1,25 @@ +// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=thread -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s + +int x = 0; + +// CHECK-LABEL: define dso_local void @foo( +void foo(void) { + // CHECK: call void @__sanitizer_cov_trace_pc + + // CHECK: call void @__tsan_read4(i8* bitcast (i32* @x to i8*)) + // CHECK-NEXT: load i32, i32* @x, align 4 + + // CHECK: call void @__sanitizer_cov_trace_const_cmp4 + // CHECK: br + + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: br + if (x) + // CHECK: call void @__sanitizer_cov_trace_pc + // CHECK: call void @__tsan_write4(i8* bitcast (i32* @x to i8*)) + // CHECK-NEXT: store i32 42, i32* @x, align 4 + // CHECK: br + x = 42; + + // CHECK: ret void +} diff --git a/clang/test/Driver/fsanitize-coverage.c b/clang/test/Driver/fsanitize-coverage.c --- a/clang/test/Driver/fsanitize-coverage.c +++ b/clang/test/Driver/fsanitize-coverage.c @@ -12,8 +12,10 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC +// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC +// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1 diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp @@ -5,7 +5,6 @@ // // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t // RUN: %run %t 2>&1 | FileCheck %s -// XFAIL: tsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp @@ -5,7 +5,6 @@ // // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t // RUN: %run %t 2>&1 | FileCheck %s -// XFAIL: tsan #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp @@ -2,7 +2,7 @@ // REQUIRES: has_sancovcc,stable-runtime // UNSUPPORTED: i386-darwin -// XFAIL: ubsan,tsan +// XFAIL: ubsan // XFAIL: android && asan // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb,no-prune 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 3 diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp @@ -1,7 +1,5 @@ // Tests -fsanitize-coverage=stack-depth // -// XFAIL: tsan -// // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \ diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp @@ -1,7 +1,6 @@ // Tests trace pc guard coverage collection. // // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux -// XFAIL: tsan // // RUN: DIR=%t_workdir // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"