Skip to content

Commit 8f92fee

Browse files
committed
[MLIR][RemoveDeadValues] Privatize public function beforehand.
1 parent 4904fb9 commit 8f92fee

File tree

5 files changed

+211
-192
lines changed

5 files changed

+211
-192
lines changed

mlir/include/mlir/Analysis/DataFlow/LivenessAnalysis.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
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

2930
namespace 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

108112
private:
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

mlir/include/mlir/IR/Visitors.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff 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

mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,6 @@ RunLivenessAnalysis::RunLivenessAnalysis(Operation *op) {
325325
}
326326

327327
const Liveness *RunLivenessAnalysis::getLiveness(Value val) {
328+
assert(valid && "getLiveness called after invalidate");
328329
return solver.lookupState<Liveness>(val);
329330
}

0 commit comments

Comments
 (0)