[Mlir-commits] [mlir] [mlir][vector] Skip vector mask elimination for funcs without body (PR #173330)
Prathamesh Tagore
llvmlistbot at llvm.org
Mon Dec 29 10:07:46 PST 2025
https://github.com/meshtag updated https://github.com/llvm/llvm-project/pull/173330
>From 153621ea2c895a54cdf710ba211b971b5a909c79 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..88be7e529bb9e 100644
--- a/mlir/test/Dialect/Vector/eliminate-masks.mlir
+++ b/mlir/test/Dialect/Vector/eliminate-masks.mlir
@@ -45,6 +45,12 @@ func.func @eliminate_redundant_masks_through_insert_and_extracts(%tensor: tensor
// -----
+// Test to ensure that functions without a body are skipped.
+// CHECK-LABEL: func.func private @negative_no_func_body()
+func.func private @negative_no_func_body()
+
+// -----
+
// CHECK-LABEL: @negative_extract_slice_size_shrink
// CHECK-NOT: vector.constant_mask
// CHECK: %[[MASK:.*]] = vector.create_mask
More information about the Mlir-commits
mailing list