[Mlir-commits] [mlir] [mlir][spirv] Handle failed conversions of struct elements (PR #70005)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Oct 27 07:31:09 PDT 2023
================
@@ -207,21 +207,19 @@ convertStructTypeWithOffset(spirv::StructType type,
if (type != VulkanLayoutUtils::decorateType(type))
return std::nullopt;
- auto elementsVector = llvm::to_vector<8>(
- llvm::map_range(type.getElementTypes(), [&](Type elementType) {
- return converter.convertType(elementType);
- }));
+ SmallVector<Type> elementsVector;
+ if (failed(converter.convertTypes(type.getElementTypes(), elementsVector)))
+ return std::nullopt;
return LLVM::LLVMStructType::getLiteral(type.getContext(), elementsVector,
/*isPacked=*/false);
}
/// Converts SPIR-V struct with no offset to packed LLVM struct.
-static Type convertStructTypePacked(spirv::StructType type,
- LLVMTypeConverter &converter) {
- auto elementsVector = llvm::to_vector<8>(
- llvm::map_range(type.getElementTypes(), [&](Type elementType) {
- return converter.convertType(elementType);
- }));
+static std::optional<Type>
+convertStructTypePacked(spirv::StructType type, LLVMTypeConverter &converter) {
----------------
kuhar wrote:
I've just noticed this: it's already the convention to return `nullptr` when type conversion failed. Can we drop the `optional` and keep `Type` as the return value?
https://github.com/llvm/llvm-project/pull/70005
More information about the Mlir-commits
mailing list