2017-06-23 10:38:45 +08:00
|
|
|
// Generate instrumentation and sampling profile data.
|
2016-09-13 12:32:40 +08:00
|
|
|
// RUN: llvm-profdata merge \
|
2017-06-23 10:38:45 +08:00
|
|
|
// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
|
2016-09-13 12:32:40 +08:00
|
|
|
// RUN: -o %t.profdata
|
2017-06-23 10:38:45 +08:00
|
|
|
// RUN: llvm-profdata merge -sample \
|
|
|
|
// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
|
|
|
|
// RUN: -o %t-sample.profdata
|
|
|
|
//
|
2016-09-13 12:32:40 +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 \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2017-01-31 00:22:50 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
|
|
|
// RUN: -fdiagnostics-show-hotness -verify
|
2016-09-13 12:32:40 +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 \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2017-01-31 00:22:50 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
2017-12-02 03:59:45 +08:00
|
|
|
// RUN: -fdiagnostics-show-hotness -Xclang -verify
|
2016-09-13 12:32:40 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
2017-12-02 03:59:37 +08:00
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2017-12-02 03:59:37 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
|
|
|
|
// RUN: -verify
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
2017-12-02 03:59:45 +08:00
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2017-12-02 03:59:45 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rpass-missed=inline \
|
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
|
2016-09-13 12:32:40 +08:00
|
|
|
// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
|
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2016-09-13 12:32:40 +08:00
|
|
|
// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -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 \
|
2019-06-20 01:41:30 +08:00
|
|
|
// RUN: -fno-experimental-new-pass-manager \
|
2017-07-01 13:45:26 +08:00
|
|
|
// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
|
2016-09-13 12:32:40 +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 \
|
2017-07-01 13:45:26 +08:00
|
|
|
// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
|
|
|
|
// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
|
|
|
|
// RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
|
|
|
|
// 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 \
|
|
|
|
// RUN: -Rpass=inline -Rpass-analysis=inline \
|
|
|
|
// RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
|
2016-09-13 12:32:40 +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) {
|
|
|
|
// HOTNESS_OFF: foo inlined into bar
|
|
|
|
// HOTNESS_OFF-NOT: hotness:
|
2017-07-01 13:45:26 +08:00
|
|
|
// THRESHOLD-NOT: inlined
|
|
|
|
// THRESHOLD-NOT: hotness
|
2016-09-13 12:32:40 +08:00
|
|
|
// NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
|
2017-07-01 13:45:26 +08:00
|
|
|
// NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
|
2021-01-13 05:19:30 +08:00
|
|
|
// expected-remark@+1 {{foo inlined into bar with (cost=always): always inliner at callsite bar:8:10; (hotness:}}
|
2016-09-13 12:32:40 +08:00
|
|
|
sum += foo(x, x - 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
for (int i = 0; i < 30; i++)
|
2019-02-01 18:44:43 +08:00
|
|
|
// expected-remark@+1 {{bar not inlined into main because it should never be inlined (cost=never): no alwaysinline attribute (hotness:}}
|
2016-09-13 12:32:40 +08:00
|
|
|
bar(argc);
|
|
|
|
return sum;
|
|
|
|
}
|