@@ -104,12 +104,16 @@ Location LatticeAnchor::getLoc() const {
104
104
// ===----------------------------------------------------------------------===//
105
105
106
106
LogicalResult DataFlowSolver::initializeAndRun (Operation *top) {
107
+ // Enable enqueue to the worklist.
108
+ isRunning = true ;
107
109
// Initialize the analyses.
108
110
for (DataFlowAnalysis &analysis : llvm::make_pointee_range (childAnalyses)) {
109
111
DATAFLOW_DEBUG (llvm::dbgs ()
110
112
<< " Priming analysis: " << analysis.debugName << " \n " );
111
- if (failed (analysis.initialize (top)))
113
+ if (failed (analysis.initialize (top))) {
114
+ isRunning = false ;
112
115
return failure ();
116
+ }
113
117
}
114
118
115
119
// Run the analysis until fixpoint.
@@ -121,19 +125,25 @@ LogicalResult DataFlowSolver::initializeAndRun(Operation *top) {
121
125
122
126
DATAFLOW_DEBUG (llvm::dbgs () << " Invoking '" << analysis->debugName
123
127
<< " ' on: " << point << " \n " );
124
- if (failed (analysis->visit (point)))
128
+ if (failed (analysis->visit (point))) {
129
+ isRunning = false ;
125
130
return failure ();
131
+ }
126
132
}
127
133
128
134
// Iterate until all states are in some initialized state and the worklist
129
135
// is exhausted.
130
136
} while (!worklist.empty ());
131
137
138
+ // Prevent further updates to the worklist
139
+ isRunning = false ;
132
140
return success ();
133
141
}
134
142
135
143
void DataFlowSolver::propagateIfChanged (AnalysisState *state,
136
144
ChangeResult changed) {
145
+ assert (isRunning &&
146
+ " DataFlowSolver is not running, should not use propagateIfChanged" );
137
147
if (changed == ChangeResult::Change) {
138
148
DATAFLOW_DEBUG (llvm::dbgs () << " Propagating update to " << state->debugName
139
149
<< " of " << state->anchor << " \n "
0 commit comments