Mehdi Amini 1fdcad94b2
[MLIR][MemRefToLLVM] Fix crash in MemorySpaceCastOpLowering when type conversion fails (#186404)
`MemorySpaceCastOpLowering::matchAndRewrite` called
`cast<LLVMStructType>` on the result of
`typeConverter->convertType(resultType)` without checking whether the
conversion succeeded. When the destination memref has a non-integer
address space (e.g. `#gpu.address_space<workgroup>`), `convertType`
returns a null `Type`, and the subsequent `cast<>` dereferences a null
pointer, causing a crash.

Fix by checking the result of `convertType` and returning
`notifyMatchFailure` on failure, allowing the conversion framework to
produce a proper diagnostic instead of crashing.

Fixes #186041

Assisted-by: Claude Code
2026-03-13 15:42:11 +00:00
..