1// RUN: %clang_pgogen -mllvm -pgo-function-entry-coverage %s -o %t.out
2// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.out
3// RUN: llvm-profdata merge -o %t.profdata %t.profraw
4// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --implicit-check-not goo
5
6// We deliberately merge the raw profile twice to test that internal counts can
7// grow larger than one. Technically, accumulating coverage values is different
8// than accumulating counts, but this helps discriminate cold functions from hot
9// functions when the number of raw profiles is large.
10// RUN: llvm-profdata merge -o %t2.profdata %t.profraw %t.profraw
11// RUN: llvm-profdata show %t2.profdata | FileCheck %s --check-prefix=COUNTS
12
13// RUN: %clang_cspgogen -O1 -mllvm -pgo-function-entry-coverage %s -o %t.cs.out
14// RUN: env LLVM_PROFILE_FILE=%t.csprofraw %run %t.cs.out
15// RUN: llvm-profdata merge -o %t.csprofdata %t.csprofraw
16// RUN: llvm-profdata show --covered %t.csprofdata --showcs | FileCheck %s --implicit-check-not goo
17// RUN: llvm-profdata merge -o %t2.csprofdata %t.csprofraw %t.csprofraw
18// RUN: llvm-profdata show --showcs %t2.csprofdata | FileCheck %s --check-prefix=COUNTS
19
20void markUsed(int a) {
21 volatile int g;
22 g = a;
23}
24
25__attribute__((noinline)) int foo(int i) { return 4 * i + 1; }
26__attribute__((noinline)) int bar(int i) { return 4 * i + 2; }
27__attribute__((noinline)) int goo(int i) { return 4 * i + 3; }
28
29int main(int argc, char *argv[]) {
30 markUsed(a: foo(i: 5));
31 markUsed(a: argc ? bar(i: 6) : goo(i: 7));
32 return 0;
33}
34
35// CHECK-DAG: main
36// CHECK-DAG: foo
37// CHECK-DAG: bar
38
39// COUNTS: Maximum function count: 2
40

source code of compiler-rt/test/profile/instrprof-entry-coverage.c