Przeglądaj źródła

[spirv] Fix crashes in matrix casting for Release build (#1070)

Some method calls are wrapped in assert(), which gets removed
in Release build and results in some local variables not updated.
Lei Zhang 7 lat temu
rodzic
commit
39c8e337b1
1 zmienionych plików z 6 dodań i 8 usunięć
  1. 6 8
      tools/clang/lib/SPIRV/SPIRVEmitter.cpp

+ 6 - 8
tools/clang/lib/SPIRV/SPIRVEmitter.cpp

@@ -5574,10 +5574,9 @@ uint32_t SPIRVEmitter::castToInt(const uint32_t fromVal, QualType fromType,
       // The source matrix and the target matrix must have the same dimensions.
       QualType toElemType = {};
       uint32_t toNumRows = 0, toNumCols = 0;
-      assert(TypeTranslator::isMxNMatrix(toIntType, &toElemType, &toNumRows,
-                                         &toNumCols) &&
-             numRows == toNumRows && numCols == toNumCols);
-      (void)toElemType;
+      const bool isMat = TypeTranslator::isMxNMatrix(toIntType, &toElemType,
+                                                     &toNumRows, &toNumCols);
+      assert(isMat && numRows == toNumRows && numCols == toNumCols);
       (void)toNumRows;
       (void)toNumCols;
 
@@ -5636,10 +5635,9 @@ uint32_t SPIRVEmitter::castToFloat(const uint32_t fromVal, QualType fromType,
       // The source matrix and the target matrix must have the same dimensions.
       QualType toElemType = {};
       uint32_t toNumRows = 0, toNumCols = 0;
-      assert(TypeTranslator::isMxNMatrix(toFloatType, &toElemType, &toNumRows,
-                                         &toNumCols) &&
-             numRows == toNumRows && numCols == toNumCols);
-      (void)toElemType;
+      const auto isMat = TypeTranslator::isMxNMatrix(toFloatType, &toElemType,
+                                                     &toNumRows, &toNumCols);
+      assert(isMat && numRows == toNumRows && numCols == toNumCols);
       (void)toNumRows;
       (void)toNumCols;