[PATCH] D77638: [part 3] sancov/inline-bool-flag compiler-rt test.

Pratyai Mazumder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 04:49:51 PDT 2020


pratyai created this revision.
pratyai added reviewers: kcc, vitalybuka.
Herald added subscribers: Sanitizers, dberris.
Herald added a project: Sanitizers.

(must follow part-1[D77244 <https://reviews.llvm.org/D77244>], and part-2[D77637 <https://reviews.llvm.org/D77637>])

In the previous part, we implemented the instrumentation of sancov/inline-bool-flag, and its wiring through the clang-flags.

This is the last part where we add the compiler-rt /.. test, as discussed in part-1[D77244 <https://reviews.llvm.org/D77244>] comments. The test is making the similar assertions as the sibling test for `inline-8bit-counters`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77638

Files:
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
===================================================================
--- /dev/null
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
@@ -0,0 +1,42 @@
+// Tests -fsanitize-coverage=inline-bool-flag,pc-table
+//
+// REQUIRES: has_sancovcc,stable-runtime
+// UNSUPPORTED: i386-darwin
+//
+// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+// XFAIL: tsan
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+
+const bool *first_flag;
+
+extern "C" void __sanitizer_cov_bool_flag_init(const bool *start,
+                                               const bool *end) {
+  printf("INIT: %p %p\n", start, end);
+  assert(end - start > 1);
+  first_flag = start;
+}
+
+uintptr_t FirstPC;
+uintptr_t FirstPCFlag;
+
+extern "C" void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
+                                         const uintptr_t *pcs_end) {
+  const uintptr_t *B = (const uintptr_t *)pcs_beg;
+  const uintptr_t *E = (const uintptr_t *)pcs_end;
+  assert(B + 1 < E);
+  FirstPC = B[0];
+  FirstPCFlag = B[1];
+}
+
+int main() {
+  assert(first_flag);
+  assert(*first_flag);
+  assert(FirstPC == (uintptr_t)&main);
+  assert(FirstPCFlag == 1);
+  fprintf(stderr, "PASS\n");
+  // CHECK: PASS
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77638.255639.patch
Type: text/x-patch
Size: 1404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200407/3e30ab64/attachment.bin>


More information about the llvm-commits mailing list