LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
llvm::PluginInlineAdvisorAnalysis Class Reference

Used for dynamically registering InlineAdvisors as plugins. More...

#include "llvm/Analysis/InlineAdvisor.h"

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

Classes

struct  Result
 

Public Types

typedef InlineAdvisor *(* AdvisorFactory) (Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC)
 

Public Member Functions

 PluginInlineAdvisorAnalysis (AdvisorFactory Factory)
 
Result run (Module &M, ModuleAnalysisManager &MAM)
 
Result getResult ()
 
- Public Member Functions inherited from llvm::PassInfoMixin< DerivedT >
void printPipeline (raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
 

Static Public Attributes

static AnalysisKey Key
 
static bool HasBeenRegistered = false
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::AnalysisInfoMixin< PluginInlineAdvisorAnalysis >
static AnalysisKeyID ()
 Returns an opaque, unique ID for this analysis type.
 
- Static Public Member Functions inherited from llvm::PassInfoMixin< DerivedT >
static StringRef name ()
 Gets the name of the pass we are mixed into.
 

Detailed Description

Used for dynamically registering InlineAdvisors as plugins.

An advisor plugin adds a new advisor at runtime by registering an instance of PluginInlineAdvisorAnalysis in the current ModuleAnalysisManager. For example, the following code dynamically registers a DefaultInlineAdvisor:

namespace {

InlineAdvisor *defaultAdvisorFactory(Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC) { return new DefaultInlineAdvisor(M, FAM, Params, IC); }

struct DefaultDynamicAdvisor : PassInfoMixin<DefaultDynamicAdvisor> { PreservedAnalyses run(Module &, ModuleAnalysisManager &MAM) { PluginInlineAdvisorAnalysis PA(defaultAdvisorFactory); MAM.registerPass([&] { return PA; }); return PreservedAnalyses::all(); } };

} // namespace

extern "C" LLVM_ATTRIBUTE_WEAK llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "DynamicDefaultAdvisor", LLVM_VERSION_STRING, [](PassBuilder &PB) { PB.registerPipelineStartEPCallback( [](ModulePassManager &MPM, OptimizationLevel Level) { MPM.addPass(DefaultDynamicAdvisor()); }); }}; }

A plugin must implement an AdvisorFactory and register it with a PluginInlineAdvisorAnlysis to the provided ModuleanAlysisManager.

If such a plugin has been registered InlineAdvisorAnalysis::Result::tryCreate will return the dynamically loaded advisor.

Definition at line 286 of file InlineAdvisor.h.

Member Typedef Documentation

◆ AdvisorFactory

typedef InlineAdvisor *(* llvm::PluginInlineAdvisorAnalysis::AdvisorFactory) (Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC)

Definition at line 292 of file InlineAdvisor.h.

Constructor & Destructor Documentation

◆ PluginInlineAdvisorAnalysis()

llvm::PluginInlineAdvisorAnalysis::PluginInlineAdvisorAnalysis ( AdvisorFactory  Factory)
inline

Definition at line 297 of file InlineAdvisor.h.

References assert(), and HasBeenRegistered.

Member Function Documentation

◆ getResult()

Result llvm::PluginInlineAdvisorAnalysis::getResult ( )
inline

Definition at line 308 of file InlineAdvisor.h.

◆ run()

Result llvm::PluginInlineAdvisorAnalysis::run ( Module M,
ModuleAnalysisManager MAM 
)
inline

Definition at line 307 of file InlineAdvisor.h.

Member Data Documentation

◆ HasBeenRegistered

bool PluginInlineAdvisorAnalysis::HasBeenRegistered = false
static

◆ Key

AnalysisKey PluginInlineAdvisorAnalysis::Key
static

Definition at line 289 of file InlineAdvisor.h.


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