[PATCH] D127689: [inliner] Add per-SCC Inline Advisor printing option
Jin Xin Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 13 13:23:27 PDT 2022
Northbadge created this revision.
Northbadge added a reviewer: mtrofin.
Herald added subscribers: ormris, hiraditya.
Herald added a project: All.
Northbadge requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Allows inline advisor to print debug output after each scc pass
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127689
Files:
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Transforms/IPO/Inliner.cpp
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -105,6 +105,10 @@
static cl::opt<bool> KeepAdvisorForPrinting("keep-inline-advisor-for-printing",
cl::init(false), cl::Hidden);
+/// Allows inline advisor to print content after each CGSCC inliner pass
+static cl::opt<bool> EnableAdvisorPrinting("enable-inline-advisor-printing",
+ cl::init(false), cl::Hidden);
+
extern cl::opt<InlinerFunctionImportStatsOpts> InlinerFunctionImportStats;
static cl::opt<std::string> CGSCCInlineReplayFile(
@@ -1114,9 +1118,14 @@
// into the callers so that our optimizations can reflect that.
// For PreLinkThinLTO pass, we disable hot-caller heuristic for sample PGO
// because it makes profile annotation in the backend inaccurate.
- if (MandatoryFirst)
+ if (MandatoryFirst) {
PM.addPass(InlinerPass(/*OnlyMandatory*/ true));
+ if (EnableAdvisorPrinting)
+ PM.addPass(InlineAdvisorAnalysisPrinterPass(dbgs()));
+ }
PM.addPass(InlinerPass());
+ if (EnableAdvisorPrinting)
+ PM.addPass(InlineAdvisorAnalysisPrinterPass(dbgs()));
}
PreservedAnalyses ModuleInlinerWrapperPass::run(Module &M,
Index: llvm/lib/Analysis/InlineAdvisor.cpp
===================================================================
--- llvm/lib/Analysis/InlineAdvisor.cpp
+++ llvm/lib/Analysis/InlineAdvisor.cpp
@@ -630,3 +630,22 @@
IA->getAdvisor()->print(OS);
return PreservedAnalyses::all();
}
+
+PreservedAnalyses InlineAdvisorAnalysisPrinterPass::run(
+ LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM, LazyCallGraph &CG,
+ CGSCCUpdateResult &UR) {
+ const auto &MAMProxy =
+ AM.getResult<ModuleAnalysisManagerCGSCCProxy>(InitialC, CG);
+
+ if (InitialC.size() == 0) {
+ OS << "SCC is empty!\n";
+ return PreservedAnalyses::all();
+ }
+ Module &M = *InitialC.begin()->getFunction().getParent();
+ const auto *IA = MAMProxy.getCachedResult<InlineAdvisorAnalysis>(M);
+ if (!IA)
+ OS << "No Inline Advisor\n";
+ else
+ IA->getAdvisor()->print(OS);
+ return PreservedAnalyses::all();
+}
Index: llvm/include/llvm/Analysis/InlineAdvisor.h
===================================================================
--- llvm/include/llvm/Analysis/InlineAdvisor.h
+++ llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -9,6 +9,7 @@
#ifndef LLVM_ANALYSIS_INLINEADVISOR_H
#define LLVM_ANALYSIS_INLINEADVISOR_H
+#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/Config/llvm-config.h"
@@ -271,6 +272,9 @@
explicit InlineAdvisorAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+
+ PreservedAnalyses run(LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM,
+ LazyCallGraph &CG, CGSCCUpdateResult &UR);
};
std::unique_ptr<InlineAdvisor>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127689.436541.patch
Type: text/x-patch
Size: 3086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220613/8e0bdaf3/attachment.bin>
More information about the llvm-commits
mailing list