Summary: This permits combining -fsanitize-coverage with -fsanitize=bounds or -fsanitize=thread. Note that, GCC already supports combining these. Tested: - Add Clang end-to-end test checking IR is generated for both combinations of sanitizers. - Several previously failing TSAN tests now pass. Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=45831 Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: #sanitizers, dvyukov, nickdesaulniers, cfe-commits Tags: #clang, #sanitizers Differential Revision: https://reviews.llvm.org/D79628
43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
// Tests -fsanitize-coverage=inline-8bit-counters,pc-table
|
|
//
|
|
// REQUIRES: has_sancovcc,stable-runtime
|
|
// UNSUPPORTED: i386-darwin
|
|
//
|
|
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
|
|
// RUN: %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <assert.h>
|
|
|
|
const char *first_counter;
|
|
|
|
extern "C"
|
|
void __sanitizer_cov_8bit_counters_init(const char *start, const char *end) {
|
|
printf("INIT: %p %p\n", start, end);
|
|
assert(end - start > 1);
|
|
first_counter = 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_counter);
|
|
assert(*first_counter == 1);
|
|
assert(FirstPC == (uintptr_t)&main);
|
|
assert(FirstPCFlag == 1);
|
|
fprintf(stderr, "PASS\n");
|
|
// CHECK: PASS
|
|
}
|