[flang-commits] [flang] [flang] Create TBAA subtree for COMMON block variables. (PR #156558)

via flang-commits flang-commits at lists.llvm.org
Wed Sep 3 08:19:45 PDT 2025


================
@@ -11,12 +11,21 @@
 
 mlir::LLVM::TBAATagAttr
 fir::TBAATree::SubtreeState::getTag(llvm::StringRef uniqueName) const {
-  std::string id = (parentId + "/" + uniqueName).str();
+  std::string id = (parentId + '/' + uniqueName).str();
   mlir::LLVM::TBAATypeDescriptorAttr type =
       mlir::LLVM::TBAATypeDescriptorAttr::get(
           context, id, mlir::LLVM::TBAAMemberAttr::get(parent, 0));
   return mlir::LLVM::TBAATagAttr::get(type, type, 0);
-  // return tag;
+}
+
+fir::TBAATree::SubtreeState &
+fir::TBAATree::SubtreeState::getOrCreateNamedSubtree(mlir::StringAttr name) {
+  if (!namedSubtrees.contains(name))
+    namedSubtrees.insert(
+        {name, SubtreeState(context, parentId + '/' + name.str(), parent)});
----------------
jeanPerier wrote:

Nit: could return the insert iterator result here instead of doing a new search afterwards.

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


More information about the flang-commits mailing list