dead branch elim: Track killed backedges
authorDavid Neto <dneto@google.com>
Thu, 4 Jan 2018 23:52:38 +0000 (18:52 -0500)
committerDavid Neto <dneto@google.com>
Fri, 5 Jan 2018 00:06:55 +0000 (19:06 -0500)
commitac9a828e6ee296e4814064c3aecd9883a3db2a1d
tree226255f0876e5bea9ffc43b030a5ee4105907342
parentc32e79eeefe1554076c4e094a61aa9a98d97c540
dead branch elim: Track killed backedges

When deleting branches and blocks, also remove them from
the backedges set, in case they were there.

This prevents us from keeping stale pointers to deleted Instruction
objects.  That memory could be used later by another instruction,
incorrectly signaling that something has a backedge reference, and
the dead branch eliminator could end up deleting live blocks.

Adds accessor method ir::BasicBlock::terminator

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1168
source/opt/basic_block.h
source/opt/dead_branch_elim_pass.cpp