[flang-commits] [flang] [Flang] Fix symbol name clash when dummy procedure name is the same as common-block-name (PR #155508)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Wed Aug 27 08:24:43 PDT 2025
================
@@ -82,6 +82,46 @@ void ExternalNameConversionPass::runOnOperation() {
mlir::SymbolTable::getSymbolAttrName());
auto deconstructedName = fir::NameUniquer::deconstruct(symName);
if (fir::NameUniquer::isExternalFacingUniquedName(deconstructedName)) {
+ // Check if this is a private function that would conflict with a common
+ // block and get its mangled name.
+ if (auto funcOp = llvm::dyn_cast<mlir::func::FuncOp>(funcOrGlobal)) {
+ if (funcOp.isPrivate()) {
+ std::string mangledName =
+ mangleExternalName(deconstructedName, appendUnderscoreOpt);
+ auto mod = funcOp->getParentOfType<mlir::ModuleOp>();
+ bool hasConflictingCommonBlock = false;
+
+ // Check if any existing global has the same mangled name.
+ mlir::SymbolTable symbolTable(mod);
----------------
vzakhari wrote:
Please note that the the initial construction of the symbol table for an operation is the expensive operation. The lookups/insertions happening after the initial construction are cheaper.
I would suggest creating the symbol table once at the beginning of the pass, and then update it and use it for lookups for each `funcOrGlobal`.
https://github.com/llvm/llvm-project/pull/155508
More information about the flang-commits
mailing list