[flang-commits] [flang] [flang] Use alias analysis in lowering record assignments (PR #176483)

via flang-commits flang-commits at lists.llvm.org
Tue Jan 20 01:09:04 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:

You can turn that into `!isTemporaryLHS && aa.alias(...`?

When the LHS is a new temporary, there is no need to try to use Fortran aliasing rules to prove that there is no aliasing.

https://github.com/llvm/llvm-project/pull/176483


More information about the flang-commits mailing list