[flang-commits] [flang] [flang][NFCI] Stop tracking memory source after a load in a more explicit manner. (PR #126156)
Joel E. Denny via flang-commits
flang-commits at lists.llvm.org
Wed Feb 12 15:00:49 PST 2025
================
@@ -600,6 +590,40 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
defOp = v.getDefiningOp();
return;
}
+
+ // If we are loading a box reference, but following the data,
+ // we gather the attributes of the box to populate the source
+ // and stop tracking.
+ if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(ty);
+ boxTy && followingData) {
+
+ if (mlir::isa<fir::PointerType>(boxTy.getEleTy()))
+ attributes.set(Attribute::Pointer);
+
+ auto def = getOriginalDef(op.getMemref());
+ if (auto addrOfOp = def.template getDefiningOp<fir::AddrOfOp>()) {
+ global = addrOfOp.getSymbol();
+
+ if (hasGlobalOpTargetAttr(def, addrOfOp))
+ attributes.set(Attribute::Target);
+
+ type = SourceKind::Global;
+ }
+
+ // TODO: Add support to fir.alloca and fir.allocmem
+ // if (auto allocOp = def.template getDefiningOp<fir::AllocaOp>()) {
+ // ...
+ // }
+
+ if (isDummyArgument(def)) {
+ defOp = nullptr;
+ v = def;
+ }
+
+ breakFromLoop = true;
+ return;
----------------
jdenny-ornl wrote:
I just noticed that we now return here without setting `type = SourceKind::Indirect` in some cases when we don't have a dummy arg or AddrOfOp. As a result, some cases that used to be Indirect are now Unknown. That seems fine for `AliasAnalysis::alias`, whose logic treats them equivalently. Is this change intentional?
https://github.com/llvm/llvm-project/pull/126156
More information about the flang-commits
mailing list