Skip to content

[SpirvOpt] --eliminate-dead-code-aggressive causes a crash when DebugBuildIdentifier is used #6619

@jkwak-work

Description

@jkwak-work

When DebugBuildIdentifier is used with a SpirvOpt option, --eliminate-dead-code-aggressive, it causes a crash in Release build; or fails an assertion in Debug build.

Here is the repro SpirvCode:

$ cat dump.2.spv-asm
               OpCapability RayTracingKHR
               OpCapability Shader
               OpExtension "SPV_KHR_non_semantic_info"
               OpExtension "SPV_KHR_ray_tracing"
         %15 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
               OpMemoryModel Logical GLSL450
               OpEntryPoint MissKHR %jkwak_1 "main" %c_pi %c_twoPi
         %18 = OpString "01cfb4b77c321225f096da8ac72f29d42f0632a7"
               OpSource Slang 1
       %void = OpTypeVoid
       %uint = OpTypeInt 32 0
     %uint_0 = OpConstant %uint 0
         %22 = OpTypeFunction %void
      %float = OpTypeFloat 32
%_ptr_Private_float = OpTypePointer Private %float
%float_3_14159274 = OpConstant %float 3.14159274
%float_6_28318548 = OpConstant %float 6.28318548
         %17 = OpExtInst %void %15 DebugBuildIdentifier %18 %uint_0
       %c_pi = OpVariable %_ptr_Private_float Private
    %c_twoPi = OpVariable %_ptr_Private_float Private
%jkwak_1 = OpFunction %void None %22
         %23 = OpLabel
               OpStore %c_pi %float_3_14159274
               OpStore %c_twoPi %float_6_28318548
               OpReturn
               OpFunctionEnd

Then I compiled it to Spirv binary:

$ /c/vulkan-sdk-1.4.341/Debug/spirv-as.exe dump.2.spv-asm -o dump.2.spv-asm.spv
$ /c/vulkan-sdk-1.4.341/Debug/spirv-val.exe dump.2.spv-asm.spv && echo Good
Good

Then I ran spirv-opt with the option --eliminate-dead-code-aggressive:

$ /c/vulkan-sdk-1.4.341/Debug/spirv-opt.exe dump.2.spv-asm.spv -o dump.2.opt.spv --eliminate-dead-code-aggressive
Assertion failed: def && "Definition is not registered.", file D:\sbf\git\SPIRV-Tools\source\opt\def_use_manager.cpp, line 56

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions