| 1 | // XFAIL: target={{.*}}-aix{{.*}} |
| 2 | // RUN: %clang_profgen -o %t -O3 %s |
| 3 | // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t |
| 4 | // RUN: llvm-profdata merge -o %t.profdata %t.profraw |
| 5 | // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s |
| 6 | |
| 7 | int __llvm_profile_runtime = 0; |
| 8 | void __llvm_profile_initialize_file(void); |
| 9 | int __llvm_profile_write_file(void); |
| 10 | void __llvm_profile_set_filename(const char *); |
| 11 | int foo(int); |
| 12 | int 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 the |
| 19 | // 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 | } |
| 28 | int foo(int X) { |
| 29 | // There should be no profiling information for @foo, since it was called |
| 30 | // after the profile was written (and the atexit was suppressed by defining |
| 31 | // 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 | |