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