| 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 (under the legacy PM). The inliner is not added to the new |
| 5 |
// PM pipeline unless optimizations are present. |
| 6 |
|
| 7 |
// The inliner for the new PM does not seem to be enabled at O0, but we still |
| 8 |
// get the same remarks with at least O1. The remarks are also slightly |
| 9 |
// different and located in another test file. |
| 10 |
// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s |
| 11 |
// |
| 12 |
// Check that we can override -Rpass= with -Rno-pass. |
| 13 |
// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 14 |
// RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 15 |
// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 16 |
// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 17 |
// RUN: %clang_cc1 %s -Rpass -Rno-pass -round-trip-args -mllvm -mandatory-inlining-first=false -O1 -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 18 |
// |
| 19 |
// The inliner for the new PM does not seem to be enabled at O0, but we still |
| 20 |
// get the same remarks with at least O1. |
| 21 |
// RUN: %clang_cc1 %s -Rpass=inline -O1 -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 22 |
// RUN: %clang_cc1 %s -Rpass=inline -O1 -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 23 |
// |
| 24 |
// Check that -w doesn't disable remarks. |
| 25 |
// RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 26 |
// RUN: %clang_cc1 %s -Rpass=inline -O1 -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 27 |
// |
| 28 |
// -Reverything implies -Rpass=.*. |
| 29 |
// RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 30 |
// |
| 31 |
// -Rpass implies -Rpass=.* |
| 32 |
// RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 33 |
|
| 34 |
// CHECK-REMARKS: remark: |
| 35 |
// CHECK-NO-REMARKS-NOT: remark: |
| 36 |
|
| 37 |
// -Rpass should produce source location annotations, exclusively (just |
| 38 |
// like -gmlt). |
| 39 |
// CHECK: , !dbg ! |
| 40 |
// CHECK-NOT: DW_TAG_base_type |
| 41 |
|
| 42 |
// The CU should be marked NoDebug (to prevent writing debug info to |
| 43 |
// the final output). |
| 44 |
// CHECK: !llvm.dbg.cu = !{![[CU:.*]]} |
| 45 |
// CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug |
| 46 |
|
| 47 |
int foo(int x, int y) __attribute__((always_inline)); |
| 48 |
int foo(int x, int y) { return x + y; } |
| 49 |
|
| 50 |
float foz(int x, int y) __attribute__((noinline)); |
| 51 |
float foz(int x, int y) { return x * y; } |
| 52 |
|
| 53 |
// The negative diagnostics are emitted twice because the inliner runs |
| 54 |
// twice. |
| 55 |
// |
| 56 |
int bar(int j) { |
| 57 |
// expected-remark@+3 {{'foz' not inlined into 'bar' because it should never be inlined (cost=never)}} |
| 58 |
// expected-remark@+2 {{'foz' not inlined into 'bar' because it should never be inlined (cost=never)}} |
| 59 |
// expected-remark@+1 {{'foo' inlined into 'bar'}} |
| 60 |
return foo(j, j - 2) * foz(j - 2, j); |
| 61 |
} |