Skip to content

Commit f872706

Browse files
authored
[InstrProf] Test that entry coverage counts accumulate (#81806)
1 parent 1fe8e2b commit f872706

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compiler-rt/test/profile/instrprof-block-coverage.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clang_profuse=%t.profdata -mllvm -pgo-verify-bfi -o - -S -emit-llvm %s 2>%t.errs | FileCheck %s --implicit-check-not="!prof"
66
// RUN: FileCheck %s < %t.errs --allow-empty --check-prefix=CHECK-ERROR
77

8+
// RUN: llvm-profdata merge -o %t2.profdata %t1.profraw %t1.profraw %t2.profraw %t2.profraw
9+
// RUN: llvm-profdata show %t2.profdata | FileCheck %s --check-prefix=COUNTS
10+
811
#include <stdlib.h>
912

1013
// CHECK: @foo({{.*}})
@@ -45,3 +48,5 @@ int main(int argc, char *argv[]) {
4548
// CHECK-DAG: ![[PROF2]] = !{!"branch_weights", i32 0, i32 1}
4649

4750
// CHECK-ERROR-NOT: warning: {{.*}}: Found inconsistent block coverage
51+
52+
// COUNTS: Maximum function count: 4

compiler-rt/test/profile/instrprof-entry-coverage.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
44
// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --implicit-check-not goo
55

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+
613
// RUN: %clang_cspgogen -O1 -mllvm -pgo-function-entry-coverage %s -o %t.cs.out
714
// RUN: env LLVM_PROFILE_FILE=%t.csprofraw %run %t.cs.out
815
// RUN: llvm-profdata merge -o %t.csprofdata %t.csprofraw
916
// 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
1019

1120
void markUsed(int a) {
1221
volatile int g;
@@ -26,3 +35,5 @@ int main(int argc, char *argv[]) {
2635
// CHECK-DAG: main
2736
// CHECK-DAG: foo
2837
// CHECK-DAG: bar
38+
39+
// COUNTS: Maximum function count: 2

0 commit comments

Comments
 (0)