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 -gline-tables-only -verify
8 // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s
9
10 // -Rpass should produce source location annotations, exclusively (just
11 // like -gmlt).
12 // CHECK: , !dbg !
13 // CHECK-NOT: DW_TAG_base_type
14
15 // But llvm.dbg.cu should be missing (to prevent writing debug info to
16 // the final output).
17 // CHECK-NOT: !llvm.dbg.cu = !{
18
19 int foo(int x, int y) __attribute__((always_inline));
foo(int x,int y)20 int foo(int x, int y) { return x + y; }
21
22 float foz(int x, int y) __attribute__((noinline));
foz(int x,int y)23 float foz(int x, int y) { return x * y; }
24
25 // The negative diagnostics are emitted twice because the inliner runs
26 // twice.
27 //
bar(int j)28 int bar(int j) {
29 // expected-remark@+6 {{foz should never be inlined (cost=never)}}
30 // expected-remark@+5 {{foz will not be inlined into bar}}
31 // expected-remark@+4 {{foz should never be inlined}}
32 // expected-remark@+3 {{foz will not be inlined into bar}}
33 // expected-remark@+2 {{foo should always be inlined}}
34 // expected-remark@+1 {{foo inlined into bar}}
35 return foo(j, j - 2) * foz(j - 2, j);
36 }
37