Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / coverage-trace-pc.cpp
blobc03a6f02f77196fa0a7c0705a2f90545387971d7
1 // Test -fsanitize-coverage=edge,indirect-call,trace-pc
2 // RUN: %clangxx_asan -O0 -DTRACE_RT %s -o %t-rt.o -c
3 // RUN: %clangxx_asan -O0 -fsanitize-coverage=edge,trace-pc,indirect-calls %s -o %t %t-rt.o
4 // RUN: %run %t
5 #ifdef TRACE_RT
6 int pc_count;
7 void *last_callee;
8 extern "C" void __sanitizer_cov_trace_pc() {
9 pc_count++;
11 extern "C" void __sanitizer_cov_trace_pc_indir(void *callee) {
12 last_callee = callee;
14 #else
15 #include <stdio.h>
16 #include <assert.h>
17 extern int pc_count;
18 extern void *last_callee;
20 __attribute__((noinline)) void foo() { printf("foo\n"); }
21 __attribute__((noinline)) void bar() { printf("bar\n"); }
23 int main(int argc, char **argv) {
24 void (*f)(void) = argc ? foo : bar;
25 int c1 = pc_count;
26 f();
27 int c2 = pc_count;
28 assert(c1 < c2);
29 assert(last_callee == foo);
31 #endif