LLVM 20.0.0git
|
#include "llvm/Analysis/MLInlineAdvisor.h"
Public Member Functions | |
MLInlineAdvisor (Module &M, ModuleAnalysisManager &MAM, std::unique_ptr< MLModelRunner > ModelRunner, 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 |
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. | |
virtual void | onPassEntry (LazyCallGraph::SCC *SCC=nullptr) |
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). | |
virtual void | onPassExit (LazyCallGraph::SCC *SCC=nullptr) |
This must be called when the Inliner pass is exited, as function passes may be run subsequently. | |
virtual void | print (raw_ostream &OS) const |
Support for printer pass. | |
const char * | getAnnotatedInlinePassName () const |
NOTE pass name is annotated only when inline advisor constructor provides InlineContext. | |
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) | |
virtual std::unique_ptr< InlineAdvice > | getAdviceImpl (CallBase &CB)=0 |
virtual std::unique_ptr< InlineAdvice > | getMandatoryAdvice (CallBase &CB, bool Advice) |
OptimizationRemarkEmitter & | getCallerORE (CallBase &CB) |
Protected Attributes | |
std::unique_ptr< MLModelRunner > | ModelRunner |
std::function< bool(CallBase &)> | GetDefaultAdvice |
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::unique_ptr< MLModelRunner > | ModelRunner, | ||
std::function< bool(CallBase &)> | GetDefaultAdvice | ||
) |
Definition at line 139 of file MLInlineAdvisor.cpp.
References assert(), F, llvm::LazyCallGraph::get(), getInlinableCS(), getLocalCalls(), I, instructions, llvm::InlineAdvisor::M, ModelRunner, and llvm::scc_begin().
|
virtualdefault |
|
protectedvirtual |
Definition at line 452 of file MLInlineAdvisor.cpp.
References ModelRunner.
Referenced by getAdviceImpl().
|
overrideprotectedvirtual |
Implements llvm::InlineAdvisor.
Definition at line 342 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::Always, llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), DEBUG_TYPE, F, llvm::InlineAdvisor::FAM, getAdviceFromModel(), getCachedFPI(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCaller(), GetDefaultAdvice, getInitialFunctionLevel(), llvm::getInliningCostEstimate(), llvm::getInliningCostFeatures(), getMandatoryAdvice(), llvm::InlineAdvisor::getMandatoryKind(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult(), I, llvm::inlineCostFeatureToMlFeature(), InteractiveChannelBaseName, InteractiveIncludeDefault, llvm::ProfileSummaryInfo::isFunctionEntryCold(), ModelRunner, llvm::InlineAdvisor::Never, llvm::NumberOfFeatures, and SkipPolicy.
FunctionPropertiesInfo & MLInlineAdvisor::getCachedFPI | ( | Function & | F | ) | const |
Definition at line 333 of file MLInlineAdvisor.cpp.
References F, llvm::InlineAdvisor::FAM, and llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult().
Referenced by getAdviceImpl(), getIRSize(), getLocalCalls(), onSuccessfulInlining(), and llvm::MLInlineAdvice::recordUnsuccessfulInliningImpl().
Definition at line 191 of file MLInlineAdvisor.cpp.
References F, and llvm::LazyCallGraph::lookup().
Referenced by getAdviceImpl().
|
inline |
Definition at line 39 of file MLInlineAdvisor.h.
References F, getCachedFPI(), and llvm::FunctionPropertiesInfo::TotalInstructionCount.
Referenced by onSuccessfulInlining().
int64_t MLInlineAdvisor::getLocalCalls | ( | Function & | F | ) |
Definition at line 273 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 466 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::getCallerORE(), and getMandatoryAdviceImpl().
Referenced by getAdviceImpl().
|
protectedvirtual |
Definition at line 482 of file MLInlineAdvisor.cpp.
References llvm::InlineAdvisor::getCallerORE().
Referenced by getMandatoryAdvice().
|
inline |
Definition at line 47 of file MLInlineAdvisor.h.
References ModelRunner.
|
inline |
Definition at line 45 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 195 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 245 of file MLInlineAdvisor.cpp.
References assert(), getLocalCalls(), I, KeepFPICache, and N.
void MLInlineAdvisor::onSuccessfulInlining | ( | const MLInlineAdvice & | Advice, |
bool | CalleeWasDeleted | ||
) |
Definition at line 282 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(), if(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::invalidate(), llvm::LazyCallGraph::lookup(), SizeIncreaseThreshold, and llvm::MLInlineAdvice::updateCachedCallerFPI().
Referenced by llvm::MLInlineAdvice::recordInliningImpl(), and llvm::MLInlineAdvice::recordInliningWithCalleeDeletedImpl().
Definition at line 67 of file MLInlineAdvisor.h.
Referenced by getAdviceImpl().
|
protected |
Definition at line 66 of file MLInlineAdvisor.h.
Referenced by getAdviceFromModel(), getAdviceImpl(), getModelRunner(), and MLInlineAdvisor().