Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / instrprof-block-coverage.c
blob4f1e77810ab5fd162a4b44c9def8c4dbac916084
1 // RUN: %clang_pgogen -mllvm -pgo-block-coverage %s -o %t.out
2 // RUN: env LLVM_PROFILE_FILE=%t1.profraw %run %t.out 1
3 // RUN: env LLVM_PROFILE_FILE=%t2.profraw %run %t.out 2
4 // RUN: llvm-profdata merge -o %t.profdata %t1.profraw %t2.profraw
5 // RUN: %clang_profuse=%t.profdata -mllvm -pgo-verify-bfi -o - -S -emit-llvm %s 2>%t.errs | FileCheck %s --implicit-check-not="!prof"
6 // RUN: FileCheck %s < %t.errs --allow-empty --check-prefix=CHECK-ERROR
8 #include <stdlib.h>
10 // CHECK: @foo({{.*}})
11 // CHECK-SAME: !prof ![[PROF0:[0-9]+]]
12 void foo(int a) {
13 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PROF1:[0-9]+]]
14 if (a % 2 == 0) {
16 } else {
20 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PROF1]]
21 for (int i = 1; i < a; i++) {
22 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PROF2:[0-9]+]]
23 if (a % 3 == 0) {
25 } else {
26 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PROF2]]
27 if (a % 1001 == 0) {
28 return;
33 return;
36 // CHECK: @main({{.*}})
37 // CHECK-SAME: !prof ![[PROF0]]
38 int main(int argc, char *argv[]) {
39 foo(atoi(argv[1]));
40 return 0;
43 // CHECK-DAG: ![[PROF0]] = !{!"function_entry_count", i64 10000}
44 // CHECK-DAG: ![[PROF1]] = !{!"branch_weights", i32 1, i32 1}
45 // CHECK-DAG: ![[PROF2]] = !{!"branch_weights", i32 0, i32 1}
47 // CHECK-ERROR-NOT: warning: {{.*}}: Found inconsistent block coverage