SPIRV-Tools/source
Steven Perron 6c7885dbde
Change branch handling in ADCE to fix errors (#4596)
Consider the new test case.  The conditional branch in the continue
block is never marked as live.  However, `IsDead` will say it is not
dead, so it does not get deleted.  Because it was never marked as live,
`%false` was not mark as live either, but it gets deleted.  This results
in invalid code.

To fix this properly, we had to reconsider how branches are handle.  We
make the following changes:

1) Terminator instructions that are not branch or OpUnreachable must be
kept, so they are marked as live when initializing the worklist.

2) Branches and OpUnreachable instructions are marked as live if
  a) the block does not have a merge instruction and another instruction
     in the block is marked as live, or
  b) the merge instruction in the same block is marked as live.

3) Any instruction that is not marked as live is removed.

4) If a terminator is to be removed, an OpUnreachable is added.  This
happens when the entire block is dead, and the block will be removed.
The OpUnreachable is generated to make sure the block still has a
terminator, and is valid.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/4509.
2021-10-29 10:46:43 -04:00
..
fuzz Suppress protobuf warning (#4551) 2021-09-28 14:52:52 +00:00
link Fix Linker generator ID (#4601) 2021-10-29 10:32:41 -04:00
lint spirv-lint: Add lint based on divergence analysis (#4488) 2021-08-27 14:43:23 -04:00
opt Change branch handling in ADCE to fix errors (#4596) 2021-10-29 10:46:43 -04:00
reduce spirv-reduce: Eliminate skeletal structured control flow construct (#4360) 2021-07-06 07:14:36 +01:00
util fix parsing of bad binary exponents in hex floats (#4501) 2021-09-03 12:27:12 -04:00
val Only validate workgroup layout for explicit workgroup memory (#4542) 2021-10-28 16:27:56 -04:00
assembly_grammar.cpp Add validation for SPV_NV_cooperative_matrix (#2404) 2019-02-25 17:43:11 -05:00
assembly_grammar.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
binary.cpp spirv-val: Fix ubsan error (#4505) 2021-09-07 15:37:40 -04:00
binary.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
cfa.h Avoid copying a ref in a loop (#4000) 2020-10-29 09:20:45 -04:00
CMakeLists.txt spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493) 2021-09-15 14:38:53 -04:00
common_debug_info.h spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493) 2021-09-15 14:38:53 -04:00
diagnostic.cpp fix strncpy bound error (#4331) 2021-06-29 10:07:13 -04:00
diagnostic.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
disassemble.cpp Initial support for SPV_KHR_integer_dot_product (#4327) 2021-06-23 13:32:24 -04:00
disassemble.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
enum_set.h Instrument: Debug Printf support (#3215) 2020-03-12 09:19:52 -04:00
enum_string_mapping.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
enum_string_mapping.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
ext_inst.cpp spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493) 2021-09-15 14:38:53 -04:00
ext_inst.h Handle conflict between debug info and existing validation rule (#3104) 2020-01-23 17:04:30 -05:00
extensions.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
extensions.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
instruction.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
latest_version_glsl_std_450_header.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
latest_version_opencl_std_header.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
latest_version_spirv_header.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
libspirv.cpp Remove WebGPU support (#4108) 2021-01-14 16:45:18 -05:00
macro.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
name_mapper.cpp Update some language usage. (#3611) 2020-07-29 13:50:58 -04:00
name_mapper.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
opcode.cpp Add validation for SPV_EXT_shader_atomic_float_min_max (#4105) 2021-03-24 08:49:21 -04:00
opcode.h Take new (raytracing) termination instructions into account. (#4050) 2020-12-07 10:26:05 -05:00
operand.cpp spirv-opt: Switch from Vulkan.DebugInfo to Shader.DebugInfo (#4493) 2021-09-15 14:38:53 -04:00
operand.h Handle conflict between debug info and existing validation rule (#3104) 2020-01-23 17:04:30 -05:00
parsed_operand.cpp Replace asserts with returns 2018-08-08 15:13:04 -04:00
parsed_operand.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
pch_source.cpp Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
pch_source.h Enable precompiled headers for spirv-tools(-shared) and some unit tests (#2026) 2018-11-06 09:26:23 -05:00
print.cpp Enabled tvOS platform (#4329) 2021-06-29 15:14:38 -04:00
print.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
software_version.cpp Add missing function parameters in libspirv.h 2018-04-03 10:10:43 -04:00
spirv_constant.h Fix Linker generator ID (#4601) 2021-10-29 10:32:41 -04:00
spirv_definition.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
spirv_endian.cpp Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00
spirv_endian.h Rewrite include guards (#1793) 2018-08-03 08:05:33 -04:00
spirv_fuzzer_options.cpp spirv-fuzz: Add pass recommendations (#3757) 2020-09-18 15:51:35 +01:00
spirv_fuzzer_options.h spirv-fuzz: Add pass recommendations (#3757) 2020-09-18 15:51:35 +01:00
spirv_optimizer_options.cpp Add —preserve-bindings and —preserve-spec-constants (#2693) 2019-07-10 14:12:19 -04:00
spirv_optimizer_options.h Add —preserve-bindings and —preserve-spec-constants (#2693) 2019-07-10 14:12:19 -04:00
spirv_reducer_options.cpp spirv-reduce: Support reducing a specific function (#3774) 2020-09-11 06:29:43 +01:00
spirv_reducer_options.h spirv-reduce: Support reducing a specific function (#3774) 2020-09-11 06:29:43 +01:00
spirv_target_env.cpp Include a maximum value for spv_target_env (#4559) 2021-10-06 14:50:12 +00:00
spirv_target_env.h Stop consuming input in fuzzers to select target environment (#4544) 2021-10-04 13:42:12 -04:00
spirv_validator_options.cpp Add a feature for allowing LocalSizeId (#4492) 2021-08-26 14:33:19 -04:00
spirv_validator_options.h Add a feature for allowing LocalSizeId (#4492) 2021-08-26 14:33:19 -04:00
table.cpp Remove WebGPU support (#4108) 2021-01-14 16:45:18 -05:00
table.h Use last version (#2578) 2019-05-10 11:02:01 -04:00
text_handler.cpp Avoid implicit fallthrough, by duplicating code (#4556) 2021-10-01 08:43:59 -04:00
text_handler.h Remove source/message.h (#1838) 2018-08-14 15:41:21 -04:00
text.cpp Support OpenCL.DebugInfo.100 extended instruction set (#3080) 2019-12-19 17:16:26 -05:00
text.h Cleanup includes. (#1795) 2018-08-03 15:06:09 -04:00