xref: /aosp_15_r20/external/compiler-rt/test/profile/instrprof-reset-counters.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_profgen -o %t -O3 %s
2*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
3*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.profdata %t.profraw
4*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot void __llvm_profile_reset_counters(void);
7*7c3d14c8STreehugger Robot void foo(int);
main(void)8*7c3d14c8STreehugger Robot int main(void) {
9*7c3d14c8STreehugger Robot   foo(0);
10*7c3d14c8STreehugger Robot   __llvm_profile_reset_counters();
11*7c3d14c8STreehugger Robot   foo(1);
12*7c3d14c8STreehugger Robot   return 0;
13*7c3d14c8STreehugger Robot }
foo(int N)14*7c3d14c8STreehugger Robot void foo(int N) {
15*7c3d14c8STreehugger Robot   // CHECK-LABEL: define void @foo(
16*7c3d14c8STreehugger Robot   // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[FOO:[0-9]+]]
17*7c3d14c8STreehugger Robot   if (N) {}
18*7c3d14c8STreehugger Robot }
19*7c3d14c8STreehugger Robot // CHECK: ![[FOO]] = !{!"branch_weights", i32 2, i32 1}
20