Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,23 @@ void AbstractDenseBackwardDataFlowAnalysis::visitCallOperation(
AbstractDenseLattice *before) {
// Find the callee.
Operation *callee = call.resolveCallable(&symbolTable);
auto callable = dyn_cast_or_null<CallableOpInterface>(callee);
if (!callable)
return setToExitState(before);

auto callable = dyn_cast_or_null<CallableOpInterface>(callee);
// No region means the callee is only declared in this module.
Region *region = callable.getCallableRegion();
if (!region || region->empty() || !getSolverConfig().isInterprocedural()) {
// If that is the case or if the solver is not interprocedural,
// let the hook handle it.
if (!getSolverConfig().isInterprocedural() ||
(callable && (!callable.getCallableRegion() ||
callable.getCallableRegion()->empty()))) {
return visitCallControlFlowTransfer(
call, CallControlFlowAction::ExternalCallee, after, before);
}

if (!callable)
return setToExitState(before);

Region *region = callable.getCallableRegion();

// Call-level control flow specifies the data flow here.
//
// func.func @callee() {
Expand Down
18 changes: 18 additions & 0 deletions mlir/test/Analysis/DataFlow/test-next-access.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,21 @@ func.func @call_opaque_callee(%arg0: memref<f32>) {
memref.load %arg0[] {name = "post"} : memref<f32>
return
}

// -----

// CHECK-LABEL: @indirect_call
func.func @indirect_call(%arg0: memref<f32>, %arg1: (memref<f32>) -> ()) {
// IP: name = "pre"
// IP-SAME: next_access = ["unknown"]
// IP_AR: name = "pre"
// IP_AR-SAME: next_access = ["unknown"]
// LOCAL: name = "pre"
// LOCAL-SAME: next_access = ["unknown"]
// LC_AR: name = "pre"
// LC_AR-SAME: next_access = {{\[}}["call"]]
memref.load %arg0[] {name = "pre"} : memref<f32>
func.call_indirect %arg1(%arg0) {name = "call"} : (memref<f32>) -> ()
memref.load %arg0[] {name = "post"} : memref<f32>
return
}