[Mlir-commits] [mlir] [mlir][dataflow] disallow outside use of propagateIfChanged for DataFlowSolver (PR #120885)

Hongren Zheng llvmlistbot at llvm.org
Thu Dec 26 22:16:30 PST 2024


ZenithalHourlyRate wrote:

> Alternatively, placing an assert inside propagateIfChanged checking that the solver is running might do the trick.

Added a `isRunning` flag. It is working but management of that flag should be careful (unset it in each return).

> Do you have a better idea on how an API can be exposed that way? 

I was thinking that adding `propagateIfChanged` to `AnalysisState` so all children `AnalysisState` could access it.  

```cpp

class DataFlowSolver {
  friend class AnalysisState;
};

class AnalysisState {

  // existing API
  virtual void onUpdate(DataFlowSolver *solver) const;

  // NOTE: it is not virtual
  void propagateIfChanged(DataFlowSolver *solver, AnalysisState *state, ChangeResult changed) {
    solver->propagateIfChanged(state, changed);
  }

};

```

https://github.com/llvm/llvm-project/pull/120885


More information about the Mlir-commits mailing list