[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

Marco Elver via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 14 15:15:16 PDT 2020


melver updated this revision to Diff 264112.
melver added a comment.

Fix formatting.

PTAL.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79628/new/

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c


Index: clang/test/Driver/fsanitize-coverage.c
===================================================================
--- clang/test/Driver/fsanitize-coverage.c
+++ 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
Index: clang/test/CodeGen/sanitize-coverage-thread.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-thread.c
@@ -0,0 +1,25 @@
+// RUN: %clang %s -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
+}
Index: clang/test/CodeGen/sanitize-coverage-bounds.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-bounds.c
@@ -0,0 +1,29 @@
+// RUN: %clang %s -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
+}
Index: clang/lib/Driver/SanitizerArgs.cpp
===================================================================
--- clang/lib/Driver/SanitizerArgs.cpp
+++ 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 |


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79628.264112.patch
Type: text/x-patch
Size: 4913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200514/c622073c/attachment.bin>


More information about the cfe-commits mailing list