Skip to content

Commit

Permalink
[mlir] fix crash when call a function decl
Browse files Browse the repository at this point in the history
Check region before use it.
Fixes #60215  #60215

Differential Revision: https://reviews.llvm.org/D142544
  • Loading branch information
python3kgae committed Jan 25, 2023
1 parent cb70343 commit 4ef085c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp
Expand Up @@ -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)) {
Expand Down
14 changes: 14 additions & 0 deletions mlir/test/Analysis/DataFlow/test-written-to.mlir
Expand Up @@ -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
}

0 comments on commit 4ef085c

Please sign in to comment.