LLVM 20.0.0git
|
Used for dynamically registering InlineAdvisors as plugins. More...
#include "llvm/Analysis/InlineAdvisor.h"
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 AnalysisKey * | ID () |
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. | |
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.
typedef InlineAdvisor *(* llvm::PluginInlineAdvisorAnalysis::AdvisorFactory) (Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC) |
Definition at line 292 of file InlineAdvisor.h.
|
inline |
Definition at line 297 of file InlineAdvisor.h.
References assert(), and HasBeenRegistered.
|
inline |
Definition at line 308 of file InlineAdvisor.h.
|
inline |
Definition at line 307 of file InlineAdvisor.h.
|
static |
Definition at line 290 of file InlineAdvisor.h.
Referenced by PluginInlineAdvisorAnalysis(), and llvm::InlineAdvisorAnalysis::Result::tryCreate().
|
static |
Definition at line 289 of file InlineAdvisor.h.