[Mlir-commits] [mlir] [MLIR][Transform] Fix crash in transform.structured.split with zero-result operations (PR #204363)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jun 17 07:59:14 PDT 2026
https://github.com/JasonHonKL updated https://github.com/llvm/llvm-project/pull/204363
>From da2c7186b0ae506ff3d5a00b47b002a069af3d28 Mon Sep 17 00:00:00 2001
From: JasonHonKL <j2004nol at gmail.com>
Date: Wed, 17 Jun 2026 22:53:36 +0800
Subject: [PATCH] Fix crash in transform.structured.split when operation has 0
results
The split operation would crash when trying to access getResult(0) on
an operation with no results (like a void function call). This fix
splits the validation into two separate checks with early returns to
prevent accessing invalid result indices.
Fixes crash where:
- transform.structured.split receives operation with 0 results
- Code unconditionally accesses op->getResult(0)
- Assertion failure: resultNumber out of range
Now returns proper error message instead of crashing.
---
.../Linalg/TransformOps/LinalgTransformOps.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index f44693096b26b..aa55d39e1af23 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -2882,13 +2882,22 @@ SplitOp::apply(transform::TransformRewriter &rewriter,
if (isa<TransformHandleTypeInterface>(getDynamicChunkSizes().getType())) {
chunkSizes = llvm::map_to_vector(
state.getPayloadOps(getDynamicChunkSizes()), [&](Operation *op) {
- if (op->getNumResults() != 1 ||
- !op->getResult(0).getType().isIndex()) {
+ if (op -> getNumResults() != 1){
diag = emitSilenceableError()
- << "expected dynamic split point handle to point to a "
+ << "expected dynamic split point handle to point to a "
"single-result index-typed op";
diag.attachNote(op->getLoc()) << "dynamic split point";
+ return OpFoldResult();
}
+
+ if (!op->getResult(0).getType().isIndex()){
+ diag = emitSilenceableError()
+ << "expected dynamic split point handle to point to a "
+ "single-result index-typed op";
+ diag.attachNote(op->getLoc()) << "dynamic split point";
+ return OpFoldResult();
+ }
+
return OpFoldResult(op->getResult(0));
});
} else {
More information about the Mlir-commits
mailing list