From eac228b5661cac5700ad9843c74fcbaa12135b60 Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Fri, 17 Oct 2025 12:05:07 +0100 Subject: [PATCH] [mlir][spirv] Emit error when block to be unlinked has uses after structurization This fixes the bug where deserializer would fail, with as assert, during the control flow structurization when a block to be removed still had uses. This indicates that the block that was sunk still is being referenced outside the region as the control flow is not structured. closes #163099 --- mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp index 0c3e87a8dc1ef..d9ad8fb144b61 100644 --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp @@ -2619,6 +2619,11 @@ LogicalResult ControlFlowStructurizer::structurize() { // region. We cannot handle such cases given that once a value is sinked into // the SelectionOp/LoopOp's region, there is no escape for it. for (auto *block : constructBlocks) { + if (!block->use_empty()) + return emitError(block->getParent()->getLoc(), + "failed control flow structurization: " + "block has uses outside of the " + "enclosing selection/loop construct"); for (Operation &op : *block) if (!op.use_empty()) return op.emitOpError("failed control flow structurization: value has "