diff --git a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp index d423d37b9770c..bbe139fd4fb69 100644 --- a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp @@ -407,10 +407,6 @@ void DeadCodeAnalysis::visitRegionTerminator( void DeadCodeAnalysis::visitCallableTerminator(Operation *op, CallableOpInterface callable) { - // If there are no exiting values, we have nothing to do. - if (op->getNumOperands() == 0) - return; - // Add as predecessors to all callsites this return op. auto *callsites = getOrCreateFor(op, callable); bool canResolve = op->hasTrait(); diff --git a/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir b/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir index 020c8b2a0e84d..b1af670440c2d 100644 --- a/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir +++ b/mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir @@ -118,6 +118,18 @@ func.func @test_callgraph(%cond: i1, %arg0: i32) -> i32 { return %2 : i32 } +func.func private @bax(%arg0: i32) { + return {void_return} +} + +func.func @test_callgraph_void_return(%arg0: i32) -> i32 { + // CHECK: call_void_return: + // CHECK: op_preds: (all) predecessors: + // CHECK: func.return {void_return} + func.call @bax(%arg0) {tag = "call_void_return"}: (i32) -> () + return %arg0 : i32 +} + // CHECK: test_unknown_branch: // CHECK: region #0 // CHECK: ^bb0 = live diff --git a/mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir b/mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir index 4a243571c231a..709d787bb306b 100644 --- a/mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir +++ b/mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir @@ -68,6 +68,23 @@ func.func @test_multiple_return_sites(%cond: i1, %a: i32, %ptr: memref) -> // ----- +// CHECK-LABEL: test_tag: after_call +// CHECK: operand #0 +// CHECK-NEXT: - write0 +func.func private @void_return(%ptr: memref) { + return +} + +func.func @test_call_void_return() { + %ptr = memref.alloc() : memref + %c0 = arith.constant 0 : i32 + memref.store %c0, %ptr[] {tag_name = "write0"} : memref + func.call @void_return(%ptr) : (memref) -> () + memref.load %ptr[] {tag = "after_call"} : memref + return +} + +// ----- func.func private @callee(%arg0: memref) -> memref { %2 = arith.constant 2.0 : f32