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