[flang-commits] [flang] [RFC][flang] Replace special symbols in uniqued global names. (PR #104859)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 20 06:35:48 PDT 2024
================
@@ -0,0 +1,80 @@
+//=== CompilerGeneratedNames.cpp - convert special symbols in global names ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/Dialect/FIRDialect.h"
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Dialect/FIROpsSupport.h"
+#include "flang/Optimizer/Support/InternalNames.h"
+#include "flang/Optimizer/Transforms/Passes.h"
+#include "mlir/IR/Attributes.h"
+#include "mlir/IR/SymbolTable.h"
+#include "mlir/Pass/Pass.h"
+
+namespace fir {
+#define GEN_PASS_DEF_COMPILERGENERATEDNAMESCONVERSION
+#include "flang/Optimizer/Transforms/Passes.h.inc"
+} // namespace fir
+
+using namespace mlir;
+
+namespace {
+
+class CompilerGeneratedNamesConversionPass
+ : public fir::impl::CompilerGeneratedNamesConversionBase<
+ CompilerGeneratedNamesConversionPass> {
+public:
+ using CompilerGeneratedNamesConversionBase<
+ CompilerGeneratedNamesConversionPass>::
+ CompilerGeneratedNamesConversionBase;
+
+ mlir::ModuleOp getModule() { return getOperation(); }
+ void runOnOperation() override;
+};
+} // namespace
+
+void CompilerGeneratedNamesConversionPass::runOnOperation() {
+ auto op = getOperation();
+ auto *context = &getContext();
+
+ llvm::DenseMap<mlir::StringAttr, mlir::FlatSymbolRefAttr> remappings;
+ for (auto &funcOrGlobal : op->getRegion(0).front()) {
+ if (llvm::isa<mlir::func::FuncOp>(funcOrGlobal) ||
+ llvm::isa<fir::GlobalOp>(funcOrGlobal)) {
+ auto symName = funcOrGlobal.getAttrOfType<mlir::StringAttr>(
+ mlir::SymbolTable::getSymbolAttrName());
+ auto deconstructedName = fir::NameUniquer::deconstruct(symName);
+ if (deconstructedName.first != fir::NameUniquer::NameKind::NOT_UNIQUED &&
----------------
vdonaldson wrote:
In addition to the `.nonTbpDefinedIoTable` suffix, IO.cpp also has two instances of a `.list` suffix.
https://github.com/llvm/llvm-project/pull/104859
More information about the flang-commits
mailing list