LLVM 19.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MLInlineAdvisor Class Reference

#include "llvm/Analysis/MLInlineAdvisor.h"

Inheritance diagram for llvm::MLInlineAdvisor:
Inheritance graph
[legend]

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 MLModelRunnergetModelRunner () const
 
FunctionPropertiesInfogetCachedFPI (Function &) 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.
 
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 chargetAnnotatedInlinePassName () const
 NOTE pass name is annotated only when inline advisor constructor provides InlineContext.
 

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)
 
virtual std::unique_ptr< InlineAdvicegetAdviceImpl (CallBase &CB)=0
 
virtual std::unique_ptr< InlineAdvicegetMandatoryAdvice (CallBase &CB, bool Advice)
 
OptimizationRemarkEmittergetCallerORE (CallBase &CB)
 

Protected Attributes

std::unique_ptr< MLModelRunnerModelRunner
 
std::function< bool(CallBase &)> GetDefaultAdvice
 
- 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::MLInlineAdvisor ( Module M,
ModuleAnalysisManager MAM,
std::unique_ptr< MLModelRunner ModelRunner,
std::function< bool(CallBase &)>  GetDefaultAdvice 
)

◆ ~MLInlineAdvisor()

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

Member Function Documentation

◆ getAdviceFromModel()

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

Definition at line 425 of file MLInlineAdvisor.cpp.

References ModelRunner.

Referenced by getAdviceImpl().

◆ getAdviceImpl()

std::unique_ptr< InlineAdvice > MLInlineAdvisor::getAdviceImpl ( CallBase CB)
overrideprotectedvirtual

◆ getCachedFPI()

FunctionPropertiesInfo & MLInlineAdvisor::getCachedFPI ( Function F) const

◆ getInitialFunctionLevel()

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

Definition at line 175 of file MLInlineAdvisor.cpp.

References F, and llvm::LazyCallGraph::lookup().

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 439 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 455 of file MLInlineAdvisor.cpp.

References llvm::InlineAdvisor::getCallerORE().

Referenced by getMandatoryAdvice().

◆ getModelRunner()

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

Definition at line 47 of file MLInlineAdvisor.h.

References ModelRunner.

◆ isForcedToStop()

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

Definition at line 45 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 179 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 231 of file MLInlineAdvisor.cpp.

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

◆ onSuccessfulInlining()

void MLInlineAdvisor::onSuccessfulInlining ( const MLInlineAdvice Advice,
bool  CalleeWasDeleted 
)

Member Data Documentation

◆ GetDefaultAdvice

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

Definition at line 67 of file MLInlineAdvisor.h.

Referenced by getAdviceImpl().

◆ ModelRunner

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

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