[flang-commits] [flang] [flang] AliasAnalysis: distinguish addr of arg vs. addr in arg (PR #87723)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Apr 8 02:34:12 PDT 2024


================
@@ -171,10 +171,28 @@ void AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface op,
                                         << " at " << *op << "\n");
       tag = state.getFuncTree(func).directDataTree.getTag(name);
     } else {
-      // SourceKind::Direct is likely to be extended to cases which are not a
-      // SymbolRefAttr in the future
-      LLVM_DEBUG(llvm::dbgs().indent(2) << "Can't get name for direct "
-                                        << source << " at " << *op << "\n");
+      bool sourceIsDummyArgument = false;
+      if (auto blockArg =
+              source.u.get<mlir::Value>().dyn_cast<mlir::BlockArgument>())
+        sourceIsDummyArgument = blockArg.getOwner()->isEntryBlock();
----------------
tblah wrote:

The entry block is defined as the first block in a region. Any container op has a region e.g.
```
fir.if %cond {
  ^bb0:
    // this is an entry block
    cf.br ^bb1
  ^bb1:
    [...]
}
```

So I think we need to do a bit more to determine if the source is a dummy argument. Maybe look to see if the immediate parent of the entry block is a function?

I can see we make the same mistake already in `flang/lib/Optimizer/Analysis/AliasAnalysis.cpp`.

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


More information about the flang-commits mailing list