LLVM 22.0.0git
llvm::MLInlineAdvisor Class Reference

#include "llvm/Analysis/MLInlineAdvisor.h"

Inheritance diagram for llvm::MLInlineAdvisor:
[legend]

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 MLModelRunnergetModelRunner () const
FunctionPropertiesInfogetCachedFPI (Function &) const
const std::vector< TensorSpec > & getFeatureMap () const
Public Member Functions inherited from llvm::InlineAdvisor
 InlineAdvisor (InlineAdvisor &&)=delete
virtual ~InlineAdvisor ()
std::unique_ptr< InlineAdvicegetAdvice (CallBase &CB, bool MandatoryOnly=false)
 Get an InlineAdvice containing a recommendation on whether to inline or not.
const chargetAnnotatedInlinePassName () 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< InlineAdvicegetAdviceImpl (CallBase &CB) override
std::unique_ptr< InlineAdvicegetMandatoryAdvice (CallBase &CB, bool Advice) override
virtual std::unique_ptr< MLInlineAdvicegetMandatoryAdviceImpl (CallBase &CB)
virtual std::unique_ptr< MLInlineAdvicegetAdviceFromModel (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)
OptimizationRemarkEmittergetCallerORE (CallBase &CB)

Protected Attributes

std::unique_ptr< MLModelRunnerModelRunner
std::function< bool(CallBase &)> GetDefaultAdvice
std::vector< TensorSpecFeatureMap
Protected Attributes inherited from llvm::InlineAdvisor
ModuleM
FunctionAnalysisManagerFAM
const std::optional< InlineContextIC
const std::string AnnotatedInlinePassName
std::unique_ptr< ImportedFunctionsInliningStatisticsImportedFunctionsStats

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)

Detailed Description

Definition at line 28 of file MLInlineAdvisor.h.

Constructor & Destructor Documentation

◆ MLInlineAdvisor()

◆ ~MLInlineAdvisor()

virtual llvm::MLInlineAdvisor::~MLInlineAdvisor ( )
virtualdefault

Member Function Documentation

◆ getAdviceFromModel()

std::unique_ptr< MLInlineAdvice > MLInlineAdvisor::getAdviceFromModel ( CallBase & CB,
OptimizationRemarkEmitter & ORE )
protectedvirtual

Definition at line 494 of file MLInlineAdvisor.cpp.

References ModelRunner.

Referenced by getAdviceImpl().

◆ getAdviceImpl()

◆ getCachedFPI()

FunctionPropertiesInfo & MLInlineAdvisor::getCachedFPI ( Function & F) const

Definition at line 360 of file MLInlineAdvisor.cpp.

References F, and llvm::InlineAdvisor::FAM.

Referenced by getAdviceImpl(), getIRSize(), getLocalCalls(), and onSuccessfulInlining().

◆ getFeatureMap()

const std::vector< TensorSpec > & llvm::MLInlineAdvisor::getFeatureMap ( ) const
inline

Definition at line 51 of file MLInlineAdvisor.h.

References FeatureMap.

Referenced by getAdviceImpl(), and MLInlineAdvisor().

◆ getInitialFeatureMap()

const std::vector< TensorSpec > & MLInlineAdvisor::getInitialFeatureMap ( )
static

◆ getInitialFunctionLevel()

unsigned MLInlineAdvisor::getInitialFunctionLevel ( const Function & F) const
protected

Definition at line 219 of file MLInlineAdvisor.cpp.

References F.

Referenced by getAdviceImpl().

◆ getIRSize()

int64_t llvm::MLInlineAdvisor::getIRSize ( Function & F) const
inline

◆ getLocalCalls()

int64_t MLInlineAdvisor::getLocalCalls ( Function & F)

◆ getMandatoryAdvice()

std::unique_ptr< InlineAdvice > MLInlineAdvisor::getMandatoryAdvice ( CallBase & CB,
bool Advice )
overrideprotectedvirtual

Reimplemented from llvm::InlineAdvisor.

Definition at line 508 of file MLInlineAdvisor.cpp.

References llvm::InlineAdvisor::getCallerORE(), and getMandatoryAdviceImpl().

Referenced by getAdviceImpl().

◆ getMandatoryAdviceImpl()

std::unique_ptr< MLInlineAdvice > MLInlineAdvisor::getMandatoryAdviceImpl ( CallBase & CB)
protectedvirtual

Definition at line 524 of file MLInlineAdvisor.cpp.

References llvm::InlineAdvisor::getCallerORE().

Referenced by getMandatoryAdvice().

◆ getModelRunner()

const MLModelRunner & llvm::MLInlineAdvisor::getModelRunner ( ) const
inline

Definition at line 49 of file MLInlineAdvisor.h.

References ModelRunner.

◆ isForcedToStop()

bool llvm::MLInlineAdvisor::isForcedToStop ( ) const
inline

Definition at line 47 of file MLInlineAdvisor.h.

◆ onPassEntry()

void MLInlineAdvisor::onPassEntry ( LazyCallGraph::SCC * SCC)
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 223 of file MLInlineAdvisor.cpp.

References assert(), getLocalCalls(), I, and N.

◆ onPassExit()

void MLInlineAdvisor::onPassExit ( LazyCallGraph::SCC * SCC)
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 273 of file MLInlineAdvisor.cpp.

References assert(), getLocalCalls(), I, KeepFPICache, and N.

◆ onSuccessfulInlining()

Member Data Documentation

◆ FeatureMap

std::vector<TensorSpec> llvm::MLInlineAdvisor::FeatureMap
protected

Definition at line 72 of file MLInlineAdvisor.h.

Referenced by getFeatureMap(), getInitialFeatureMap(), and MLInlineAdvisor().

◆ GetDefaultAdvice

std::function<bool(CallBase &)> llvm::MLInlineAdvisor::GetDefaultAdvice
protected

Definition at line 71 of file MLInlineAdvisor.h.

Referenced by getAdviceImpl(), and MLInlineAdvisor().

◆ ModelRunner

std::unique_ptr<MLModelRunner> llvm::MLInlineAdvisor::ModelRunner
protected

The documentation for this class was generated from the following files: