Home | History | Annotate | Line # | Download | only in profile
      1      1.1  joerg // RUN: %clang_profgen -o %t -O3 %s
      2      1.1  joerg // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
      3      1.1  joerg // RUN: llvm-profdata merge -o %t.profdata %t.profraw
      4      1.1  joerg // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
      5      1.1  joerg 
      6      1.1  joerg int __llvm_profile_runtime = 0;
      7  1.1.1.2  joerg void __llvm_profile_initialize_file(void);
      8      1.1  joerg int __llvm_profile_write_file(void);
      9      1.1  joerg void __llvm_profile_set_filename(const char *);
     10      1.1  joerg int foo(int);
     11      1.1  joerg int main(int argc, const char *argv[]) {
     12  1.1.1.3  joerg   // CHECK-LABEL: define {{.*}} @main(
     13  1.1.1.3  joerg   // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
     14      1.1  joerg   if (argc > 1)
     15      1.1  joerg     return 1;
     16      1.1  joerg 
     17  1.1.1.2  joerg   // Since the runtime has been suppressed, initialize the file name, as the
     18  1.1.1.2  joerg   // writing will fail below as the file name has not been specified.
     19  1.1.1.2  joerg   __llvm_profile_initialize_file();
     20  1.1.1.2  joerg 
     21      1.1  joerg   // Write out the profile.
     22      1.1  joerg   __llvm_profile_write_file();
     23      1.1  joerg 
     24      1.1  joerg   // Change the profile.
     25      1.1  joerg   return foo(0);
     26      1.1  joerg }
     27      1.1  joerg int foo(int X) {
     28      1.1  joerg   // There should be no profiling information for @foo, since it was called
     29  1.1.1.2  joerg   // after the profile was written (and the atexit was suppressed by defining
     30      1.1  joerg   // profile_runtime).
     31  1.1.1.3  joerg   // CHECK-LABEL: define {{.*}} @foo(
     32      1.1  joerg   // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}}
     33      1.1  joerg   return X <= 0 ? -X : X;
     34      1.1  joerg }
     35  1.1.1.3  joerg // CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}
     36