File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,8 @@ class DataFlowSolver {
401
401
402
402
// / Propagate an update to an analysis state if it changed by pushing
403
403
// / dependent work items to the back of the queue.
404
+ // / This should only be used when DataFlowSolver is running.
405
+ // / Otherwise, the solver won't process the work items.
404
406
void propagateIfChanged (AnalysisState *state, ChangeResult changed);
405
407
406
408
// / Get the configuration of the solver.
@@ -410,6 +412,9 @@ class DataFlowSolver {
410
412
// / Configuration of the dataflow solver.
411
413
DataFlowConfig config;
412
414
415
+ // / The solver is working on the worklist.
416
+ bool isRunning = false ;
417
+
413
418
// / The solver's work queue. Work items can be inserted to the front of the
414
419
// / queue to be processed greedily, speeding up computations that otherwise
415
420
// / quickly degenerate to quadratic due to propagation of state updates.
Original file line number Diff line number Diff line change 10
10
#include " mlir/IR/Location.h"
11
11
#include " mlir/IR/Operation.h"
12
12
#include " mlir/IR/Value.h"
13
+ #include " llvm/ADT/ScopeExit.h"
13
14
#include " llvm/ADT/iterator.h"
14
15
#include " llvm/Config/abi-breaking.h"
15
16
#include " llvm/Support/Casting.h"
@@ -104,6 +105,10 @@ Location LatticeAnchor::getLoc() const {
104
105
// ===----------------------------------------------------------------------===//
105
106
106
107
LogicalResult DataFlowSolver::initializeAndRun (Operation *top) {
108
+ // Enable enqueue to the worklist.
109
+ isRunning = true ;
110
+ auto guard = llvm::make_scope_exit ([&]() { isRunning = false ; });
111
+
107
112
// Initialize the analyses.
108
113
for (DataFlowAnalysis &analysis : llvm::make_pointee_range (childAnalyses)) {
109
114
DATAFLOW_DEBUG (llvm::dbgs ()
@@ -134,6 +139,8 @@ LogicalResult DataFlowSolver::initializeAndRun(Operation *top) {
134
139
135
140
void DataFlowSolver::propagateIfChanged (AnalysisState *state,
136
141
ChangeResult changed) {
142
+ assert (isRunning &&
143
+ " DataFlowSolver is not running, should not use propagateIfChanged" );
137
144
if (changed == ChangeResult::Change) {
138
145
DATAFLOW_DEBUG (llvm::dbgs () << " Propagating update to " << state->debugName
139
146
<< " of " << state->anchor << " \n "
You can’t perform that action at this time.
0 commit comments