optimization-remark-with-hotness-new-pm.c 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // Generate instrumentation and sampling profile data.
  8. // RUN: llvm-profdata merge \
  9. // RUN: %S/Inputs/optimization-remark-with-hotness.proftext \
  10. // RUN: -o %t.profdata
  11. // RUN: llvm-profdata merge -sample \
  12. // RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \
  13. // RUN: -o %t-sample.profdata
  14. //
  15. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  16. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  17. // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
  18. // RUN: -fexperimental-new-pass-manager -O1 \
  19. // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
  20. // RUN: -fdiagnostics-show-hotness -verify
  21. // The clang version of the previous test.
  22. // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
  23. // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \
  24. // RUN: -fexperimental-new-pass-manager -O1 \
  25. // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
  26. // RUN: -fdiagnostics-show-hotness -Xclang -verify
  27. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  28. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  29. // RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
  30. // RUN: -fexperimental-new-pass-manager -O1 \
  31. // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
  32. // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
  33. // RUN: -verify
  34. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  35. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  36. // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
  37. // RUN: -fexperimental-new-pass-manager -O1 \
  38. // RUN: -Rpass-analysis=inline -Rpass-missed=inline \
  39. // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
  40. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  41. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  42. // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
  43. // RUN: -fexperimental-new-pass-manager -O1 \
  44. // RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
  45. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  46. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  47. // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
  48. // RUN: -fexperimental-new-pass-manager -O1 \
  49. // RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
  50. // RUN: -check-prefix=HOTNESS_OFF %s
  51. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  52. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  53. // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
  54. // RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness \
  55. // RUN: -fdiagnostics-hotness-threshold=100 2>&1 \
  56. // RUN: | FileCheck -allow-empty -check-prefix=THRESHOLD %s
  57. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
  58. // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \
  59. // RUN: -Rpass=inline -Rpass-analysis=inline \
  60. // RUN: -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
  61. // RUN: | FileCheck -check-prefix=NO_PGO %s
  62. int foo(int x, int y) __attribute__((always_inline));
  63. int foo(int x, int y) { return x + y; }
  64. int sum = 0;
  65. void bar(int x) {
  66. // HOTNESS_OFF: foo inlined into bar
  67. // HOTNESS_OFF-NOT: hotness:
  68. // THRESHOLD-NOT: inlined
  69. // THRESHOLD-NOT: hotness
  70. // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
  71. // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
  72. // expected-remark@+1 {{foo inlined into bar with (cost=always): always inline attribute (hotness:}}
  73. sum += foo(x, x - 2);
  74. }
  75. int main(int argc, const char *argv[]) {
  76. for (int i = 0; i < 30; i++)
  77. // expected-remark@+1 {{bar inlined into main with}}
  78. bar(argc);
  79. return sum;
  80. }