LLVM  14.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 ()
 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 ()
 This must be called when the Inliner pass is exited, as function passes may be run subsequently. More...
 

Protected Types

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

Protected Member Functions

 InlineAdvisor (Module &M, FunctionAnalysisManager &FAM)
 
virtual std::unique_ptr< InlineAdvicegetAdviceImpl (CallBase &CB)=0
 
virtual std::unique_ptr< InlineAdvicegetMandatoryAdvice (CallBase &CB, bool Advice)
 
void freeDeletedFunctions ()
 We may want to defer deleting functions to after the inlining for a whole module has finished. More...
 
bool isFunctionDeleted (const Function *F) const
 
OptimizationRemarkEmittergetCallerORE (CallBase &CB)
 

Static Protected Member Functions

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

Protected Attributes

ModuleM
 
FunctionAnalysisManagerFAM
 
std::unique_ptr< ImportedFunctionsInliningStatisticsImportedFunctionsStats
 

Friends

class InlineAdvice
 

Detailed Description

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

Definition at line 139 of file InlineAdvisor.h.

Member Enumeration Documentation

◆ MandatoryInliningKind

Enumerator
NotMandatory 
Always 
Never 

Definition at line 190 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 
)
protected

Definition at line 506 of file InlineAdvisor.cpp.

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

Member Function Documentation

◆ freeDeletedFunctions()

void InlineAdvisor::freeDeletedFunctions ( )
protected

We may want to defer deleting functions to after the inlining for a whole module has finished.

This allows us to reliably use function pointers as unique identifiers, as an efficient implementation detail of the InlineAdvisor. Otherwise, it is possible the memory allocator re-allocate Function objects at the same address of a deleted Function; and Functions are potentially created during the function passes called after each SCC inlining (e.g. argument promotion does that).

Definition at line 163 of file InlineAdvisor.cpp.

References F.

Referenced by ~InlineAdvisor().

◆ 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 554 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().

◆ 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 525 of file InlineAdvisor.cpp.

References getCallerORE().

Referenced by getAdvice().

◆ getMandatoryKind()

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

◆ isFunctionDeleted()

bool llvm::InlineAdvisor::isFunctionDeleted ( const Function F) const
inlineprotected

Definition at line 186 of file InlineAdvisor.h.

References F.

◆ onPassEntry()

virtual void llvm::InlineAdvisor::onPassEntry ( )
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 160 of file InlineAdvisor.h.

Referenced by llvm::InlinerPass::run().

◆ onPassExit()

virtual void llvm::InlineAdvisor::onPassExit ( )
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.

Definition at line 165 of file InlineAdvisor.h.

Referenced by llvm::InlinerPass::run().

Friends And Related Function Documentation

◆ InlineAdvice

friend class InlineAdvice
friend

Definition at line 199 of file InlineAdvisor.h.

Member Data Documentation

◆ FAM

FunctionAnalysisManager& llvm::InlineAdvisor::FAM
protected

◆ ImportedFunctionsStats

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

Definition at line 175 of file InlineAdvisor.h.

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

◆ M

Module& llvm::InlineAdvisor::M
protected

Definition at line 173 of file InlineAdvisor.h.

Referenced by InlineAdvisor().


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