[llvm] r335914 - [ThinLTO] Port InlinerFunctionImportStats handling to new PM
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 28 13:07:47 PDT 2018
Author: tejohnson
Date: Thu Jun 28 13:07:47 2018
New Revision: 335914
URL: http://llvm.org/viewvc/llvm-project?rev=335914&view=rev
Log:
[ThinLTO] Port InlinerFunctionImportStats handling to new PM
Summary:
The InlinerFunctionImportStats will collect and dump stats regarding how
many function inlined into the module were imported by ThinLTO.
Reviewers: wmi, dexonsmith
Subscribers: mehdi_amini, inglorion, llvm-commits, eraman
Differential Revision: https://reviews.llvm.org/D48729
Modified:
llvm/trunk/include/llvm/Transforms/IPO/Inliner.h
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
llvm/trunk/test/Transforms/Inline/inline_stats.ll
Modified: llvm/trunk/include/llvm/Transforms/IPO/Inliner.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/Inliner.h?rev=335914&r1=335913&r2=335914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/Inliner.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/Inliner.h Thu Jun 28 13:07:47 2018
@@ -96,12 +96,17 @@ class InlinerPass : public PassInfoMixin
public:
InlinerPass(InlineParams Params = getInlineParams())
: Params(std::move(Params)) {}
+ ~InlinerPass();
+ InlinerPass(InlinerPass &&Arg)
+ : Params(std::move(Arg.Params)),
+ ImportedFunctionsStats(std::move(Arg.ImportedFunctionsStats)) {}
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
private:
InlineParams Params;
+ std::unique_ptr<ImportedFunctionsInliningStatistics> ImportedFunctionsStats;
};
} // end namespace llvm
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=335914&r1=335913&r2=335914&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Jun 28 13:07:47 2018
@@ -793,6 +793,14 @@ bool LegacyInlinerBase::removeDeadFuncti
return true;
}
+InlinerPass::~InlinerPass() {
+ if (ImportedFunctionsStats) {
+ assert(InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No);
+ ImportedFunctionsStats->dump(InlinerFunctionImportStats ==
+ InlinerFunctionImportStatsOpts::Verbose);
+ }
+}
+
PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
CGSCCAnalysisManager &AM, LazyCallGraph &CG,
CGSCCUpdateResult &UR) {
@@ -804,6 +812,13 @@ PreservedAnalyses InlinerPass::run(LazyC
Module &M = *InitialC.begin()->getFunction().getParent();
ProfileSummaryInfo *PSI = MAM.getCachedResult<ProfileSummaryAnalysis>(M);
+ if (!ImportedFunctionsStats &&
+ InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No) {
+ ImportedFunctionsStats =
+ llvm::make_unique<ImportedFunctionsInliningStatistics>();
+ ImportedFunctionsStats->setModuleInfo(M);
+ }
+
// We use a single common worklist for calls across the entire SCC. We
// process these in-order and append new calls introduced during inlining to
// the end.
@@ -1009,6 +1024,9 @@ PreservedAnalyses InlinerPass::run(LazyC
Calls.push_back({CS, NewHistoryID});
}
+ if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)
+ ImportedFunctionsStats->recordInline(F, Callee);
+
// Merge the attributes based on the inlining.
AttributeFuncs::mergeAttributesForInlining(F, Callee);
Modified: llvm/trunk/test/Transforms/Inline/inline_stats.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/inline_stats.ll?rev=335914&r1=335913&r2=335914&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/inline_stats.ll (original)
+++ llvm/trunk/test/Transforms/Inline/inline_stats.ll Thu Jun 28 13:07:47 2018
@@ -1,6 +1,11 @@
+; First with legacy PM
; 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
+; Do again with new PM
+; RUN: opt -S -passes=inline -inliner-function-import-stats=basic < %s 2>&1 | FileCheck %s -check-prefix=CHECK-BASIC -check-prefix=CHECK
+; RUN: opt -S -passes=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
More information about the llvm-commits
mailing list