37 lines · c
1// XFAIL: target={{.*}}-aix{{.*}}2// RUN: %clang_profgen -o %t -O3 %s3// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t4// RUN: llvm-profdata merge -o %t.profdata %t.profraw5// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s6 7int __llvm_profile_runtime = 0;8void __llvm_profile_initialize_file(void);9int __llvm_profile_write_file(void);10void __llvm_profile_set_filename(const char *);11int foo(int);12int main(int argc, const char *argv[]) {13 // CHECK-LABEL: define {{.*}} @main(14 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]15 if (argc > 42)16 return 1;17 18 // Since the runtime has been suppressed, initialize the file name, as the19 // writing will fail below as the file name has not been specified.20 __llvm_profile_initialize_file();21 22 // Write out the profile.23 __llvm_profile_write_file();24 25 // Change the profile.26 return foo(0);27}28int foo(int X) {29 // There should be no profiling information for @foo, since it was called30 // after the profile was written (and the atexit was suppressed by defining31 // profile_runtime).32 // CHECK-LABEL: define {{.*}} @foo(33 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}}34 return X <= 0 ? -X : X;35}36// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}37