Skip to content

Commit 3d42b48

Browse files
[mlir][bufferize] Use resolveCallableInTable to cleanup getCalledFunction (NFC) (#165658)
Simplify the implementation of `getCalledFunction` using `resolveCallableInTable`.
1 parent cf85cf4 commit 3d42b48

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ getBufferizedFunctionArgType(FuncOp funcOp, int64_t index,
9595
/// Return the FuncOp called by `callOp`.
9696
static FuncOp getCalledFunction(CallOpInterface callOp,
9797
SymbolTableCollection &symbolTables) {
98-
SymbolRefAttr sym =
99-
llvm::dyn_cast_if_present<SymbolRefAttr>(callOp.getCallableForCallee());
100-
if (!sym)
101-
return nullptr;
102-
return dyn_cast_or_null<FuncOp>(
103-
symbolTables.lookupNearestSymbolFrom(callOp, sym));
98+
return dyn_cast_or_null<FuncOp>(callOp.resolveCallableInTable(&symbolTables));
10499
}
105100

106101
/// Return the FuncOp called by `callOp`.

mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,8 @@ static void removeBufferizationAttributes(BlockArgument bbArg) {
285285
static func::FuncOp
286286
getCalledFunction(func::CallOp callOp,
287287
mlir::SymbolTableCollection &symbolTable) {
288-
SymbolRefAttr sym =
289-
llvm::dyn_cast_if_present<SymbolRefAttr>(callOp.getCallableForCallee());
290-
if (!sym)
291-
return nullptr;
292288
return dyn_cast_or_null<func::FuncOp>(
293-
symbolTable.lookupNearestSymbolFrom(callOp, sym));
289+
callOp.resolveCallableInTable(&symbolTable));
294290
}
295291

296292
/// Return "true" if the given function signature has tensor semantics.

0 commit comments

Comments
 (0)