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