Skip to content

Conversation

badumbatish
Copy link
Contributor

@badumbatish badumbatish commented Oct 8, 2025

SparseForwardDataFlowAnalysis, with the comments specifying that StateT must be subclassing AbstractSparseLattice, also places a static assert in the class itself.

This commit adds the same missing assert for SparseBackwardDataFlowAnalysis.

@badumbatish badumbatish requested a review from cxy-1993 October 8, 2025 20:36
@llvmbot llvmbot added the mlir label Oct 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2025

@llvm/pr-subscribers-mlir

Author: Jasmine Tang (badumbatish)

Changes

SparseForwardDataFlowAnalysis, with the comments specifying that StateT must be sublclassing AbstractSparseLattice, also places a static assert in the class itself.

This commit adds the same missing assert for SparseBackwardDataFlowAnalysis


Full diff: https://github.com/llvm/llvm-project/pull/162547.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h (+4)
diff --git a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
index 3f8874d02afad..1a33ecf8b5aa9 100644
--- a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
@@ -518,6 +518,10 @@ class AbstractSparseBackwardDataFlowAnalysis : public DataFlowAnalysis {
 template <typename StateT>
 class SparseBackwardDataFlowAnalysis
     : public AbstractSparseBackwardDataFlowAnalysis {
+  static_assert(
+      std::is_base_of<AbstractSparseLattice, StateT>::value,
+      "analysis state class expected to subclass AbstractSparseLattice");
+
 public:
   explicit SparseBackwardDataFlowAnalysis(DataFlowSolver &solver,
                                           SymbolTableCollection &symbolTable)

@ftynse
Copy link
Member

ftynse commented Oct 11, 2025

Let us know if you need help landing this.

@badumbatish
Copy link
Contributor Author

i can merge this, ty!

@badumbatish badumbatish merged commit 2118721 into llvm:main Oct 13, 2025
11 checks passed
@badumbatish badumbatish deleted the static_assert_sparse branch October 13, 2025 04:19
DharuniRAcharya pushed a commit to DharuniRAcharya/llvm-project that referenced this pull request Oct 13, 2025
…m#162547)

SparseForwardDataFlowAnalysis, with the comments specifying that StateT
must be subclassing AbstractSparseLattice, also places a static assert
in the class itself.

This commit adds the same missing assert for
SparseBackwardDataFlowAnalysis.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants