[SanitizerCoverage] Add compiler-rt test for -fsanitize-coverage=inline-bool-flag

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: dberris, #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D77638
This commit is contained in:
Pratyai Mazumder 2020-04-09 02:41:58 -07:00 committed by Vitaly Buka
parent 2a1418f242
commit 2d39559d68
1 changed files with 42 additions and 0 deletions

View File

@ -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
}