[flang-commits] [flang] [flang] Use alias analysis in lowering record assignments (PR #176483)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 28 08:33:05 PST 2026
================
@@ -1566,8 +1567,14 @@ void fir::factory::genRecordAssignment(fir::FirOpBuilder &builder,
mlir::isa<fir::BaseBoxType>(fir::getBase(rhs).getType());
auto recTy = mlir::dyn_cast<fir::RecordType>(baseTy);
assert(recTy && "must be a record type");
+
+ // Use alias analysis to guard the fast path.
+ fir::AliasAnalysis aa;
+ bool disjoint = aa.alias(fir::getBase(lhs), fir::getBase(rhs)) ==
----------------
jeanPerier wrote:
Oups, sorry, yes I meant `disjoint = isTemporaryLHS ...`, and this should not cause not new regressions, I assume this may come from the fact that extra parentheses are needed `disjoint = isTemporaryLHS || (aa.alias(fir::getBase(lhs), fir::getBase(rhs)) == mlir::AliasResult::NoAlias)`.
> [...] and then use that to guard the guard itself (as in, say, recTy.isSequence()?).
Yes, I will review your new update, thanks
> or is the preference to have a single combined patch?
I prefer to do it either as a pre-patch or a combined patch like you did (a post patch would have opened the door to perf regressions and having to spent time analyzing them to validate they come from this patch/will be fixed).
https://github.com/llvm/llvm-project/pull/176483
More information about the flang-commits
mailing list