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.
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
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
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
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
28 // -Reverything implies -Rpass=.*.
29 // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
31 // -Rpass implies -Rpass=.*
32 // RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
34 // CHECK-REMARKS: remark:
35 // CHECK-NO-REMARKS-NOT: remark:
37 // -Rpass should produce source location annotations, exclusively (just
40 // CHECK-NOT: DW_TAG_base_type
42 // The CU should be marked NoDebug (to prevent writing debug info to
44 // CHECK: !llvm.dbg.cu = !{![[CU:.*]]}
45 // CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug
47 int foo(int x
, int y
) __attribute__((always_inline
));
48 int foo(int x
, int y
) { return x
+ y
; }
50 float foz(int x
, int y
) __attribute__((noinline
));
51 float foz(int x
, int y
) { return x
* y
; }
53 // The negative diagnostics are emitted twice because the inliner runs
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
);