[flang-commits] [flang] [flang] [NFCI] Using getSource instead of getOriginalDef (PR #128984)
Renaud Kauffmann via flang-commits
flang-commits at lists.llvm.org
Fri Feb 28 08:34:27 PST 2025
================
@@ -621,38 +587,34 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
if (mlir::isa<fir::PointerType>(boxTy.getEleTy()))
attributes.set(Attribute::Pointer);
- auto def = getOriginalDef(op.getMemref(), attributes,
- isCapturedInInternalProcedure,
- approximateSource);
- if (auto addrOfOp = def.template getDefiningOp<fir::AddrOfOp>()) {
- global = addrOfOp.getSymbol();
-
- if (hasGlobalOpTargetAttr(def, addrOfOp))
- attributes.set(Attribute::Target);
+ auto boxSrc = getSource(op.getMemref());
+ attributes |= boxSrc.attributes;
+ approximateSource |= boxSrc.approximateSource;
+ isCapturedInInternalProcedure |=
+ boxSrc.isCapturedInInternalProcedure;
+ global = llvm::dyn_cast<mlir::SymbolRefAttr>(boxSrc.origin.u);
+ if (global) {
type = SourceKind::Global;
- }
- // TODO: Add support to fir.allocmem
- else if (auto allocOp =
- def.template getDefiningOp<fir::AllocaOp>()) {
- v = def;
- defOp = v.getDefiningOp();
- type = SourceKind::Allocate;
- } else if (isDummyArgument(def)) {
- defOp = nullptr;
- v = def;
} else {
- type = SourceKind::Indirect;
+ auto def = llvm::cast<mlir::Value>(boxSrc.origin.u);
+ // TODO: Add support to fir.allocmem
+ if (auto allocOp = def.template getDefiningOp<fir::AllocaOp>()) {
----------------
Renaud-K wrote:
If the attributes are merged and the sourceKind come boxSrc, how much different would it be to just follow the source? :) We would be back to square one.
This is why I want to ultimately introduce SourceKind::Emboxed. It is an indirection for which we are comfortable applying static attributes to make an aliasing determination. While, for other type of indirection, lowering cannot guarantee that an alias situation is always indicated with a fir.ptr type for instance.
https://github.com/llvm/llvm-project/pull/128984
More information about the flang-commits
mailing list