Skip to content

Conversation

@jeanPerier
Copy link
Contributor

When merging the list of recursive reference under two components, duplicates should be removed.
If the recursive reference to parents nodes (referred by depth of the parents node) are [1, 2, 5] and [4, 5], the new list should be [1,2,4,5].

With std::merge, the order was correct but 5 was duplicated use std::set_union instead that removes duplicates.

With this patch Fujitsu tests 0394_0030.f90 and 0390_0230.f90 finally compile with -g in about 10s. Their compilation was hanging before #146543, and they were now hitting an error "LLVM ERROR: SmallVector unable to grow" which is fixed by this patch.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Jul 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 4, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: None (jeanPerier)

Changes

When merging the list of recursive reference under two components, duplicates should be removed.
If the recursive reference to parents nodes (referred by depth of the parents node) are [1, 2, 5] and [4, 5], the new list should be [1,2,4,5].

With std::merge, the order was correct but 5 was duplicated use std::set_union instead that removes duplicates.

With this patch Fujitsu tests 0394_0030.f90 and 0390_0230.f90 finally compile with -g in about 10s. Their compilation was hanging before #146543, and they were now hitting an error "LLVM ERROR: SmallVector unable to grow" which is fixed by this patch.


Full diff: https://github.com/llvm/llvm-project/pull/147024.diff

1 Files Affected:

  • (modified) flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp (+3-3)
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index a848058486e2c..abad500d3f657 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -303,9 +303,9 @@ void DerivedTypeCache::postComponentVisitUpdate(
     return;
   ActiveLevels oldLevels;
   oldLevels.swap(activeRecursionLevels);
-  std::merge(componentActiveRecursionLevels.begin(),
-             componentActiveRecursionLevels.end(), oldLevels.begin(),
-             oldLevels.end(), std::back_inserter(activeRecursionLevels));
+  std::set_union(componentActiveRecursionLevels.begin(),
+                 componentActiveRecursionLevels.end(), oldLevels.begin(),
+                 oldLevels.end(), std::back_inserter(activeRecursionLevels));
 }
 
 void DerivedTypeCache::finalize(mlir::Type ty, mlir::LLVM::DITypeAttr attr,

Copy link
Contributor

@abidh abidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks good to me.

@jeanPerier jeanPerier merged commit 274e798 into llvm:main Jul 4, 2025
12 checks passed
@jeanPerier jeanPerier deleted the jpr_debug_fix branch July 4, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants