[Mlir-commits] [flang] [mlir] [mlir][Analysis] Add dependency declaration for dataflow analyses (PR #193112)

Ivan Butygin llvmlistbot at llvm.org
Wed Apr 22 04:14:42 PDT 2026


================
@@ -627,9 +679,29 @@ class DataFlowAnalysis {
   ///
   /// This function will union lattice anchor to same equivalent class if the
   /// analysis can determine the lattice content of lattice anchor is
-  /// necessarily identical under the corrensponding lattice type.
+  /// necessarily identical under the corresponding lattice type.
   virtual void initializeEquivalentLatticeAnchor(Operation *top) {}
 
+  /// Register the analyses that this analysis depends on. Each dependency
+  /// must be loaded into the solver before `initializeAndRun` is called.
+  ///
+  /// Dependencies are not auto-loaded, because `DataFlowSolver::load` accepts
+  /// arbitrary constructor arguments that the framework cannot synthesize.
+  /// Subclasses that override this method should call the parent's
+  /// `getDependentAnalyses` first to preserve inherited dependencies.
+  virtual void getDependentAnalyses(AnalysisDependencies &deps) const {}
+
+  /// Return the TypeID of this analysis. Valid only after
+  /// `DataFlowSolver::load<AnalysisT>` has returned; must not be read from
+  /// the analysis constructor body. Used by the solver to match declared
+  /// dependencies.
+  TypeID getTypeID() const { return analysisID; }
+
+  /// Return a printable name for the analysis. Valid only after
+  /// `DataFlowSolver::load<AnalysisT>` has returned; must not be read from
+  /// the analysis constructor body. Used for diagnostics and debug logging.
+  StringRef getName() const { return analysisName; }
----------------
Hardcode84 wrote:

I tried to do it and it's just blows all the existing analyses, current template takes state type but not the analysis itself and passing it through ctor explicitly is too verbose, not worth it. And `load` is the only way to add analyses currently as `childAnalyses` is private.

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


More information about the Mlir-commits mailing list