[Mlir-commits] [mlir] [mlir][spirv] Handle failed conversions of struct elements (PR #70005)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 24 00:16:49 PDT 2023


github-actions[bot] wrote:


<!--LLVM CODE FORMAT COMMENT: {clang-format}-->

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 3fe2be75c0707d3e386fdf96aec1deb69828ae74 4020ea59189025f5b681a381ca7444f9da414979 -- mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index 5f752765f6d7..87acca4cb281 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -199,9 +199,11 @@ static Value processCountOrOffset(Location loc, Value value, Type srcType,
   return optionallyTruncateOrExtend(loc, broadcasted, dstType, rewriter);
 }
 
-static bool convertTypes(LLVMTypeConverter &converter, const spirv::StructType::ElementTypeRange &types, SmallVectorImpl<Type> &out) {
-  for(const auto &type: types) {
-    if(auto convertedType = converter.convertType(type))
+static bool convertTypes(LLVMTypeConverter &converter,
+                         const spirv::StructType::ElementTypeRange &types,
+                         SmallVectorImpl<Type> &out) {
+  for (const auto &type : types) {
+    if (auto convertedType = converter.convertType(type))
       out.push_back(convertedType);
     else
       return false;
@@ -218,17 +220,17 @@ convertStructTypeWithOffset(spirv::StructType type,
     return std::nullopt;
 
   SmallVector<Type> elementsVector;
-  if(!convertTypes(converter, type.getElementTypes(), elementsVector))
+  if (!convertTypes(converter, 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 std::optional<Type> convertStructTypePacked(spirv::StructType type,
-                                    LLVMTypeConverter &converter) {
+static std::optional<Type>
+convertStructTypePacked(spirv::StructType type, LLVMTypeConverter &converter) {
   SmallVector<Type> elementsVector;
-  if(!convertTypes(converter, type.getElementTypes(), elementsVector))
+  if (!convertTypes(converter, type.getElementTypes(), elementsVector))
     return std::nullopt;
   return LLVM::LLVMStructType::getLiteral(type.getContext(), elementsVector,
                                           /*isPacked=*/true);

``````````

</details>


https://github.com/llvm/llvm-project/pull/70005


More information about the Mlir-commits mailing list