optimization-remark.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
  2. // and -Rpass-analysis) with the inliner. The test is designed to
  3. // always trigger the inliner, so it should be independent of the
  4. // optimization level.
  5. // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify
  6. // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -gline-tables-only -verify
  7. // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s
  8. //
  9. // Check that we can override -Rpass= with -Rno-pass.
  10. // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
  11. // RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
  12. // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
  13. // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
  14. //
  15. // FIXME: -Reverything should imply -Rpass=.*.
  16. // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
  17. //
  18. // FIXME: -Rpass should either imply -Rpass=.* or should be rejected.
  19. // RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
  20. // CHECK-REMARKS: remark:
  21. // CHECK-NO-REMARKS-NOT: remark:
  22. // -Rpass should produce source location annotations, exclusively (just
  23. // like -gmlt).
  24. // CHECK: , !dbg !
  25. // CHECK-NOT: DW_TAG_base_type
  26. // But llvm.dbg.cu should be missing (to prevent writing debug info to
  27. // the final output).
  28. // CHECK-NOT: !llvm.dbg.cu = !{
  29. int foo(int x, int y) __attribute__((always_inline));
  30. int foo(int x, int y) { return x + y; }
  31. float foz(int x, int y) __attribute__((noinline));
  32. float foz(int x, int y) { return x * y; }
  33. // The negative diagnostics are emitted twice because the inliner runs
  34. // twice.
  35. //
  36. int bar(int j) {
  37. // expected-remark@+6 {{foz should never be inlined (cost=never)}}
  38. // expected-remark@+5 {{foz will not be inlined into bar}}
  39. // expected-remark@+4 {{foz should never be inlined}}
  40. // expected-remark@+3 {{foz will not be inlined into bar}}
  41. // expected-remark@+2 {{foo should always be inlined}}
  42. // expected-remark@+1 {{foo inlined into bar}}
  43. return foo(j, j - 2) * foz(j - 2, j);
  44. }