diff options
author | Kirill Naumov <knaumov@azul.com> | 2020-06-11 22:24:10 +0000 |
---|---|---|
committer | Kirill Naumov <knaumov@azul.com> | 2020-06-17 13:40:17 +0000 |
commit | 37e06e8f5c6ee39a1d7cbaf7d5f5a3ebfa1b4e15 (patch) | |
tree | d81d88f7ecd0ce0b2c2ac1ba6c0c3bd13fb9b900 /llvm/lib/Analysis/InlineCost.cpp | |
parent | ccd127008aa2aa0a303c9a0a48f4080a5bb7cd0b (diff) | |
download | llvm-37e06e8f5c6ee39a1d7cbaf7d5f5a3ebfa1b4e15.zip llvm-37e06e8f5c6ee39a1d7cbaf7d5f5a3ebfa1b4e15.tar.gz llvm-37e06e8f5c6ee39a1d7cbaf7d5f5a3ebfa1b4e15.tar.bz2 |
[InlineCost] InlineCostAnnotationWriterPass introduced
This class allows to see the inliner's decisions for better
optimization verifications and tests. To use, use flag
"-passes="print<inline-cost>"".
Reviewers: apilipenko, mtrofin, davidxl, fedor.sergeev
Reviewed By: mtrofin
Differential revision: https://reviews.llvm.org/D81743
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index ba327ca..fd4e7c7 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -2509,3 +2509,40 @@ InlineParams llvm::getInlineParams(unsigned OptLevel, unsigned SizeOptLevel) { Params.LocallyHotCallSiteThreshold = LocallyHotCallSiteThreshold; return Params; } + +PreservedAnalyses +InlineCostAnnotationPrinterPass::run(Function &F, + FunctionAnalysisManager &FAM) { + PrintInstructionComments = true; + std::function<AssumptionCache &(Function &)> GetAssumptionCache = [&]( + Function &F) -> AssumptionCache & { + return FAM.getResult<AssumptionAnalysis>(F); + }; + Module *M = F.getParent(); + ProfileSummaryInfo PSI(*M); + DataLayout DL(M); + TargetTransformInfo TTI(DL); + // FIXME: Redesign the usage of InlineParams to expand the scope of this pass. + // In the current implementation, the type of InlineParams doesn't matter as + // the pass serves only for verification of inliner's decisions. + // We can add a flag which determines InlineParams for this run. Right now, + // the default InlineParams are used. + const InlineParams Params = llvm::getInlineParams(); + for (BasicBlock &BB : F) { + for (Instruction &I : BB) { + if (CallInst *CI = dyn_cast<CallInst>(&I)) { + Function *CalledFunction = CI->getCalledFunction(); + if (!CalledFunction || CalledFunction->isDeclaration()) + continue; + OptimizationRemarkEmitter ORE(CalledFunction); + InlineCostCallAnalyzer ICCA(*CalledFunction, *CI, Params, TTI, + GetAssumptionCache, nullptr, &PSI, &ORE); + ICCA.analyze(); + OS << " Analyzing call of " << CalledFunction->getName() + << "... (caller:" << CI->getCaller()->getName() << ")\n"; + ICCA.dump(); + } + } + } + return PreservedAnalyses::all(); +}
\ No newline at end of file |