Adding new def -> use mapping container
authorAlan Baker <alanbaker@google.com>
Tue, 14 Nov 2017 19:11:50 +0000 (14:11 -0500)
committerDavid Neto <dneto@google.com>
Thu, 23 Nov 2017 21:40:02 +0000 (16:40 -0500)
commit746bfd210adaf43ab16590d7226a95686b42e107
treed2f6cc87c9f692343fdd7f09bcbd31f32febed55
parentb02c9a58023da4b3a860294ca69d701d0bd203c4
Adding new def -> use mapping container

Replaced representation of uses

* Changed uses from unordered_map<uint32_t, UseList> to
set<pairInstruction*, Instruction*>>
* Replaced GetUses with ForEachUser and ForEachUse functions
* updated passes to use new functions
* partially updated tests
* lots of cleanup still todo

Adding an unique id to Instruction generated by IRContext

Each instruction is given an unique id that can be used for ordering
purposes. The ids are generated via the IRContext.

Major changes:
* Instructions now contain a uint32_t for unique id and a cached context
pointer
 * Most constructors have been modified to take a context as input
 * unfortunately I cannot remove the default and copy constructors, but
 developers should avoid these
* Added accessors to parents of basic block and function
* Removed the copy constructors for BasicBlock and Function and replaced
them with Clone functions
* Reworked BuildModule to return an IRContext owning the built module
 * Since all instructions require a context, the context now becomes the
basic unit for IR
* Added a constructor to context to create an owned module internally
* Replaced uses of Instruction's copy constructor with Clone whereever I
found them
* Reworked the linker functionality to perform clones into a different
context instead of moves
* Updated many tests to be consistent with the above changes
 * Still need to add new tests to cover added functionality
* Added comparison operators to Instruction

Adding tests for Instruction, IRContext and IR loading

Fixed some header comments for BuildModule

Fixes to get tests passing again

* Reordered two linker steps to avoid use/def problems
* Fixed def/use manager uses in merge return pass
* Added early return for GetAnnotations
* Changed uses of Instruction::ToNop in passes to IRContext::KillInst

Simplifying the uses for some contexts in passes
26 files changed:
source/link/linker.cpp
source/opt/aggressive_dead_code_elim_pass.cpp
source/opt/block_merge_pass.cpp
source/opt/common_uniform_elim_pass.cpp
source/opt/dead_branch_elim_pass.cpp
source/opt/dead_variable_elimination.cpp
source/opt/decoration_manager.cpp
source/opt/def_use_manager.cpp
source/opt/def_use_manager.h
source/opt/eliminate_dead_constant_pass.cpp
source/opt/inline_pass.cpp
source/opt/instruction.h
source/opt/ir_context.cpp
source/opt/ir_context.h
source/opt/local_access_chain_convert_pass.cpp
source/opt/local_single_block_elim_pass.cpp
source/opt/local_single_store_elim_pass.cpp
source/opt/mem_pass.cpp
source/opt/merge_return_pass.cpp
source/opt/set_spec_constant_default_value_pass.cpp
source/opt/strength_reduction_pass.cpp
test/link/entry_points_test.cpp
test/link/global_values_amount_test.cpp
test/opt/def_use_test.cpp
test/opt/ir_context_test.cpp
test/opt/set_spec_const_default_value_test.cpp