1 1.1 joerg // RUN: %clang_profgen -o %t -O3 %s 2 1.1 joerg // RUN: env LLVM_PROFILE_FILE=%t1.profraw %run %t %t2.profraw 3 1.1 joerg // RUN: llvm-profdata merge -o %t1.profdata %t1.profraw 4 1.1 joerg // RUN: %clang_profuse=%t1.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK 5 1.1 joerg // RUN: llvm-profdata merge -o %t2.profdata %t2.profraw 6 1.1 joerg // RUN: %clang_profuse=%t2.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK 7 1.1 joerg 8 1.1 joerg int __llvm_profile_write_file(void); 9 1.1 joerg void __llvm_profile_set_filename(const char *); 10 1.1 joerg int foo(int); 11 1.1 joerg int main(int argc, const char *argv[]) { 12 1.1.1.2 joerg // CHECK-LABEL: define {{.*}} @main( 13 1.1.1.2 joerg // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] 14 1.1 joerg if (argc < 2) 15 1.1 joerg return 1; 16 1.1 joerg 17 1.1 joerg // Write out the profile. 18 1.1 joerg __llvm_profile_write_file(); 19 1.1 joerg 20 1.1 joerg // Change the profile. 21 1.1 joerg int Ret = foo(0); 22 1.1 joerg 23 1.1 joerg // It'll write out again at exit; change the filename so we get two files. 24 1.1 joerg __llvm_profile_set_filename(argv[1]); 25 1.1 joerg return Ret; 26 1.1 joerg } 27 1.1 joerg int foo(int X) { 28 1.1.1.2 joerg // CHECK-LABEL: define {{.*}} @foo( 29 1.1 joerg // CHECK1: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}} 30 1.1.1.2 joerg // CHECK2: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]] 31 1.1 joerg return X <= 0 ? -X : X; 32 1.1 joerg } 33 1.1.1.2 joerg // CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} 34 1.1.1.2 joerg // CHECK2: ![[PD2]] = !{!"branch_weights", i32 2, i32 1} 35