Go to the documentation of this file.
9 #ifndef LLVM_ANALYSIS_INLINEADVISOR_H
10 #define LLVM_ANALYSIS_INLINEADVISOR_H
15 #include "llvm/Config/llvm-config.h"
24 class OptimizationRemark;
25 class ImportedFunctionsInliningStatistics;
26 class OptimizationRemarkEmitter;
27 struct ReplayInlinerSettings;
82 assert(Recorded &&
"InlineAdvice should have been informed of the "
83 "inliner's decision in all cases");
134 void markRecorded() {
135 assert(!Recorded &&
"Recording should happen exactly once");
138 void recordInlineStatsIfNeeded();
140 bool Recorded =
false;
147 bool EmitRemarks =
true)
149 OIC(OIC), EmitRemarks(EmitRemarks) {}
152 void recordUnsuccessfulInliningImpl(
const InlineResult &Result)
override;
153 void recordInliningWithCalleeDeletedImpl()
override;
154 void recordInliningImpl()
override;
179 bool MandatoryOnly =
false);
193 OS <<
"Unimplemented InlineAdvisor print\n";
236 std::unique_ptr<InlineAdvice> getAdviceImpl(
CallBase &CB)
override;
254 return !PAC.preservedWhenStateless();
264 std::unique_ptr<InlineAdvisor> Advisor;
284 std::unique_ptr<InlineAdvisor>
287 std::unique_ptr<InlineAdvisor>
299 shouldInline(CallBase &CB, function_ref<InlineCost(CallBase &CB)> GetInlineCost,
300 OptimizationRemarkEmitter &ORE,
bool EnableDeferral =
true);
304 const BasicBlock *Block,
const Function &Callee,
305 const Function &Caller,
bool IsMandatory,
306 function_ref<
void(OptimizationRemark &)> ExtraContext = {},
311 const BasicBlock *Block,
const Function &Callee,
312 const Function &Caller,
const InlineCost &IC,
313 bool ForProfileContext =
false,
325 #endif // LLVM_ANALYSIS_INLINEADVISOR_H
virtual void print(raw_ostream &OS) const
Support for printer pass.
A set of analyses that are preserved following a run of a transformation pass.
virtual void onPassEntry(LazyCallGraph::SCC *SCC=nullptr)
This must be called when the Inliner pass is entered, to allow the InlineAdvisor update internal stat...
void recordInlining()
Exactly one of the record* APIs must be called.
InlineAdvisor * getAdvisor() const
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< InlineAdvisor > getReleaseModeAdvisor(Module &M, ModuleAnalysisManager &MAM)
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
std::unique_ptr< ImportedFunctionsInliningStatistics > ImportedFunctionsStats
A CRTP mix-in to automatically provide informational APIs needed for passes.
Result run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Function *const Caller
Caller and Callee are pre-inlining.
void emitInlinedIntoBasedOnCost(OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, const Function &Callee, const Function &Caller, const InlineCost &IC, bool ForProfileContext=false, const char *PassName=nullptr)
Emit ORE message based in cost (default heuristic).
InlineAdvisorAnalysisPrinterPass(raw_ostream &OS)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Thresholds to tune inline cost analysis.
void addLocationToRemarks(OptimizationRemark &Remark, DebugLoc DLoc)
Add location info to ORE message.
OptimizationRemarkEmitter & getCallerORE(CallBase &CB)
LLVM Basic Block Representation.
Printer pass for the FunctionPropertiesAnalysis results.
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
void emitInlinedInto(OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, const Function &Callee, const Function &Caller, bool IsMandatory, function_ref< void(OptimizationRemark &)> ExtraContext={}, const char *PassName=nullptr)
Emit ORE message.
const bool IsInliningRecommended
An SCC of the call graph.
virtual void onPassExit(LazyCallGraph::SCC *SCC=nullptr)
This must be called when the Inliner pass is exited, as function passes may be run subsequently.
OptimizationRemarkEmitter & ORE
The default (manual heuristics) implementation of the InlineAdvisor.
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
ModuleAnalysisManager MAM
This class implements an extremely fast bulk output stream that can only output to a stream.
const BasicBlock * getOriginalCallSiteBasicBlock() const
API to communicate dependencies between analyses during invalidation.
Provides context on when an inline advisor is constructed in the pipeline (e.g., link phase,...
Capture state between an inlining decision having had been made, and its impact being observable.
InliningAdvisorMode
There are 3 scenarios we can use the InlineAdvisor:
const char * getAnnotatedInlinePassName() const
NOTE pass name is annotated only when inline advisor constructor provides InlineContext.
InlineAdvisor(InlineAdvisor &&)=delete
void recordUnattemptedInlining()
Call to indicate inlining was not attempted.
void recordInliningWithCalleeDeleted()
Call after inlining succeeded, and results in the callee being delete-able, meaning,...
A special type used by analysis passes to provide an address that identifies that particular analysis...
const Optional< InlineContext > IC
const BasicBlock *const Block
virtual void recordInliningImpl()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setInlineRemark(CallBase &CB, StringRef Message)
Set the inline-remark attribute.
@ BasicBlock
Various leaf nodes.
print Print MemDeps of function
A Module instance is used to store all the information related to an LLVM module.
A CRTP mix-in that provides informational APIs needed for analysis passes.
virtual void recordUnsuccessfulInliningImpl(const InlineResult &Result)
bool isInliningRecommended() const
Get the inlining recommendation.
bool tryCreate(InlineParams Params, InliningAdvisorMode Mode, const ReplayInlinerSettings &ReplaySettings, InlineContext IC)
Result(Module &M, ModuleAnalysisManager &MAM)
DefaultInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC)
Interface for deciding whether to inline a call site or not.
InlineAdvisorAnalysis()=default
virtual void recordUnattemptedInliningImpl()
Machine Check Debug Module
virtual void recordInliningWithCalleeDeletedImpl()
@ ReplaySampleProfileInliner
virtual std::unique_ptr< InlineAdvice > getMandatoryAdvice(CallBase &CB, bool Advice)
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
FunctionAnalysisManager & FAM
std::unique_ptr< InlineAdvice > getAdvice(CallBase &CB, bool MandatoryOnly=false)
Get an InlineAdvice containing a recommendation on whether to inline or not.
virtual std::unique_ptr< InlineAdvice > getAdviceImpl(CallBase &CB)=0
std::string inlineCostStr(const InlineCost &IC)
Utility for extracting the inline cost message to a string.
static MandatoryInliningKind getMandatoryKind(CallBase &CB, FunctionAnalysisManager &FAM, OptimizationRemarkEmitter &ORE)
std::string AnnotateInlinePassName(InlineContext IC)
The InlineAdvisorAnalysis is a module pass because the InlineAdvisor needs to capture state right bef...
std::unique_ptr< InlineAdvisor > getDevelopmentModeAdvisor(Module &M, ModuleAnalysisManager &MAM, std::function< bool(CallBase &)> GetDefaultAdvice)
InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, OptimizationRemarkEmitter &ORE, bool IsInliningRecommended)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const std::string AnnotatedInlinePassName
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A container for analyses that lazily runs them and caches their results.
DefaultInlineAdvice(InlineAdvisor *Advisor, CallBase &CB, Optional< InlineCost > OIC, OptimizationRemarkEmitter &ORE, bool EmitRemarks=true)
A lazily constructed view of the call graph of a module.
const DebugLoc & getOriginalCallSiteDebugLoc() const
InlineAdvisor *const Advisor
InlineResult is basically true or false.
void recordUnsuccessfulInlining(const InlineResult &Result)
Call after the decision for a call site was to not inline.
static const char PassName[]
Optional< InlineCost > shouldInline(CallBase &CB, function_ref< InlineCost(CallBase &CB)> GetInlineCost, OptimizationRemarkEmitter &ORE, bool EnableDeferral=true)
Return the cost only if the inliner should attempt to inline at the given CallSite.
bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
ThinOrFullLTOPhase LTOPhase