Skip to content

Conversation

@meshtag
Copy link
Member

@meshtag meshtag commented Dec 23, 2025

Avoids a crash in test-eliminate-vector-masks pass by bailing out when the target function has no body.

Fixes #132160.

Avoids a crash in test-eliminate-vector-masks pass by bailing out when the target
function has no body.
@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-vector

Author: Prathamesh Tagore (meshtag)

Changes

Avoids a crash in test-eliminate-vector-masks pass by bailing out when the target function has no body.

Fixes #132160.


Full diff: https://github.com/llvm/llvm-project/pull/173330.diff

2 Files Affected:

  • (modified) mlir/lib/Dialect/Vector/Transforms/VectorMaskElimination.cpp (+4)
  • (modified) mlir/test/Dialect/Vector/eliminate-masks.mlir (+6)
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>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MLIR] -test-eliminate-vector-masks triggers Assertion `!NodePtr->isKnownSentinel()' failed.

2 participants