Move initialization of the const mgr to the constructor.
authorSteven Perron <stevenperron@google.com>
Fri, 12 Jan 2018 16:23:57 +0000 (11:23 -0500)
committerSteven Perron <stevenperron@google.com>
Fri, 12 Jan 2018 18:53:21 +0000 (13:53 -0500)
commit24f9947050d6e69bccc0061473216075980978e8
tree92fc11c4c37e9eb23e756dce7e52100c33eb9f0e
parent86dec646f55be4429eb509330588feb524d2b9cb
Move initialization of the const mgr to the constructor.

The current code expects the users of the constant manager to initialize
it with all of the constants in the module.  The problem is that you do
not want to redo the work multiple times.  So I decided to move that
code to the constructor of the constant manager.  This way it will
always be initialized on first use.

I also removed an assert that expects all constant instructions to be
successfully mapped.  This is because not all OpConstant* instruction
can map to a constant, and neither do the OpSpecConstant* instructions.

The real problem is that an OpConstantComposite can contain a member
that is OpUndef.  I tried to treat OpUndef like OpConstantNull, but this
failed because an OpSpecConstantComposite with an OpUndef cannot be
changed to an OpConstantComposite.  Since I feel this case will not be
common, I decided to not complicate the code.

Fixes #1193.
source/opt/ccp_pass.cpp
source/opt/constants.cpp
source/opt/constants.h
source/opt/instruction.h
test/opt/ccp_test.cpp