summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/Inline
diff options
context:
space:
mode:
authorPiotr Padlewski <piotr.padlewski@gmail.com>2016-07-29 00:27:16 +0000
committerPiotr Padlewski <piotr.padlewski@gmail.com>2016-07-29 00:27:16 +0000
commit84abc74f2c118311945e1691bc2797a55d35e3e3 (patch)
tree268f9c0d39f6b6477fc00bb8d0384549d3e09eac /llvm/test/Transforms/Inline
parent13becd4f43226b7272625180ff497081f058a687 (diff)
downloadbcm5719-llvm-84abc74f2c118311945e1691bc2797a55d35e3e3.tar.gz
bcm5719-llvm-84abc74f2c118311945e1691bc2797a55d35e3e3.zip
Added ThinLTO inlining statistics
Summary: copypasta doc of ImportedFunctionsInliningStatistics class \brief Calculate and dump ThinLTO specific inliner stats. The main statistics are: (1) Number of inlined imported functions, (2) Number of imported functions inlined into importing module (indirect), (3) Number of non imported functions inlined into importing module (indirect). The difference between first and the second is that first stat counts all performed inlines on imported functions, but the second one only the functions that have been eventually inlined to a function in the importing module (by a chain of inlines). Because llvm uses bottom-up inliner, it is possible to e.g. import function `A`, `B` and then inline `B` to `A`, and after this `A` might be too big to be inlined into some other function that calls it. It calculates this statistic by building graph, where the nodes are functions, and edges are performed inlines and then by marking the edges starting from not imported function. If `Verbose` is set to true, then it also dumps statistics per each inlined function, sorted by the greatest inlines count like - number of performed inlines - number of performed inlines to importing module Reviewers: eraman, tejohnson, mehdi_amini Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D22491 llvm-svn: 277089
Diffstat (limited to 'llvm/test/Transforms/Inline')
-rw-r--r--llvm/test/Transforms/Inline/inline_stats.ll87
1 files changed, 87 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Inline/inline_stats.ll b/llvm/test/Transforms/Inline/inline_stats.ll
new file mode 100644
index 00000000000..cf0d43e9215
--- /dev/null
+++ b/llvm/test/Transforms/Inline/inline_stats.ll
@@ -0,0 +1,87 @@
+; RUN: opt -S -inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
+; RUN: opt -S -inline -inliner-function-import-stats=verbose < %s 2>&1 | FileCheck %s -check-prefix="CHECK-VERBOSE" -check-prefix=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
+}
+
+define void @external1() alwaysinline !thinlto_src_module !0 {
+ call fastcc void @internal2()
+ call fastcc void @external2();
+ 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"}
OpenPOWER on IntegriCloud