1*7c3d14c8STreehugger Robot // 1. Test that __llvm_profile_set_filename has higher precedence than 2*7c3d14c8STreehugger Robot // the default path. 3*7c3d14c8STreehugger Robot // RUN: %clang_profgen -o %t -O3 %s 4*7c3d14c8STreehugger Robot // RUN: %run %t %t.profraw 5*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.profdata %t.profraw 6*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s 7*7c3d14c8STreehugger Robot // RUN: rm %t.profraw 8*7c3d14c8STreehugger Robot // RUN: rm %t.profdata 9*7c3d14c8STreehugger Robot // 2. Test that __llvm_profile_set_filename has higher precedence than 10*7c3d14c8STreehugger Robot // environment variable 11*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.env.profraw %run %t %t.profraw 12*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.profdata %t.profraw 13*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s 14*7c3d14c8STreehugger Robot // RUN: rm %t.profraw 15*7c3d14c8STreehugger Robot // RUN: rm %t.profdata 16*7c3d14c8STreehugger Robot // 3. Test that __llvm_profile_set_filename has higher precedence than 17*7c3d14c8STreehugger Robot // the command line. 18*7c3d14c8STreehugger Robot // RUN: %clang_profgen=%t.cmd.profraw -o %t.cmd -O3 %s 19*7c3d14c8STreehugger Robot // RUN: %run %t.cmd %t.profraw 20*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.profdata %t.profraw 21*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s 22*7c3d14c8STreehugger Robot // RUN: rm %t.profraw 23*7c3d14c8STreehugger Robot // RUN: rm %t.profdata 24*7c3d14c8STreehugger Robot // 4. Test that command line has high precedence than the default path 25*7c3d14c8STreehugger Robot // RUN: %clang_profgen=%t.cmd.profraw -DNO_API -o %t.cmd -O3 %s 26*7c3d14c8STreehugger Robot // RUN: %run %t.cmd %t.profraw 27*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.cmd.profdata %t.cmd.profraw 28*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.cmd.profdata -o - -S -emit-llvm %s | FileCheck %s 29*7c3d14c8STreehugger Robot // RUN: rm %t.cmd.profraw 30*7c3d14c8STreehugger Robot // RUN: rm %t.cmd.profdata 31*7c3d14c8STreehugger Robot // 5. Test that the environment variable has higher precedence than 32*7c3d14c8STreehugger Robot // the command line. 33*7c3d14c8STreehugger Robot // RUN: env LLVM_PROFILE_FILE=%t.env.profraw %run %t.cmd %t.profraw 34*7c3d14c8STreehugger Robot // RUN: llvm-profdata merge -o %t.env.profdata %t.env.profraw 35*7c3d14c8STreehugger Robot // RUN: %clang_profuse=%t.env.profdata -o - -S -emit-llvm %s | FileCheck %s 36*7c3d14c8STreehugger Robot // RUN: rm %t.env.profraw 37*7c3d14c8STreehugger Robot // RUN: rm %t.env.profdata 38*7c3d14c8STreehugger Robot 39*7c3d14c8STreehugger Robot #ifdef CALL_SHARED 40*7c3d14c8STreehugger Robot extern void func(int); 41*7c3d14c8STreehugger Robot #endif 42*7c3d14c8STreehugger Robot void __llvm_profile_set_filename(const char *); main(int argc,const char * argv[])43*7c3d14c8STreehugger Robotint main(int argc, const char *argv[]) { 44*7c3d14c8STreehugger Robot // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] 45*7c3d14c8STreehugger Robot if (argc < 2) 46*7c3d14c8STreehugger Robot return 1; 47*7c3d14c8STreehugger Robot #ifndef NO_API 48*7c3d14c8STreehugger Robot __llvm_profile_set_filename(argv[1]); 49*7c3d14c8STreehugger Robot #endif 50*7c3d14c8STreehugger Robot 51*7c3d14c8STreehugger Robot #ifdef CALL_SHARED 52*7c3d14c8STreehugger Robot func(1); 53*7c3d14c8STreehugger Robot #endif 54*7c3d14c8STreehugger Robot return 0; 55*7c3d14c8STreehugger Robot } 56*7c3d14c8STreehugger Robot // CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} 57*7c3d14c8STreehugger Robot // SHARED: Total functions: 2 58