[flang-commits] [flang] [flang][NFC] use mlir::SymbolTable in lowering (PR #86673)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Mar 26 08:49:31 PDT 2024
================
@@ -3677,10 +3677,14 @@ fir::parseSelector(mlir::OpAsmParser &parser, mlir::OperationState &result,
return mlir::success();
}
-mlir::func::FuncOp
-fir::createFuncOp(mlir::Location loc, mlir::ModuleOp module,
- llvm::StringRef name, mlir::FunctionType type,
- llvm::ArrayRef<mlir::NamedAttribute> attrs) {
+mlir::func::FuncOp fir::createFuncOp(mlir::Location loc, mlir::ModuleOp module,
+ llvm::StringRef name,
+ mlir::FunctionType type,
+ llvm::ArrayRef<mlir::NamedAttribute> attrs,
+ const mlir::SymbolTable *symbolTable) {
+ if (symbolTable)
+ if (auto f = symbolTable->lookup<mlir::func::FuncOp>(name))
+ return f;
----------------
vzakhari wrote:
Is it possible to make sure that the `symbolTable` is kept in sync with the module? E.g. can we put assertions here and other functions where we lookup symbols to verify that `symbolTable->lookup(name) == module.lookupSymbol(name)`. Whenever the assertion fails this will indicate that there is code that adds/removes the symbol to/form the module and does not update the `symbolTable` - then we can track it down and fix.
https://github.com/llvm/llvm-project/pull/86673
More information about the flang-commits
mailing list