diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp index 04d47387403d8e..478ff6d6f75cac 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(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 09c9212fa216ca..11a9f0316aecd7 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) { 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 +}