xref: /aosp_15_r20/external/compiler-rt/test/profile/instrprof-write-file-atexit-explicitly.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_profgen -o %t -O3 %s
2*7c3d14c8STreehugger Robot // RUN: %run %t %t.profraw
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 int __llvm_profile_runtime = 0;
7*7c3d14c8STreehugger Robot int __llvm_profile_register_write_file_atexit(void);
8*7c3d14c8STreehugger Robot void __llvm_profile_set_filename(const char *);
main(int argc,const char * argv[])9*7c3d14c8STreehugger Robot int main(int argc, const char *argv[]) {
10*7c3d14c8STreehugger Robot   __llvm_profile_register_write_file_atexit();
11*7c3d14c8STreehugger Robot   // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
12*7c3d14c8STreehugger Robot   if (argc < 2)
13*7c3d14c8STreehugger Robot     return 1;
14*7c3d14c8STreehugger Robot   __llvm_profile_set_filename(argv[1]);
15*7c3d14c8STreehugger Robot   return 0;
16*7c3d14c8STreehugger Robot }
17*7c3d14c8STreehugger Robot // CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}
18