Skip to content

[InstrProf] Test that entry coverage counts accumulate #81806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler-rt/test/profile/instrprof-block-coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// RUN: %clang_profuse=%t.profdata -mllvm -pgo-verify-bfi -o - -S -emit-llvm %s 2>%t.errs | FileCheck %s --implicit-check-not="!prof"
// RUN: FileCheck %s < %t.errs --allow-empty --check-prefix=CHECK-ERROR

// RUN: llvm-profdata merge -o %t2.profdata %t1.profraw %t1.profraw %t2.profraw %t2.profraw
// RUN: llvm-profdata show %t2.profdata | FileCheck %s --check-prefix=COUNTS

#include <stdlib.h>

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

// CHECK-ERROR-NOT: warning: {{.*}}: Found inconsistent block coverage

// COUNTS: Maximum function count: 4
11 changes: 11 additions & 0 deletions compiler-rt/test/profile/instrprof-entry-coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
// 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;
Expand All @@ -26,3 +35,5 @@ int main(int argc, char *argv[]) {
// CHECK-DAG: main
// CHECK-DAG: foo
// CHECK-DAG: bar

// COUNTS: Maximum function count: 2