2
0
Эх сурвалжийг харах

Fix a misfiring assert due to unused static const involving matrix type (#3582)

Vishal Sharma 4 жил өмнө
parent
commit
6ad56561e2

+ 2 - 2
lib/HLSL/HLMatrixLowerPass.cpp

@@ -531,8 +531,8 @@ void HLMatrixLowerPass::replaceAllVariableUses(
     }
 
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Use.getUser())) {
-      DXASSERT(CE->getOpcode() == Instruction::AddrSpaceCast,
-               "Unexpected constant user");
+      DXASSERT(CE->getOpcode() == Instruction::AddrSpaceCast ||
+        CE->use_empty(), "Unexpected constant user");
       replaceAllVariableUses(GEPIdxStack, CE, LoweredPtr);
       DXASSERT_NOMSG(CE->use_empty());
       CE->destroyConstant();

+ 16 - 0
tools/clang/test/HLSLFileCheck/hlsl/types/matrix/unused_static_global_matrix_array.hlsl

@@ -0,0 +1,16 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// Regression test for github issue #3579
+
+// CHECK: define void @main
+
+
+cbuffer C
+{
+ float1x1 foo[1];
+}
+
+static const float1x1 bar[1] = foo;
+
+void main() {}
+