KhronosGroup / SPIRV-Tools

Apache License 2.0
1.03k stars 541 forks source link

spirv-opt --eliminate-dead-branches generates code that spirv-val rejects #2450

Open afd opened 5 years ago

afd commented 5 years ago

This archive contains files necessary to reproduce the problem

Generating SPIR-V from variant_136_reduced_final.frag using glslangValidator, and then optimizing it with the --eliminate-dead-branches option leads to SPIR-V that the validator rejects with:

error: line 34: block <ID> 23 branches to the selection construct, but not to the selection header <ID> 8
  %23 = OpLabel

Issue found using GraphicsFuzz.

alan-baker commented 5 years ago

The input to SPIR-V opt is invalid, though the validator doesn't catch it. The branch from 22 -> 9 is an illegal exit from the construct headed by 8.

in

alan-baker commented 5 years ago

Marking this as a validation issue.

afd commented 5 years ago

Thanks. In that case there must be another issue that led to spirv-opt (or glslangValidator) getting the SPIR-V into an invalid state. I'll have a look at the chain of shaders that led to this.