[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:06:17 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());
----------------
jdenny-ornl wrote:
I think it would also be helpful to have a brief comment on this getSource call: This getSource call will never recurse through a second LoadOp because followData will necessarily become false within the call and thus the above `boxTy && followData` guard will prevent this block from executing again.
But is that true for the part of the LoadOp case outside that block: the omp::TargetOp handling? Recursing to that from this getSource call was not possible with getOriginalDef, but I'm not sure now.
If we want to be more confident that this PR is NFC, we could add a mode parameter for getSource that causes it to stop with Indirect on any case that getOriginalDef didn't handle. We could then gradually extend the implementation to eliminate those Indirect cases in later PRs as driven by real use cases. That approach seems to achieve a reasonable balance with the maintenance rationale for eliminating getOriginalDef.
https://github.com/llvm/llvm-project/pull/128984
More information about the flang-commits
mailing list