[flang-commits] [flang] [flang] Stop tracking memory source after a load in a more explicit manner. (PR #126156)
via flang-commits
flang-commits at lists.llvm.org
Fri Feb 7 01:29:02 PST 2025
================
@@ -600,6 +590,41 @@ 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;
+ }
----------------
jeanPerier wrote:
Aren't here other cases where the Target attribute should be set (local/dummy allocatables with TARGET attribute for instance)?
Why not calling `getSource` on op.getMemref() and propagating the TARGET/POINTER attribute/whatever is relevant to propagate from the variable containing the address to the address?
https://github.com/llvm/llvm-project/pull/126156
More information about the flang-commits
mailing list