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