[flang-commits] [flang] [flang][NFC] use mlir::SymbolTable in lowering (PR #86673)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 27 03:53:20 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;
----------------
jeanPerier wrote:

It is OK from a correctness point of view if symbols are not added to the symbolTable (when not found there, the code fallbacks to looking at the module), but you are right that if the symbols are deleted/replaced, that would be an issue. I added the suggested assert in the lookups (under EXPENSIVE_CHECKS, since doing the check kills any compilation time improvement of using the map). 

https://github.com/llvm/llvm-project/pull/86673


More information about the flang-commits mailing list