Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_inline8bit_counter.cpp
blob68eca85eb4d425bf3cd3650541722da08359fa02
1 // Tests -fsanitize-coverage=inline-8bit-counters,pc-table
2 //
3 // REQUIRES: has_sancovcc,stable-runtime
4 // UNSUPPORTED: i386-darwin
5 //
6 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
7 // RUN: %run %t 2>&1 | FileCheck %s
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <assert.h>
13 const char *first_counter;
15 extern "C"
16 void __sanitizer_cov_8bit_counters_init(const char *start, const char *end) {
17 printf("INIT: %p %p\n", start, end);
18 assert(end - start > 1);
19 first_counter = start;
22 uintptr_t FirstPC;
23 uintptr_t FirstPCFlag;
25 extern "C" void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
26 const uintptr_t *pcs_end) {
27 const uintptr_t *B = (const uintptr_t *)pcs_beg;
28 const uintptr_t *E = (const uintptr_t *)pcs_end;
29 assert(B + 1 < E);
30 FirstPC = B[0];
31 FirstPCFlag = B[1];
35 int main() {
36 assert(first_counter);
37 assert(*first_counter == 1);
38 assert(FirstPC == (uintptr_t)&main);
39 assert(FirstPCFlag == 1);
40 fprintf(stderr, "PASS\n");
41 // CHECK: PASS