2019-06-20 01:41:30 +08:00
|
|
|
// This test is similar to Frontend/optimization-remark-with-hotness.c but
|
|
|
|
// testing the output under the new pass manager. The inliner is not added to
|
|
|
|
// the default new PM pipeline at O0, so we compile with optimizations here. As
|
|
|
|
// a result, some of the remarks will be different since we turn on inlining,
|
|
|
|
// but the test is meant to show that remarks get dumped. The remarks are also
|
|
|
|
// slightly different in text.
|
|
|
|
|
|
|
|
// Generate instrumentation and sampling profile data.
|
|
|
|
// RUN: llvm-profdata merge \
|
|
|
|
// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
|
|
|
|
// RUN: -o %t.profdata
|
|
|
|
// RUN: llvm-profdata merge -sample \
|
|
|
|
// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
|
|
|
|
// RUN: -o %t-sample.profdata
|
|
|
|
//
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -fdiagnostics-show-hotness -verify
|
2019-06-20 01:41:30 +08:00
|
|
|
// The clang version of the previous test.
|
|
|
|
// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
|
|
|
|
// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
|
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -fdiagnostics-show-hotness -Xclang -verify
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
|
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -verify
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
2021-01-16 05:56:57 +08:00
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
2021-01-16 05:56:57 +08:00
|
|
|
// RUN: -fexperimental-new-pass-manager -O1 \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -check-prefix=HOTNESS_OFF %s
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
2021-01-16 05:56:57 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
2021-01-16 05:56:57 +08:00
|
|
|
// RUN: -Rpass=inline -Rpass-analysis=inline \
|
2021-10-01 07:13:05 +08:00
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: | FileCheck -check-prefix=NO_PGO %s
|
|
|
|
|
|
|
|
int foo(int x, int y) __attribute__((always_inline));
|
|
|
|
int foo(int x, int y) { return x + y; }
|
|
|
|
|
|
|
|
int sum = 0;
|
|
|
|
|
|
|
|
void bar(int x) {
|
2021-08-11 02:51:31 +08:00
|
|
|
// HOTNESS_OFF: 'foo' inlined into 'bar'
|
2019-06-20 01:41:30 +08:00
|
|
|
// HOTNESS_OFF-NOT: hotness:
|
|
|
|
// THRESHOLD-NOT: inlined
|
|
|
|
// THRESHOLD-NOT: hotness
|
|
|
|
// NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
|
|
|
|
// NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
|
2021-10-01 07:13:05 +08:00
|
|
|
// expected-remark@+1 {{'foo' inlined into 'bar': always inline attribute at callsite bar:8:10; (hotness:}}
|
2019-06-20 01:41:30 +08:00
|
|
|
sum += foo(x, x - 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
for (int i = 0; i < 30; i++)
|
2021-08-11 02:51:31 +08:00
|
|
|
// expected-remark@+1 {{'bar' inlined into 'main' with}}
|
2019-06-20 01:41:30 +08:00
|
|
|
bar(argc);
|
|
|
|
return sum;
|
|
|
|
}
|