[flang-commits] [flang] [flang][debug] Only import debug info for specified renamed variables (PR #194926)

via flang-commits flang-commits at lists.llvm.org
Thu May 7 10:02:21 PDT 2026


================
@@ -823,10 +823,30 @@ void AddDebugInfoPass::handleOnlyClause(
     fir::UseStmtOp useOp, mlir::LLVM::DISubprogramAttr spAttr,
     mlir::LLVM::DIFileAttr fileAttr, mlir::SymbolTable *symbolTable,
     llvm::DenseSet<mlir::LLVM::DIImportedEntityAttr> &importedModules) {
+
+  auto onlySymbols = useOp.getOnlySymbols();
+  auto renames = useOp.getRenames();
+
   // Process ONLY symbols (without renames)
-  if (auto onlySymbols = useOp.getOnlySymbols()) {
+  if (onlySymbols) {
     for (mlir::Attribute attr : *onlySymbols) {
       auto symbolRef = mlir::cast<mlir::FlatSymbolRefAttr>(attr);
+
+      // Check if this symbol is also in renames, if so skip it
+      bool isInRenames = false;
+      if (renames) {
+        for (auto renameAttr : *renames) {
+          auto rename = mlir::cast<fir::UseRenameAttr>(renameAttr);
+          if (rename.getSymbol().getValue() == symbolRef.getValue()) {
+            isInRenames = true;
+            break;
+          }
+        }
+      }
+
+      if (isInRenames)
+        continue;
+
----------------
timsmith78 wrote:

@abidh , I implemented a different algorithm that removes the O(n^2) complexity.  Please take a look and let me know if you think this is ok.  If it is ok, I'd appreciate if you would approve and merge this as I do not yet have commit access.

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


More information about the flang-commits mailing list