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

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Tue Aug 19 04:01:46 PDT 2025


================
@@ -310,14 +318,55 @@ void AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface op,
              source.kind == fir::AliasAnalysis::SourceKind::Global &&
              !source.isBoxData()) {
     mlir::SymbolRefAttr glbl = llvm::cast<mlir::SymbolRefAttr>(source.origin.u);
-    const char *name = glbl.getRootReference().data();
-    LLVM_DEBUG(llvm::dbgs().indent(2) << "Found reference to global " << name
-                                      << " at " << *op << "\n");
-    if (source.isPointer())
+    mlir::StringAttr name = glbl.getRootReference();
+    LLVM_DEBUG(llvm::dbgs().indent(2) << "Found reference to global "
+                                      << name.str() << " at " << *op << "\n");
+    if (source.isPointer()) {
       tag = state.getFuncTreeWithScope(func, scopeOp).targetDataTree.getTag();
-    else
-      tag =
-          state.getFuncTreeWithScope(func, scopeOp).globalDataTree.getTag(name);
+    } else {
+      // In general, place the tags under the "global data" root.
+      fir::TBAATree::SubtreeState *subTree =
+          &state.getMutableFuncTreeWithScope(func, scopeOp).globalDataTree;
+
+      // The COMMON blocks have their own sub-tree root under the "global data"
----------------
tblah wrote:

Can non-common block global data alias with common blocks? Maybe it depends how confident we are that information about common blocks doesn't get lost during lowering.

If we are confident then we could express this by putting the common block tree one level up (as a sibling to the global data tree).

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


More information about the flang-commits mailing list