[Mlir-commits] [mlir] [Func][GPU] Create func::ConstantOp using parents with SymbolTable trait (PR #107748)
Mehdi Amini
llvmlistbot at llvm.org
Sun Sep 8 16:32:56 PDT 2024
================
@@ -128,7 +128,9 @@ LogicalResult ConstantOp::verify() {
Type type = getType();
// Try to find the referenced function.
- auto fn = (*this)->getParentOfType<ModuleOp>().lookupSymbol<FuncOp>(fnName);
+ SymbolTable symbolTable(
+ (*this)->getParentWithTrait<mlir::OpTrait::SymbolTable>());
+ auto fn = symbolTable.lookup<FuncOp>(fnName);
----------------
joker-eph wrote:
Building a symbolTable is not cheap unfortunately, so this call is pretty expensive.
More importantly the verifier has support for SymbolTable verifications, see the last paragraph for this section: https://mlir.llvm.org/docs/SymbolsAndSymbolTables/#referencing-a-symbol
> Operations that reference a Symbol and want to perform verification and general mutation of the symbol should implement the SymbolUserOpInterface to ensure that symbol accesses are legal and efficient.
https://github.com/llvm/llvm-project/pull/107748
More information about the Mlir-commits
mailing list