003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/Analysis
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
Analysis
/
📁
..
📄
AliasAnalysis.h
(51.98 KB)
📄
AliasAnalysisEvaluator.h
(2.7 KB)
📄
AliasSetTracker.h
(15.42 KB)
📄
AssumeBundleQueries.h
(6.66 KB)
📄
AssumptionCache.h
(8.39 KB)
📄
BasicAliasAnalysis.h
(10.2 KB)
📄
BlockFrequencyInfo.h
(5.59 KB)
📄
BlockFrequencyInfoImpl.h
(56.46 KB)
📄
BranchProbabilityInfo.h
(10.1 KB)
📄
CFG.h
(7.76 KB)
📄
CFGPrinter.h
(9.31 KB)
📄
CFLAliasAnalysisUtils.h
(1.66 KB)
📄
CFLAndersAliasAnalysis.h
(3.97 KB)
📄
CFLSteensAliasAnalysis.h
(4.58 KB)
📄
CGSCCPassManager.h
(41.2 KB)
📄
CallGraph.h
(18.88 KB)
📄
CallGraphSCCPass.h
(5.01 KB)
📄
CallPrinter.h
(799 B)
📄
CaptureTracking.h
(4.78 KB)
📄
CmpInstAnalysis.h
(2.57 KB)
📄
CodeMetrics.h
(3.15 KB)
📄
ConstantFolding.h
(8.01 KB)
📄
DDG.h
(19.15 KB)
📄
DOTGraphTraitsPass.h
(5.5 KB)
📄
DemandedBits.h
(4.07 KB)
📄
DependenceAnalysis.h
(41.83 KB)
📄
DependenceGraphBuilder.h
(7.74 KB)
📄
DivergenceAnalysis.h
(7.38 KB)
📄
DomPrinter.h
(1.04 KB)
📄
DomTreeUpdater.h
(13.2 KB)
📄
DominanceFrontier.h
(6.63 KB)
📄
DominanceFrontierImpl.h
(7.12 KB)
📄
EHPersonalities.h
(3.22 KB)
📄
GlobalsModRef.h
(5.96 KB)
📄
GuardUtils.h
(2.11 KB)
📄
HeatUtils.h
(1.16 KB)
📄
IVDescriptors.h
(14.56 KB)
📄
IVUsers.h
(6.07 KB)
📄
IndirectCallPromotionAnalysis.h
(2.61 KB)
📄
IndirectCallVisitor.h
(1.16 KB)
📄
InlineAdvisor.h
(8.71 KB)
📄
InlineCost.h
(11.33 KB)
📄
InlineFeaturesAnalysis.h
(1.5 KB)
📄
InlineModelFeatureMaps.h
(3.41 KB)
📄
InlineSizeEstimatorAnalysis.h
(1.07 KB)
📄
InstructionPrecedenceTracking.h
(5.9 KB)
📄
InstructionSimplify.h
(13.36 KB)
📄
Interval.h
(4.84 KB)
📄
IntervalIterator.h
(10.64 KB)
📄
IntervalPartition.h
(4.05 KB)
📄
IteratedDominanceFrontier.h
(2.62 KB)
📄
LazyBlockFrequencyInfo.h
(4.34 KB)
📄
LazyBranchProbabilityInfo.h
(4.21 KB)
📄
LazyCallGraph.h
(50.13 KB)
📄
LazyValueInfo.h
(5.4 KB)
📄
LegacyDivergenceAnalysis.h
(2.53 KB)
📄
Lint.h
(1.35 KB)
📄
Loads.h
(7.86 KB)
📄
LoopAccessAnalysis.h
(29.75 KB)
📄
LoopAnalysisManager.h
(5.83 KB)
📄
LoopCacheAnalysis.h
(11.91 KB)
📄
LoopInfo.h
(48.27 KB)
📄
LoopInfoImpl.h
(27.14 KB)
📄
LoopIterator.h
(8.83 KB)
📄
LoopNestAnalysis.h
(5.61 KB)
📄
LoopPass.h
(4.29 KB)
📄
LoopUnrollAnalyzer.h
(3.42 KB)
📄
MLInlineAdvisor.h
(3.48 KB)
📄
MLModelRunner.h
(1.16 KB)
📄
MemoryBuiltins.h
(13.42 KB)
📄
MemoryDependenceAnalysis.h
(20.82 KB)
📄
MemoryLocation.h
(10.99 KB)
📄
MemorySSA.h
(45.92 KB)
📄
MemorySSAUpdater.h
(14.55 KB)
📄
ModuleSummaryAnalysis.h
(3.44 KB)
📄
MustExecute.h
(20.2 KB)
📄
ObjCARCAliasAnalysis.h
(3.35 KB)
📄
ObjCARCAnalysisUtils.h
(10.22 KB)
📄
ObjCARCInstKind.h
(4.87 KB)
📄
OptimizationRemarkEmitter.h
(5.93 KB)
📄
PHITransAddr.h
(4.77 KB)
📄
Passes.h
(3.88 KB)
📄
PhiValues.h
(5.25 KB)
📄
PostDominators.h
(3.41 KB)
📄
ProfileSummaryInfo.h
(9.3 KB)
📄
PtrUseVisitor.h
(9.96 KB)
📄
RegionInfo.h
(35.23 KB)
📄
RegionInfoImpl.h
(25.16 KB)
📄
RegionIterator.h
(14.07 KB)
📄
RegionPass.h
(4.05 KB)
📄
RegionPrinter.h
(2.25 KB)
📄
ScalarEvolution.h
(89.21 KB)
📄
ScalarEvolutionAliasAnalysis.h
(2.09 KB)
📄
ScalarEvolutionDivision.h
(2.48 KB)
📄
ScalarEvolutionExpressions.h
(28.61 KB)
📄
ScalarEvolutionNormalization.h
(2.47 KB)
📄
ScopedNoAliasAA.h
(2.83 KB)
📄
SparsePropagation.h
(19.43 KB)
📄
StackLifetime.h
(6.16 KB)
📄
StackSafetyAnalysis.h
(4.91 KB)
📄
SyncDependenceAnalysis.h
(2.85 KB)
📄
SyntheticCountsUtils.h
(1.85 KB)
📄
TargetFolder.h
(11.04 KB)
📄
TargetLibraryInfo.def
(55.35 KB)
📄
TargetLibraryInfo.h
(16.86 KB)
📄
TargetTransformInfo.h
(96.51 KB)
📄
TargetTransformInfoImpl.h
(37.63 KB)
📄
Trace.h
(4.1 KB)
📄
TypeBasedAliasAnalysis.h
(3.05 KB)
📄
TypeMetadataUtils.h
(1.94 KB)
📁
Utils
📄
ValueLattice.h
(15.14 KB)
📄
ValueLatticeUtils.h
(1.66 KB)
📄
ValueTracking.h
(35.82 KB)
📄
VecFuncs.def
(10.94 KB)
📄
VectorUtils.h
(37.26 KB)
Editing: InlineAdvisor.h
//===- InlineAdvisor.h - Inlining decision making abstraction -*- C++ ---*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // #ifndef LLVM_INLINEADVISOR_H_ #define LLVM_INLINEADVISOR_H_ #include <memory> #include <unordered_set> #include <vector> #include "llvm/Analysis/InlineCost.h" #include "llvm/IR/PassManager.h" namespace llvm { class BasicBlock; class CallBase; class Function; class Module; class OptimizationRemarkEmitter; /// There are 3 scenarios we can use the InlineAdvisor: /// - Default - use manual heuristics. /// /// - Release mode, the expected mode for production, day to day deployments. /// In this mode, when building the compiler, we also compile a pre-trained ML /// model to native code, and link it as a static library. This mode has low /// overhead and no additional dependencies for the compiler runtime. /// /// - Development mode, for training new models. /// In this mode, we trade off runtime performance for flexibility. This mode /// requires the full C Tensorflow API library, and evaluates models /// dynamically. This mode also permits generating training logs, for offline /// training. enum class InliningAdvisorMode : int { Default, Release, Development }; class InlineAdvisor; /// Capture state between an inlining decision having had been made, and /// its impact being observable. When collecting model training data, this /// allows recording features/decisions/partial reward data sets. /// /// Derivations of this type are expected to be tightly coupled with their /// InliningAdvisors. The base type implements the minimal contractual /// obligations. class InlineAdvice { public: InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, OptimizationRemarkEmitter &ORE, bool IsInliningRecommended); InlineAdvice(InlineAdvice &&) = delete; InlineAdvice(const InlineAdvice &) = delete; virtual ~InlineAdvice() { assert(Recorded && "InlineAdvice should have been informed of the " "inliner's decision in all cases"); } /// Exactly one of the record* APIs must be called. Implementers may extend /// behavior by implementing the corresponding record*Impl. /// /// Call after inlining succeeded, and did not result in deleting the callee. void recordInlining() { markRecorded(); recordInliningImpl(); } /// Call after inlining succeeded, and resulted in deleting the callee. void recordInliningWithCalleeDeleted(); /// Call after the decision for a call site was to not inline. void recordUnsuccessfulInlining(const InlineResult &Result) { markRecorded(); recordUnsuccessfulInliningImpl(Result); } /// Call to indicate inlining was not attempted. void recordUnattemptedInlining() { markRecorded(); recordUnattemptedInliningImpl(); } /// Get the inlining recommendation. bool isInliningRecommended() const { return IsInliningRecommended; } const DebugLoc &getOriginalCallSiteDebugLoc() const { return DLoc; } const BasicBlock *getOriginalCallSiteBasicBlock() const { return Block; } protected: virtual void recordInliningImpl() {} virtual void recordInliningWithCalleeDeletedImpl() {} virtual void recordUnsuccessfulInliningImpl(const InlineResult &Result) {} virtual void recordUnattemptedInliningImpl() {} InlineAdvisor *const Advisor; /// Caller and Callee are pre-inlining. Function *const Caller; Function *const Callee; // Capture the context of CB before inlining, as a successful inlining may // change that context, and we want to report success or failure in the // original context. const DebugLoc DLoc; const BasicBlock *const Block; OptimizationRemarkEmitter &ORE; const bool IsInliningRecommended; private: void markRecorded() { assert(!Recorded && "Recording should happen exactly once"); Recorded = true; } bool Recorded = false; }; /// Interface for deciding whether to inline a call site or not. class InlineAdvisor { public: InlineAdvisor(InlineAdvisor &&) = delete; virtual ~InlineAdvisor() { freeDeletedFunctions(); } /// Get an InlineAdvice containing a recommendation on whether to /// inline or not. \p CB is assumed to be a direct call. \p FAM is assumed to /// be up-to-date wrt previous inlining decisions. /// Returns an InlineAdvice with the inlining recommendation. virtual std::unique_ptr<InlineAdvice> getAdvice(CallBase &CB) = 0; /// 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). virtual void onPassEntry() {} /// 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. virtual void onPassExit() {} protected: InlineAdvisor(FunctionAnalysisManager &FAM) : FAM(FAM) {} FunctionAnalysisManager &FAM; /// 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). void freeDeletedFunctions(); bool isFunctionDeleted(const Function *F) const { return DeletedFunctions.count(F); } private: friend class InlineAdvice; void markFunctionAsDeleted(Function *F); std::unordered_set<const Function *> DeletedFunctions; }; /// The default (manual heuristics) implementation of the InlineAdvisor. This /// implementation does not need to keep state between inliner pass runs, and is /// reusable as-is for inliner pass test scenarios, as well as for regular use. class DefaultInlineAdvisor : public InlineAdvisor { public: DefaultInlineAdvisor(FunctionAnalysisManager &FAM, InlineParams Params) : InlineAdvisor(FAM), Params(Params) {} private: std::unique_ptr<InlineAdvice> getAdvice(CallBase &CB) override; void onPassExit() override { freeDeletedFunctions(); } InlineParams Params; }; /// The InlineAdvisorAnalysis is a module pass because the InlineAdvisor /// needs to capture state right before inlining commences over a module. class InlineAdvisorAnalysis : public AnalysisInfoMixin<InlineAdvisorAnalysis> { public: static AnalysisKey Key; InlineAdvisorAnalysis() = default; struct Result { Result(Module &M, ModuleAnalysisManager &MAM) : M(M), MAM(MAM) {} bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &) { // InlineAdvisor must be preserved across analysis invalidations. return false; } bool tryCreate(InlineParams Params, InliningAdvisorMode Mode); InlineAdvisor *getAdvisor() const { return Advisor.get(); } void clear() { Advisor.reset(); } private: Module &M; ModuleAnalysisManager &MAM; std::unique_ptr<InlineAdvisor> Advisor; }; Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); } }; #ifdef LLVM_HAVE_TF_AOT std::unique_ptr<InlineAdvisor> getReleaseModeAdvisor(Module &M, ModuleAnalysisManager &MAM); #endif // Default (manual policy) decision making helper APIs. Shared with the legacy // pass manager inliner. /// Return the cost only if the inliner should attempt to inline at the given /// CallSite. If we return the cost, we will emit an optimisation remark later /// using that cost, so we won't do so from this function. Return None if /// inlining should not be attempted. Optional<InlineCost> shouldInline(CallBase &CB, function_ref<InlineCost(CallBase &CB)> GetInlineCost, OptimizationRemarkEmitter &ORE, bool EnableDeferral = true); /// Emit ORE message. void emitInlinedInto(OptimizationRemarkEmitter &ORE, DebugLoc DLoc, const BasicBlock *Block, const Function &Callee, const Function &Caller, const InlineCost &IC, bool ForProfileContext = false, const char *PassName = nullptr); /// Add location info to ORE message. void addLocationToRemarks(OptimizationRemark &Remark, DebugLoc DLoc); /// Set the inline-remark attribute. void setInlineRemark(CallBase &CB, StringRef Message); /// Utility for extracting the inline cost message to a string. std::string inlineCostStr(const InlineCost &IC); } // namespace llvm #endif // LLVM_INLINEADVISOR_H_
Upload File
Create Folder