[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
Wed Nov 5 12:31:16 PST 2025


================
@@ -23,21 +23,53 @@ def ViewLikeOpInterface : OpInterface<"ViewLikeOpInterface"> {
   }];
   let cppNamespace = "::mlir";
 
-  let methods = [
-    InterfaceMethod<
-      "Returns the source buffer from which the view is created.",
-      "::mlir::Value", "getViewSource">,
-    InterfaceMethod<
-      /*desc=*/[{ Returns the buffer which the view created. }],
-      /*retTy=*/"::mlir::Value",
-      /*methodName=*/"getViewDest",
-      /*args=*/(ins),
-      /*methodBody=*/"",
-      /*defaultImplementation=*/[{
+  let methods =
+      [InterfaceMethod<
+           "Returns the source buffer from which the view is created.",
+           "::mlir::Value", "getViewSource">,
+       InterfaceMethod<
+           /*desc=*/[{ Returns the buffer which the view created. }],
+           /*retTy=*/"::mlir::Value",
+           /*methodName=*/"getViewDest",
+           /*args=*/(ins),
+           /*methodBody=*/"",
+           /*defaultImplementation=*/[{
         return $_op->getResult(0);
-      }]
-    >
-  ];
+      }]>,
+       InterfaceMethod<
+           /*desc=*/
+           [{
+             Returns true iff the source buffer and the resulting view
+             are known to start at the same "address".
+           }],
+           /*retTy=*/"bool",
+           /*methodName=*/"isKnownToHaveSameStart",
----------------
vzakhari wrote:

Matthias and I discussed this offline. Matthias raised a valid concern that it is unclear what the aliasing rules are for the memref subviews, as long as the subview actually holds the original base pointer of the view and the offset. Should the aliasing replies be based on the base addresses or their offsetted values - this seems to require a broader discussion in MLIR community.

We agreed that I implement a Flang specific interface to help making FIR alias analysis more generic, and then we'll present the working implementation in an RFC and discuss whether it is worth making this interface MLIR-global.

I will close this PR and will work on the new interface in Flang.

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


More information about the flang-commits mailing list