From 1838561dfe0e60cf87c6b15ab3c63f4124359c09 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 19 Apr 2017 23:05:53 +0000 Subject: [PATCH] [sanitizer-coverage] remove more unused code llvm-svn: 300780 --- .../include/sanitizer/coverage_interface.h | 8 --- compiler-rt/lib/dfsan/done_abilist.txt | 6 -- .../sanitizer_coverage_interface.inc | 2 - .../sanitizer_coverage_libcdep.cc | 18 ------ .../test/asan/TestCases/coverage-reset.cc | 63 ------------------- 5 files changed, 97 deletions(-) delete mode 100644 compiler-rt/test/asan/TestCases/coverage-reset.cc diff --git a/compiler-rt/include/sanitizer/coverage_interface.h b/compiler-rt/include/sanitizer/coverage_interface.h index adf0960d2321..911a3e854b77 100644 --- a/compiler-rt/include/sanitizer/coverage_interface.h +++ b/compiler-rt/include/sanitizer/coverage_interface.h @@ -35,14 +35,6 @@ extern "C" { // Get the number of unique covered blocks (or edges). // This can be useful for coverage-directed in-process fuzzers. uintptr_t __sanitizer_get_total_unique_coverage(); - - // Reset the basic-block (edge) coverage to the initial state. - // Useful for in-process fuzzing to start collecting coverage from scratch. - // Experimental, will likely not work for multi-threaded process. - void __sanitizer_reset_coverage(); - // Set *data to the array of covered PCs and return the size of that array. - // Some of the entries in *data will be zero. - uintptr_t __sanitizer_get_coverage_guards(uintptr_t **data); #ifdef __cplusplus } // extern "C" #endif diff --git a/compiler-rt/lib/dfsan/done_abilist.txt b/compiler-rt/lib/dfsan/done_abilist.txt index d3ac553db2c5..cbbedbc33601 100644 --- a/compiler-rt/lib/dfsan/done_abilist.txt +++ b/compiler-rt/lib/dfsan/done_abilist.txt @@ -285,14 +285,8 @@ fun:__sanitizer_cov_module_init=uninstrumented fun:__sanitizer_cov_module_init=discard fun:__sanitizer_cov_with_check=uninstrumented fun:__sanitizer_cov_with_check=discard -fun:__sanitizer_reset_coverage=uninstrumented -fun:__sanitizer_reset_coverage=discard fun:__sanitizer_set_death_callback=uninstrumented fun:__sanitizer_set_death_callback=discard -fun:__sanitizer_get_coverage_guards=uninstrumented -fun:__sanitizer_get_coverage_guards=discard -fun:__sanitizer_get_total_unique_coverage=uninstrumented -fun:__sanitizer_get_total_unique_coverage=discard fun:__sanitizer_get_total_unique_coverage=uninstrumented fun:__sanitizer_get_total_unique_coverage=discard fun:__sanitizer_update_counter_bitset_and_clear_counters=uninstrumented diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc index 139a8b989c5f..42b4d3aba01b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc @@ -15,10 +15,8 @@ INTERFACE_FUNCTION(__sanitizer_cov_module_init) INTERFACE_FUNCTION(__sanitizer_cov_with_check) INTERFACE_FUNCTION(__sanitizer_dump_coverage) INTERFACE_FUNCTION(__sanitizer_dump_trace_pc_guard_coverage) -INTERFACE_FUNCTION(__sanitizer_get_coverage_guards) INTERFACE_FUNCTION(__sanitizer_get_total_unique_coverage) INTERFACE_FUNCTION(__sanitizer_maybe_open_cov_file) -INTERFACE_FUNCTION(__sanitizer_reset_coverage) INTERFACE_WEAK_FUNCTION(__sancov_default_options) INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp) INTERFACE_WEAK_FUNCTION(__sanitizer_cov_trace_cmp1) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc index d3447a553739..bb59c344edc2 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc @@ -58,10 +58,6 @@ static atomic_uint32_t dump_once_guard; // Ensure that CovDump runs only once. static atomic_uintptr_t coverage_counter; -static void ResetGlobalCounters() { - return atomic_store(&coverage_counter, 0, memory_order_relaxed); -} - // pc_array is the array containing the covered PCs. // To make the pc_array thread- and async-signal-safe it has to be large enough. // 128M counters "ought to be enough for anybody" (4M on 32-bit). @@ -674,20 +670,6 @@ uptr __sanitizer_get_total_unique_coverage() { return atomic_load(&coverage_counter, memory_order_relaxed); } -SANITIZER_INTERFACE_ATTRIBUTE -void __sanitizer_reset_coverage() { - ResetGlobalCounters(); - coverage_data.ReinitializeGuards(); - internal_bzero_aligned16( - coverage_data.data(), - RoundUpTo(coverage_data.size() * sizeof(coverage_data.data()[0]), 16)); -} -SANITIZER_INTERFACE_ATTRIBUTE -uptr __sanitizer_get_coverage_guards(uptr **data) { - *data = coverage_data.data(); - return coverage_data.size(); -} - // Default empty implementations (weak). Users should redefine them. SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_cmp, void) {} SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_trace_cmp1, void) {} diff --git a/compiler-rt/test/asan/TestCases/coverage-reset.cc b/compiler-rt/test/asan/TestCases/coverage-reset.cc deleted file mode 100644 index 11c5ef66ecf6..000000000000 --- a/compiler-rt/test/asan/TestCases/coverage-reset.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Test __sanitizer_reset_coverage(). - -// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t -// RUN: %env_asan_opts=coverage=1 %run %t - -// https://github.com/google/sanitizers/issues/618 -// UNSUPPORTED: android - -#include -#include -#include -static volatile int sink; -__attribute__((noinline)) void bar() { sink = 2; } -__attribute__((noinline)) void foo() { sink = 1; } - -// In MSVC 2015, printf is an inline function, which causes this test to fail as -// it introduces an extra coverage point. Define away printf on that platform to -// avoid the issue. -#if _MSC_VER >= 1900 -# define printf(arg, ...) -#endif - -#define GET_AND_PRINT_COVERAGE() \ - bitset = 0; \ - for (size_t i = 0; i < n_guards; i++) \ - if (guards[i]) bitset |= 1U << i; \ - printf("line %d: bitset %zd total: %zd\n", __LINE__, bitset, \ - __sanitizer_get_total_unique_coverage()); - -#define IS_POWER_OF_TWO(a) ((a & ((a) - 1)) == 0) - -int main() { - size_t *guards = 0; - size_t bitset; - size_t n_guards = __sanitizer_get_coverage_guards(&guards); - - GET_AND_PRINT_COVERAGE(); - size_t main_bit = bitset; - assert(IS_POWER_OF_TWO(main_bit)); - - foo(); - GET_AND_PRINT_COVERAGE(); - size_t foo_bit = bitset & ~main_bit; - assert(IS_POWER_OF_TWO(foo_bit)); - - bar(); - GET_AND_PRINT_COVERAGE(); - size_t bar_bit = bitset & ~(main_bit | foo_bit); - assert(IS_POWER_OF_TWO(bar_bit)); - - __sanitizer_reset_coverage(); - assert(__sanitizer_get_total_unique_coverage() == 0); - GET_AND_PRINT_COVERAGE(); - assert(bitset == 0); - - foo(); - GET_AND_PRINT_COVERAGE(); - assert(bitset == foo_bit); - - bar(); - GET_AND_PRINT_COVERAGE(); - assert(bitset == (foo_bit | bar_bit)); -}