[Mlir-commits] [mlir] de58a4f - [mlir][Analysis] Guard data flow analysis from no block function

Kai Sasaki llvmlistbot at llvm.org
Tue Feb 21 22:28:49 PST 2023


Author: Kai Sasaki
Date: 2023-02-22T15:20:11+09:00
New Revision: de58a4f163006de0d2f2b905fa0677c83aa326d8

URL: https://github.com/llvm/llvm-project/commit/de58a4f163006de0d2f2b905fa0677c83aa326d8
DIFF: https://github.com/llvm/llvm-project/commit/de58a4f163006de0d2f2b905fa0677c83aa326d8.diff

LOG: [mlir][Analysis] Guard data flow analysis from no block function

Foo analysis for testing the data flow analysis does not support the region without any block. Although that analysis is assumed to be used for testing purpose, it is generally better to be explicit about the scope the framework supports.

The original issue was reported here.
https://github.com/llvm/llvm-project/issues/60580

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D144359

Added: 
    mlir/test/Analysis/invalid.mlir

Modified: 
    mlir/test/lib/Analysis/TestDataFlowFramework.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/Analysis/invalid.mlir b/mlir/test/Analysis/invalid.mlir
new file mode 100644
index 0000000000000..899c095804a02
--- /dev/null
+++ b/mlir/test/Analysis/invalid.mlir
@@ -0,0 +1,7 @@
+// RUN: mlir-opt -split-input-file -pass-pipeline='builtin.module(func.func(test-foo-analysis))'  %s -verify-diagnostics
+
+// -----
+
+// expected-error @+1 {{expected at least one block in the region}}
+func.func private @no_block_func_declaration() -> ()
+

diff  --git a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp
index 00449249a7082..5a66f1916515d 100644
--- a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp
+++ b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp
@@ -96,6 +96,9 @@ LogicalResult FooAnalysis::initialize(Operation *top) {
   if (top->getNumRegions() != 1)
     return top->emitError("expected a single region top-level op");
 
+  if (top->getRegion(0).getBlocks().empty())
+    return top->emitError("expected at least one block in the region");
+
   // Initialize the top-level state.
   getOrCreate<FooState>(&top->getRegion(0).front())->join(0);
 


        


More information about the Mlir-commits mailing list