61 lines · c
1// RUN: rm -f %t.profraw2//3// 1. Test that __llvm_profile_set_filename has higher precedence than4// the default path.5// RUN: %clang_profgen -o %t -O3 %s6// RUN: %run %t %t.profraw7// RUN: llvm-profdata merge -o %t.profdata %t.profraw8// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s9// RUN: rm %t.profraw10// RUN: rm %t.profdata11// 2. Test that __llvm_profile_set_filename has higher precedence than12// environment variable13// RUN: env LLVM_PROFILE_FILE=%t.env.profraw %run %t %t.profraw14// RUN: llvm-profdata merge -o %t.profdata %t.profraw15// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s16// RUN: rm %t.profraw17// RUN: rm %t.profdata18// 3. Test that __llvm_profile_set_filename has higher precedence than19// the command line.20// RUN: %clang_profgen=%t.cmd.profraw -o %t-cmd -O3 %s21// RUN: %run %t-cmd %t.profraw22// RUN: llvm-profdata merge -o %t.profdata %t.profraw23// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s24// RUN: rm %t.profraw25// RUN: rm %t.profdata26// 4. Test that command line has high precedence than the default path27// RUN: %clang_profgen=%t.cmd.profraw -DNO_API -o %t-cmd -O3 %s28// RUN: %run %t-cmd %t.profraw29// RUN: llvm-profdata merge -o %t.cmd.profdata %t.cmd.profraw30// RUN: %clang_profuse=%t.cmd.profdata -o - -S -emit-llvm %s | FileCheck %s31// RUN: rm %t.cmd.profraw32// RUN: rm %t.cmd.profdata33// 5. Test that the environment variable has higher precedence than34// the command line.35// RUN: env LLVM_PROFILE_FILE=%t.env.profraw %run %t-cmd %t.profraw36// RUN: llvm-profdata merge -o %t.env.profdata %t.env.profraw37// RUN: %clang_profuse=%t.env.profdata -o - -S -emit-llvm %s | FileCheck %s38// RUN: rm %t.env.profraw39// RUN: rm %t.env.profdata40// RUN: rm %t %t-cmd41 42#ifdef CALL_SHARED43extern void func(int);44#endif45void __llvm_profile_set_filename(const char *);46int main(int argc, const char *argv[]) {47 // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]]48 if (argc < 2)49 return 1;50#ifndef NO_API51 __llvm_profile_set_filename(argv[1]);52#endif53 54#ifdef CALL_SHARED55 func(1);56#endif57 return 0;58}59// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}60// SHARED: Total functions: 261