| 1 |
// This test is similar to Frontend/optimization-remark-with-hotness.c but |
| 2 |
// testing the output under the new pass manager. The inliner is not added to |
| 3 |
// the default new PM pipeline at O0, so we compile with optimizations here. As |
| 4 |
// a result, some of the remarks will be different since we turn on inlining, |
| 5 |
// but the test is meant to show that remarks get dumped. The remarks are also |
| 6 |
// slightly different in text. |
| 7 |
|
| 8 |
// Generate instrumentation and sampling profile data. |
| 9 |
// RUN: llvm-profdata merge \ |
| 10 |
// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \ |
| 11 |
// RUN: -o %t.profdata |
| 12 |
// RUN: llvm-profdata merge -sample \ |
| 13 |
// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \ |
| 14 |
// RUN: -o %t-sample.profdata |
| 15 |
// |
| 16 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 17 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 18 |
// RUN: -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata \ |
| 19 |
// RUN: -Rpass=inline \ |
| 20 |
// RUN: -O1 \ |
| 21 |
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
| 22 |
// RUN: -fdiagnostics-show-hotness -verify |
| 23 |
// The clang version of the previous test. |
| 24 |
// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \ |
| 25 |
// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \ |
| 26 |
// RUN: -O1 \ |
| 27 |
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
| 28 |
// RUN: -fdiagnostics-show-hotness -Xclang -verify |
| 29 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 30 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 31 |
// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \ |
| 32 |
// RUN: -O1 \ |
| 33 |
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
| 34 |
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \ |
| 35 |
// RUN: -verify |
| 36 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 37 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 38 |
// RUN: -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
| 39 |
// RUN: -O1 \ |
| 40 |
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \ |
| 41 |
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify |
| 42 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 43 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 44 |
// RUN: -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
| 45 |
// RUN: -O1 \ |
| 46 |
// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s |
| 47 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 48 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 49 |
// RUN: -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
| 50 |
// RUN: -O1 \ |
| 51 |
// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \ |
| 52 |
// RUN: -check-prefix=HOTNESS_OFF %s |
| 53 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 54 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 55 |
// RUN: -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ |
| 56 |
// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \ |
| 57 |
// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \ |
| 58 |
// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s |
| 59 |
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ |
| 60 |
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ |
| 61 |
// RUN: -Rpass=inline -Rpass-analysis=inline \ |
| 62 |
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \ |
| 63 |
// RUN: | FileCheck -check-prefix=NO_PGO %s |
| 64 |
|
| 65 |
int foo(int x, int y) __attribute__((always_inline)); |
| 66 |
int foo(int x, int y) { return x + y; } |
| 67 |
|
| 68 |
int sum = 0; |
| 69 |
|
| 70 |
void bar(int x) { |
| 71 |
// HOTNESS_OFF: 'foo' inlined into 'bar' |
| 72 |
// HOTNESS_OFF-NOT: hotness: |
| 73 |
// THRESHOLD-NOT: inlined |
| 74 |
// THRESHOLD-NOT: hotness |
| 75 |
// NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information |
| 76 |
// NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information |
| 77 |
// expected-remark@+1 {{'foo' inlined into 'bar' with (cost=always): always inline attribute at callsite bar:8:10; (hotness:}} |
| 78 |
sum += foo(x, x - 2); |
| 79 |
} |
| 80 |
|
| 81 |
int main(int argc, const char *argv[]) { |
| 82 |
for (int i = 0; i < 30; i++) |
| 83 |
// expected-remark@+1 {{'bar' inlined into 'main' with}} |
| 84 |
bar(argc); |
| 85 |
return sum; |
| 86 |
} |