[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
Wed May 1 13:22:49 PDT 2024


================
@@ -399,19 +404,30 @@ 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 && fir::isa_ref_type(ty))
----------------
jdenny-ornl wrote:

> > That test doesn't deal with a fortran pointer, so this patch leaves it as SourceKind::Argument
> 
> `fir::isa_ref_type(ty)` does not mean fortran POINTER. `fir::isPointerType(ty)` does.

Right, when I wrote that comment, I somehow forgot that I generalized beyond pointers.  See my previous comment.
 
> > What additional benefits do you mean?
> 
> Boxes are also passed by value. You would want to distinguish between them and their data as well. In this case `followBoxAddrLoad` would not be set.

While the cases I'm trying to address so far specifically involve the `fir::LoadOp` case in `AliasAnalysis::getSource`, I'd appreciate any fortran example that does not.  My understanding of relevant use cases is probably too narrow.

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


More information about the flang-commits mailing list