LLVM 22.0.0git
|
#include "llvm/Analysis/MLInlineAdvisor.h"
Public Member Functions | |
MLInlineAdvisor (Module &M, ModuleAnalysisManager &MAM, std::function< std::unique_ptr< MLModelRunner >(const std::vector< TensorSpec > &)> GetModelRunner, std::function< bool(CallBase &)> GetDefaultAdvice) | |
virtual | ~MLInlineAdvisor ()=default |
void | onPassEntry (LazyCallGraph::SCC *SCC) override |
This must be called when the Inliner pass is entered, to allow the InlineAdvisor update internal state, as result of function passes run between Inliner pass runs (for the same module). | |
void | onPassExit (LazyCallGraph::SCC *SCC) override |
This must be called when the Inliner pass is exited, as function passes may be run subsequently. | |
int64_t | getIRSize (Function &F) const |
void | onSuccessfulInlining (const MLInlineAdvice &Advice, bool CalleeWasDeleted) |
bool | isForcedToStop () const |
int64_t | getLocalCalls (Function &F) |
const MLModelRunner & | getModelRunner () const |
FunctionPropertiesInfo & | getCachedFPI (Function &) const |
const std::vector< TensorSpec > & | getFeatureMap () const |
Public Member Functions inherited from llvm::InlineAdvisor | |
InlineAdvisor (InlineAdvisor &&)=delete | |
virtual | ~InlineAdvisor () |
std::unique_ptr< InlineAdvice > | getAdvice (CallBase &CB, bool MandatoryOnly=false) |
Get an InlineAdvice containing a recommendation on whether to inline or not. | |
const char * | getAnnotatedInlinePassName () const |
NOTE pass name is annotated only when inline advisor constructor provides InlineContext. |
Static Public Member Functions | |
static const std::vector< TensorSpec > & | getInitialFeatureMap () |
Protected Member Functions | |
std::unique_ptr< InlineAdvice > | getAdviceImpl (CallBase &CB) override |
std::unique_ptr< InlineAdvice > | getMandatoryAdvice (CallBase &CB, bool Advice) override |
virtual std::unique_ptr< MLInlineAdvice > | getMandatoryAdviceImpl (CallBase &CB) |
virtual std::unique_ptr< MLInlineAdvice > | getAdviceFromModel (CallBase &CB, OptimizationRemarkEmitter &ORE) |
unsigned | getInitialFunctionLevel (const Function &F) const |
Protected Member Functions inherited from llvm::InlineAdvisor | |
InlineAdvisor (Module &M, FunctionAnalysisManager &FAM, std::optional< InlineContext > IC=std::nullopt) | |
OptimizationRemarkEmitter & | getCallerORE (CallBase &CB) |
Protected Attributes | |
std::unique_ptr< MLModelRunner > | ModelRunner |
std::function< bool(CallBase &)> | GetDefaultAdvice |
std::vector< TensorSpec > | FeatureMap |
Protected Attributes inherited from llvm::InlineAdvisor | |
Module & | M |
FunctionAnalysisManager & | FAM |
const std::optional< InlineContext > | IC |
const std::string | AnnotatedInlinePassName |
std::unique_ptr< ImportedFunctionsInliningStatistics > | ImportedFunctionsStats |
Additional Inherited Members | |
Protected Types inherited from llvm::InlineAdvisor | |
enum class | MandatoryInliningKind { NotMandatory , Always , Never } |
Static Protected Member Functions inherited from llvm::InlineAdvisor | |
static MandatoryInliningKind | getMandatoryKind (CallBase &CB, FunctionAnalysisManager &FAM, OptimizationRemarkEmitter &ORE) |
Definition at line 28 of file MLInlineAdvisor.h.
MLInlineAdvisor::MLInlineAdvisor | ( | Module & | M, |
ModuleAnalysisManager & | MAM, | ||
std::function< std::unique_ptr< MLModelRunner >(const std::vector< TensorSpec > &)> | GetModelRunner, | ||
std::function< bool(CallBase &)> | GetDefaultAdvice ) |
Definition at line 147 of file MLInlineAdvisor.cpp.
References llvm::TensorSpec::createSpec(), llvm::DefaultDecisionSpec, F, FeatureMap, GetDefaultAdvice, getFeatureMap(), getInitialFeatureMap(), getInlinableCS(), getLocalCalls(), I, llvm::InlineAdvisor::InlineAdvisor(), instructions, InteractiveIncludeDefault, llvm::InlineAdvisor::M, MAM, ModelRunner, llvm::scc_begin(), and StopImmediatelyForTest.
|
virtualdefault |
|
protectedvirtual |
Definition at line 518 of file MLInlineAdvisor.cpp.
References ModelRunner.
Referenced by getAdviceImpl().
|
overrideprotectedvirtual |
Implements llvm::InlineAdvisor.
Definition at line 384 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::Always, llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), llvm::callee_embedding, llvm::caller_embedding, DEBUG_TYPE, F, llvm::InlineAdvisor::FAM, getAdviceFromModel(), getCachedFPI(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCaller(), GetDefaultAdvice, getFeatureMap(), getInitialFunctionLevel(), llvm::getInliningCostEstimate(), llvm::getInliningCostFeatures(), getMandatoryAdvice(), llvm::InlineAdvisor::getMandatoryKind(), I, IfCallerIsNotCold, llvm::inlineCostFeatureToMlFeature(), InteractiveChannelBaseName, InteractiveIncludeDefault, llvm::isa(), ModelRunner, llvm::InlineAdvisor::Never, llvm::NumberOfFeatures, SkipPolicy, and llvm::transform().
FunctionPropertiesInfo & MLInlineAdvisor::getCachedFPI | ( | Function & | F | ) | const |
Definition at line 376 of file MLInlineAdvisor.cpp.
References F, and llvm::InlineAdvisor::FAM.
Referenced by getAdviceImpl(), getIRSize(), getLocalCalls(), and onSuccessfulInlining().
|
inline |
Definition at line 51 of file MLInlineAdvisor.h.
References FeatureMap.
Referenced by getAdviceImpl(), and MLInlineAdvisor().
|
static |
Definition at line 114 of file MLInlineAdvisor.cpp.
References FeatureMap, INLINE_COST_FEATURE_ITERATOR, INLINE_FEATURE_ITERATOR, and POPULATE_NAMES.
Referenced by MLInlineAdvisor().
|
inline |
Definition at line 41 of file MLInlineAdvisor.h.
References F, getCachedFPI(), and llvm::FunctionPropertiesInfo::TotalInstructionCount.
Referenced by onSuccessfulInlining().
int64_t MLInlineAdvisor::getLocalCalls | ( | Function & | F | ) |
Definition at line 305 of file MLInlineAdvisor.cpp.
References llvm::FunctionPropertiesInfo::DirectCallsToDefinedFunctions, F, and getCachedFPI().
Referenced by MLInlineAdvisor(), onPassEntry(), and onPassExit().
|
overrideprotectedvirtual |
Reimplemented from llvm::InlineAdvisor.
Definition at line 532 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::getCallerORE(), and getMandatoryAdviceImpl().
Referenced by getAdviceImpl().
|
protectedvirtual |
Definition at line 548 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::getCallerORE().
Referenced by getMandatoryAdvice().
|
inline |
Definition at line 49 of file MLInlineAdvisor.h.
References ModelRunner.
|
inline |
Definition at line 47 of file MLInlineAdvisor.h.
|
overridevirtual |
This must be called when the Inliner pass is entered, to allow the InlineAdvisor update internal state, as result of function passes run between Inliner pass runs (for the same module).
Reimplemented from llvm::InlineAdvisor.
Definition at line 227 of file MLInlineAdvisor.cpp.
References assert(), getLocalCalls(), I, and N.
|
overridevirtual |
This must be called when the Inliner pass is exited, as function passes may be run subsequently.
This allows an implementation of InlineAdvisor to prepare for a partial update, based on the optional SCC.
Reimplemented from llvm::InlineAdvisor.
Definition at line 277 of file MLInlineAdvisor.cpp.
References assert(), getLocalCalls(), I, KeepFPICache, and N.
void MLInlineAdvisor::onSuccessfulInlining | ( | const MLInlineAdvice & | Advice, |
bool | CalleeWasDeleted ) |
Definition at line 314 of file MLInlineAdvisor.cpp.
References llvm::PreservedAnalyses::abandon(), llvm::PreservedAnalyses::all(), assert(), llvm::MLInlineAdvice::CalleeIRSize, llvm::MLInlineAdvice::CallerAndCalleeEdges, llvm::MLInlineAdvice::CallerIRSize, llvm::FunctionPropertiesInfo::DirectCallsToDefinedFunctions, llvm::InlineAdvisor::FAM, getCachedFPI(), llvm::MLInlineAdvice::getCallee(), llvm::MLInlineAdvice::getCaller(), getIRSize(), SizeIncreaseThreshold, and llvm::MLInlineAdvice::updateCachedCallerFPI().
|
protected |
Definition at line 72 of file MLInlineAdvisor.h.
Referenced by getFeatureMap(), getInitialFeatureMap(), and MLInlineAdvisor().
Definition at line 71 of file MLInlineAdvisor.h.
Referenced by getAdviceImpl(), and MLInlineAdvisor().
|
protected |
Definition at line 70 of file MLInlineAdvisor.h.
Referenced by getAdviceFromModel(), getAdviceImpl(), getModelRunner(), and MLInlineAdvisor().