]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Frontend/optimization-remark-with-hotness.c
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / Frontend / optimization-remark-with-hotness.c
1 // RUN: llvm-profdata merge \
2 // RUN:     %S/Inputs/optimization-remark-with-hotness.proftext   \
3 // RUN:     -o %t.profdata
4 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
5 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
6 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
7 // RUN:     -Rpass-analysis=inline -fdiagnostics-show-hotness -verify
8 // The clang version of the previous test.
9 // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
10 // RUN:     -fprofile-instr-use=%t.profdata -Rpass=inline \
11 // RUN:     -Rpass-analysis=inline -fdiagnostics-show-hotness -Xclang -verify
12 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
13 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
14 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
15 // RUN:     -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
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-path=%t.profdata -Rpass=inline \
19 // RUN:     -Rpass-analysis=inline -Rno-pass-with-hotness  2>&1 | FileCheck \
20 // RUN:     -check-prefix=HOTNESS_OFF %s
21 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
22 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
23 // RUN:     -Rpass=inline -Rpass-analysis=inline -fdiagnostics-show-hotness  2>&1 \
24 // RUN:     | FileCheck -check-prefix=NO_PGO %s
25
26 int foo(int x, int y) __attribute__((always_inline));
27 int foo(int x, int y) { return x + y; }
28
29 int sum = 0;
30
31 void bar(int x) {
32   // HOTNESS_OFF: foo inlined into bar
33   // HOTNESS_OFF-NOT: hotness:
34   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
35   // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}}
36   // expected-remark@+1 {{foo inlined into bar (hotness: 30)}}
37   sum += foo(x, x - 2);
38 }
39
40 int main(int argc, const char *argv[]) {
41   for (int i = 0; i < 30; i++)
42     // expected-remark@+1 {{bar should never be inlined}}
43     bar(argc);
44   return sum;
45 }