KhronosGroup / SPIRV-Tools

Apache License 2.0
1.05k stars 549 forks source link

opt: invalid SPIR-V produced: block <ID> 21[%21] exits the selection headed by <ID> 11[%11], but not via a structured exit #2710

Closed paulthomson closed 5 years ago

paulthomson commented 5 years ago

bug_report.zip

spiv-opt produces invalid SPIR-V. Output:

error: line 34: block <ID> 21[%21] exits the selection headed by <ID> 11[%11], but not via a structured exit
  %21 = OpLabel

error: line 0: Validation failed after pass merge-blocks

I manually checked the SPIR-V. I believe there is a branch to a continue target that also illegally exits a selection.

Tool versions:

To reproduce:

glslangValidator -V shader.frag -o shader.frag.spv

spirv-opt shader.frag.spv -o temp.spv --validate-after-all --reduce-load-size --scalar-replacement=100 --simplify-instructions --redundancy-elimination --merge-blocks

The following shader files are included in the attached archive:

Issue found using GraphicsFuzz.

paulthomson commented 5 years ago

This is not a bug. We apparently need to run --eliminate-dead-branches before --merge-blocks. We will update the fuzzer.