[flang-commits] [flang] [mlir] [RFC][mlir] ViewLikeOpInterface method for detecting partial views. (PR #164020)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Mon Nov 3 11:15:24 PST 2025


================
@@ -559,10 +563,19 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
           type = SourceKind::Allocate;
           breakFromLoop = true;
         })
-        .Case<fir::ConvertOp>([&](auto op) {
-          // Skip ConvertOp's and track further through the operand.
-          v = op->getOperand(0);
+        .Case<mlir::ViewLikeOpInterface>([&](auto op) {
----------------
vzakhari wrote:

Flang alias analysis has special handling for HLFIR/FIR operations that carry extra information about the rules of aliasing for objects created from Fortran variables. For example, there are special rules for DUMMY arguments of functions that cannot alias each other unless they have TARGET or POINTER attributes. Flang carries this extra information on `[hl]fir.declare` operations. For the two given "addresses", Flang alias analysis tries to discover the "sources" of those addresses, e.g. by tracking through view-like operations, and then reasons about the aliasing having reached `[hl]fir.declare` operations.

I think the HLFIR/FIR specifics used by Flang alias analysis can be abstracted by using some generic interfaces that `[hl]fir.declare` (and some other operations, e.g. `fir.global`), but I want to leave this out of scope of this PR.

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


More information about the flang-commits mailing list