Skip to content

Commit 4ef085c

Browse files
committed
[mlir] fix crash when call a function decl
Check region before use it. Fixes #60215 #60215 Differential Revision: https://reviews.llvm.org/D142544
1 parent cb70343 commit 4ef085c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ void AbstractSparseBackwardDataFlowAnalysis::visitOperation(Operation *op) {
414414
Operation *callableOp = call.resolveCallable(&symbolTable);
415415
if (auto callable = dyn_cast_or_null<CallableOpInterface>(callableOp)) {
416416
Region *region = callable.getCallableRegion();
417-
if (!region->empty()) {
417+
if (region && !region->empty()) {
418418
Block &block = region->front();
419419
for (auto [blockArg, operand] :
420420
llvm::zip(block.getArguments(), operandLattices)) {

mlir/test/Analysis/DataFlow/test-written-to.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,17 @@ func.func @test_switch(%arg0 : index, %m0: memref<i32>) {
246246
memref.store %1, %m0[] {tag_name = "b"} : memref<i32>
247247
return
248248
}
249+
250+
// -----
251+
252+
// CHECK-LABEL: llvm.func @decl(i64)
253+
// CHECK-LABEL: llvm.func @func(%arg0: i64) {
254+
// CHECK-NEXT: llvm.call @decl(%arg0) : (i64) -> ()
255+
// CHECK-NEXT: llvm.return
256+
257+
llvm.func @decl(i64)
258+
259+
llvm.func @func(%lb : i64) -> () {
260+
llvm.call @decl(%lb) : (i64) -> ()
261+
llvm.return
262+
}

0 commit comments

Comments
 (0)