[flang-commits] [flang] [flang] [NFCI] Using getSource instead of getOriginalDef (PR #128984)
Joel E. Denny via flang-commits
flang-commits at lists.llvm.org
Wed Mar 5 08:18:12 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>()) {
+ v = def;
+ defOp = v.getDefiningOp();
+ type = SourceKind::Allocate;
----------------
jdenny-ornl wrote:
> `Direct` was a misnomer
I agree it wasn't the right name for the direction I was taking it.
https://github.com/llvm/llvm-project/pull/128984
More information about the flang-commits
mailing list