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

Joel E. Denny via flang-commits flang-commits at lists.llvm.org
Fri Apr 5 13:59:52 PDT 2024


================
@@ -399,16 +407,18 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v) {
   if (!defOp && type == SourceKind::Unknown)
     // Check if the memory source is coming through a dummy argument.
     if (isDummyArgument(v)) {
-      type = SourceKind::Argument;
       ty = v.getType();
       if (fir::valueHasFirAttribute(v, fir::getTargetAttrName()))
         attributes.set(Attribute::Target);
-
       if (Source::isPointerReference(ty))
         attributes.set(Attribute::Pointer);
+      if (followBoxAddr && attributes.test(Attribute::Pointer))
----------------
jdenny-ornl wrote:

For this `isDummyArg()` case: The pointer check is needed to handle dummy arguments of type `!fir.box<!fir.array<...>>`.  This is in part because followBoxAddr is set when DesignateOp is applied to a `!fir.box`.

For the AddrOfOp case: I didn't figure out how to get flang to generate a global with that type, even after asking in flang slack #general.  I did find that flang/test/Fir/cg-ops.fir has such a global (again, I don't know the corresponding fortran).  However, AddrOfOp turns even that into a `!fir.ref`, so followBoxAddr isn't set at the DesignateOp, so I still don't know how to create the problem for AddrOfOp.

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


More information about the flang-commits mailing list