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