llvm-project
1f4074b7 - [mlir][llvm] Fix SROA crash on empty LLVM struct types (#184596)

Commit
1 day ago
[mlir][llvm] Fix SROA crash on empty LLVM struct types (#184596) When SROA runs on an alloca of an empty struct type (llvm.struct<()>), it crashes with: Assertion `\!subelementIndexMap->empty()' failed. The root cause is in LLVMStructType::getSubelementIndexMap(): for an empty struct (no body fields), the loop doesn't execute and an empty DenseMap is returned as a non-null optional. Later, getTypeAtIndex() asserts the map is non-empty, triggering the crash. Fix this by returning std::nullopt for empty structs, indicating they cannot be destructured. This is consistent with how LLVMArrayType handles the zero-element case. Fixes #108366
Author
Parents
Loading