1; RUN: opt -S -inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
2; RUN: opt -S -inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=CHECK
3
4; CHECK: ------- Dumping inliner stats for [<stdin>] -------
5; CHECK-BASIC-NOT: -- List of inlined functions:
6; CHECK-BASIC-NOT: -- Inlined not imported function
7; CHECK-VERBOSE: -- List of inlined functions:
8; CHECK-VERBOSE: Inlined not imported function [internal2]: #inlines = 6, #inlines_to_importing_module = 2
9; CHECK-VERBOSE: Inlined imported function [external2]: #inlines = 4, #inlines_to_importing_module = 1
10; CHECK-VERBOSE: Inlined imported function [external1]: #inlines = 3, #inlines_to_importing_module = 2
11; CHECK-VERBOSE: Inlined imported function [external5]: #inlines = 1, #inlines_to_importing_module = 1
12; CHECK-VERBOSE: Inlined imported function [external3]: #inlines = 1, #inlines_to_importing_module = 0
13
14; CHECK: -- Summary:
15; CHECK: All functions: 10, imported functions: 7
16; CHECK: inlined functions: 5 [50% of all functions]
17; CHECK: imported functions inlined anywhere: 4 [57.14% of imported functions]
18; CHECK: imported functions inlined into importing module: 3 [42.86% of imported functions], remaining: 4 [57.14% of imported functions]
19; CHECK: non-imported functions inlined anywhere: 1 [33.33% of non-imported functions]
20; CHECK: non-imported functions inlined into importing module: 1 [33.33% of non-imported functions]
21
22define void @internal() {
23    call fastcc void @external1()
24    call fastcc void @internal2()
25    call coldcc void @external_big()
26    ret void
27}
28
29define void @internal2() alwaysinline {
30    ret void
31}
32
33define void @internal3() {
34    call fastcc void @external1()
35    call fastcc void @external5()
36    ret void
37}
38
39declare void @external_decl()
40
41define void @external1() alwaysinline !thinlto_src_module !0 {
42    call fastcc void @internal2()
43    call fastcc void @external2();
44    call void @external_decl();
45    ret void
46}
47
48define void @external2() alwaysinline !thinlto_src_module !1 {
49    ret void
50}
51
52define void @external3() alwaysinline !thinlto_src_module !1 {
53    ret void
54}
55
56define void @external4() !thinlto_src_module !1 {
57    call fastcc void @external1()
58    call fastcc void @external2()
59    ret void
60}
61
62define void @external5() !thinlto_src_module !1 {
63    ret void
64}
65
66; Assume big piece of code here. This function won't be inlined, so all the
67; inlined function it will have won't affect real inlines.
68define void @external_big() noinline !thinlto_src_module !1 {
69; CHECK-NOT: call fastcc void @internal2()
70    call fastcc void @internal2()
71    call fastcc void @internal2()
72    call fastcc void @internal2()
73    call fastcc void @internal2()
74
75; CHECK-NOT: call fastcc void @external2()
76    call fastcc void @external2()
77    call fastcc void @external2()
78; CHECK-NOT: call fastcc void @external3()
79    call fastcc void @external3()
80    ret void
81}
82
83; It should not be imported, but it should not break anything.
84define void @external_notcalled() !thinlto_src_module !0 {
85    call void @external_notcalled()
86    ret void
87}
88
89!0 = !{!"file.cc"}
90!1 = !{!"other.cc"}
91