SPIRV-Tools/source/opt
Steven Perron 93c4c184d5 Handle types with self references.
By using forward pointers, we are able to define a struct that has a
pointer to itself.  This could be directly or indirectly.  The current
implementation of the type manager did not handle this case.  There are
three changes that are made in this commit inorder to handle this case:

1) Change the handling of OpTypeForwardPointer

The current handling of OpTypeForwardsPointer is broken if there is a
reference to the pointer before the real definition.  When build the
type that contain the forward delared pointer, the type manager will ask
for the type for that ID, and will get a nullptr because it does not
exists.  This nullptr is not handleded very well.

The change is to keep track of the incomplete types the first time
through all of the types.  An incomplete type is a ForwardPointer or any
type that references an incomplete type.

Then we implement a second pass through the incomplete types that will
complete them.

2) Hashing types.

When hashing a type, we want to uses all of the subtypes as part of the
hash.  However, with types that reference them selves, this creates an
infinite recursion.  To get around this, we keep track of which types
have been seen on the path from the root type.  If we have see the
current type already then we can stop the recursion.

3) Comparing types.

In order to check if two types are the same, we must check that all of
their subtypes are the same as well.  This also causes an infinit
recursion.  The solution is to stop comparing the subtypes if we are
trying to compare two pointer types that we are already in the middle of
comparing.  The ideas is that if the two pointer are different, then in
progress compare will return false itself.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1578.
2018-05-30 15:48:38 -04:00
..
aggressive_dead_code_elim_pass.cpp Get ADCE to handle OpCopyMemory 2018-05-16 13:50:47 -04:00
aggressive_dead_code_elim_pass.h Use a bit vector in ADCE 2018-04-13 16:38:02 -04:00
basic_block.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
basic_block.h Add register liveness analysis. 2018-04-20 09:45:15 -04:00
block_merge_pass.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
block_merge_pass.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
build_module.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
build_module.h Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
ccp_pass.cpp Fixes #1361. Mark all non-constant global values as varying in CCP 2018-03-01 15:24:41 -05:00
ccp_pass.h Fix constant propagation of induction variables. 2018-01-08 15:34:35 -05:00
cfg_cleanup_pass.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
cfg_cleanup_pass.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
cfg.cpp Add register liveness analysis. 2018-04-20 09:45:15 -04:00
cfg.h Add register liveness analysis. 2018-04-20 09:45:15 -04:00
CMakeLists.txt Add pass to fold a load feeding an extract. 2018-05-14 15:40:34 -04:00
common_uniform_elim_pass.cpp Fix broken pointer of CommonUniformElimPass 2018-04-19 09:36:10 -04:00
common_uniform_elim_pass.h Fix broken pointer of CommonUniformElimPass 2018-04-19 09:36:10 -04:00
compact_ids_pass.cpp Add a new constant manager class. 2017-12-08 14:14:55 -05:00
compact_ids_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
composite.cpp InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
composite.h InsertExtractElim: Split out DeadInsertElim as separate pass 2018-01-30 08:52:14 -05:00
const_folding_rules.cpp Fold fclamp feeding compare. 2018-05-14 10:27:49 -04:00
const_folding_rules.h Consistently include latest spirv.h header file. 2018-02-27 18:47:29 -05:00
constants.cpp Fold fclamp feeding compare. 2018-05-14 10:27:49 -04:00
constants.h Fold fclamp feeding compare. 2018-05-14 10:27:49 -04:00
copy_prop_arrays.cpp Handle types with self references. 2018-05-30 15:48:38 -04:00
copy_prop_arrays.h In copy-prop-arrays, indentify copies via OpCompositeInsert 2018-03-29 09:39:55 -04:00
dead_branch_elim_pass.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
dead_branch_elim_pass.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
dead_insert_elim_pass.cpp DeadInsertElim: Don't revisit select phi nodes during MarkInsertChain 2018-04-19 14:40:00 -04:00
dead_insert_elim_pass.h DeadInsertElim: Don't revisit select phi nodes during MarkInsertChain 2018-04-19 14:40:00 -04:00
dead_variable_elimination.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
dead_variable_elimination.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
decoration_manager.cpp Teach DecorationManager about OpDecorateStringGOOGLE 2018-03-13 22:18:33 -04:00
decoration_manager.h Reimplement the DecorationManager 2018-03-12 09:56:14 -04:00
def_use_manager.cpp Fixed remaining review comments from #1380 2018-03-21 16:47:01 -04:00
def_use_manager.h Add folding of OpCompositeExtract and OpConstantComposite constant instructions. 2018-02-09 17:52:33 -05:00
dominator_analysis.cpp Rewrite local-single-store-elim to not create large data structures. 2018-04-18 16:38:18 -04:00
dominator_analysis.h Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
dominator_tree.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
dominator_tree.h Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
eliminate_dead_constant_pass.cpp Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
eliminate_dead_constant_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
eliminate_dead_functions_pass.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
eliminate_dead_functions_pass.h Have all MemPasses preserve the def-use manager. 2017-11-10 11:17:12 -05:00
feature_manager.cpp Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
feature_manager.h Add folding for redundant add/sub/mul/div/mix operations 2018-02-20 18:29:27 -05:00
flatten_decoration_pass.cpp Adding an unique id to Instruction generated by IRContext 2017-11-20 17:49:10 -05:00
flatten_decoration_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
fold_spec_constant_op_and_composite_pass.cpp Implement SSA CCP (SSA Conditional Constant Propagation). 2017-12-21 14:29:45 -05:00
fold_spec_constant_op_and_composite_pass.h Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
fold.cpp Merge arithmetic with non-trivial constant operands 2018-02-27 13:02:13 -05:00
fold.h Get CCP to use the constant floating point rules. 2018-02-16 13:49:47 -05:00
folding_rules.cpp Fold FMix feeding Extract, and use the simplification pass. 2018-05-25 14:42:59 -04:00
folding_rules.h Add folding of OpCompositeExtract and OpConstantComposite constant instructions. 2018-02-09 17:52:33 -05:00
freeze_spec_constant_value_pass.cpp Replace calls to ToNop by KillInst. 2018-01-04 11:03:04 -05:00
freeze_spec_constant_value_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
function.cpp SSA rewrite pass. 2018-03-20 20:56:55 -04:00
function.h Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
if_conversion.cpp Allow hoisting code in if-conversion. 2018-05-04 12:56:29 -04:00
if_conversion.h Allow hoisting code in if-conversion. 2018-05-04 12:56:29 -04:00
inline_exhaustive_pass.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
inline_exhaustive_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
inline_opaque_pass.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
inline_opaque_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
inline_pass.cpp Fixes handling of kill and unreachable ops in inlining. 2018-04-27 09:42:37 -04:00
inline_pass.h Reimplement the DecorationManager 2018-03-12 09:56:14 -04:00
insert_extract_elim.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
insert_extract_elim.h Remove extension whitelist from some transforms 2018-03-08 12:25:49 -05:00
instruction_list.cpp Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
instruction_list.h Refactor include of latest spir-v header versions 2017-12-14 11:18:20 -05:00
instruction.cpp Allow ADCE to remove more instructions. 2018-05-05 09:15:28 -04:00
instruction.h Allow ADCE to remove more instructions. 2018-05-05 09:15:28 -04:00
ir_builder.h Add pass to fold a load feeding an extract. 2018-05-14 15:40:34 -04:00
ir_context.cpp Allow ADCE to remove more instructions. 2018-05-05 09:15:28 -04:00
ir_context.h Allow hoisting code in if-conversion. 2018-05-04 12:56:29 -04:00
ir_loader.cpp Fixed typo that leaked to the binary 2017-12-03 20:42:14 -05:00
ir_loader.h Adding an unique id to Instruction generated by IRContext 2017-11-20 17:49:10 -05:00
iterator.h Add register liveness analysis. 2018-04-20 09:45:15 -04:00
licm_pass.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
licm_pass.h Loop invariant code motion initial implementation 2018-02-08 22:55:47 -05:00
local_access_chain_convert_pass.cpp Optimizer: update extension whitelists 2018-04-06 15:56:20 -04:00
local_access_chain_convert_pass.h Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
local_redundancy_elimination.cpp Capturing value table by reference in local redundancy elim 2018-01-17 09:58:32 -05:00
local_redundancy_elimination.h Add id to name map 2018-02-14 15:53:13 -05:00
local_single_block_elim_pass.cpp Remove redundant stores. 2018-05-15 10:24:05 -04:00
local_single_block_elim_pass.h Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
local_single_store_elim_pass.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
local_single_store_elim_pass.h Rewrite local-single-store-elim to not create large data structures. 2018-04-18 16:38:18 -04:00
local_ssa_elim_pass.cpp Optimizer: update extension whitelists 2018-04-06 15:56:20 -04:00
local_ssa_elim_pass.h Remove uses DCEInst and call ADCE 2018-02-27 21:06:08 -05:00
log.h Avoid snprintf warning in GCC 7.1 2017-05-08 15:58:24 -04:00
loop_dependence_helpers.cpp Fix for old XCode: std::set has explicit ctor 2018-04-19 16:33:12 -04:00
loop_dependence.cpp Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
loop_dependence.h Add support for MIV and Delta test dependence analysis. 2018-04-17 13:57:02 -04:00
loop_descriptor.cpp Add GetContinueBlock to loop class. 2018-05-03 14:30:41 -04:00
loop_descriptor.h Add GetContinueBlock to loop class. 2018-05-03 14:30:41 -04:00
loop_fission.cpp Support loop fission. 2018-05-01 15:15:10 -04:00
loop_fission.h Support loop fission. 2018-05-01 15:15:10 -04:00
loop_fusion_pass.cpp Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
loop_fusion_pass.h Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
loop_fusion.cpp Add GetContinueBlock to loop class. 2018-05-03 14:30:41 -04:00
loop_fusion.h Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
loop_peeling.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
loop_peeling.h Add a loop peeling pass. 2018-04-11 15:41:29 +01:00
loop_unroller.cpp Add GetContinueBlock to loop class. 2018-05-03 14:30:41 -04:00
loop_unroller.h Unroller support for multiple induction variables 2018-02-27 11:50:08 +00:00
loop_unswitch_pass.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
loop_unswitch_pass.h Add loop unswitch pass. 2018-02-27 08:52:46 -05:00
loop_utils.cpp Add GetContinueBlock to loop class. 2018-05-03 14:30:41 -04:00
loop_utils.h Support loop fission. 2018-05-01 15:15:10 -04:00
make_unique.h Relicense SPIRV-Tools under Apache 2.0 2016-09-02 10:00:29 -04:00
mem_pass.cpp Change parameter to Mempass::RemovePhiOperands 2018-04-13 09:53:37 -04:00
mem_pass.h Change parameter to Mempass::RemovePhiOperands 2018-04-13 09:53:37 -04:00
merge_return_pass.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
merge_return_pass.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
module.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
module.h Adding ostream operators for IR structures 2018-01-12 11:19:58 -05:00
null_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
optimizer.cpp Fold FMix feeding Extract, and use the simplification pass. 2018-05-25 14:42:59 -04:00
pass_manager.cpp Don't allow an instance of a pass to be run multiple times. 2018-04-11 12:02:30 -04:00
pass_manager.h Add --time-report to spirv-opt 2018-03-20 21:30:06 -04:00
pass.cpp Don't allow an instance of a pass to be run multiple times. 2018-04-11 12:02:30 -04:00
pass.h Don't allow an instance of a pass to be run multiple times. 2018-04-11 12:02:30 -04:00
passes.h Add pass to fold a load feeding an extract. 2018-05-14 15:40:34 -04:00
private_to_local_pass.cpp Teach the private to local about OpImageTexelPointer. 2018-04-04 13:42:35 -04:00
private_to_local_pass.h Add id to name map 2018-02-14 15:53:13 -05:00
propagator.cpp Fixes #1300. Adding checks for bad CCP transitions and unsettled values 2018-02-18 19:41:34 -05:00
propagator.h Fixes #1300. Adding checks for bad CCP transitions and unsettled values 2018-02-18 19:41:34 -05:00
reduce_load_size.cpp Fix getting operand without checking opcode. 2018-05-16 09:34:43 -04:00
reduce_load_size.h Add pass to fold a load feeding an extract. 2018-05-14 15:40:34 -04:00
redundancy_elimination.cpp Dominator analysis interface clean. 2018-04-20 15:41:59 -04:00
redundancy_elimination.h Add global redundancy elimination 2017-12-07 18:35:38 -05:00
reflect.h Support SPV_GOOGLE_decorate_string and SPV_GOOGLE_hlsl_functionality1 2018-03-05 13:34:13 -05:00
register_pressure.cpp Add register liveness analysis. 2018-04-20 09:45:15 -04:00
register_pressure.h Add register liveness analysis. 2018-04-20 09:45:15 -04:00
remove_duplicates_pass.cpp Avoid generating duplicate names when merging types 2018-03-05 12:02:50 -05:00
remove_duplicates_pass.h Linker code cleanups 2018-01-05 13:28:44 -05:00
replace_invalid_opc.cpp Add pass to reaplce invalid opcodes 2018-02-01 15:25:09 -05:00
replace_invalid_opc.h Add pass to reaplce invalid opcodes 2018-02-01 15:25:09 -05:00
scalar_analysis_nodes.h ZIV and SIV loop dependence analysis. 2018-04-11 09:32:42 -04:00
scalar_analysis_simplification.cpp Initial patch for scalar evolution analysis 2018-03-28 16:34:23 -04:00
scalar_analysis.cpp Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
scalar_analysis.h Add a loop fusion pass. 2018-05-01 15:40:37 -04:00
scalar_replacement_pass.cpp Remove the limit on struct size in SROA. 2018-05-18 10:03:46 -04:00
scalar_replacement_pass.h Remove the limit on struct size in SROA. 2018-05-18 10:03:46 -04:00
set_spec_constant_default_value_pass.cpp Fixes compile errors generated with -Wpedantic 2018-03-22 09:40:11 -04:00
set_spec_constant_default_value_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
simplification_pass.cpp Fold binary floating point operators. 2018-02-14 15:48:15 -05:00
simplification_pass.h Preserve analysies in the simplification pass 2018-02-22 16:06:30 -05:00
ssa_rewrite_pass.cpp Fix SSA rewrite for nested loops. 2018-04-06 15:17:52 -04:00
ssa_rewrite_pass.h Fix VS2013 build failures. 2018-03-20 21:44:17 -04:00
strength_reduction_pass.cpp Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
strength_reduction_pass.h Improving the usability of the type manager. The type manager hashes 2017-12-18 08:20:56 -05:00
strip_debug_info_pass.cpp Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
strip_debug_info_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
strip_reflect_info_pass.cpp Add --strip-reflect pass 2018-03-15 21:20:42 -04:00
strip_reflect_info_pass.h Add --strip-reflect pass 2018-03-15 21:20:42 -04:00
tree_iterator.h Add loop descriptors and some required dominator tree extensions. 2018-01-08 09:31:13 -05:00
type_manager.cpp Handle types with self references. 2018-05-30 15:48:38 -04:00
type_manager.h Handle types with self references. 2018-05-30 15:48:38 -04:00
types.cpp Handle types with self references. 2018-05-30 15:48:38 -04:00
types.h Handle types with self references. 2018-05-30 15:48:38 -04:00
unify_const_pass.cpp Change IRContext::KillInst to delete instructions. 2017-12-04 11:07:45 -05:00
unify_const_pass.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
value_number_table.cpp Allow hoisting code in if-conversion. 2018-05-04 12:56:29 -04:00
value_number_table.h Allow hoisting code in if-conversion. 2018-05-04 12:56:29 -04:00
vector_dce.cpp Improve Vector DCE 2018-04-30 11:55:50 -04:00
vector_dce.h Improve Vector DCE 2018-04-30 11:55:50 -04:00
workaround1209.cpp Create a pass to work around a driver bug related to OpUnreachable. 2018-01-18 20:31:46 -05:00
workaround1209.h Create a pass to work around a driver bug related to OpUnreachable. 2018-01-18 20:31:46 -05:00