[Mlir-commits] [mlir] 4ef085c - [mlir] fix crash when call a function decl
Xiang Li
llvmlistbot at llvm.org
Wed Jan 25 08:08:07 PST 2023
Author: Xiang Li
Date: 2023-01-25T11:06:13-05:00
New Revision: 4ef085c57210afc11e117a25441a92ec9758969a
URL: https://github.com/llvm/llvm-project/commit/4ef085c57210afc11e117a25441a92ec9758969a
DIFF: https://github.com/llvm/llvm-project/commit/4ef085c57210afc11e117a25441a92ec9758969a.diff
LOG: [mlir] fix crash when call a function decl
Check region before use it.
Fixes #60215 https://github.com/llvm/llvm-project/issues/60215
Differential Revision: https://reviews.llvm.org/D142544
Added:
Modified:
mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
mlir/test/Analysis/DataFlow/test-written-to.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
index 04d47387403d8..478ff6d6f75ca 100644
--- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
@@ -414,7 +414,7 @@ void AbstractSparseBackwardDataFlowAnalysis::visitOperation(Operation *op) {
Operation *callableOp = call.resolveCallable(&symbolTable);
if (auto callable = dyn_cast_or_null<CallableOpInterface>(callableOp)) {
Region *region = callable.getCallableRegion();
- if (!region->empty()) {
+ if (region && !region->empty()) {
Block &block = region->front();
for (auto [blockArg, operand] :
llvm::zip(block.getArguments(), operandLattices)) {
diff --git a/mlir/test/Analysis/DataFlow/test-written-to.mlir b/mlir/test/Analysis/DataFlow/test-written-to.mlir
index 09c9212fa216c..11a9f0316aecd 100644
--- a/mlir/test/Analysis/DataFlow/test-written-to.mlir
+++ b/mlir/test/Analysis/DataFlow/test-written-to.mlir
@@ -246,3 +246,17 @@ func.func @test_switch(%arg0 : index, %m0: memref<i32>) {
memref.store %1, %m0[] {tag_name = "b"} : memref<i32>
return
}
+
+// -----
+
+// CHECK-LABEL: llvm.func @decl(i64)
+// CHECK-LABEL: llvm.func @func(%arg0: i64) {
+// CHECK-NEXT: llvm.call @decl(%arg0) : (i64) -> ()
+// CHECK-NEXT: llvm.return
+
+llvm.func @decl(i64)
+
+llvm.func @func(%lb : i64) -> () {
+ llvm.call @decl(%lb) : (i64) -> ()
+ llvm.return
+}
More information about the Mlir-commits
mailing list