[flang-commits] [flang] [Flang] Fix symbol name clash when dummy procedure name is the same as common-block-name (PR #155508)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Sep 3 09:06:23 PDT 2025
================
@@ -76,12 +76,50 @@ void ExternalNameConversionPass::runOnOperation() {
auto *context = &getContext();
llvm::DenseMap<mlir::StringAttr, mlir::FlatSymbolRefAttr> remappings;
+ mlir::SymbolTable symbolTable(op);
auto processFctOrGlobal = [&](mlir::Operation &funcOrGlobal) {
auto symName = funcOrGlobal.getAttrOfType<mlir::StringAttr>(
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.
+ if (auto conflictingOp = symbolTable.lookup(mangledName))
+ if (mlir::isa<fir::GlobalOp>(conflictingOp))
----------------
clementval wrote:
```suggestion
if (symbolTable.lookup<fir::GlobalOp>(mangledName))
```
You can use lookup with the OpTy directly
https://github.com/llvm/llvm-project/pull/155508
More information about the flang-commits
mailing list