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