File tree Expand file tree Collapse file tree 5 files changed +211
-192
lines changed Expand file tree Collapse file tree 5 files changed +211
-192
lines changed Original file line number Diff line number Diff line change 2424#define MLIR_ANALYSIS_DATAFLOW_LIVENESSANALYSIS_H
2525
2626#include < mlir/Analysis/DataFlow/SparseAnalysis.h>
27+ #include < mlir/Pass/AnalysisManager.h>
2728#include < optional>
2829
2930namespace mlir ::dataflow {
@@ -101,13 +102,17 @@ struct RunLivenessAnalysis {
101102 RunLivenessAnalysis (Operation *op);
102103
103104 const Liveness *getLiveness (Value val);
104-
105+ // This only mark Liveness results are stale.
106+ void invalidate () { valid = false ; }
105107 // / Return the configuration of the solver used for this analysis.
106108 const DataFlowConfig &getSolverConfig () const { return solver.getConfig (); }
109+ // / The function is called by analysis_impl::isInvalidated.
110+ bool isInvalidated (AnalysisManager::PreservedAnalyses&) const { return !valid; }
107111
108112private:
109113 // / Stores the result of the liveness analysis that was run.
110114 DataFlowSolver solver;
115+ bool valid {true };
111116};
112117
113118} // end namespace mlir::dataflow
Original file line number Diff line number Diff line change @@ -39,20 +39,6 @@ struct ForwardIterator {
3939 }
4040};
4141
42- // / This iterator enumerates the elements in "backward" order.
43- struct BackwardIterator {
44- template <typename T>
45- static auto makeIterable (T &range) {
46- if constexpr (std::is_same<T, Operation>()) {
47- // / Make operations iterable: return the list of regions.
48- return range.getRegions ();
49- } else {
50- // / Regions and block are already iterable.
51- return llvm::reverse (range);
52- }
53- }
54- };
55-
5642// / A utility class to encode the current walk stage for "generic" walkers.
5743// / When walking an operation, we can either choose a Pre/Post order walker
5844// / which invokes the callback on an operation before/after all its attached
Original file line number Diff line number Diff line change @@ -325,5 +325,6 @@ RunLivenessAnalysis::RunLivenessAnalysis(Operation *op) {
325325}
326326
327327const Liveness *RunLivenessAnalysis::getLiveness (Value val) {
328+ assert (valid && " getLiveness called after invalidate" );
328329 return solver.lookupState <Liveness>(val);
329330}
You can’t perform that action at this time.
0 commit comments