DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] DXC crashes when declaring a variable in multiple case block

Open shobomaru opened this issue 1 year ago • 0 comments

Description LLVM assertion failed.

Steps to Reproduce dxc -T cs_6_0 -spirv path/to/file.hlsl

HLSL code:

uint Get(uint a)
{
        [branch]
        switch (a)
        {
        case 0: {
                uint d = a + 1;
                return a + 1;
        }
        case 1: {
                uint d1 = a + 2;
                return a + 2;
        }
        }
        return 0;
}

RWStructuredBuffer<uint> Out;
[numthreads(1, 1, 1)]
void main()
{
        uint a = Out[0];
        uint v = Get(a);
        Out[0] = v;
}

If change the code in one of the following ways, the issue is not occurred.

  • Remove [branch]
  • Remove uint d = a + 1; or uint d1 = a + 2; (in other words, only declaring one variable in the switch statement)

Actual Behavior

Assertion failed: (astDecls[var].instr == nullptr), function createFnVar, file DeclResultIdMapper.cpp, line 1106.

Environment

  • DXC version: libdxcompiler.dylib: 1.8(dev;4640-45018c75)
  • Host Operating System: Windows 11 23H2 and macOS 14.5

shobomaru avatar Jun 22 '24 18:06 shobomaru