[Mlir-commits] [mlir] [mlir][bufferization] Add XFAIL test for bufferize-function-boundaries returning unranked memref (PR #176746)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Mar 19 06:08:47 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
index f101f918c..4beeb338f 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
@@ -376,12 +376,14 @@ static LogicalResult getFuncOpsOrderedByCalls(
   return success();
 }
 
-// this code will decide whether removing a direct memref.cast (by returning the cast source)
-// is guaranteed to NOT lose useful type information for return-type tightening.
+// this code will decide whether removing a direct memref.cast (by returning the
+// cast source) is guaranteed to NOT lose useful type information for
+// return-type tightening.
 //
 // Goal of foldMemRefCasts:
 // - drop "signature accommodation" casts (usually layout/generalization casts)
-// - keep casts that encode strictly better info at the result (rank/dims/layout)
+// - keep casts that encode strictly better info at the result
+// (rank/dims/layout)
 //
 // "Safe to drop" means:
 // - returning the cast source instead of the cast result will not drop
@@ -390,10 +392,11 @@ static LogicalResult getFuncOpsOrderedByCalls(
 //   (c) layout information (when cast result layout is more specific)
 //
 // Notes:
-// This code will calculate whether stripping a defining memref.cast loses type precision
-// that foldMemRefCasts tries to preserve for function results.
-// canSafelyDropMemrefCast(castOp) == true means dest is not adding info --> safe to drop the cast and use the source directly.
-// It is safe to remove the memref.cast and use the cast’s source value directly
+// This code will calculate whether stripping a defining memref.cast loses type
+// precision that foldMemRefCasts tries to preserve for function results.
+// canSafelyDropMemrefCast(castOp) == true means dest is not adding info -->
+// safe to drop the cast and use the source directly. It is safe to remove the
+// memref.cast and use the cast’s source value directly
 static bool canSafelyDropMemrefCast(memref::CastOp castOp) {
   Type srcTy = castOp.getSource().getType();
   Type dstTy = castOp.getType();
@@ -403,17 +406,18 @@ static bool canSafelyDropMemrefCast(memref::CastOp castOp) {
   auto srcR = dyn_cast<MemRefType>(srcTy);
   auto dstR = dyn_cast<MemRefType>(dstTy);
 
-  //src and dst must be memref types, and at least one of them must be ranked (otherwise, no precision to lose)
+  // src and dst must be memref types, and at least one of them must be ranked
+  // (otherwise, no precision to lose)
   if (!srcU && !srcR)
     return false;
 
-  //if dest is not memref type --> 
+  // if dest is not memref type -->
   if (!dstU && !dstR)
-      return false;
+    return false;
 
   // Rank precision: do not drop unranked -> ranked.
   if (srcU && dstR)
-    return false; //our case
+    return false; // our case
   if (srcR && dstU)
     return true;
   if (srcU && dstU)
@@ -471,8 +475,8 @@ static memref::CastOp getDefiningMemRefCast(Value v) {
   return v.getDefiningOp<memref::CastOp>();
 }
 
-// this code will return the value that should be used for return-type comparison
-// and for optional cast-stripping at func.return.
+// this code will return the value that should be used for return-type
+// comparison and for optional cast-stripping at func.return.
 //
 // Rule:
 // - when the value is not a memref.cast result, return the value
@@ -480,7 +484,8 @@ static memref::CastOp getDefiningMemRefCast(Value v) {
 //     - if canSafelyDropMemrefCast(castOp) is true, return the cast source
 //       (cast is layout-only / non-precision-gaining, safe to drop)
 //     - else return the cast result
-//       (cast is precision-gaining: unranked->ranked, dynamic->static, layout refinement, etc)
+//       (cast is precision-gaining: unranked->ranked, dynamic->static, layout
+//       refinement, etc)
 static Value canonicalizeReturnValue(Value v) {
   if (auto castOp = getDefiningMemRefCast(v)) {
     if (canSafelyDropMemrefCast(castOp))
@@ -498,7 +503,8 @@ static SmallVector<Type> getReturnTypes(SmallVector<func::ReturnOp> returnOps) {
   assert(!returnOps.empty() && "expected at least one ReturnOp");
   int numOperands = returnOps.front()->getNumOperands();
 
-  // Helper function that conditionally drops memref.cast ops and returns the type.
+  // Helper function that conditionally drops memref.cast ops and returns the
+  // type.
   auto getComparableType = [&](Value v) {
     return canonicalizeReturnValue(v).getType();
   };

``````````

</details>


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


More information about the Mlir-commits mailing list