1 | // Generate instrumentation and sampling profile data. |
2 | // RUN: llvm-profdata merge \ |
3 | // RUN: %S/Inputs/optimization-remark-with-hotness.proftext \ |
4 | // RUN: -o %t.profdata |
5 | // RUN: llvm-profdata merge -sample \ |
6 | // RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \ |
7 | // RUN: -o %t-sample.profdata |
8 | // |
9 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
10 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
11 | // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
12 | // RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
13 | // RUN: -fdiagnostics-show-hotness -verify |
14 | // The clang version of the previous test. |
15 | // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \ |
16 | // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \ |
17 | // RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
18 | // RUN: -fdiagnostics-show-hotness -Xclang -verify |
19 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
20 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
21 | // RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \ |
22 | // RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
23 | // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \ |
24 | // RUN: -verify |
25 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
26 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
27 | // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
28 | // RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
29 | // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify |
30 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
31 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
32 | // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
33 | // RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s |
34 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
35 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
36 | // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
37 | // RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \ |
38 | // RUN: -check-prefix=HOTNESS_OFF %s |
39 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
40 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
41 | // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
42 | // RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \ |
43 | // RUN: -fdiagnostics-hotness-threshold=100 2>&1 \ |
44 | // RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s |
45 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
46 | // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
47 | // RUN: -Rpass=inline -Rpass-analysis=inline \ |
48 | // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \ |
49 | // RUN: | FileCheck -check-prefix=NO_PGO %s |
50 | |
51 | int foo(int x, int y) __attribute__((always_inline)); |
52 | int foo(int x, int y) { return x + y; } |
53 | |
54 | int sum = 0; |
55 | |
56 | void bar(int x) { |
57 | // HOTNESS_OFF: foo inlined into bar |
58 | // HOTNESS_OFF-NOT: hotness: |
59 | // THRESHOLD-NOT: inlined |
60 | // THRESHOLD-NOT: hotness |
61 | // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information |
62 | // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information |
63 | // expected-remark@+1 {{foo inlined into bar with (cost=always): always inliner (hotness:}} |
64 | sum += foo(x, x - 2); |
65 | } |
66 | |
67 | int main(int argc, const char *argv[]) { |
68 | for (int i = 0; i < 30; i++) |
69 | // expected-remark@+1 {{bar not inlined into main because it should never be inlined (cost=never): no alwaysinline attribute (hotness:}} |
70 | bar(argc); |
71 | return sum; |
72 | } |
73 | |