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