Skip to content

[MLIR] Use cached symbol tables to get the called function during bufferization #141341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mscuttari
Copy link
Member

@mscuttari mscuttari commented May 24, 2025

Avoid recomputing the symbol tables by using the BufferizationState class introduced in #141019.
There is also one similar TODO remaining within the getBufferType function, but that requires more reasoning and one more API change.

@llvmbot llvmbot added mlir mlir:bufferization Bufferization infrastructure labels May 24, 2025
@llvmbot
Copy link
Member

llvmbot commented May 24, 2025

@llvm/pr-subscribers-mlir-bufferization

Author: Michele Scuttari (mscuttari)

Changes

Avoid recomputing the symbol tables by using the BufferizationState class introduced in #141019.
There is also one similar TODO remaining, but that requires more reasoning as tightly bounded to the getBufferType, which is called both during analysis and bufferization.


Full diff: https://github.com/llvm/llvm-project/pull/141341.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp (+1-4)
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
index 080796208bfc1..6210f1d787bf4 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
@@ -265,10 +265,7 @@ struct CallOpInterface
     //    bufferized callee.
     SmallVector<Value> newOperands;
 
-    // TODO Avoid recomputing the symbol tables every time.
-    SymbolTableCollection symbolTable;
-
-    FuncOp funcOp = getCalledFunction(callOp, symbolTable);
+    FuncOp funcOp = getCalledFunction(callOp, state.getSymbolTables());
     assert(funcOp && "expected CallOp to a FuncOp");
     FunctionType funcType = funcOp.getFunctionType();
 

@llvmbot
Copy link
Member

llvmbot commented May 24, 2025

@llvm/pr-subscribers-mlir

Author: Michele Scuttari (mscuttari)

Changes

Avoid recomputing the symbol tables by using the BufferizationState class introduced in #141019.
There is also one similar TODO remaining, but that requires more reasoning as tightly bounded to the getBufferType, which is called both during analysis and bufferization.


Full diff: https://github.com/llvm/llvm-project/pull/141341.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp (+1-4)
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
index 080796208bfc1..6210f1d787bf4 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
@@ -265,10 +265,7 @@ struct CallOpInterface
     //    bufferized callee.
     SmallVector<Value> newOperands;
 
-    // TODO Avoid recomputing the symbol tables every time.
-    SymbolTableCollection symbolTable;
-
-    FuncOp funcOp = getCalledFunction(callOp, symbolTable);
+    FuncOp funcOp = getCalledFunction(callOp, state.getSymbolTables());
     assert(funcOp && "expected CallOp to a FuncOp");
     FunctionType funcType = funcOp.getFunctionType();
 

@mscuttari mscuttari merged commit 03f4fe1 into llvm:main May 26, 2025
14 checks passed
@mscuttari mscuttari deleted the bufferization-call-symbol-tables-caching branch May 26, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:bufferization Bufferization infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants