Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_trace_pc_guard.cpp
blobed817961c688cca8cac71cbca6f509c2bb16a34d
1 // Tests trace pc guard coverage collection.
3 // REQUIRES: has_sancovcc
4 // UNSUPPORTED: ubsan,i386-darwin,target={{(powerpc64|s390x|thumb).*}}
5 // XFAIL: tsan
6 // XFAIL: android && asan
8 // RUN: DIR=%t_workdir
9 // RUN: rm -rf $DIR
10 // RUN: mkdir -p $DIR
11 // RUN: cd $DIR
12 // RUN: %clangxx -O0 -fsanitize-coverage=trace-pc-guard %s -o %t
13 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
14 // RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov %t 2>&1 | \
15 // RUN: FileCheck --check-prefix=CHECK-SANCOV %s
16 // RUN: %env_tool_opts=coverage=0 %t 2>&1 | FileCheck --check-prefix=CHECK-NOCOV %s
17 // RUN: rm -rf $DIR
18 // Make some room to stabilize line numbers
20 #include <stdio.h>
22 int foo() {
23 fprintf(stderr, "foo\n");
24 return 1;
27 int main() {
28 fprintf(stderr, "main\n");
29 foo();
30 foo();
33 // CHECK: main
34 // CHECK-NEXT: foo
35 // CHECK-NEXT: foo
36 // CHECK-NEXT: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard.{{.*}}.sancov: 2 PCs written
38 // CHECK-SANCOV: sanitizer_coverage_trace_pc_guard.cpp:[[@LINE-16]] foo
39 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard.cpp:[[@LINE-12]] main
41 // CHECK-NOCOV-NOT: SanitizerCoverage