aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/Inline/inline_stats.ll
blob: c779054c3b1ec3baf66964fcea38457c9f76ed9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
; RUN: opt -S -passes=inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK

; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
; RUN: opt -S -passes=inliner-wrapper-no-mandatory-first -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes="CHECK-VERBOSE",CHECK

; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-BASIC,CHECK
; RUN: opt -S -passes=inliner-wrapper -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-VERBOSE,CHECK

; CHECK: ------- Dumping inliner stats for [<stdin>] -------
; CHECK-BASIC-NOT: -- List of inlined functions:
; CHECK-BASIC-NOT: -- Inlined not imported function
; CHECK-VERBOSE: -- List of inlined functions:
; CHECK-VERBOSE: Inlined not imported function [internal2]: #inlines = 6, #inlines_to_importing_module = 2
; CHECK-VERBOSE: Inlined imported function [external2]: #inlines = 4, #inlines_to_importing_module = 1
; CHECK-VERBOSE: Inlined imported function [external1]: #inlines = 3, #inlines_to_importing_module = 2
; CHECK-VERBOSE: Inlined imported function [external5]: #inlines = 1, #inlines_to_importing_module = 1
; CHECK-VERBOSE: Inlined imported function [external3]: #inlines = 1, #inlines_to_importing_module = 0

; CHECK: -- Summary:
; CHECK: All functions: 10, imported functions: 7
; CHECK: inlined functions: 5 [50% of all functions]
; CHECK: imported functions inlined anywhere: 4 [57.14% of imported functions]
; CHECK: imported functions inlined into importing module: 3 [42.86% of imported functions], remaining: 4 [57.14% of imported functions]
; CHECK: non-imported functions inlined anywhere: 1 [33.33% of non-imported functions]
; CHECK: non-imported functions inlined into importing module: 1 [33.33% of non-imported functions]

define void @internal() {
    call fastcc void @external1()
    call fastcc void @internal2()
    call coldcc void @external_big()
    ret void
}

define void @internal2() alwaysinline {
    ret void
}

define void @internal3() {
    call fastcc void @external1()
    call fastcc void @external5()
    ret void
}

declare void @external_decl()

define void @external1() alwaysinline !thinlto_src_module !0 {
    call fastcc void @internal2()
    call fastcc void @external2();
    call void @external_decl();
    ret void
}

define void @external2() alwaysinline !thinlto_src_module !1 {
    ret void
}

define void @external3() alwaysinline !thinlto_src_module !1 {
    ret void
}

define void @external4() !thinlto_src_module !1 {
    call fastcc void @external1()
    call fastcc void @external2()
    ret void
}

define void @external5() !thinlto_src_module !1 {
    ret void
}

; Assume big piece of code here. This function won't be inlined, so all the
; inlined function it will have won't affect real inlines.
define void @external_big() noinline !thinlto_src_module !1 {
; CHECK-NOT: call fastcc void @internal2()
    call fastcc void @internal2()
    call fastcc void @internal2()
    call fastcc void @internal2()
    call fastcc void @internal2()

; CHECK-NOT: call fastcc void @external2()
    call fastcc void @external2()
    call fastcc void @external2()
; CHECK-NOT: call fastcc void @external3()
    call fastcc void @external3()
    ret void
}

; It should not be imported, but it should not break anything.
define void @external_notcalled() !thinlto_src_module !0 {
    call void @external_notcalled()
    ret void
}

!0 = !{!"file.cc"}
!1 = !{!"other.cc"}