SPIR-V: Aggressively prune unreachable merge, continue target
authorDavid Neto <dneto@google.com>
Mon, 21 Oct 2019 18:50:31 +0000 (14:50 -0400)
committerDavid Neto <dneto@google.com>
Tue, 29 Oct 2019 19:33:54 +0000 (15:33 -0400)
commit8c3d5b4b6cc784a4dcd7999977d32c2ef5ec51ed
tree2d4eeaae5ad9428028318a8edb23937b850192f8
parentb131630e7c749a5dc19faa458024260c71fb170f
SPIR-V: Aggressively prune unreachable merge, continue target

More aggressively prune unreachable code as follows.
When no control flow edges reach a merge block or continue target:
- delete their contents so that:
  - a merge block becomes OpLabel, then OpUnreachable
  - a continue target becomes OpLabel, then an OpBranch back to the
    loop header
- any basic block which is dominated by such a merge block or continue
  target is removed as well.
- decorations targeting the removed instructions are removed.

Enables the SPIR-V builder post-processing step the GLSLANG_WEB case.
44 files changed:
SPIRV/GlslangToSpv.cpp
SPIRV/InReadableOrder.cpp
SPIRV/SpvBuilder.h
SPIRV/SpvPostProcess.cpp
SPIRV/spvIR.h
StandAlone/StandAlone.cpp
Test/baseResults/hlsl.constantbuffer.frag.out
Test/baseResults/hlsl.doLoop.frag.out
Test/baseResults/hlsl.forLoop.frag.out
Test/baseResults/hlsl.if.frag.out
Test/baseResults/hlsl.structbuffer.coherent.frag.out
Test/baseResults/hlsl.structbuffer.frag.out
Test/baseResults/hlsl.structbuffer.rw.frag.out
Test/baseResults/hlsl.wavequery.frag.out
Test/baseResults/remap.similar_1a.everything.frag.out
Test/baseResults/remap.similar_1a.none.frag.out
Test/baseResults/remap.similar_1b.everything.frag.out
Test/baseResults/remap.similar_1b.none.frag.out
Test/baseResults/spv.controlFlowAttributes.frag.out
Test/baseResults/spv.dead-after-continue.vert.out [new file with mode: 0644]
Test/baseResults/spv.dead-after-discard.frag.out [new file with mode: 0644]
Test/baseResults/spv.dead-after-loop-break.vert.out [new file with mode: 0644]
Test/baseResults/spv.dead-after-return.vert.out [new file with mode: 0644]
Test/baseResults/spv.dead-after-switch-break.vert.out [new file with mode: 0644]
Test/baseResults/spv.dead-complex-continue-after-return.vert.out [new file with mode: 0644]
Test/baseResults/spv.dead-complex-merge-after-return.vert.out [new file with mode: 0644]
Test/baseResults/spv.earlyReturnDiscard.frag.out
Test/baseResults/spv.for-notest.vert.out
Test/baseResults/spv.forwardFun.frag.out
Test/baseResults/spv.functionCall.frag.out
Test/baseResults/spv.merge-unreachable.frag.out
Test/hlsl.doLoop.frag
Test/hlsl.forLoop.frag
Test/hlsl.if.frag
Test/spv.controlFlowAttributes.frag
Test/spv.dead-after-continue.vert [new file with mode: 0644]
Test/spv.dead-after-discard.frag [new file with mode: 0644]
Test/spv.dead-after-loop-break.vert [new file with mode: 0644]
Test/spv.dead-after-return.vert [new file with mode: 0644]
Test/spv.dead-after-switch-break.vert [new file with mode: 0644]
Test/spv.dead-complex-continue-after-return.vert [new file with mode: 0644]
Test/spv.dead-complex-merge-after-return.vert [new file with mode: 0644]
gtests/Spv.FromFile.cpp
gtests/TestFixture.h