File: instrprof-entry-coverage.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (39 lines) | stat: -rw-r--r-- 1,607 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// RUN: %clang_pgogen -mllvm -pgo-function-entry-coverage %s -o %t.out
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.out
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --implicit-check-not goo

// We deliberately merge the raw profile twice to test that internal counts can
// grow larger than one. Technically, accumulating coverage values is different
// than accumulating counts, but this helps discriminate cold functions from hot
// functions when the number of raw profiles is large.
// RUN: llvm-profdata merge -o %t2.profdata %t.profraw %t.profraw
// RUN: llvm-profdata show %t2.profdata | FileCheck %s --check-prefix=COUNTS

// RUN: %clang_cspgogen -O1 -mllvm -pgo-function-entry-coverage %s -o %t.cs.out
// RUN: env LLVM_PROFILE_FILE=%t.csprofraw %run %t.cs.out
// RUN: llvm-profdata merge -o %t.csprofdata %t.csprofraw
// RUN: llvm-profdata show --covered %t.csprofdata --showcs | FileCheck %s --implicit-check-not goo
// RUN: llvm-profdata merge -o %t2.csprofdata %t.csprofraw %t.csprofraw
// RUN: llvm-profdata show --showcs %t2.csprofdata | FileCheck %s --check-prefix=COUNTS

void markUsed(int a) {
  volatile int g;
  g = a;
}

__attribute__((noinline)) int foo(int i) { return 4 * i + 1; }
__attribute__((noinline)) int bar(int i) { return 4 * i + 2; }
__attribute__((noinline)) int goo(int i) { return 4 * i + 3; }

int main(int argc, char *argv[]) {
  markUsed(foo(5));
  markUsed(argc ? bar(6) : goo(7));
  return 0;
}

// CHECK-DAG: main
// CHECK-DAG: foo
// CHECK-DAG: bar

// COUNTS: Maximum function count: 2