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 | |
6 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify |
7 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -debug-info-kind=line-tables-only -verify |
8 | // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s |
9 | // |
10 | // Check that we can override -Rpass= with -Rno-pass. |
11 | // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
12 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
13 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
14 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
15 | // |
16 | // Check that -w doesn't disable remarks. |
17 | // RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
18 | // |
19 | // FIXME: -Reverything should imply -Rpass=.*. |
20 | // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
21 | // |
22 | // FIXME: -Rpass should either imply -Rpass=.* or should be rejected. |
23 | // RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
24 | |
25 | // CHECK-REMARKS: remark: |
26 | // CHECK-NO-REMARKS-NOT: remark: |
27 | |
28 | // -Rpass should produce source location annotations, exclusively (just |
29 | // like -gmlt). |
30 | // CHECK: , !dbg ! |
31 | // CHECK-NOT: DW_TAG_base_type |
32 | |
33 | // The CU should be marked NoDebug (to prevent writing debug info to |
34 | // the final output). |
35 | // CHECK: !llvm.dbg.cu = !{![[CU:.*]]} |
36 | // CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug |
37 | |
38 | int foo(int x, int y) __attribute__((always_inline)); |
39 | int foo(int x, int y) { return x + y; } |
40 | |
41 | float foz(int x, int y) __attribute__((noinline)); |
42 | float foz(int x, int y) { return x * y; } |
43 | |
44 | // The negative diagnostics are emitted twice because the inliner runs |
45 | // twice. |
46 | // |
47 | int bar(int j) { |
48 | // expected-remark@+3 {{foz not inlined into bar because it should never be inlined (cost=never)}} |
49 | // expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}} |
50 | // expected-remark@+1 {{foo inlined into bar}} |
51 | return foo(j, j - 2) * foz(j - 2, j); |
52 | } |
53 | |