xref: /minix3/sys/external/bsd/compiler_rt/dist/test/profile/instrprof-write-file-atexit-explicitly.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_profgen -o %t -O3 %s
2*0a6a1f1dSLionel Sambuc // RUN: %run %t %t.profraw
3*0a6a1f1dSLionel Sambuc // RUN: llvm-profdata merge -o %t.profdata %t.profraw
4*0a6a1f1dSLionel Sambuc // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc int __llvm_profile_runtime = 0;
7*0a6a1f1dSLionel Sambuc int __llvm_profile_register_write_file_atexit(void);
8*0a6a1f1dSLionel Sambuc void __llvm_profile_set_filename(const char *);
main(int argc,const char * argv[])9*0a6a1f1dSLionel Sambuc int main(int argc, const char *argv[]) {
10*0a6a1f1dSLionel Sambuc   __llvm_profile_register_write_file_atexit();
11*0a6a1f1dSLionel Sambuc   // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1
12*0a6a1f1dSLionel Sambuc   if (argc < 2)
13*0a6a1f1dSLionel Sambuc     return 1;
14*0a6a1f1dSLionel Sambuc   __llvm_profile_set_filename(argv[1]);
15*0a6a1f1dSLionel Sambuc   return 0;
16*0a6a1f1dSLionel Sambuc }
17*0a6a1f1dSLionel Sambuc // CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 2}
18