LLVM 19.0.0git
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::InlineAdvisor Class Referenceabstract

Interface for deciding whether to inline a call site or not. More...

#include "llvm/Analysis/InlineAdvisor.h"

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

Public Member Functions

 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 Types

enum class  MandatoryInliningKind { NotMandatory , Always , Never }
 

Protected Member Functions

 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)
 

Static Protected Member Functions

static MandatoryInliningKind getMandatoryKind (CallBase &CB, FunctionAnalysisManager &FAM, OptimizationRemarkEmitter &ORE)
 

Protected Attributes

ModuleM
 
FunctionAnalysisManagerFAM
 
const std::optional< InlineContextIC
 
const std::string AnnotatedInlinePassName
 
std::unique_ptr< ImportedFunctionsInliningStatisticsImportedFunctionsStats
 

Friends

class InlineAdvice
 

Detailed Description

Interface for deciding whether to inline a call site or not.

Definition at line 164 of file InlineAdvisor.h.

Member Enumeration Documentation

◆ MandatoryInliningKind

enum class llvm::InlineAdvisor::MandatoryInliningKind
strongprotected
Enumerator
NotMandatory 
Always 
Never 

Definition at line 215 of file InlineAdvisor.h.

Constructor & Destructor Documentation

◆ InlineAdvisor() [1/2]

llvm::InlineAdvisor::InlineAdvisor ( InlineAdvisor &&  )
delete

◆ ~InlineAdvisor()

InlineAdvisor::~InlineAdvisor ( )
virtual

◆ InlineAdvisor() [2/2]

InlineAdvisor::InlineAdvisor ( Module M,
FunctionAnalysisManager FAM,
std::optional< InlineContext IC = std::nullopt 
)
protected

Member Function Documentation

◆ getAdvice()

std::unique_ptr< InlineAdvice > InlineAdvisor::getAdvice ( CallBase CB,
bool  MandatoryOnly = false 
)

Get an InlineAdvice containing a recommendation on whether to inline or not.

CB is assumed to be a direct call. FAM is assumed to be up-to-date wrt previous inlining decisions. MandatoryOnly indicates only mandatory (always-inline) call sites should be recommended - this allows the InlineAdvisor track such inlininings. Returns:

Definition at line 614 of file InlineAdvisor.cpp.

References Always, FAM, getAdviceImpl(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCaller(), getCallerORE(), getMandatoryAdvice(), and getMandatoryKind().

◆ getAdviceImpl()

virtual std::unique_ptr< InlineAdvice > llvm::InlineAdvisor::getAdviceImpl ( CallBase CB)
protectedpure virtual

Implemented in llvm::MLInlineAdvisor, and llvm::ReplayInlineAdvisor.

Referenced by getAdvice().

◆ getAnnotatedInlinePassName()

const char * llvm::InlineAdvisor::getAnnotatedInlinePassName ( ) const
inline

NOTE pass name is annotated only when inline advisor constructor provides InlineContext.

Definition at line 198 of file InlineAdvisor.h.

References AnnotatedInlinePassName.

◆ getCallerORE()

OptimizationRemarkEmitter & InlineAdvisor::getCallerORE ( CallBase CB)
protected

◆ getMandatoryAdvice()

std::unique_ptr< InlineAdvice > InlineAdvisor::getMandatoryAdvice ( CallBase CB,
bool  Advice 
)
protectedvirtual

Reimplemented in llvm::MLInlineAdvisor.

Definition at line 543 of file InlineAdvisor.cpp.

References getCallerORE().

Referenced by getAdvice().

◆ getMandatoryKind()

InlineAdvisor::MandatoryInliningKind InlineAdvisor::getMandatoryKind ( CallBase CB,
FunctionAnalysisManager FAM,
OptimizationRemarkEmitter ORE 
)
staticprotected

◆ onPassEntry()

virtual void llvm::InlineAdvisor::onPassEntry ( LazyCallGraph::SCC SCC = nullptr)
inlinevirtual

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 in llvm::MLInlineAdvisor.

Definition at line 185 of file InlineAdvisor.h.

Referenced by llvm::InlinerPass::run(), and llvm::ModuleInlinerPass::run().

◆ onPassExit()

virtual void llvm::InlineAdvisor::onPassExit ( LazyCallGraph::SCC SCC = nullptr)
inlinevirtual

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 in llvm::MLInlineAdvisor.

Definition at line 190 of file InlineAdvisor.h.

Referenced by llvm::InlinerPass::run(), and llvm::ModuleInlinerPass::run().

◆ print()

virtual void llvm::InlineAdvisor::print ( raw_ostream OS) const
inlinevirtual

Support for printer pass.

Definition at line 193 of file InlineAdvisor.h.

References OS.

Friends And Related Function Documentation

◆ InlineAdvice

friend class InlineAdvice
friend

Definition at line 224 of file InlineAdvisor.h.

Member Data Documentation

◆ AnnotatedInlinePassName

const std::string llvm::InlineAdvisor::AnnotatedInlinePassName
protected

Definition at line 212 of file InlineAdvisor.h.

Referenced by getAnnotatedInlinePassName().

◆ FAM

FunctionAnalysisManager& llvm::InlineAdvisor::FAM
protected

◆ IC

const std::optional<InlineContext> llvm::InlineAdvisor::IC
protected

Definition at line 211 of file InlineAdvisor.h.

◆ ImportedFunctionsStats

std::unique_ptr<ImportedFunctionsInliningStatistics> llvm::InlineAdvisor::ImportedFunctionsStats
protected

Definition at line 213 of file InlineAdvisor.h.

Referenced by InlineAdvisor(), and ~InlineAdvisor().

◆ M

Module& llvm::InlineAdvisor::M
protected

Definition at line 209 of file InlineAdvisor.h.

Referenced by InlineAdvisor(), and llvm::MLInlineAdvisor::MLInlineAdvisor().


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