LLVM  13.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  /// Add either a loop pass or a loop-nest pass to the pass manager. Append \p
98  /// Pass to the list of loop passes if it has a dedicated \fn run() method for
99  /// loops and to the list of loop-nest passes if the \fn run() method is for
100  /// loop-nests instead. Also append whether \p Pass is loop-nest pass or not
101  /// to the end of \var IsLoopNestPass so we can easily identify the types of
102  /// passes in the pass manager later.
103  template <typename PassT>
104  std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
105  addPass(PassT Pass) {
106  using LoopPassModelT =
109  IsLoopNestPass.push_back(false);
110  LoopPasses.emplace_back(new LoopPassModelT(std::move(Pass)));
111  }
112 
113  template <typename PassT>
114  std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
115  addPass(PassT Pass) {
116  using LoopNestPassModelT =
119  LPMUpdater &>;
120  IsLoopNestPass.push_back(true);
121  LoopNestPasses.emplace_back(new LoopNestPassModelT(std::move(Pass)));
122  }
123 
124  // Specializations of `addPass` for `RepeatedPass`. These are necessary since
125  // `RepeatedPass` has a templated `run` method that will result in incorrect
126  // detection of `HasRunOnLoopT`.
127  template <typename PassT>
128  std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
130  using RepeatedLoopPassModelT =
133  LPMUpdater &>;
134  IsLoopNestPass.push_back(false);
135  LoopPasses.emplace_back(new RepeatedLoopPassModelT(std::move(Pass)));
136  }
137 
138  template <typename PassT>
139  std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
141  using RepeatedLoopNestPassModelT =
144  LPMUpdater &>;
145  IsLoopNestPass.push_back(true);
146  LoopNestPasses.emplace_back(
147  new RepeatedLoopNestPassModelT(std::move(Pass)));
148  }
149 
150  bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
151 
152  static bool isRequired() { return true; }
153 
154  size_t getNumLoopPasses() const { return LoopPasses.size(); }
155  size_t getNumLoopNestPasses() const { return LoopNestPasses.size(); }
156 
157 protected:
158  using LoopPassConceptT =
161  using LoopNestPassConceptT =
164 
165  // BitVector that identifies whether the passes are loop passes or loop-nest
166  // passes (true for loop-nest passes).
168  std::vector<std::unique_ptr<LoopPassConceptT>> LoopPasses;
169  std::vector<std::unique_ptr<LoopNestPassConceptT>> LoopNestPasses;
170 
171  /// Run either a loop pass or a loop-nest pass. Returns `None` if
172  /// PassInstrumentation's BeforePass returns false. Otherwise, returns the
173  /// preserved analyses of the pass.
174  template <typename IRUnitT, typename PassT>
176  runSinglePass(IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
178  PassInstrumentation &PI);
179 
180  PreservedAnalyses runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
182  LPMUpdater &U);
183  PreservedAnalyses runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM,
185  LPMUpdater &U);
186 
187 private:
188  static const Loop &getLoopFromIR(Loop &L) { return L; }
189  static const Loop &getLoopFromIR(LoopNest &LN) {
190  return LN.getOutermostLoop();
191  }
192 };
193 
194 /// The Loop pass manager.
195 ///
196 /// See the documentation for the PassManager template for details. It runs
197 /// a sequence of Loop passes over each Loop that the manager is run over. This
198 /// typedef serves as a convenient way to refer to this construct.
199 typedef PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
200  LPMUpdater &>
202 
203 /// A partial specialization of the require analysis template pass to forward
204 /// the extra parameters from a transformation's run method to the
205 /// AnalysisManager's getResult.
206 template <typename AnalysisT>
209  : PassInfoMixin<
214  (void)AM.template getResult<AnalysisT>(L, AR);
215  return PreservedAnalyses::all();
216  }
217 };
218 
219 /// An alias template to easily name a require analysis loop pass.
220 template <typename AnalysisT>
222  RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
224 
226 
227 /// This class provides an interface for updating the loop pass manager based
228 /// on mutations to the loop nest.
229 ///
230 /// A reference to an instance of this class is passed as an argument to each
231 /// Loop pass, and Loop passes should use it to update LPM infrastructure if
232 /// they modify the loop nest structure.
233 ///
234 /// \c LPMUpdater comes with two modes: the loop mode and the loop-nest mode. In
235 /// loop mode, all the loops in the function will be pushed into the worklist
236 /// and when new loops are added to the pipeline, their subloops are also
237 /// inserted recursively. On the other hand, in loop-nest mode, only top-level
238 /// loops are contained in the worklist and the addition of new (top-level)
239 /// loops will not trigger the addition of their subloops.
240 class LPMUpdater {
241 public:
242  /// This can be queried by loop passes which run other loop passes (like pass
243  /// managers) to know whether the loop needs to be skipped due to updates to
244  /// the loop nest.
245  ///
246  /// If this returns true, the loop object may have been deleted, so passes
247  /// should take care not to touch the object.
248  bool skipCurrentLoop() const { return SkipCurrentLoop; }
249 
250  /// Loop passes should use this method to indicate they have deleted a loop
251  /// from the nest.
252  ///
253  /// Note that this loop must either be the current loop or a subloop of the
254  /// current loop. This routine must be called prior to removing the loop from
255  /// the loop nest.
256  ///
257  /// If this is called for the current loop, in addition to clearing any
258  /// state, this routine will mark that the current loop should be skipped by
259  /// the rest of the pass management infrastructure.
261  assert((!LoopNestMode || L.isOutermost()) &&
262  "L should be a top-level loop in loop-nest mode.");
263  LAM.clear(L, Name);
264  assert((&L == CurrentL || CurrentL->contains(&L)) &&
265  "Cannot delete a loop outside of the "
266  "subloop tree currently being processed.");
267  if (&L == CurrentL)
268  SkipCurrentLoop = true;
269  }
270 
271  void setParentLoop(Loop *L) {
272 #ifndef NDEBUG
273  ParentL = L;
274 #endif
275  }
276 
277  /// Loop passes should use this method to indicate they have added new child
278  /// loops of the current loop.
279  ///
280  /// \p NewChildLoops must contain only the immediate children. Any nested
281  /// loops within them will be visited in postorder as usual for the loop pass
282  /// manager.
283  void addChildLoops(ArrayRef<Loop *> NewChildLoops) {
284  assert(!LoopNestMode &&
285  "Child loops should not be pushed in loop-nest mode.");
286  // Insert ourselves back into the worklist first, as this loop should be
287  // revisited after all the children have been processed.
288  Worklist.insert(CurrentL);
289 
290 #ifndef NDEBUG
291  for (Loop *NewL : NewChildLoops)
292  assert(NewL->getParentLoop() == CurrentL && "All of the new loops must "
293  "be immediate children of "
294  "the current loop!");
295 #endif
296 
297  appendLoopsToWorklist(NewChildLoops, Worklist);
298 
299  // Also skip further processing of the current loop--it will be revisited
300  // after all of its newly added children are accounted for.
301  SkipCurrentLoop = true;
302  }
303 
304  /// Loop passes should use this method to indicate they have added new
305  /// sibling loops to the current loop.
306  ///
307  /// \p NewSibLoops must only contain the immediate sibling loops. Any nested
308  /// loops within them will be visited in postorder as usual for the loop pass
309  /// manager.
310  void addSiblingLoops(ArrayRef<Loop *> NewSibLoops) {
311 #ifndef NDEBUG
312  for (Loop *NewL : NewSibLoops)
313  assert(NewL->getParentLoop() == ParentL &&
314  "All of the new loops must be siblings of the current loop!");
315 #endif
316 
317  if (LoopNestMode)
318  Worklist.insert(NewSibLoops);
319  else
320  appendLoopsToWorklist(NewSibLoops, Worklist);
321 
322  // No need to skip the current loop or revisit it, as sibling loops
323  // shouldn't impact anything.
324  }
325 
326  /// Restart the current loop.
327  ///
328  /// Loop passes should call this method to indicate the current loop has been
329  /// sufficiently changed that it should be re-visited from the begining of
330  /// the loop pass pipeline rather than continuing.
332  // Tell the currently in-flight pipeline to stop running.
333  SkipCurrentLoop = true;
334 
335  // And insert ourselves back into the worklist.
336  Worklist.insert(CurrentL);
337  }
338 
339 private:
341 
342  /// The \c FunctionToLoopPassAdaptor's worklist of loops to process.
344 
345  /// The analysis manager for use in the current loop nest.
347 
348  Loop *CurrentL;
349  bool SkipCurrentLoop;
350  const bool LoopNestMode;
351 
352 #ifndef NDEBUG
353  // In debug builds we also track the parent loop to implement asserts even in
354  // the face of loop deletion.
355  Loop *ParentL;
356 #endif
357 
359  LoopAnalysisManager &LAM, bool LoopNestMode = false)
360  : Worklist(Worklist), LAM(LAM), LoopNestMode(LoopNestMode) {}
361 };
362 
363 template <typename IRUnitT, typename PassT>
365  IRUnitT &IR, PassT &Pass, LoopAnalysisManager &AM,
367  // Get the loop in case of Loop pass and outermost loop in case of LoopNest
368  // pass which is to be passed to BeforePass and AfterPass call backs.
369  const Loop &L = getLoopFromIR(IR);
370  // Check the PassInstrumentation's BeforePass callbacks before running the
371  // pass, skip its execution completely if asked to (callback returns false).
372  if (!PI.runBeforePass<Loop>(*Pass, L))
373  return None;
374 
376  {
377  TimeTraceScope TimeScope(Pass->name(), IR.getName());
378  PA = Pass->run(IR, AM, AR, U);
379  }
380 
381  // do not pass deleted Loop into the instrumentation
382  if (U.skipCurrentLoop())
383  PI.runAfterPassInvalidated<IRUnitT>(*Pass, PA);
384  else
385  PI.runAfterPass<Loop>(*Pass, L, PA);
386  return PA;
387 }
388 
389 /// Adaptor that maps from a function to its loops.
390 ///
391 /// Designed to allow composition of a LoopPass(Manager) and a
392 /// FunctionPassManager. Note that if this pass is constructed with a \c
393 /// FunctionAnalysisManager it will run the \c LoopAnalysisManagerFunctionProxy
394 /// analysis prior to running the loop passes over the function to enable a \c
395 /// LoopAnalysisManager to be used within this run safely.
396 ///
397 /// The adaptor comes with two modes: the loop mode and the loop-nest mode, and
398 /// the worklist updater lived inside will be in the same mode as the adaptor
399 /// (refer to the documentation of \c LPMUpdater for more detailed explanation).
400 /// Specifically, in loop mode, all loops in the funciton will be pushed into
401 /// the worklist and processed by \p Pass, while only top-level loops are
402 /// processed in loop-nest mode. Please refer to the various specializations of
403 /// \fn createLoopFunctionToLoopPassAdaptor to see when loop mode and loop-nest
404 /// mode are used.
406  : public PassInfoMixin<FunctionToLoopPassAdaptor> {
407 public:
408  using PassConceptT =
411 
412  explicit FunctionToLoopPassAdaptor(std::unique_ptr<PassConceptT> Pass,
413  bool UseMemorySSA = false,
414  bool UseBlockFrequencyInfo = false,
415  bool LoopNestMode = false)
416  : Pass(std::move(Pass)), LoopCanonicalizationFPM(),
417  UseMemorySSA(UseMemorySSA),
418  UseBlockFrequencyInfo(UseBlockFrequencyInfo),
419  LoopNestMode(LoopNestMode) {
420  LoopCanonicalizationFPM.addPass(LoopSimplifyPass());
421  LoopCanonicalizationFPM.addPass(LCSSAPass());
422  }
423 
424  /// Runs the loop passes across every loop in the function.
426 
427  static bool isRequired() { return true; }
428 
429  bool isLoopNestMode() const { return LoopNestMode; }
430 
431 private:
432  std::unique_ptr<PassConceptT> Pass;
433 
434  FunctionPassManager LoopCanonicalizationFPM;
435 
436  bool UseMemorySSA = false;
437  bool UseBlockFrequencyInfo = false;
438  const bool LoopNestMode;
439 };
440 
441 /// A function to deduce a loop pass type and wrap it in the templated
442 /// adaptor.
443 ///
444 /// If \p Pass is a loop pass, the returned adaptor will be in loop mode.
445 template <typename LoopPassT>
446 inline std::enable_if_t<is_detected<HasRunOnLoopT, LoopPassT>::value,
447  FunctionToLoopPassAdaptor>
448 createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
449  bool UseBlockFrequencyInfo = false) {
450  using PassModelT =
454  std::make_unique<PassModelT>(std::move(Pass)), UseMemorySSA,
455  UseBlockFrequencyInfo, false);
456 }
457 
458 /// If \p Pass is a loop-nest pass, \p Pass will first be wrapped into a
459 /// \c LoopPassManager and the returned adaptor will be in loop-nest mode.
460 template <typename LoopNestPassT>
461 inline std::enable_if_t<!is_detected<HasRunOnLoopT, LoopNestPassT>::value,
462  FunctionToLoopPassAdaptor>
463 createFunctionToLoopPassAdaptor(LoopNestPassT Pass, bool UseMemorySSA = false,
464  bool UseBlockFrequencyInfo = false) {
465  LoopPassManager LPM;
466  LPM.addPass(std::move(Pass));
467  using PassModelT =
470  LPMUpdater &>;
471  return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
472  UseMemorySSA, UseBlockFrequencyInfo, true);
473 }
474 
475 /// If \p Pass is an instance of \c LoopPassManager, the returned adaptor will
476 /// be in loop-nest mode if the pass manager contains only loop-nest passes.
477 template <>
478 inline FunctionToLoopPassAdaptor
480  bool UseMemorySSA,
481  bool UseBlockFrequencyInfo) {
482  // Check if LPM contains any loop pass and if it does not, returns an adaptor
483  // in loop-nest mode.
484  using PassModelT =
487  LPMUpdater &>;
488  bool LoopNestMode = (LPM.getNumLoopPasses() == 0);
489  return FunctionToLoopPassAdaptor(std::make_unique<PassModelT>(std::move(LPM)),
490  UseMemorySSA, UseBlockFrequencyInfo,
491  LoopNestMode);
492 }
493 
494 /// Pass for printing a loop's contents as textual IR.
495 class PrintLoopPass : public PassInfoMixin<PrintLoopPass> {
496  raw_ostream &OS;
497  std::string Banner;
498 
499 public:
500  PrintLoopPass();
501  PrintLoopPass(raw_ostream &OS, const std::string &Banner = "");
502 
505 };
506 }
507 
508 #endif // LLVM_TRANSFORMS_SCALAR_LOOPPASSMANAGER_H
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(RepeatedPass< PassT > Pass)
Definition: LoopPassManager.h:129
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:155
llvm::RequireAnalysisLoopPass
RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > RequireAnalysisLoopPass
An alias template to easily name a require analysis loop pass.
Definition: LoopPassManager.h:223
llvm
Definition: AllocatorList.h:23
LoopSimplify.h
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1947
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
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:61
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
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:168
LCSSA.h
llvm::LPMUpdater::revisitCurrentLoop
void revisitCurrentLoop()
Restart the current loop.
Definition: LoopPassManager.h:331
llvm::FunctionToLoopPassAdaptor::isRequired
static bool isRequired()
Definition: LoopPassManager.h:427
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:175
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:169
llvm::FunctionToLoopPassAdaptor::isLoopNestMode
bool isLoopNestMode() const
Definition: LoopPassManager.h:429
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::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
std::enable_if_t< is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT Pass)
Definition: LoopPassManager.h:105
llvm::createFunctionToLoopPassAdaptor< LoopPassManager >
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor< LoopPassManager >(LoopPassManager LPM, bool UseMemorySSA, bool UseBlockFrequencyInfo)
If Pass is an instance of LoopPassManager, the returned adaptor will be in loop-nest mode if the pass...
Definition: LoopPassManager.h:479
llvm::PrintLoopPass
Pass for printing a loop's contents as textual IR.
Definition: LoopPassManager.h:495
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
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:201
LoopInfo.h
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:337
llvm::LPMUpdater
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
Definition: LoopPassManager.h:240
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::RequireAnalysisPass< AnalysisT, Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::run
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &)
Definition: LoopPassManager.h:212
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:1540
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:260
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::getNumLoopPasses
size_t getNumLoopPasses() const
Definition: LoopPassManager.h:154
llvm::LoopNest::getOutermostLoop
Loop & getOutermostLoop() const
Return the outermost loop in the loop nest.
Definition: LoopNestAnalysis.h:72
llvm::FunctionToLoopPassAdaptor::FunctionToLoopPassAdaptor
FunctionToLoopPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false, bool LoopNestMode=false)
Definition: LoopPassManager.h:412
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:1532
llvm::LoopBase::isOutermost
bool isOutermost() const
Return true if the loop does not have a parent (natural) loop.
Definition: LoopInfo.h:168
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::IsLoopNestPass
BitVector IsLoopNestPass
Definition: LoopPassManager.h:167
llvm::createFunctionToLoopPassAdaptor
std::enable_if_t< is_detected< HasRunOnLoopT, LoopPassT >::value, FunctionToLoopPassAdaptor > createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA=false, bool UseBlockFrequencyInfo=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
Definition: LoopPassManager.h:448
LAM
LoopAnalysisManager LAM
Definition: PassBuilderBindings.cpp:58
llvm::PassManager
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:466
llvm::RepeatedPass
A utility pass template that simply runs another pass multiple times.
Definition: PassManager.h:1285
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:333
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:161
llvm::FunctionToLoopPassAdaptor
Definition: LoopPassManager.h:405
PassManager.h
llvm::LPMUpdater::setParentLoop
void setParentLoop(Loop *L)
Definition: LoopPassManager.h:271
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:283
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:364
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:66
Dominators.h
llvm::LoopAnalysisManager
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
Definition: LoopAnalysisManager.h:75
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::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::addPass
std::enable_if_t<!is_detected< HasRunOnLoopT, PassT >::value > addPass(PassT Pass)
Definition: LoopPassManager.h:115
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:248
llvm::RequireAnalysisPass
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1230
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:310
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::isEmpty
bool isEmpty() const
Definition: LoopPassManager.h:150
llvm::LoopNest
This class represents a loop nest and can be used to query its properties.
Definition: LoopNestAnalysis.h:27
llvm::PassManager::addPass
std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT Pass)
Definition: PassManager.h:542
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::isRequired
static bool isRequired()
Definition: LoopPassManager.h:152