diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp --- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp @@ -414,7 +414,7 @@ Operation *callableOp = call.resolveCallable(&symbolTable); if (auto callable = dyn_cast_or_null(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 --- a/mlir/test/Analysis/DataFlow/test-written-to.mlir +++ b/mlir/test/Analysis/DataFlow/test-written-to.mlir @@ -246,3 +246,17 @@ memref.store %1, %m0[] {tag_name = "b"} : memref 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 +}