[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 14:09:13 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 the AddrOfOp case: I noticed that flang/test/Analysis/AliasAnalysis/alias-analysis-8.fir expects the relationship between the address *in* an allocatable global and the address *of* that allocatable global to be NoAlias.
For the isDummyArg() case: I just checked the same relationship for allocatable arguments and discovered my patch wasn't handling it correctly: it has it as MustAlias. The pointer check we're discussing is too strict. I'll push a patch shortly that relaxes that to `fir::isa_ref_type(ty)` to turn it into NoAlias. However, flang/test/Transforms/tbaa2.fir then fails because AddAliasTags cannot yet handle Direct for the allocatable arguments there. My patch also attempts to extend AddAliasTags accordingly.
I also tried adding `fir::isa_ref_type(ty)` to the AddrOfOp case, and check-flang still behaved. So, it doesn't improve existing test cases, and I haven't found a `!fir.box<!fir.array<...>>` case for AddrOfOp (see previous comment), so for now I've abandoned that addition as apparently useless.
https://github.com/llvm/llvm-project/pull/87723
More information about the flang-commits
mailing list