[mlir][vector] Historical VectorType assertion in a parsing driver: relation to #185587
I am reporting a historical VectorType assertion from a custom MLIR parsing/verification driver and asking whether it belongs to the already addressed ShuffleOp issue #185587 / fix #185714.
The original log has no symbolic stack, so this report does not establish a separate upstream defect or prove exact duplication. The recorded process was a custom driver; it was not a standalone mlir-opt run.
Environment
- Associated LLVM/MLIR revision:
13c6abfac84fca4bc55c0721d1853ce86a385678. - Observed executable role: a custom driver that parses/verifies an MLIR module and extracts facts.
- Driver binary SHA-256:
1cd422f2411a363f4bb66c5cecdaaab883788ae0585bbe1ab83f728e93766f83. - No extra command-line arguments were present in the saved invocation; the program was supplied on stdin.
- The historical driver source-to-binary build manifest, complete build flags, and a verified mapping of the failing instruction to source have not been recovered. A clearly identified source reference is included below.
Reproducer
The exact saved input is included below without correction or reduction. SHA-256: 4318b94ef744229107dfa79d43ca116fd36341ced7b96b6967acf46fb33a59ad. It is malformed IR and is not presented as a valid vector program.
func.func @insert_slice_shuffle(%arg0: tensor<4x4xf32>, %arg1: tensor<4x4xf32>) -> tensor<4x4xf32> {
%0 = tensor.insert_slice %arg0 into %arg1[%c0, %c0] [%c4, %c4] [%c1, %c1] : tensor<4x4xf32> into tensor<4x4xf32>
%1 = vector.shuffle %0[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] : tensor<4x4xf32> to vector<16xf32>
return %1 : tensor<4x4xf32>
}
This supplies the input missing from the initial report. It does not supply a verified reconstruction of the historical custom driver.
Steps to reproduce
The observed process was ggfa-ir-facts-r1, supplied with the original bytes on stdin and no extra arguments. I have not replaced it with mlir-opt, and no equivalence to that entry point is asserted. The saved process aborted; there has been no independent replay or post-fix run of this driver/input combination.
An existing driver-source reference is included below to make the integration concrete. It registers MLIR dialects and extensions, reads stdin, parses a module, verifies it, and extracts facts. Its SHA-256 is d0bc516af49d367ed0ebe0d8f7b9084d0daaac34b603acc9d9e460e88757e269.
Source identity limitation: I have not recovered a build manifest binding this source file to the historical binary hash above. The exact build configuration is also missing. This listing is reference material, not a claim that compiling it reproduces the observed binary or failure.
Existing parsing/verification driver reference (historical binary binding unverified)
// Read-only, verifier-backed IR facts. No pass execution or source generation.
#include "mlir/IR/AsmState.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Verifier.h"
#include "mlir/InitAllDialects.h"
#include "mlir/InitAllExtensions.h"
#include "mlir/Parser/Parser.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
using namespace mlir;
namespace json = llvm::json;
static std::string printType(Type type) {
std::string s;
llvm::raw_string_ostream stream(s);
type.print(stream);
return s;
}
static json::Object typeFacts(Type type) {
json::Object result{{"text", printType(type)}, {"kind", "other"}};
if (auto integer = dyn_cast<IntegerType>(type)) {
result["kind"] = "integer";
result["width"] = int64_t(integer.getWidth());
} else if (isa<IndexType>(type)) {
result["kind"] = "index";
}
if (auto shaped = dyn_cast<ShapedType>(type)) {
result["kind"] = isa<BaseMemRefType>(type) ? "memref" :
isa<TensorType>(type) ? "tensor" : "shaped";
result["element_type"] = printType(shaped.getElementType());
result["ranked"] = shaped.hasRank();
json::Array shape;
if (shaped.hasRank())
for (int64_t dim : shaped.getShape())
shape.push_back(ShapedType::isDynamic(dim) ? json::Value(nullptr) : json::Value(dim));
result["shape"] = std::move(shape);
if (auto memref = dyn_cast<MemRefType>(type)) {
std::string layout;
llvm::raw_string_ostream stream(layout);
memref.getLayout().print(stream);
result["layout"] = layout;
SmallVector<int64_t> strides;
int64_t offset;
if (succeeded(memref.getStridesAndOffset(strides, offset))) {
result["offset"] = ShapedType::isDynamic(offset) ? json::Value(nullptr) : json::Value(offset);
json::Array values;
for (int64_t stride : strides)
values.push_back(ShapedType::isDynamic(stride) ? json::Value(nullptr) : json::Value(stride));
result["strides"] = std::move(values);
}
}
}
return result;
}
int main(int argc, char **argv) {
if (argc != 1) {
llvm::errs() << "usage: ggfa-ir-facts-r1 < input.mlir\n";
return 2;
}
auto input = llvm::MemoryBuffer::getSTDIN();
if (!input || (*input)->getBufferSize() > 262144) {
llvm::errs() << "input missing or exceeds admitted 262144 bytes\n";
return 2;
}
DialectRegistry registry;
registerAllDialects(registry);
registerAllExtensions(registry);
MLIRContext context(registry);
context.disableMultithreading();
llvm::SourceMgr mgr;
mgr.AddNewSourceBuffer(std::move(*input), llvm::SMLoc());
auto module = parseSourceFile<ModuleOp>(mgr, &context);
if (!module || failed(verify(*module))) {
llvm::outs() << "{\"schema\":\"ggfa.ir_facts.r1\",\"verified\":false}\n";
return 1;
}
llvm::DenseMap<Operation *, int64_t> opIds;
llvm::DenseMap<Value, int64_t> valueIds;
llvm::DenseMap<Region *, int64_t> regionIds;
int64_t oi = 0, vi = 0, ri = 0;
module->walk<WalkOrder::PreOrder>([&](Operation *op) {
opIds[op] = oi++;
for (Value value : op->getResults()) valueIds[value] = vi++;
for (Region ®ion : op->getRegions()) {
regionIds[®ion] = ri++;
for (Block &block : region)
for (Value value : block.getArguments()) valueIds[value] = vi++;
}
});
if (oi > 4096) {
llvm::errs() << "operation bound exceeded\n";
return 2;
}
auto valueFact = [&](Value value) {
return json::Object{{"id", valueIds.lookup(value)}, {"type", typeFacts(value.getType())}};
};
json::Array operations;
module->walk<WalkOrder::PreOrder>([&](Operation *op) {
json::Object node{{"id", opIds.lookup(op)}, {"name", op->getName().getStringRef().str()},
{"regions", int64_t(op->getNumRegions())},
{"loop_like", isa<LoopLikeOpInterface>(op)}};
node["parent"] = op->getParentOp() ? json::Value(opIds.lookup(op->getParentOp())) : json::Value(nullptr);
node["region"] = op->getParentRegion() ? json::Value(regionIds.lookup(op->getParentRegion())) : json::Value(nullptr);
json::Array operands, results, arguments;
for (Value value : op->getOperands()) operands.push_back(valueFact(value));
for (Value value : op->getResults()) results.push_back(valueFact(value));
for (Region ®ion : op->getRegions())
for (Block &block : region)
for (Value value : block.getArguments()) arguments.push_back(valueFact(value));
node["operands"] = std::move(operands);
node["results"] = std::move(results);
node["block_arguments"] = std::move(arguments);
if (auto linalg = dyn_cast<linalg::LinalgOp>(op))
node["linalg_semantics"] = linalg.hasPureTensorSemantics() ? "tensor" :
linalg.hasPureBufferSemantics() ? "buffer" : "mixed";
if (auto load = dyn_cast<memref::LoadOp>(op))
node["access_memref"] = valueIds.lookup(load.getMemRef());
if (auto store = dyn_cast<memref::StoreOp>(op))
node["access_memref"] = valueIds.lookup(store.getMemRef());
operations.push_back(std::move(node));
});
std::string canonical;
llvm::raw_string_ostream stream(canonical);
module->print(stream, OpPrintingFlags().enableDebugInfo(false));
json::Object result{{"schema", "ggfa.ir_facts.r1"}, {"verified", true},
{"operations", std::move(operations)}, {"canonical_ir", canonical}};
llvm::outs() << json::Value(std::move(result)) << "\n";
return 0;
}
Actual behavior
The recorded custom driver terminated with SIGABRT (signal 6; subprocess return code -6), and the child was reaped. Stdout was empty. The following is the entire diagnostic text available in the saved stderr, with only its private build-directory prefix removed:
ggfa-ir-facts-r1: llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = mlir::VectorType, From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
There is no symbolic call stack in that record. No call-site trace is inferred from the source listing.
Expected behavior
If this execution reaches the ShuffleOp return-type-inference path addressed by #185714, a non-vector operand should be rejected with a handled diagnostic rather than an unchecked type cast. This expectation is conditional on the path attribution, which remains unresolved for the saved driver failure.
Analysis
Three different relationship claims should be kept separate:
- Related: #185587 and #185714 concern a matching operation/type-inference issue.
- Compatible same-mechanism explanation: the old operation definition uses type inference, its operand-list parsing precedes result inference, and the historical inference code contains the cast addressed by the fix. This supports an explanation consistent with the input and assertion.
- Exact duplicate or exact-input fix verified: neither is established by the available log. The driver lacks a saved call-site trace, and this exact input has not been checked on a post-fix binary.
I am asking whether maintainers consider the available source correspondence sufficient to associate this historical observation with #185587, or whether integration-specific evidence would be required first. It would be appropriate to mark this report related or duplicate if that relationship is established; I am not asserting an independent new root cause.
Related issues
- #185587:
vector::ShuffleOp::inferReturnTypescrash report. - #185714: validates operand typing during ShuffleOp return-type inference; merged on 2026-03-11 as
adfc1a95ad729b451f9163279f053248a1e17742.
The merged fix is an upstream fact, not a verification receipt for this exact driver/input combination. Current-main runtime behavior remains untested here.
Assisted-by: OpenAI Codex (substantial assistance with evidence review and report preparation).
@llvm/issue-subscribers-mlir
Author: lin334141-cell
The original log has no symbolic stack, so this report does not establish a separate upstream defect or prove exact duplication. The recorded process was a custom driver; it was not a standalone mlir-opt run.
Environment
- Associated LLVM/MLIR revision:
13c6abfac84fca4bc55c0721d1853ce86a385678. - Observed executable role: a custom driver that parses/verifies an MLIR module and extracts facts.
- Driver binary SHA-256:
1cd422f2411a363f4bb66c5cecdaaab883788ae0585bbe1ab83f728e93766f83. - No extra command-line arguments were present in the saved invocation; the program was supplied on stdin.
- Complete build flags and a verified mapping of the failing instruction to source are not available in this report.
Reproducer
A self-contained testcase and standalone reproduction recipe are not attached to this initial report. The saved input has SHA-256 4318b94ef744229107dfa79d43ca116fd36341ced7b96b6967acf46fb33a59ad.
It contains a vector.shuffle operation with non-vector typing and additional malformed structure. It is not presented as valid vector IR. No modified or reduced program is being substituted for the observed input.
Steps to reproduce
The saved execution passed that input through the custom parsing/verification driver described above. This historical sequence does not establish that a stock mlir-opt invocation takes the same path. No independent replay or post-fix execution of this exact driver/input combination has been performed for this report.
Actual behavior
The driver aborted with SIGABRT, signal 6 (subprocess return code -6), and its child was reaped. The diagnostic identified llvm::cast with To = mlir::VectorType and From = mlir::Type, followed by this assertion:
Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
There is no symbolic call stack in the saved stderr. The assertion line alone cannot identify the particular cast site or prove that the failure is wholly within upstream rather than an integration-specific path.
Expected behavior
If this execution reaches the ShuffleOp return-type-inference path addressed by #185714, a non-vector operand should be rejected with a handled diagnostic rather than an unchecked type cast. This expectation is conditional on the path attribution, which remains unresolved for the saved driver failure.
Analysis
Three different relationship claims should be kept separate:
- Related: #185587 and #185714 concern a matching operation/type-inference issue.
- Compatible same-mechanism explanation: the old operation definition uses type inference, its operand-list parsing precedes result inference, and the historical inference code contains the cast addressed by the fix. This supports an explanation consistent with the input and assertion.
- Exact duplicate or exact-input fix verified: neither is established by the available log. The driver lacks a saved call-site trace, and this exact input has not been checked on a post-fix binary.
I am asking whether maintainers consider the available source correspondence sufficient to associate this historical observation with #185587, or whether integration-specific evidence would be required first. It would be appropriate to mark this report related or duplicate if that relationship is established; I am not asserting an independent new root cause.
Related issues
- #185587:
vector::ShuffleOp::inferReturnTypescrash report. - #185714: validates operand typing during ShuffleOp return-type inference; merged on 2026-03-11 as
adfc1a95ad729b451f9163279f053248a1e17742.
The merged fix is an upstream fact, not a verification receipt for this exact driver/input combination. Current-main runtime behavior remains untested here.
Independent re-verification (historical-crash review)
We re-ran the original saved input (SHA-256 4318b94e…, unchanged) together with the #185714 regression sample on freshly built tools. Result: at 13c6abfac84fca4bc55c0721d1853ce86a385678 the original input does reach ShuffleOp::inferReturnTypes and aborts on the unchecked cast<VectorType>; on a tree containing #185714 the same bytes are rejected with a normal diagnostic. This supports treating the report as a duplicate of #185587, fixed by #185714.
Findings:
- Pre-fix rebuild of
13c6abfac8…(Release, assertions ON, macOS arm64): stockmlir-optaborts with SIGABRT andCasting.h:566: cast<Ty>() argument of incompatible typewhile parsing thevector.shuffleop. An lldb backtrace showsShuffleOp::parse→ShuffleOp::inferReturnTypes(theValueRangeoverload) → the uncheckedcast<VectorType>(adaptor.getV1().getType())present in that tree. The saved record names the same file and line for the same assertion. - The reference driver source published in this issue (SHA-256
d0bc516a…), rebuilt against the same revision's libraries, reproduces the same abort on the same bytes. This is a same-source rebuild, not the historical binary; that binary and its build manifest remain unavailable. - Isolation: the trigger is only the non-vector operand type. A review-added variant with a plain
tensor<4x4xf32>function argument as the shuffle operand (notensor.insert_slice, no undefined SSA names) aborts identically, so the undefined%c0/%c4/%c1names in the saved input are not part of the mechanism. - The minimal regression sample from #185714 (
vector.shuffle %a, %b [0] : i8, i8) aborts the same way at the pre-fix revision. - Post-fix: on a current-
mainbuild with assertions ON (revision61817b48e757…, LLVM 24.0.0git, tested 2026-10-29), both the original input and the official sample are rejected with the normal diagnostic added by #185714 —error: expected vector type, reported at the shuffle operand location — exit 1, no abort. - Side observation, not a defect claim:
llvmorg-22.1.6contains #140319 but does not contain #185714 (GitHub compare API:adfc1a95…is not an ancestor of the tag, and the tag's source still has the unchecked cast). On anllvmorg-22.1.6build the official sample therefore still aborts through the unfixed cast path — in that build, compiled without assertions, this surfaces asLLVM ERROR: SmallVector unable to growinstead of a cast assertion. This is the old pre-fix code on a release branch that predates the fix: it is not a post-fix regression and not a new defect. On that same build the original input is rejected at an earlier parse stage (custom op 'to' is unknown) and does not reach the unfixed inference.
Classification: HISTORICAL_DUPLICATE_FIXED_BY_185714 — same root cause as #185587, fixed by #185714; the original input does exercise the fixed call site. Detailed execution receipts are available upon request.
AI assistance was used to perform the tool runs and prepare this comment.