|
| 1 | +// RUN: %dxc -T cs_6_0 %s -fcgl | FileCheck %s |
| 2 | + |
| 3 | +// Compiling this HLSL used to trigger this assert: |
| 4 | +// |
| 5 | +// Error: assert(V[i]->getType() == Ty->getElementType() && "Wrong type in array element initializer") |
| 6 | +// File: |
| 7 | +// ..\..\third_party\dawn\third_party\dxc\lib\IR\Constants.cpp(886) |
| 8 | +// Func: static llvm::ConstantArray::getImpl |
| 9 | +// |
| 10 | +// Reported in https://github.com/microsoft/DirectXShaderCompiler/issues/5294 |
| 11 | +// |
| 12 | +// Bug was fixed in CGHLSLMSFinishCodeGen in BuildImmInit: when initializing an array, |
| 13 | +// if the init value type doesn't match the array element type, bail. We check that |
| 14 | +// a call to the global ctor function is called. |
| 15 | + |
| 16 | +// CHECK: define internal void @"\01??__EP@@YAXXZ"() #1 { |
| 17 | +// CHECK: store i32 0, i32* getelementptr inbounds ([4 x %struct.str], [4 x %struct.str]* @P, i32 0, i32 0, i32 0) |
| 18 | +// CHECK-NEXT: store i32 0, i32* getelementptr inbounds ([4 x %struct.str], [4 x %struct.str]* @P, i32 0, i32 1, i32 0) |
| 19 | +// CHECK-NEXT: store i32 0, i32* getelementptr inbounds ([4 x %struct.str], [4 x %struct.str]* @P, i32 0, i32 2, i32 0) |
| 20 | +// CHECK-NEXT: store i32 0, i32* getelementptr inbounds ([4 x %struct.str], [4 x %struct.str]* @P, i32 0, i32 3, i32 0) |
| 21 | +// CHECK-NEXT: ret void |
| 22 | +// CHECK-NEXT: } |
| 23 | +// |
| 24 | +// CHECK: define internal void @_GLOBAL__sub_I_construct_global_array_of_struct.hlsl() #1 { |
| 25 | +// CHECK: call void @"\01??__EP@@YAXXZ"() |
| 26 | +// CHECK-NEXT: ret void |
| 27 | +// CHECK-NEXT: } |
| 28 | + |
| 29 | +struct str { |
| 30 | + int i; |
| 31 | +}; |
| 32 | + |
| 33 | +str func(inout str pointer) { |
| 34 | + return pointer; |
| 35 | +} |
| 36 | + |
| 37 | +static str P[4] = (str[4])0; |
| 38 | + |
| 39 | +[numthreads(1, 1, 1)] |
| 40 | +void main() { |
| 41 | + const str r = func(P[2]); |
| 42 | + return; |
| 43 | +} |
0 commit comments