9#ifndef LLVM_ANALYSIS_MLINLINEADVISOR_H
10#define LLVM_ANALYSIS_MLINLINEADVISOR_H
31 std::function<std::unique_ptr<MLModelRunner>(
32 const std::vector<TensorSpec> &)>
45 bool CalleeWasDeleted);
52 static const std::vector<TensorSpec> &getInitialFeatureMap();
55 std::unique_ptr<InlineAdvice> getAdviceImpl(
CallBase &CB)
override;
57 std::unique_ptr<InlineAdvice> getMandatoryAdvice(
CallBase &CB,
58 bool Advice)
override;
60 virtual std::unique_ptr<MLInlineAdvice> getMandatoryAdviceImpl(
CallBase &CB);
62 virtual std::unique_ptr<MLInlineAdvice>
68 unsigned getInitialFunctionLevel(
const Function &
F)
const;
75 int64_t getModuleIRSize()
const;
76 std::unique_ptr<InlineAdvice>
77 getSkipAdviceIfUnreachableCallsite(
CallBase &CB);
83 mutable std::map<const Function *, FunctionPropertiesInfo> FPICache;
87 int64_t NodeCount = 0;
88 int64_t EdgeCount = 0;
89 int64_t EdgesOfLastSeenNodes = 0;
92 std::map<const LazyCallGraph::Node *, unsigned> FunctionLevels;
93 const int32_t InitialIRSize = 0;
94 int32_t CurrentIRSize = 0;
98 bool ForceStop =
false;
131 std::optional<FunctionPropertiesUpdater> FPU;
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This header defines various interfaces for pass management in LLVM.
Implements a lazy call graph analysis and related passes for the new pass manager.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Implements a dense probed hash-table based set.
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
Function *const Caller
Caller and Callee are pre-inlining.
OptimizationRemarkEmitter & ORE
InlineAdvisor *const Advisor
LLVM_ABI InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, OptimizationRemarkEmitter &ORE, bool IsInliningRecommended)
InlineAdvisor(InlineAdvisor &&)=delete
InlineResult is basically true or false.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
InlineAdvice that tracks changes post inlining.
~MLInlineAdvice() override=default
void updateCachedCallerFPI(FunctionAnalysisManager &FAM) const
const int64_t CallerIRSize
MLInlineAdvice(MLInlineAdvisor *Advisor, CallBase &CB, OptimizationRemarkEmitter &ORE, bool Recommendation)
const int64_t CalleeIRSize
void recordInliningImpl() override
Function * getCaller() const
const int64_t CallerAndCalleeEdges
void recordUnsuccessfulInliningImpl(const InlineResult &Result) override
Function * getCallee() const
void recordInliningWithCalleeDeletedImpl() override
void recordUnattemptedInliningImpl() override
const std::vector< TensorSpec > & getFeatureMap() const
std::unique_ptr< MLModelRunner > ModelRunner
FunctionPropertiesInfo & getCachedFPI(Function &) const
void onPassExit(LazyCallGraph::SCC *SCC) override
This must be called when the Inliner pass is exited, as function passes may be run subsequently.
const MLModelRunner & getModelRunner() const
void onPassEntry(LazyCallGraph::SCC *SCC) override
This must be called when the Inliner pass is entered, to allow the InlineAdvisor update internal stat...
~MLInlineAdvisor() override=default
MLInlineAdvisor(Module &M, ModuleAnalysisManager &MAM, std::function< std::unique_ptr< MLModelRunner >(const std::vector< TensorSpec > &)> GetModelRunner, std::function< bool(CallBase &)> GetDefaultAdvice)
std::vector< TensorSpec > FeatureMap
int64_t getIRSize(Function &F) const
std::function< bool(CallBase &)> GetDefaultAdvice
bool isForcedToStop() const
MLModelRunner interface: abstraction of a mechanism for evaluating a ML model.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.