Remove constants from constant manager in KillInst
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>
Thu, 15 Feb 2018 20:27:38 +0000 (12:27 -0800)
committerSteven Perron <stevenperron@google.com>
Sat, 17 Feb 2018 01:37:12 +0000 (20:37 -0500)
commit27d23a92a0e893aa60d9e93bc7a02204493cf70d
tree7fc0560932e65a4d2f5d5ee2bf8b1c388f60d5d7
parent50f307f88978180add62087ebc5172cf739f647d
Remove constants from constant manager in KillInst

Registering a constant in constant manager establishes a relation
between instruction that defined it and constant object. On complex
shaders this could result in the constant definition getting removed as
part of one of the DCE pass, and a subsequent simplification pass trying
to use the defining instruction for the constant.

To fix this, we now remove associated constant entries from constant
manager when killing constant instructions; the constant object is still
registered and can be remapped to a new instruction later.

GetDefiningInstruction shouldn't ever return nullptr after this change
so add an assertion to check for that.
source/opt/constants.cpp
source/opt/constants.h
source/opt/ir_context.cpp