2014-05-10 07:14:58 +08:00
|
|
|
// RUN: %clang_profgen -o %t -O3 %s
|
|
|
|
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
|
|
|
|
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
|
|
|
|
// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
|
|
|
|
|
|
|
|
int __llvm_profile_runtime = 0;
|
2014-05-19 04:05:35 +08:00
|
|
|
void __llvm_profile_initialize_file(void);
|
2014-05-10 07:14:58 +08:00
|
|
|
int __llvm_profile_write_file(void);
|
|
|
|
void __llvm_profile_set_filename(const char *);
|
|
|
|
int foo(int);
|
|
|
|
int main(int argc, const char *argv[]) {
|
2014-11-13 17:24:32 +08:00
|
|
|
// CHECK-LABEL: define {{.*}} @main(
|
2014-11-19 07:03:14 +08:00
|
|
|
// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]
|
2016-03-26 12:01:57 +08:00
|
|
|
if (argc > 42)
|
2014-05-10 07:14:58 +08:00
|
|
|
return 1;
|
|
|
|
|
2014-05-19 04:05:35 +08:00
|
|
|
// Since the runtime has been suppressed, initialize the file name, as the
|
|
|
|
// writing will fail below as the file name has not been specified.
|
|
|
|
__llvm_profile_initialize_file();
|
|
|
|
|
2014-05-10 07:14:58 +08:00
|
|
|
// Write out the profile.
|
|
|
|
__llvm_profile_write_file();
|
|
|
|
|
|
|
|
// Change the profile.
|
|
|
|
return foo(0);
|
|
|
|
}
|
|
|
|
int foo(int X) {
|
|
|
|
// There should be no profiling information for @foo, since it was called
|
2014-05-15 10:22:34 +08:00
|
|
|
// after the profile was written (and the atexit was suppressed by defining
|
2014-05-10 07:14:58 +08:00
|
|
|
// profile_runtime).
|
2014-11-13 17:24:32 +08:00
|
|
|
// CHECK-LABEL: define {{.*}} @foo(
|
2014-05-10 07:14:58 +08:00
|
|
|
// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}}
|
|
|
|
return X <= 0 ? -X : X;
|
|
|
|
}
|
2020-10-01 03:11:46 +08:00
|
|
|
// CHECK: ![[PD1]] = !{!"branch_weights", i64 1, i64 2}
|