LLVM  17.0.0git
InlineAdvisor.h
Go to the documentation of this file.
1 //===- InlineAdvisor.h - Inlining decision making abstraction -*- C++ ---*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 #ifndef LLVM_ANALYSIS_INLINEADVISOR_H
10 #define LLVM_ANALYSIS_INLINEADVISOR_H
11 
15 #include "llvm/Config/llvm-config.h"
16 #include "llvm/IR/PassManager.h"
17 #include <memory>
18 
19 namespace llvm {
20 class BasicBlock;
21 class CallBase;
22 class Function;
23 class Module;
24 class OptimizationRemark;
25 class ImportedFunctionsInliningStatistics;
26 class OptimizationRemarkEmitter;
27 struct ReplayInlinerSettings;
28 
29 /// There are 4 scenarios we can use the InlineAdvisor:
30 /// - Default - use manual heuristics.
31 ///
32 /// - Release mode, the expected mode for production, day to day deployments.
33 /// In this mode, when building the compiler, we also compile a pre-trained ML
34 /// model to native code, and link it as a static library. This mode has low
35 /// overhead and no additional dependencies for the compiler runtime.
36 ///
37 /// - Development mode, for training new models.
38 /// In this mode, we trade off runtime performance for flexibility. This mode
39 /// requires the full C Tensorflow API library, and evaluates models
40 /// dynamically. This mode also permits generating training logs, for offline
41 /// training.
42 ///
43 /// - Dynamically load an advisor via a plugin (PluginInlineAdvisorAnalysis)
45 
46 // Each entry represents an inline driver.
47 enum class InlinePass : int {
52  MLInliner,
56 };
57 
58 /// Provides context on when an inline advisor is constructed in the pipeline
59 /// (e.g., link phase, inline driver).
60 struct InlineContext {
62 
64 };
65 
67 
68 class InlineAdvisor;
69 /// Capture state between an inlining decision having had been made, and
70 /// its impact being observable. When collecting model training data, this
71 /// allows recording features/decisions/partial reward data sets.
72 ///
73 /// Derivations of this type are expected to be tightly coupled with their
74 /// InliningAdvisors. The base type implements the minimal contractual
75 /// obligations.
76 class InlineAdvice {
77 public:
80 
81  InlineAdvice(InlineAdvice &&) = delete;
82  InlineAdvice(const InlineAdvice &) = delete;
83  virtual ~InlineAdvice() {
84  assert(Recorded && "InlineAdvice should have been informed of the "
85  "inliner's decision in all cases");
86  }
87 
88  /// Exactly one of the record* APIs must be called. Implementers may extend
89  /// behavior by implementing the corresponding record*Impl.
90  ///
91  /// Call after inlining succeeded, and did not result in deleting the callee.
92  void recordInlining();
93 
94  /// Call after inlining succeeded, and results in the callee being
95  /// delete-able, meaning, it has no more users, and will be cleaned up
96  /// subsequently.
98 
99  /// Call after the decision for a call site was to not inline.
101  markRecorded();
103  }
104 
105  /// Call to indicate inlining was not attempted.
107  markRecorded();
109  }
110 
111  /// Get the inlining recommendation.
113  const DebugLoc &getOriginalCallSiteDebugLoc() const { return DLoc; }
114  const BasicBlock *getOriginalCallSiteBasicBlock() const { return Block; }
115 
116 protected:
117  virtual void recordInliningImpl() {}
119  virtual void recordUnsuccessfulInliningImpl(const InlineResult &Result) {}
121 
123  /// Caller and Callee are pre-inlining.
124  Function *const Caller;
125  Function *const Callee;
126 
127  // Capture the context of CB before inlining, as a successful inlining may
128  // change that context, and we want to report success or failure in the
129  // original context.
130  const DebugLoc DLoc;
131  const BasicBlock *const Block;
134 
135 private:
136  void markRecorded() {
137  assert(!Recorded && "Recording should happen exactly once");
138  Recorded = true;
139  }
140  void recordInlineStatsIfNeeded();
141 
142  bool Recorded = false;
143 };
144 
146 public:
148  std::optional<InlineCost> OIC,
149  OptimizationRemarkEmitter &ORE, bool EmitRemarks = true)
150  : InlineAdvice(Advisor, CB, ORE, OIC.has_value()), OriginalCB(&CB),
151  OIC(OIC), EmitRemarks(EmitRemarks) {}
152 
153 private:
154  void recordUnsuccessfulInliningImpl(const InlineResult &Result) override;
155  void recordInliningWithCalleeDeletedImpl() override;
156  void recordInliningImpl() override;
157 
158 private:
159  CallBase *const OriginalCB;
160  std::optional<InlineCost> OIC;
161  bool EmitRemarks;
162 };
163 
164 /// Interface for deciding whether to inline a call site or not.
166 public:
167  InlineAdvisor(InlineAdvisor &&) = delete;
168  virtual ~InlineAdvisor();
169 
170  /// Get an InlineAdvice containing a recommendation on whether to
171  /// inline or not. \p CB is assumed to be a direct call. \p FAM is assumed to
172  /// be up-to-date wrt previous inlining decisions. \p MandatoryOnly indicates
173  /// only mandatory (always-inline) call sites should be recommended - this
174  /// allows the InlineAdvisor track such inlininings.
175  /// Returns:
176  /// - An InlineAdvice with the inlining recommendation.
177  /// - Null when no recommendation is made (https://reviews.llvm.org/D110658).
178  /// TODO: Consider removing the Null return scenario by incorporating the
179  /// SampleProfile inliner into an InlineAdvisor
180  std::unique_ptr<InlineAdvice> getAdvice(CallBase &CB,
181  bool MandatoryOnly = false);
182 
183  /// This must be called when the Inliner pass is entered, to allow the
184  /// InlineAdvisor update internal state, as result of function passes run
185  /// between Inliner pass runs (for the same module).
186  virtual void onPassEntry(LazyCallGraph::SCC *SCC = nullptr) {}
187 
188  /// This must be called when the Inliner pass is exited, as function passes
189  /// may be run subsequently. This allows an implementation of InlineAdvisor
190  /// to prepare for a partial update, based on the optional SCC.
191  virtual void onPassExit(LazyCallGraph::SCC *SCC = nullptr) {}
192 
193  /// Support for printer pass
194  virtual void print(raw_ostream &OS) const {
195  OS << "Unimplemented InlineAdvisor print\n";
196  }
197 
198  /// NOTE pass name is annotated only when inline advisor constructor provides InlineContext.
199  const char *getAnnotatedInlinePassName() const {
200  return AnnotatedInlinePassName.c_str();
201  }
202 
203 protected:
205  std::optional<InlineContext> IC = std::nullopt);
206  virtual std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) = 0;
207  virtual std::unique_ptr<InlineAdvice> getMandatoryAdvice(CallBase &CB,
208  bool Advice);
209 
212  const std::optional<InlineContext> IC;
213  const std::string AnnotatedInlinePassName;
214  std::unique_ptr<ImportedFunctionsInliningStatistics> ImportedFunctionsStats;
215 
217 
221 
223 
224 private:
225  friend class InlineAdvice;
226 };
227 
228 /// The default (manual heuristics) implementation of the InlineAdvisor. This
229 /// implementation does not need to keep state between inliner pass runs, and is
230 /// reusable as-is for inliner pass test scenarios, as well as for regular use.
232 public:
234  InlineParams Params, InlineContext IC)
235  : InlineAdvisor(M, FAM, IC), Params(Params) {}
236 
237 private:
238  std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) override;
239 
240  InlineParams Params;
241 };
242 
243 /// Used for dynamically registering InlineAdvisors as plugins
244 ///
245 /// An advisor plugin adds a new advisor at runtime by registering an instance
246 /// of PluginInlineAdvisorAnalysis in the current ModuleAnalysisManager.
247 /// For example, the following code dynamically registers a
248 /// DefaultInlineAdvisor:
249 ///
250 /// namespace {
251 ///
252 /// InlineAdvisor *defaultAdvisorFactory(Module &M, FunctionAnalysisManager
253 /// &FAM,
254 /// InlineParams Params, InlineContext IC)
255 /// {
256 /// return new DefaultInlineAdvisor(M, FAM, Params, IC);
257 /// }
258 ///
259 /// struct DefaultDynamicAdvisor : PassInfoMixin<DefaultDynamicAdvisor> {
260 /// PreservedAnalyses run(Module &, ModuleAnalysisManager &MAM) {
261 /// PluginInlineAdvisorAnalysis PA(defaultAdvisorFactory);
262 /// MAM.registerPass([&] { return PA; });
263 /// return PreservedAnalyses::all();
264 /// }
265 /// };
266 ///
267 /// } // namespace
268 ///
269 /// extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
270 /// llvmGetPassPluginInfo() {
271 /// return {LLVM_PLUGIN_API_VERSION, "DynamicDefaultAdvisor",
272 /// LLVM_VERSION_STRING,
273 /// [](PassBuilder &PB) {
274 /// PB.registerPipelineStartEPCallback(
275 /// [](ModulePassManager &MPM, OptimizationLevel Level) {
276 /// MPM.addPass(DefaultDynamicAdvisor());
277 /// });
278 /// }};
279 /// }
280 ///
281 /// A plugin must implement an AdvisorFactory and register it with a
282 /// PluginInlineAdvisorAnlysis to the provided ModuleanAlysisManager.
283 ///
284 /// If such a plugin has been registered
285 /// InlineAdvisorAnalysis::Result::tryCreate will return the dynamically loaded
286 /// advisor.
287 ///
289  : public AnalysisInfoMixin<PluginInlineAdvisorAnalysis> {
290 public:
291  static AnalysisKey Key;
292  static bool HasBeenRegistered;
293 
294  typedef InlineAdvisor *(*AdvisorFactory)(Module &M,
296  InlineParams Params,
297  InlineContext IC);
298 
299  PluginInlineAdvisorAnalysis(AdvisorFactory Factory) : Factory(Factory) {
300  HasBeenRegistered = true;
301  assert(Factory != nullptr &&
302  "The plugin advisor factory should not be a null pointer.");
303  }
304 
305  struct Result {
307  };
308 
309  Result run(Module &M, ModuleAnalysisManager &MAM) { return {Factory}; }
310  Result getResult() { return {Factory}; }
311 
312 private:
313  AdvisorFactory Factory;
314 };
315 
316 /// The InlineAdvisorAnalysis is a module pass because the InlineAdvisor
317 /// needs to capture state right before inlining commences over a module.
318 class InlineAdvisorAnalysis : public AnalysisInfoMixin<InlineAdvisorAnalysis> {
319 public:
320  static AnalysisKey Key;
321  InlineAdvisorAnalysis() = default;
322  struct Result {
326  // Check whether the analysis has been explicitly invalidated. Otherwise,
327  // it's stateless and remains preserved.
328  auto PAC = PA.getChecker<InlineAdvisorAnalysis>();
329  return !PAC.preservedWhenStateless();
330  }
332  const ReplayInlinerSettings &ReplaySettings,
333  InlineContext IC);
334  InlineAdvisor *getAdvisor() const { return Advisor.get(); }
335 
336  private:
337  Module &M;
339  std::unique_ptr<InlineAdvisor> Advisor;
340  };
341 
343 };
344 
345 /// Printer pass for the FunctionPropertiesAnalysis results.
347  : public PassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
348  raw_ostream &OS;
349 
350 public:
352 
354 
357 };
358 
359 std::unique_ptr<InlineAdvisor>
361 
362 std::unique_ptr<InlineAdvisor>
364  std::function<bool(CallBase &)> GetDefaultAdvice);
365 
366 // Default (manual policy) decision making helper APIs. Shared with the legacy
367 // pass manager inliner.
368 
369 /// Return the cost only if the inliner should attempt to inline at the given
370 /// CallSite. If we return the cost, we will emit an optimisation remark later
371 /// using that cost, so we won't do so from this function. Return std::nullopt
372 /// if inlining should not be attempted.
373 std::optional<InlineCost>
374 shouldInline(CallBase &CB, function_ref<InlineCost(CallBase &CB)> GetInlineCost,
375  OptimizationRemarkEmitter &ORE, bool EnableDeferral = true);
376 
377 /// Emit ORE message.
378 void emitInlinedInto(OptimizationRemarkEmitter &ORE, DebugLoc DLoc,
379  const BasicBlock *Block, const Function &Callee,
380  const Function &Caller, bool IsMandatory,
381  function_ref<void(OptimizationRemark &)> ExtraContext = {},
382  const char *PassName = nullptr);
383 
384 /// Emit ORE message based in cost (default heuristic).
385 void emitInlinedIntoBasedOnCost(OptimizationRemarkEmitter &ORE, DebugLoc DLoc,
386  const BasicBlock *Block, const Function &Callee,
387  const Function &Caller, const InlineCost &IC,
388  bool ForProfileContext = false,
389  const char *PassName = nullptr);
390 
391 /// Add location info to ORE message.
392 void addLocationToRemarks(OptimizationRemark &Remark, DebugLoc DLoc);
393 
394 /// Set the inline-remark attribute.
395 void setInlineRemark(CallBase &CB, StringRef Message);
396 
397 /// Utility for extracting the inline cost message to a string.
398 std::string inlineCostStr(const InlineCost &IC);
399 } // namespace llvm
400 #endif // LLVM_ANALYSIS_INLINEADVISOR_H
llvm::InlinePass::AlwaysInliner
@ AlwaysInliner
llvm::InlineAdvisor::print
virtual void print(raw_ostream &OS) const
Support for printer pass.
Definition: InlineAdvisor.h:194
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm::InlineAdvisor::onPassEntry
virtual void onPassEntry(LazyCallGraph::SCC *SCC=nullptr)
This must be called when the Inliner pass is entered, to allow the InlineAdvisor update internal stat...
Definition: InlineAdvisor.h:186
llvm::InlineAdvice::recordInlining
void recordInlining()
Exactly one of the record* APIs must be called.
Definition: InlineAdvisor.cpp:186
llvm::InlineAdvisorAnalysis::Result::getAdvisor
InlineAdvisor * getAdvisor() const
Definition: InlineAdvisor.h:334
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::getReleaseModeAdvisor
std::unique_ptr< InlineAdvisor > getReleaseModeAdvisor(Module &M, ModuleAnalysisManager &MAM)
M
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
Definition: README.txt:252
llvm::InlineAdvisor::ImportedFunctionsStats
std::unique_ptr< ImportedFunctionsInliningStatistics > ImportedFunctionsStats
Definition: InlineAdvisor.h:214
llvm::InlineAdvisor::M
Module & M
Definition: InlineAdvisor.h:210
llvm::PluginInlineAdvisorAnalysis
Used for dynamically registering InlineAdvisors as plugins.
Definition: InlineAdvisor.h:288
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::Function
Definition: Function.h:59
llvm::InlinePass::EarlyInliner
@ EarlyInliner
llvm::PluginInlineAdvisorAnalysis::AdvisorFactory
InlineAdvisor *(* AdvisorFactory)(Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC)
Definition: InlineAdvisor.h:294
llvm::InlineAdvisorAnalysis::run
Result run(Module &M, ModuleAnalysisManager &MAM)
Definition: InlineAdvisor.h:342
llvm::shouldInline
std::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.
Definition: InlineAdvisor.cpp:377
llvm::InlineAdvisorAnalysisPrinterPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Definition: InlineAdvisor.cpp:630
llvm::InlineAdvice::Caller
Function *const Caller
Caller and Callee are pre-inlining.
Definition: InlineAdvisor.h:124
llvm::DefaultInlineAdvice::DefaultInlineAdvice
DefaultInlineAdvice(InlineAdvisor *Advisor, CallBase &CB, std::optional< InlineCost > OIC, OptimizationRemarkEmitter &ORE, bool EmitRemarks=true)
Definition: InlineAdvisor.h:147
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::InlineAdvisor::IC
const std::optional< InlineContext > IC
Definition: InlineAdvisor.h:212
llvm::emitInlinedIntoBasedOnCost
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).
Definition: InlineAdvisor.cpp:509
llvm::InlineAdvice::~InlineAdvice
virtual ~InlineAdvice()
Definition: InlineAdvisor.h:83
llvm::InlineAdvisorAnalysisPrinterPass::InlineAdvisorAnalysisPrinterPass
InlineAdvisorAnalysisPrinterPass(raw_ostream &OS)
Definition: InlineAdvisor.h:351
llvm::ModuleAnalysisManager
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition: PassManager.h:907
llvm::InlineParams
Thresholds to tune inline cost analysis.
Definition: InlineCost.h:205
llvm::InlineAdvisor::MandatoryInliningKind::Always
@ Always
llvm::InlineAdvisor::MandatoryInliningKind::Never
@ Never
llvm::DefaultInlineAdvice
Definition: InlineAdvisor.h:145
llvm::addLocationToRemarks
void addLocationToRemarks(OptimizationRemark &Remark, DebugLoc DLoc)
Add location info to ORE message.
Definition: InlineAdvisor.cpp:465
llvm::PluginInlineAdvisorAnalysis::run
Result run(Module &M, ModuleAnalysisManager &MAM)
Definition: InlineAdvisor.h:309
llvm::InlineAdvisor::getCallerORE
OptimizationRemarkEmitter & getCallerORE(CallBase &CB)
Definition: InlineAdvisor.cpp:625
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::InlineAdvisorAnalysisPrinterPass
Printer pass for the FunctionPropertiesAnalysis results.
Definition: InlineAdvisor.h:346
llvm::ThinOrFullLTOPhase
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
Definition: Pass.h:73
llvm::emitInlinedInto
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.
Definition: InlineAdvisor.cpp:491
llvm::InlineAdvice::IsInliningRecommended
const bool IsInliningRecommended
Definition: InlineAdvisor.h:133
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:419
llvm::InlineAdvisor::onPassExit
virtual void onPassExit(LazyCallGraph::SCC *SCC=nullptr)
This must be called when the Inliner pass is exited, as function passes may be run subsequently.
Definition: InlineAdvisor.h:191
llvm::InlineAdvice::ORE
OptimizationRemarkEmitter & ORE
Definition: InlineAdvisor.h:132
llvm::DefaultInlineAdvisor
The default (manual heuristics) implementation of the InlineAdvisor.
Definition: InlineAdvisor.h:231
int
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
Definition: README.txt:536
MAM
ModuleAnalysisManager MAM
Definition: PassBuilderBindings.cpp:61
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::InlineAdvice::getOriginalCallSiteBasicBlock
const BasicBlock * getOriginalCallSiteBasicBlock() const
Definition: InlineAdvisor.h:114
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:661
LazyCallGraph.h
llvm::InlineContext
Provides context on when an inline advisor is constructed in the pipeline (e.g., link phase,...
Definition: InlineAdvisor.h:60
llvm::InlineAdvisor::MandatoryInliningKind
MandatoryInliningKind
Definition: InlineAdvisor.h:216
llvm::PluginInlineAdvisorAnalysis::Key
static AnalysisKey Key
Definition: InlineAdvisor.h:291
llvm::InlineAdvisorAnalysis::Result
Definition: InlineAdvisor.h:322
llvm::PluginInlineAdvisorAnalysis::getResult
Result getResult()
Definition: InlineAdvisor.h:310
llvm::InlineAdvice
Capture state between an inlining decision having had been made, and its impact being observable.
Definition: InlineAdvisor.h:76
llvm::InliningAdvisorMode
InliningAdvisorMode
There are 4 scenarios we can use the InlineAdvisor:
Definition: InlineAdvisor.h:44
llvm::InlineAdvisor::getAnnotatedInlinePassName
const char * getAnnotatedInlinePassName() const
NOTE pass name is annotated only when inline advisor constructor provides InlineContext.
Definition: InlineAdvisor.h:199
llvm::InlineAdvisor::InlineAdvisor
InlineAdvisor(InlineAdvisor &&)=delete
llvm::InlineAdvice::recordUnattemptedInlining
void recordUnattemptedInlining()
Call to indicate inlining was not attempted.
Definition: InlineAdvisor.h:106
llvm::InlineAdvice::recordInliningWithCalleeDeleted
void recordInliningWithCalleeDeleted()
Call after inlining succeeded, and results in the callee being delete-able, meaning,...
Definition: InlineAdvisor.cpp:192
CGSCCPassManager.h
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::InlinePass::MLInliner
@ MLInliner
llvm::InlineAdvice::Block
const BasicBlock *const Block
Definition: InlineAdvisor.h:131
llvm::InlineAdvice::recordInliningImpl
virtual void recordInliningImpl()
Definition: InlineAdvisor.h:117
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::setInlineRemark
void setInlineRemark(CallBase &CB, StringRef Message)
Set the inline-remark attribute.
Definition: InlineAdvisor.cpp:364
llvm::InlineAdvice::DLoc
const DebugLoc DLoc
Definition: InlineAdvisor.h:130
InlineCost.h
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::InlinePass::CGSCCInliner
@ CGSCCInliner
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::InliningAdvisorMode::Development
@ Development
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:394
llvm::InlineContext::Pass
InlinePass Pass
Definition: InlineAdvisor.h:63
llvm::InlineAdvice::recordUnsuccessfulInliningImpl
virtual void recordUnsuccessfulInliningImpl(const InlineResult &Result)
Definition: InlineAdvisor.h:119
llvm::InlineAdvice::isInliningRecommended
bool isInliningRecommended() const
Get the inlining recommendation.
Definition: InlineAdvisor.h:112
llvm::AMDGPU::CPol::SCC
@ SCC
Definition: SIDefines.h:313
llvm::InlineAdvisor::MandatoryInliningKind::NotMandatory
@ NotMandatory
llvm::InlineAdvisorAnalysis::Result::tryCreate
bool tryCreate(InlineParams Params, InliningAdvisorMode Mode, const ReplayInlinerSettings &ReplaySettings, InlineContext IC)
Definition: InlineAdvisor.cpp:202
llvm::InlineAdvisorAnalysis::Result::Result
Result(Module &M, ModuleAnalysisManager &MAM)
Definition: InlineAdvisor.h:323
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition: OptimizationRemarkEmitter.h:33
llvm::DefaultInlineAdvisor::DefaultInlineAdvisor
DefaultInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, InlineParams Params, InlineContext IC)
Definition: InlineAdvisor.h:233
llvm::InlineAdvisor
Interface for deciding whether to inline a call site or not.
Definition: InlineAdvisor.h:165
llvm::PluginInlineAdvisorAnalysis::HasBeenRegistered
static bool HasBeenRegistered
Definition: InlineAdvisor.h:292
llvm::InlineAdvisorAnalysis::InlineAdvisorAnalysis
InlineAdvisorAnalysis()=default
llvm::InlineAdvice::recordUnattemptedInliningImpl
virtual void recordUnattemptedInliningImpl()
Definition: InlineAdvisor.h:120
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::InlineAdvice::recordInliningWithCalleeDeletedImpl
virtual void recordInliningWithCalleeDeletedImpl()
Definition: InlineAdvisor.h:118
llvm::InlinePass::ReplaySampleProfileInliner
@ ReplaySampleProfileInliner
llvm::InlineAdvisor::getMandatoryAdvice
virtual std::unique_ptr< InlineAdvice > getMandatoryAdvice(CallBase &CB, bool Advice)
Definition: InlineAdvisor.cpp:544
llvm::CGSCCUpdateResult
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
Definition: CGSCCPassManager.h:232
llvm::PluginInlineAdvisorAnalysis::PluginInlineAdvisorAnalysis
PluginInlineAdvisorAnalysis(AdvisorFactory Factory)
Definition: InlineAdvisor.h:299
llvm::InlineAdvisor::FAM
FunctionAnalysisManager & FAM
Definition: InlineAdvisor.h:211
llvm::InlinePass::ModuleInliner
@ ModuleInliner
llvm::InlineAdvisor::getAdvice
std::unique_ptr< InlineAdvice > getAdvice(CallBase &CB, bool MandatoryOnly=false)
Get an InlineAdvice containing a recommendation on whether to inline or not.
Definition: InlineAdvisor.cpp:615
llvm::InlinePass
InlinePass
Definition: InlineAdvisor.h:47
llvm::InlineAdvisor::getAdviceImpl
virtual std::unique_ptr< InlineAdvice > getAdviceImpl(CallBase &CB)=0
PassManager.h
llvm::PluginInlineAdvisorAnalysis::Result::Factory
AdvisorFactory Factory
Definition: InlineAdvisor.h:306
llvm::inlineCostStr
std::string inlineCostStr(const InlineCost &IC)
Utility for extracting the inline cost message to a string.
Definition: InlineAdvisor.cpp:357
llvm::InlinePass::SampleProfileInliner
@ SampleProfileInliner
llvm::InlineAdvisor::getMandatoryKind
static MandatoryInliningKind getMandatoryKind(CallBase &CB, FunctionAnalysisManager &FAM, OptimizationRemarkEmitter &ORE)
Definition: InlineAdvisor.cpp:593
llvm::AnnotateInlinePassName
std::string AnnotateInlinePassName(InlineContext IC)
Definition: InlineAdvisor.cpp:587
llvm::InlineAdvisorAnalysis
The InlineAdvisorAnalysis is a module pass because the InlineAdvisor needs to capture state right bef...
Definition: InlineAdvisor.h:318
llvm::InlineAdvisorAnalysis::Key
static AnalysisKey Key
Definition: InlineAdvisor.h:320
llvm::InliningAdvisorMode::Default
@ Default
llvm::getDevelopmentModeAdvisor
std::unique_ptr< InlineAdvisor > getDevelopmentModeAdvisor(Module &M, ModuleAnalysisManager &MAM, std::function< bool(CallBase &)> GetDefaultAdvice)
llvm::InlineAdvice::InlineAdvice
InlineAdvice(InlineAdvisor *Advisor, CallBase &CB, OptimizationRemarkEmitter &ORE, bool IsInliningRecommended)
Definition: InlineAdvisor.cpp:174
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1184
llvm::InlineAdvisor::AnnotatedInlinePassName
const std::string AnnotatedInlinePassName
Definition: InlineAdvisor.h:213
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: PassManager.h:310
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::InliningAdvisorMode::Release
@ Release
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::LazyCallGraph
A lazily constructed view of the call graph of a module.
Definition: LazyCallGraph.h:110
llvm::PluginInlineAdvisorAnalysis::Result
Definition: InlineAdvisor.h:305
llvm::InlineAdvice::getOriginalCallSiteDebugLoc
const DebugLoc & getOriginalCallSiteDebugLoc() const
Definition: InlineAdvisor.h:113
llvm::InlineAdvice::Advisor
InlineAdvisor *const Advisor
Definition: InlineAdvisor.h:122
llvm::InlineResult
InlineResult is basically true or false.
Definition: InlineCost.h:179
llvm::InlineAdvice::Callee
Function *const Callee
Definition: InlineAdvisor.h:125
llvm::ReplayInlinerSettings
Replay Inliner Setup.
Definition: ReplayInlineAdvisor.h:43
llvm::InlineAdvice::recordUnsuccessfulInlining
void recordUnsuccessfulInlining(const InlineResult &Result)
Call after the decision for a call site was to not inline.
Definition: InlineAdvisor.h:100
llvm::InlineAdvisor::~InlineAdvisor
virtual ~InlineAdvisor()
Definition: InlineAdvisor.cpp:536
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:671
llvm::InlinePass::ReplayCGSCCInliner
@ ReplayCGSCCInliner
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::InlineAdvisorAnalysis::Result::invalidate
bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
Definition: InlineAdvisor.h:324
llvm::InlineContext::LTOPhase
ThinOrFullLTOPhase LTOPhase
Definition: InlineAdvisor.h:61