LLVM  16.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]
Collaboration diagram for llvm::InlineAdvisor:
Collaboration 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. More...
 
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). More...
 
virtual void onPassExit (LazyCallGraph::SCC *SCC=nullptr)
 This must be called when the Inliner pass is exited, as function passes may be run subsequently. More...
 
virtual void print (raw_ostream &OS) const
 Support for printer pass. More...
 
const char * getAnnotatedInlinePassName () const
 NOTE pass name is annotated only when inline advisor constructor provides InlineContext. More...
 

Protected Types

enum  MandatoryInliningKind { MandatoryInliningKind::NotMandatory, MandatoryInliningKind::Always, MandatoryInliningKind::Never }
 

Protected Member Functions

 InlineAdvisor (Module &M, FunctionAnalysisManager &FAM, Optional< InlineContext > IC=NoneType::None)
 
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 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 163 of file InlineAdvisor.h.

Member Enumeration Documentation

◆ MandatoryInliningKind

Enumerator
NotMandatory 
Always 
Never 

Definition at line 214 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,
Optional< InlineContext IC = NoneType::None 
)
protected

Definition at line 514 of file InlineAdvisor.cpp.

References ImportedFunctionsStats, InlinerFunctionImportStats, M, M, and llvm::No.

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 606 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::ReplayInlineAdvisor, and llvm::MLInlineAdvisor.

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 197 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 535 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 184 of file InlineAdvisor.h.

Referenced by llvm::ModuleInlinerPass::run(), and llvm::InlinerPass::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 189 of file InlineAdvisor.h.

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

◆ print()

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

Support for printer pass.

Definition at line 192 of file InlineAdvisor.h.

Friends And Related Function Documentation

◆ InlineAdvice

friend class InlineAdvice
friend

Definition at line 223 of file InlineAdvisor.h.

Member Data Documentation

◆ AnnotatedInlinePassName

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

Definition at line 211 of file InlineAdvisor.h.

Referenced by getAnnotatedInlinePassName().

◆ FAM

FunctionAnalysisManager& llvm::InlineAdvisor::FAM
protected

◆ IC

const Optional<InlineContext> llvm::InlineAdvisor::IC
protected

Definition at line 210 of file InlineAdvisor.h.

◆ ImportedFunctionsStats

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

Definition at line 212 of file InlineAdvisor.h.

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

◆ M

Module& llvm::InlineAdvisor::M
protected

Definition at line 208 of file InlineAdvisor.h.

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


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