LLVM  14.0.0git
LoopPassManager.h
Go to the documentation of this file.
1 //===- LoopPassManager.h - Loop pass management -----------------*- 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 /// \file
9 ///
10 /// This header provides classes for managing a pipeline of passes over loops
11 /// in LLVM IR.
12 ///
13 /// The primary loop pass pipeline is managed in a very particular way to
14 /// provide a set of core guarantees:
15 /// 1) Loops are, where possible, in simplified form.
16 /// 2) Loops are *always* in LCSSA form.
17 /// 3) A collection of Loop-specific analysis results are available:
18 /// - LoopInfo
19 /// - DominatorTree
20 /// - ScalarEvolution
21 /// - AAManager
22 /// 4) All loop passes preserve #1 (where possible), #2, and #3.
23 /// 5) Loop passes run over each loop in the loop nest from the innermost to
24 /// the outermost. Specifically, all inner loops are processed before
25 /// passes run over outer loops. When running the pipeline across an inner
26 /// loop creates new inner loops, those are added and processed in this
27 /// order as well.
28 ///
29 /// This process is designed to facilitate transformations which simplify,
30 /// reduce, and remove loops. For passes which are more oriented towards
31 /// optimizing loops, especially optimizing loop *nests* instead of single
32 /// loops in isolation, this framework is less interesting.
33 ///
34 //===----------------------------------------------------------------------===//
35 
36 #ifndef LLVM_TRANSFORMS_SCALAR_LOOPPASSMANAGER_H
37 #define LLVM_TRANSFORMS_SCALAR_LOOPPASSMANAGER_H
38 
41 #include "llvm/Analysis/LoopInfo.h"
43 #include "llvm/IR/Dominators.h"
45 #include "llvm/IR/PassManager.h"
49 #include <memory>
50 
51 namespace llvm {
52 
53 // Forward declarations of an update tracking API used in the pass manager.
54 class LPMUpdater;
55 
56 namespace {
57 
58 template <typename PassT>
59 using HasRunOnLoopT = decltype(std::declval<PassT>().run(
60  std::declval<Loop &>(), std::declval<LoopAnalysisManager &>(),
61  std::declval<LoopStandardAnalysisResults &>(),
62  std::declval<LPMUpdater &>()));
63 
64 } // namespace
65 
66 // Explicit specialization and instantiation declarations for the pass manager.
67 // See the comments on the definition of the specialization for details on how
68 // it differs from the primary template.
69 template <>
71  LPMUpdater &>
72  : public PassInfoMixin<
74  LPMUpdater &>> {
75 public:
76  explicit PassManager() {}
77 
78  // FIXME: These are equivalent to the default move constructor/move
79  // assignment. However, using = default triggers linker errors due to the
80  // explicit instantiations below. Find a way to use the default and remove the
81  // duplicated code here.
83  : IsLoopNestPass(std::move(Arg.IsLoopNestPass)),
84  LoopPasses(std::move(Arg.LoopPasses)),
85  LoopNestPasses(std::move(Arg.LoopNestPasses)) {}
86 
88  IsLoopNestPass = std::move(RHS.IsLoopNestPass);
89  LoopPasses = std::move(RHS.LoopPasses);
90  LoopNestPasses = std::move(RHS.LoopNestPasses);
91  return *this;
92  }
93 
96 
97  void printPipeline(raw_ostream &OS,
98  function_ref<StringRef(StringRef)> MapClassName2PassName);
99  /// Add either a loop pass or a loop-nest pass to the pass manager. Append \p
100  /// Pass to the list of loop passes if it has a dedicated \fn run() method for
101  /// loops and to the list of loop-nest passes if the \fn run() method is for
102  /// loop-nests instead. Also append whether \p Pass is loop-nest pass or not
103  /// to the end of \var IsLoopNestPass so we can easily identify the types of
104  /// passes in the pass manager later.
105  template <typename PassT>
107  std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
108  addPass(PassT &&Pass) {
109  using LoopPassModelT =
112  IsLoopNestPass.push_back(false);
113  // Do not use make_unique or emplace_back, they cause too many template
114  // instantiations, causing terrible compile times.
115  LoopPasses.push_back(std::unique_ptr<LoopPassConceptT>(
116  new LoopPassModelT(std::forward<PassT>(Pass))));
117  }
118 
119  template <typename PassT>
121  std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
122  addPass(PassT &&Pass) {
123  using LoopNestPassModelT =
126  LPMUpdater &>;
127  IsLoopNestPass.push_back(true);
128  // Do not use make_unique or emplace_back, they cause too many template
129  // instantiations, causing terrible compile times.
130  LoopNestPasses.push_back(std::unique_ptr<LoopNestPassConceptT>(
131  new LoopNestPassModelT(std::forward<PassT>(Pass))));
132  }
133 
134  // Specializations of `addPass` for `RepeatedPass`. These are necessary since
135  // `RepeatedPass` has a templated `run` method that will result in incorrect
136  // detection of `HasRunOnLoopT`.
137  template <typename PassT>
139  std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
141  using RepeatedLoopPassModelT =
144  LPMUpdater &>;
145  IsLoopNestPass.push_back(false);
146  // Do not use make_unique or emplace_back, they cause too many template
147  // instantiations, causing terrible compile times.
148  LoopPasses.push_back(std::unique_ptr<LoopPassConceptT>(
149  new RepeatedLoopPassModelT(std::move(Pass))));
150  }
151 
152  template <typename PassT>
154  std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
156  using RepeatedLoopNestPassModelT =
159  LPMUpdater &>;
160  IsLoopNestPass.push_back(true);
161  // Do not use make_unique or emplace_back, they cause too many template
162  // instantiations, causing terrible compile times.
163  LoopNestPasses.push_back(std::unique_ptr<LoopNestPassConceptT>(
164  new RepeatedLoopNestPassModelT(std::move(Pass))));
165  }
166 
167  bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
168 
169  static bool isRequired() { return true; }
170 
171  size_t getNumLoopPasses() const { return LoopPasses.size(); }
172  size_t getNumLoopNestPasses() const { return LoopNestPasses.size(); }
173 
174 protected:
175  using LoopPassConceptT =
178  using LoopNestPassConceptT =
181 
182  // BitVector that identifies whether the passes are loop passes or loop-nest
183  // passes (true for loop-nest passes).
185  std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
186  std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
187 
188  /// Run either a loop pass or a loop-nest pass. Returns `None` if
189  /// PassInstrumentation's BeforePass returns false. Otherwise, returns the
190  /// preserved analyses of the pass.
191  template <typename IRUnitT, typename PassT>
193  runSinglePass(IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
195  PassInstrumentation &PI);
196 
197  PreservedAnalyses runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
199  LPMUpdater &U);
200  PreservedAnalyses runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
202  LPMUpdater &U);
203 
204 private:
205  static const Loop &getLoopFromIR(Loop &L) { return L; }
206  static const Loop &getLoopFromIR(LoopNest &LN) {
207  return LN.getOutermostLoop();
208  }
209 };
210 
211 /// The Loop pass manager.
212 ///
213 /// See the documentation for the PassManager template for details. It runs
214 /// a sequence of Loop passes over each Loop that the manager is run over. This
215 /// typedef serves as a convenient way to refer to this construct.
216 typedef PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
217  LPMUpdater &>
219 
220 /// A partial specialization of the require analysis template pass to forward
221 /// the extra parameters from a transformation's run method to the
222 /// AnalysisManager's getResult.
223 template <typename AnalysisT>
226  : PassInfoMixin<
231  (void)AM.template getResult<AnalysisT>(L, AR);
232  return PreservedAnalyses::all();
233  }
235  function_ref<StringRef(StringRef)> MapClassName2PassName) {
236  auto ClassName = AnalysisT::name();
237  auto PassName = MapClassName2PassName(ClassName);
238  OS << "require<" << PassName << ">";
239  }
240 };
241 
242 /// An alias template to easily name a require analysis loop pass.
243 template <typename AnalysisT>
245  RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
247 
249 
250 /// This class provides an interface for updating the loop pass manager based
251 /// on mutations to the loop nest.
252 ///
253 /// A reference to an instance of this class is passed as an argument to each
254 /// Loop pass, and Loop passes should use it to update LPM infrastructure if
255 /// they modify the loop nest structure.
256 ///
257 /// \c LPMUpdater comes with two modes: the loop mode and the loop-nest mode. In
258 /// loop mode, all the loops in the function will be pushed into the worklist
259 /// and when new loops are added to the pipeline, their subloops are also
260 /// inserted recursively. On the other hand, in loop-nest mode, only top-level
261 /// loops are contained in the worklist and the addition of new (top-level)
262 /// loops will not trigger the addition of their subloops.
263 class LPMUpdater {
264 public:
265  /// This can be queried by loop passes which run other loop passes (like pass
266  /// managers) to know whether the loop needs to be skipped due to updates to
267  /// the loop nest.
268  ///
269  /// If this returns true, the loop object may have been deleted, so passes
270  /// should take care not to touch the object.
271  bool skipCurrentLoop() const { return SkipCurrentLoop; }
272 
273  /// Loop passes should use this method to indicate they have deleted a loop
274  /// from the nest.
275  ///
276  /// Note that this loop must either be the current loop or a subloop of the
277  /// current loop. This routine must be called prior to removing the loop from
278  /// the loop nest.
279  ///
280  /// If this is called for the current loop, in addition to clearing any
281  /// state, this routine will mark that the current loop should be skipped by
282  /// the rest of the pass management infrastructure.
284  LAM.clear(L, Name);
285  assert((&L == CurrentL || CurrentL->contains(&L)) &&
286  "Cannot delete a loop outside of the "
287  "subloop tree currently being processed.");
288  if (&L == CurrentL)
289  SkipCurrentLoop = true;
290  }
291 
292  void setParentLoop(Loop *L) {
293 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
294  ParentL = L;
295 #endif
296  }
297 
298  /// Loop passes should use this method to indicate they have added new child
299  /// loops of the current loop.
300  ///
301  /// \p NewChildLoops must contain only the immediate children. Any nested
302  /// loops within them will be visited in postorder as usual for the loop pass
303  /// manager.
304  void addChildLoops(ArrayRef<Loop *> NewChildLoops) {
305  assert(!LoopNestMode &&
306  "Child loops should not be pushed in loop-nest mode.");
307  // Insert ourselves back into the worklist first, as this loop should be
308  // revisited after all the children have been processed.
309  Worklist.insert(CurrentL);
310 
311 #ifndef NDEBUG
312  for (Loop *NewL : NewChildLoops)
313  assert(NewL->getParentLoop() == CurrentL && "All of the new loops must "
314  "be immediate children of "
315  "the current loop!");
316 #endif
317 
318  appendLoopsToWorklist(NewChildLoops, Worklist);
319 
320  // Also skip further processing of the current loop--it will be revisited
321  // after all of its newly added children are accounted for.
322  SkipCurrentLoop = true;
323  }
324 
325  /// Loop passes should use this method to indicate they have added new
326  /// sibling loops to the current loop.
327  ///
328  /// \p NewSibLoops must only contain the immediate sibling loops. Any nested
329  /// loops within them will be visited in postorder as usual for the loop pass
330  /// manager.
331  void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
332 #if defined(LLVM_ENABLE_ABI_BREAKING_CHECKS) && !defined(NDEBUG)
333  for (Loop *NewL : NewSibLoops)
334  assert(NewL->getParentLoop() == ParentL &&
335  "All of the new loops must be siblings of the current loop!");
336 #endif
337 
338  if (LoopNestMode)
339  Worklist.insert(NewSibLoops);
340  else
341  appendLoopsToWorklist(NewSibLoops, Worklist);
342 
343  // No need to skip the current loop or revisit it, as sibling loops
344  // shouldn't impact anything.
345  }
346 
347  /// Restart the current loop.
348  ///
349  /// Loop passes should call this method to indicate the current loop has been
350  /// sufficiently changed that it should be re-visited from the begining of
351  /// the loop pass pipeline rather than continuing.
353  // Tell the currently in-flight pipeline to stop running.
354  SkipCurrentLoop = true;
355 
356  // And insert ourselves back into the worklist.
357  Worklist.insert(CurrentL);
358  }
359 
360 private:
362 
363  /// The \c FunctionToLoopPassAdaptor's worklist of loops to process.
365 
366  /// The analysis manager for use in the current loop nest.
368 
369  Loop *CurrentL;
370  bool SkipCurrentLoop;
371  const bool LoopNestMode;
372 
373 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
374  // In debug builds we also track the parent loop to implement asserts even in
375  // the face of loop deletion.
376  Loop *ParentL;
377 #endif
378 
380  LoopAnalysisManager &LAM, bool LoopNestMode = false)
381  : Worklist(Worklist), LAM(LAM), LoopNestMode(LoopNestMode) {}
382 };
383 
384 template <typename IRUnitT, typename PassT>
386  IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
388  // Get the loop in case of Loop pass and outermost loop in case of LoopNest
389  // pass which is to be passed to BeforePass and AfterPass call backs.
390  const Loop &L = getLoopFromIR(IR);
391  // Check the PassInstrumentation's BeforePass callbacks before running the
392  // pass, skip its execution completely if asked to (callback returns false).
393  if (!PI.runBeforePass<Loop>(*Pass, L))
394  return None;
395 
397  {
398  TimeTraceScope TimeScope(Pass->name(), IR.getName());
399  PA = Pass->run(IR, AM, AR, U);
400  }
401 
402  // do not pass deleted Loop into the instrumentation
403  if (U.skipCurrentLoop())
404  PI.runAfterPassInvalidated<IRUnitT>(*Pass, PA);
405  else
406  PI.runAfterPass<Loop>(*Pass, L, PA);
407  return PA;
408 }
409 
410 /// Adaptor that maps from a function to its loops.
411 ///
412 /// Designed to allow composition of a LoopPass(Manager) and a
413 /// FunctionPassManager. Note that if this pass is constructed with a \c
414 /// FunctionAnalysisManager it will run the \c LoopAnalysisManagerFunctionProxy
415 /// analysis prior to running the loop passes over the function to enable a \c
416 /// LoopAnalysisManager to be used within this run safely.
417 ///
418 /// The adaptor comes with two modes: the loop mode and the loop-nest mode, and
419 /// the worklist updater lived inside will be in the same mode as the adaptor
420 /// (refer to the documentation of \c LPMUpdater for more detailed explanation).
421 /// Specifically, in loop mode, all loops in the funciton will be pushed into
422 /// the worklist and processed by \p Pass, while only top-level loops are
423 /// processed in loop-nest mode. Please refer to the various specializations of
424 /// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
425 /// mode are used.
427  : public PassInfoMixin<FunctionToLoopPassAdaptor> {
428 public:
429  using PassConceptT =
432 
433  explicit FunctionToLoopPassAdaptor(std::unique_ptr<PassConceptT> Pass,
434  bool UseMemorySSA = false,
435  bool UseBlockFrequencyInfo = false,
436  bool UseBranchProbabilityInfo = false,
437  bool LoopNestMode = false)
438  : Pass(std::move(Pass)), LoopCanonicalizationFPM(),
439  UseMemorySSA(UseMemorySSA),
440  UseBlockFrequencyInfo(UseBlockFrequencyInfo),
441  UseBranchProbabilityInfo(UseBranchProbabilityInfo),
442  LoopNestMode(LoopNestMode) {
443  LoopCanonicalizationFPM.addPass(LoopSimplifyPass());
444  LoopCanonicalizationFPM.addPass(LCSSAPass());
445  }
446 
447  /// Runs the loop passes across every loop in the function.
449  void printPipeline(raw_ostream &OS,
450  function_ref<StringRef(StringRef)> MapClassName2PassName);
451 
452  static bool isRequired() { return true; }
453 
454  bool isLoopNestMode() const { return LoopNestMode; }
455 
456 private:
457  std::unique_ptr<PassConceptT> Pass;
458 
459  FunctionPassManager LoopCanonicalizationFPM;
460 
461  bool UseMemorySSA = false;
462  bool UseBlockFrequencyInfo = false;
463  bool UseBranchProbabilityInfo = false;
464  const bool LoopNestMode;
465 };
466 
467 /// A function to deduce a loop pass type and wrap it in the templated
468 /// adaptor.
469 ///
470 /// If \p Pass is a loop pass, the returned adaptor will be in loop mode.
471 template <typename LoopPassT>
472 inline std::enable_if_t<is_detected<HasRunOnLoopT, LoopPassT>::value,
473  FunctionToLoopPassAdaptor>
474 createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA = false,
475  bool UseBlockFrequencyInfo = false,
476  bool UseBranchProbabilityInfo = false) {
477  using PassModelT =
480  // Do not use make_unique, it causes too many template instantiations,
481  // causing terrible compile times.
483  std::unique_ptr<FunctionToLoopPassAdaptor::PassConceptT>(
484  new PassModelT(std::forward<LoopPassT>(Pass))),
485  UseMemorySSA, UseBlockFrequencyInfo, UseBranchProbabilityInfo, false);
486 }
487 
488 /// If \p Pass is a loop-nest pass, \p Pass will first be wrapped into a
489 /// \c LoopPassManager and the returned adaptor will be in loop-nest mode.
490 template <typename LoopNestPassT>
491 inline std::enable_if_t<!is_detected<HasRunOnLoopT, LoopNestPassT>::value,
492  FunctionToLoopPassAdaptor>
493 createFunctionToLoopPassAdaptor(LoopNestPassT &&Pass, bool UseMemorySSA = false,
494  bool UseBlockFrequencyInfo = false,
495  bool UseBranchProbabilityInfo = false) {
496  LoopPassManager LPM;
497  LPM.addPass(std::forward<LoopNestPassT>(Pass));
498  using PassModelT =
501  LPMUpdater &>;
502  // Do not use make_unique, it causes too many template instantiations,
503  // causing terrible compile times.
505  std::unique_ptr<FunctionToLoopPassAdaptor::PassConceptT>(
506  new PassModelT(std::move(LPM))),
507  UseMemorySSA, UseBlockFrequencyInfo, UseBranchProbabilityInfo, true);
508 }
509 
510 /// If \p Pass is an instance of \c LoopPassManager, the returned adaptor will
511 /// be in loop-nest mode if the pass manager contains only loop-nest passes.
512 template <>
513 inline FunctionToLoopPassAdaptor
515  LoopPassManager &&LPM, bool UseMemorySSA, bool UseBlockFrequencyInfo,
516  bool UseBranchProbabilityInfo) {
517  // Check if LPM contains any loop pass and if it does not, returns an adaptor
518  // in loop-nest mode.
519  using PassModelT =
522  LPMUpdater &>;
523  bool LoopNestMode = (LPM.getNumLoopPasses() == 0);
524  // Do not use make_unique, it causes too many template instantiations,
525  // causing terrible compile times.
527  std::unique_ptr<FunctionToLoopPassAdaptor::PassConceptT>(
528  new PassModelT(std::move(LPM))),
529  UseMemorySSA, UseBlockFrequencyInfo, UseBranchProbabilityInfo,
530  LoopNestMode);
531 }
532 
533 /// Pass for printing a loop's contents as textual IR.
534 class PrintLoopPass : public PassInfoMixin<PrintLoopPass> {
535  raw_ostream &OS;
536  std::string Banner;
537 
538 public:
539  PrintLoopPass();
540  PrintLoopPass(raw_ostream &OS, const std::string &Banner = "");
541 
544 };
545 }
546 
547 #endif // LLVM_TRANSFORMS_SCALAR_LOOPPASSMANAGER_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >
Definition: LoopPassManager.h:70
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::getNumLoopNestPasses
size_t getNumLoopNestPasses() const
Definition: LoopPassManager.h:172
llvm::FunctionToLoopPassAdaptor::FunctionToLoopPassAdaptor
FunctionToLoopPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false, bool LoopNestMode=false)
Definition: LoopPassManager.h:433
llvm::createFunctionToLoopPassAdaptor< LoopPassManager >
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor< LoopPassManager >(LoopPassManager &&LPM, bool UseMemorySSA, bool UseBlockFrequencyInfo, bool UseBranchProbabilityInfo)
If Pass is an instance of LoopPassManager, the returned adaptor will be in loop-nest mode if the pass...
Definition: LoopPassManager.h:514
llvm::RequireAnalysisLoopPass
RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > RequireAnalysisLoopPass
An alias template to easily name a require analysis loop pass.
Definition: LoopPassManager.h:246
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
LoopSimplify.h
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1965
llvm::TimeTraceScope
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
Definition: TimeProfiler.h:65
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(RepeatedPass< PassT > &&Pass)
Definition: LoopPassManager.h:140
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:62
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
llvm::PassManager::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
Definition: PassManager.h:553
llvm::LoopBase::contains
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
Definition: LoopInfo.h:122
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::LoopPasses
std::vector< std::unique_ptr< LoopPassConceptT > > LoopPasses
Definition: LoopPassManager.h:185
LCSSA.h
llvm::LPMUpdater::revisitCurrentLoop
void revisitCurrentLoop()
Restart the current loop.
Definition: LoopPassManager.h:352
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&Pass)
Definition: LoopPassManager.h:122
llvm::FunctionToLoopPassAdaptor::isRequired
static bool isRequired()
Definition: LoopPassManager.h:452
LLVM_ATTRIBUTE_MINSIZE
#define LLVM_ATTRIBUTE_MINSIZE
Definition: Compiler.h:218
llvm::LoopStandardAnalysisResults
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
Definition: LoopAnalysisManager.h:52
llvm::Optional
Definition: APInt.h:33
llvm::FunctionToLoopPassAdaptor::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Runs the loop passes across every loop in the function.
Definition: LoopPassManager.cpp:182
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::PassManager
PassManager(PassManager &&Arg)
Definition: LoopPassManager.h:82
LoopAnalysisManager.h
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
PriorityWorklist.h
llvm::LoopSimplifyPass
This pass is responsible for loop canonicalization.
Definition: LoopSimplify.h:53
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::LoopNestPasses
std::vector< std::unique_ptr< LoopNestPassConceptT > > LoopNestPasses
Definition: LoopPassManager.h:186
llvm::FunctionToLoopPassAdaptor::isLoopNestMode
bool isLoopNestMode() const
Definition: LoopPassManager.h:454
PassInstrumentation.h
llvm::AnalysisManager::clear
void clear(IRUnitT &IR, llvm::StringRef Name)
Clear any cached analysis results for a single unit of IR.
Definition: PassManagerImpl.h:36
llvm::PrintLoopPass
Pass for printing a loop's contents as textual IR.
Definition: LoopPassManager.h:534
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
LoopUtils.h
IR
Statically lint checks LLVM IR
Definition: Lint.cpp:744
llvm::BitVector
Definition: BitVector.h:74
llvm::None
const NoneType None
Definition: None.h:23
llvm::LoopPassManager
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
Definition: LoopPassManager.h:218
LoopInfo.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::PassInstrumentation::runAfterPass
void runAfterPass(const PassT &Pass, const IRUnitT &IR, const PreservedAnalyses &PA) const
AfterPass instrumentation point - takes Pass instance that has just been executed and constant refere...
Definition: PassInstrumentation.h:242
llvm::PrintLoopPass::run
PreservedAnalyses run(Loop &L, LoopAnalysisManager &, LoopStandardAnalysisResults &, LPMUpdater &)
Definition: LoopPassManager.cpp:355
llvm::LPMUpdater
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Definition: LoopPassManager.h:263
llvm::SmallPriorityWorklist
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
Definition: PriorityWorklist.h:256
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::detail::PassConcept
Template for the abstract base class used to dispatch polymorphically over pass objects.
Definition: PassManagerInternal.h:37
llvm::PassInstrumentation::runAfterPassInvalidated
void runAfterPassInvalidated(const PassT &Pass, const PreservedAnalyses &PA) const
AfterPassInvalidated instrumentation point - takes Pass instance that has just been executed.
Definition: PassInstrumentation.h:253
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::operator=
PassManager & operator=(PassManager &&RHS)
Definition: LoopPassManager.h:87
llvm::createFunctionToLoopPassAdaptor
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool UseBranchProbabilityInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
Definition: LoopPassManager.h:474
llvm::RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::run
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &)
Definition: LoopPassManager.h:229
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::PassInstrumentation
This class provides instrumentation entry points for the Pass Manager, doing calls to callbacks regis...
Definition: PassInstrumentation.h:180
LoopNestAnalysis.h
llvm::LPMUpdater::markLoopAsDeleted
void markLoopAsDeleted(Loop &L, llvm::StringRef Name)
Loop passes should use this method to indicate they have deleted a loop from the nest.
Definition: LoopPassManager.h:283
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::getNumLoopPasses
size_t getNumLoopPasses() const
Definition: LoopPassManager.h:171
llvm::LoopNest::getOutermostLoop
Loop & getOutermostLoop() const
Return the outermost loop in the loop nest.
Definition: LoopNestAnalysis.h:80
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::appendLoopsToWorklist
void appendLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
Definition: LoopUtils.cpp:1479
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT &&Pass)
Definition: LoopPassManager.h:108
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::IsLoopNestPass
BitVector IsLoopNestPass
Definition: LoopPassManager.h:184
LAM
LoopAnalysisManager LAM
Definition: PassBuilderBindings.cpp:58
llvm::PassManager
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:472
llvm::RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: LoopPassManager.h:234
llvm::RepeatedPass
A utility pass template that simply runs another pass multiple times.
Definition: PassManager.h:1315
name
static const char * name
Definition: SVEIntrinsicOpts.cpp:78
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::PassManager
PassManager()
Definition: LoopPassManager.h:76
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::PassInstrumentation::runBeforePass
bool runBeforePass(const PassT &Pass, const IRUnitT &IR) const
BeforePass instrumentation point - takes Pass instance to be executed and constant reference to IR it...
Definition: PassInstrumentation.h:217
llvm::PrintLoopPass::PrintLoopPass
PrintLoopPass()
Definition: LoopPassManager.cpp:351
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:161
llvm::FunctionToLoopPassAdaptor::printPipeline
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: LoopPassManager.cpp:176
llvm::FunctionToLoopPassAdaptor
Definition: LoopPassManager.h:426
PassManager.h
llvm::LPMUpdater::setParentLoop
void setParentLoop(Loop *L)
Definition: LoopPassManager.h:292
llvm::LPMUpdater::addChildLoops
void addChildLoops(ArrayRef< Loop * > NewChildLoops)
Loop passes should use this method to indicate they have added new child loops of the current loop.
Definition: LoopPassManager.h:304
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::runSinglePass
Optional< PreservedAnalyses > runSinglePass(IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U, PassInstrumentation &PI)
Run either a loop pass or a loop-nest pass.
Definition: LoopPassManager.h:385
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::detail::PassModel
A template wrapper used to implement the polymorphic API.
Definition: PassManagerInternal.h:69
Dominators.h
llvm::LoopAnalysisManager
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
Definition: LoopAnalysisManager.h:76
llvm::LCSSAPass
Converts loops into loop-closed SSA form.
Definition: LCSSA.h:37
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::LPMUpdater::skipCurrentLoop
bool skipCurrentLoop() const
This can be queried by loop passes which run other loop passes (like pass managers) to know whether t...
Definition: LoopPassManager.h:271
llvm::RequireAnalysisPass
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1248
llvm::LPMUpdater::addSiblingLoops
void addSiblingLoops(ArrayRef< Loop * > NewSibLoops)
Loop passes should use this method to indicate they have added new sibling loops to the current loop.
Definition: LoopPassManager.h:331
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::isEmpty
bool isEmpty() const
Definition: LoopPassManager.h:167
llvm::LoopNest
This class represents a loop nest and can be used to query its properties.
Definition: LoopNestAnalysis.h:28
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:669
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!is_detected< HasRunOnLoopT, PassT >::value > addPass(RepeatedPass< PassT > &&Pass)
Definition: LoopPassManager.h:155
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::isRequired
static bool isRequired()
Definition: LoopPassManager.h:169