[Mlir-commits] [mlir] [mlir] Avoid verifying live user in conversion diagnostic (PR #210566)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 22 13:54:41 PDT 2026
qyingwu wrote:
@matthias-springer @joker-eph
Thanks! I dug further and I think you were right that the fix belongs in the verifier.
The crash happens while reporting the unresolved materialization diagnostic, but the actual bad dereference is in the SPIR-V verifier:
```text
legalizeUnresolvedMaterialization
-> Diagnostic::operator<<(Operation *)
-> Operation::print
-> AsmState::AsmState
-> verifyOpAndAdjustFlags
-> mlir::verify
-> spirv::FuncOp::verifyBody
-> retOp.getValue().getType()
```
The relevant backtrace frames are:
frame #3 mlir::detail::ValueImpl::getType(this=0x0)
frame #4 mlir::Value::getType()
frame #5 mlir::spirv::FuncOp::verifyBody() at SPIRVOps.cpp:1229
frame #30 verifyOpAndAdjustFlags at AsmPrinter.cpp:2113
frame #34 mlir::Diagnostic::appendOp
frame #37 legalizeUnresolvedMaterialization at DialectConversion.cpp:3395
frame #38 mlir::OperationConverter::applyConversion
So the failed conversion leaves a malformed spirv.ReturnValue with a missing/null operand, and diagnostic printing triggers verification of that IR. The patch now makes spirv::FuncOp::verifyBody() diagnose the missing return value before reading its type, and removes the dialect-conversion printing workaround.
I also reran:
`build/bin/llvm-lit -v mlir/test/Transforms/test-legalize-erased-op-with-uses.mlir`
It passes after the current fix.
https://github.com/llvm/llvm-project/pull/210566
More information about the Mlir-commits
mailing list