40 lines · c
1// RUN: %clang_pgogen -mllvm -pgo-function-entry-coverage %s -o %t.out2// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.out3// RUN: llvm-profdata merge -o %t.profdata %t.profraw4// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --implicit-check-not goo5 6// We deliberately merge the raw profile twice to test that internal counts can7// grow larger than one. Technically, accumulating coverage values is different8// than accumulating counts, but this helps discriminate cold functions from hot9// functions when the number of raw profiles is large.10// RUN: llvm-profdata merge -o %t2.profdata %t.profraw %t.profraw11// RUN: llvm-profdata show %t2.profdata | FileCheck %s --check-prefix=COUNTS12 13// RUN: %clang_cspgogen -O1 -mllvm -pgo-function-entry-coverage %s -o %t.cs.out14// RUN: env LLVM_PROFILE_FILE=%t.csprofraw %run %t.cs.out15// RUN: llvm-profdata merge -o %t.csprofdata %t.csprofraw16// RUN: llvm-profdata show --covered %t.csprofdata --showcs | FileCheck %s --implicit-check-not goo17// RUN: llvm-profdata merge -o %t2.csprofdata %t.csprofraw %t.csprofraw18// RUN: llvm-profdata show --showcs %t2.csprofdata | FileCheck %s --check-prefix=COUNTS19 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(foo(5));31 markUsed(argc ? bar(6) : goo(7));32 return 0;33}34 35// CHECK-DAG: main36// CHECK-DAG: foo37// CHECK-DAG: bar38 39// COUNTS: Maximum function count: 240