brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · e2f5e11 Raw
36 lines · c
1// RUN: rm -rf %t1.profraw %t2.profraw2// RUN: %clang_profgen -o %t -O3 %s3// RUN: env LLVM_PROFILE_FILE=%t1.profraw %run %t %t2.profraw4// RUN: llvm-profdata merge -o %t1.profdata %t1.profraw5// RUN: %clang_profuse=%t1.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK6// RUN: llvm-profdata merge -o %t2.profdata %t2.profraw7// RUN: %clang_profuse=%t2.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK8 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 < 2)16    return 1;17 18  // Write out the profile.19  __llvm_profile_write_file();20 21  // Change the profile.22  int Ret = foo(0);23 24  // It'll write out again at exit; change the filename so we get two files.25  __llvm_profile_set_filename(argv[1]);26  return Ret;27}28int foo(int X) {29  // CHECK-LABEL: define {{.*}} @foo(30  // CHECK1: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}}31  // CHECK2: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]]32  return X <= 0 ? -X : X;33}34// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}35// CHECK2: ![[PD2]] = !{!"branch_weights", i32 2, i32 1}36