LLVM  8.0.1
LoopAnalysisManager.h
Go to the documentation of this file.
1 //===- LoopAnalysisManager.h - Loop analysis management ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This header provides classes for managing per-loop analyses. These are
12 /// typically used as part of a loop pass pipeline over the loop nests of
13 /// a function.
14 ///
15 /// Loop analyses are allowed to make some simplifying assumptions:
16 /// 1) Loops are, where possible, in simplified form.
17 /// 2) Loops are *always* in LCSSA form.
18 /// 3) A collection of analysis results are available:
19 /// - LoopInfo
20 /// - DominatorTree
21 /// - ScalarEvolution
22 /// - AAManager
23 ///
24 /// The primary mechanism to provide these invariants is the loop pass manager,
25 /// but they can also be manually provided in order to reason about a loop from
26 /// outside of a dedicated pass manager.
27 ///
28 //===----------------------------------------------------------------------===//
29 
30 #ifndef LLVM_ANALYSIS_LOOPANALYSISMANAGER_H
31 #define LLVM_ANALYSIS_LOOPANALYSISMANAGER_H
32 
35 #include "llvm/ADT/STLExtras.h"
39 #include "llvm/Analysis/LoopInfo.h"
45 #include "llvm/IR/Dominators.h"
46 #include "llvm/IR/PassManager.h"
47 
48 namespace llvm {
49 
50 /// The adaptor from a function pass to a loop pass computes these analyses and
51 /// makes them available to the loop passes "for free". Each loop pass is
52 /// expected expected to update these analyses if necessary to ensure they're
53 /// valid after it runs.
63 };
64 
65 /// Enables memory ssa as a dependency for loop passes.
67 
68 /// Extern template declaration for the analysis set for this IR unit.
69 extern template class AllAnalysesOn<Loop>;
70 
72 /// The loop analysis manager.
73 ///
74 /// See the documentation for the AnalysisManager template for detail
75 /// documentation. This typedef serves as a convenient way to refer to this
76 /// construct in the adaptors and proxies used to integrate this into the larger
77 /// pass manager infrastructure.
80 
81 /// A proxy from a \c LoopAnalysisManager to a \c Function.
84 
85 /// A specialized result for the \c LoopAnalysisManagerFunctionProxy which
86 /// retains a \c LoopInfo reference.
87 ///
88 /// This allows it to collect loop objects for which analysis results may be
89 /// cached in the \c LoopAnalysisManager.
91 public:
92  explicit Result(LoopAnalysisManager &InnerAM, LoopInfo &LI)
93  : InnerAM(&InnerAM), LI(&LI) {}
94  Result(Result &&Arg) : InnerAM(std::move(Arg.InnerAM)), LI(Arg.LI) {
95  // We have to null out the analysis manager in the moved-from state
96  // because we are taking ownership of the responsibilty to clear the
97  // analysis state.
98  Arg.InnerAM = nullptr;
99  }
101  InnerAM = RHS.InnerAM;
102  LI = RHS.LI;
103  // We have to null out the analysis manager in the moved-from state
104  // because we are taking ownership of the responsibilty to clear the
105  // analysis state.
106  RHS.InnerAM = nullptr;
107  return *this;
108  }
110  // InnerAM is cleared in a moved from state where there is nothing to do.
111  if (!InnerAM)
112  return;
113 
114  // Clear out the analysis manager if we're being destroyed -- it means we
115  // didn't even see an invalidate call when we got invalidated.
116  InnerAM->clear();
117  }
118 
119  /// Accessor for the analysis manager.
120  LoopAnalysisManager &getManager() { return *InnerAM; }
121 
122  /// Handler for invalidation of the proxy for a particular function.
123  ///
124  /// If the proxy, \c LoopInfo, and associated analyses are preserved, this
125  /// will merely forward the invalidation event to any cached loop analysis
126  /// results for loops within this function.
127  ///
128  /// If the necessary loop infrastructure is not preserved, this will forcibly
129  /// clear all of the cached analysis results that are keyed on the \c
130  /// LoopInfo for this function.
131  bool invalidate(Function &F, const PreservedAnalyses &PA,
133 
134 private:
135  LoopAnalysisManager *InnerAM;
136  LoopInfo *LI;
137 };
138 
139 /// Provide a specialized run method for the \c LoopAnalysisManagerFunctionProxy
140 /// so it can pass the \c LoopInfo to the result.
141 template <>
144 
145 // Ensure the \c LoopAnalysisManagerFunctionProxy is provided as an extern
146 // template.
148 
151 /// A proxy from a \c FunctionAnalysisManager to a \c Loop.
153  LoopStandardAnalysisResults &>
155 
156 /// Returns the minimum set of Analyses that all loop passes must preserve.
158 }
159 
160 #endif // LLVM_ANALYSIS_LOOPANALYSISMANAGER_H
This file provides a priority worklist.
LoopAnalysisManager & getManager()
Accessor for the analysis manager.
PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This is the interface for a simple mod/ref and alias analysis over globals.
InnerAnalysisManagerProxy< LoopAnalysisManager, Function > LoopAnalysisManagerFunctionProxy
A proxy from a LoopAnalysisManager to a Function.
The main scalar evolution driver.
A cache of @llvm.assume calls within a function.
OuterAnalysisManagerProxy< FunctionAnalysisManager, Loop, LoopStandardAnalysisResults & > FunctionAnalysisManagerLoopProxy
A proxy from a FunctionAnalysisManager to a Loop.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
F(f)
Definition: BitVector.h:938
This is the interface for a SCEV-based alias analysis.
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition: MemorySSA.h:701
Result(LoopAnalysisManager &InnerAM, LoopInfo &LI)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:145
A specialized result for the LoopAnalysisManagerFunctionProxy which retains a LoopInfo reference...
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:1019
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
Definition: PassManager.h:1154
Provides information about what library functions are available for the current target.
Result run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs...)
Run the analysis pass and create our proxy result object.
Definition: PassManager.h:1101
amdgpu Simplify well known AMD library false Value Value * Arg
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:465
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:642
This templated class represents "all analyses that operate over <a particular IR unit>" (e...
Definition: PassManager.h:92
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
This pass exposes codegen information to IR-level passes.
This header defines various interfaces for pass management in LLVM.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:1038
cl::opt< bool > EnableMSSALoopDependency
Enables memory ssa as a dependency for loop passes.