[Mlir-commits] [mlir] [mlir][vector] Skip vector mask elimination for funcs without body (PR #173330)

Prathamesh Tagore llvmlistbot at llvm.org
Sun Dec 28 16:13:13 PST 2025


https://github.com/meshtag updated https://github.com/llvm/llvm-project/pull/173330

>From 6a3f338ad24634ede2d215ad9385e45e2d6c6310 Mon Sep 17 00:00:00 2001
From: Prathamesh Tagore <prathameshtagore at gmail.com>
Date: Tue, 23 Dec 2025 03:33:13 +0100
Subject: [PATCH] [mlir][vector] Skip vector mask elimination for funcs without
 body

Avoids a crash in test-eliminate-vector-masks pass by bailing out when the target
function has no body.
---
 .../lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp | 4 ++++
 mlir/test/Dialect/Vector/eliminate-masks.mlir               | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp
index 8a181a429e41c..6f75ce7a04511 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp
@@ -99,6 +99,10 @@ void eliminateVectorMasks(IRRewriter &rewriter, FunctionOpInterface function,
   if (!vscaleRange)
     return;
 
+  // Early exit for functions without a body.
+  if (function.isExternal())
+    return;
+
   OpBuilder::InsertionGuard g(rewriter);
 
   // Build worklist so we can safely insert new ops in
diff --git a/mlir/test/Dialect/Vector/eliminate-masks.mlir b/mlir/test/Dialect/Vector/eliminate-masks.mlir
index 0b78687fb9832..71b4a1f959b39 100644
--- a/mlir/test/Dialect/Vector/eliminate-masks.mlir
+++ b/mlir/test/Dialect/Vector/eliminate-masks.mlir
@@ -163,3 +163,9 @@ func.func @negative_value_bounds_scalable_dim_not_all_true(%tensor: tensor<2x100
   "test.some_use"(%mask) : (vector<3x[4]xi1>) -> ()
   return
 }
+
+// -----
+
+// Test to ensure that functions without a body are skipped.
+// CHECK-LABEL: func.func private @decl_only(tensor<*xi32>)
+func.func private @decl_only(tensor<*xi32>)



More information about the Mlir-commits mailing list