[flang-commits] [flang] [flang] AliasAnalysis: Handle fir.load on fir.alloca (PR #117785)
Joel E. Denny via flang-commits
flang-commits at lists.llvm.org
Tue Jan 21 12:51:41 PST 2025
================
@@ -522,6 +546,12 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
.Case<fir::AllocaOp, fir::AllocMemOp>([&](auto op) {
// Unique memory allocation.
type = SourceKind::Allocate;
+ // If there's no DeclareOp, then we need to get the pointer attribute
+ // from the type. TODO: That case occurs in our test suite
+ // (alias-analysis-2.fir), but does flang currently generate such
+ // code?
+ if (isPointerReference(ty))
+ attributes.set(Attribute::Pointer);
----------------
jdenny-ornl wrote:
If you're opposed to C1 because it expands the definition of non-data, the only remaining solution we've discussed is C3 alone. I've pushed a commit to the PR to leave C3 uncommented but to comment out C1 and C2.
If we go with C3 alone, what happens when an address is loaded from within `fir.alloca !fir.ptr<T>`? Without C2, how will it pick up a pointer attribute so we can detect aliasing properly? C3 doesn't help because there's no box and so no BoxAddrOp.
I've extended alias-analysis-2.fir with a new T3 to show such a case. It fails with C3 alone but passes when using C1+C2. I don't know if this case is realistic because I don't know how to make flang generate `fir.alloca !fir.ptr<T>`.
https://github.com/llvm/llvm-project/pull/117785
More information about the flang-commits
mailing list