KhronosGroup / SPIRV-Tools

Apache License 2.0
1.05k stars 549 forks source link

spirv-opt generates code that spirv-val rejects: The continue construct with the continue target ... is not post dominated by the back-edge block ... #2454

Closed afd closed 4 years ago

afd commented 5 years ago

Files to reproduce problem

glsl_reduced.frag is a minimized GLSL shader. When compiled to SPIR-V with glslangValidator we get glsl_reduced.spv. I tried to further reduce this using spirv-reduce, but it failed due to a spirv-reduce bug, which I will report separately.

Doing:

spirv-opt glsl_reduced.spv --convert-local-access-chains --eliminate-local-singl e-store --eliminate-local-single-store --eliminate-dead-code-aggressive --copy-p ropagate-arrays --inline-entry-points-exhaustive --if-conversion --eliminate-loc al-single-store --scalar-replacement=100 --inline-entry-points-exhaustive --priv ate-to-local --ccp --eliminate-dead-branches --private-to-local --vector-dce --s calar-replacement=100 --merge-blocks --eliminate-dead-branches --eliminate-dead- branches --merge-return --scalar-replacement=100 --simplify-instructions --merge -blocks --private-to-local --inline-entry-points-exhaustive --eliminate-local-si ngle-block -o temp.spv

spirv-val temp.spv

should trigger the problem:

error: line 77: The continue construct with the continue target 46[%46] is not p ost dominated by the back-edge block 58[%58] %58 = OpLabel

I did not try to reduce the spirv-opt flags, in case (as with #2450) there may be an issue both with the optimizer generating invalid code and the validator not picking this up soon enough.

Found using GraphicsFuzz

alan-baker commented 5 years ago

Same underlying issue as #2433.