Use AssertType in gvn
Summary:
gvn gives up if the SSATmp being replaced is a strict subtype of the
replacement. This is more conservative than necessary, while still
allowing a worse type for the replacement.
The correct check should be that the replacement is a (weak) subtype
of the SSATmp being replaced; and when that check fails, we can simply
insert an AssertType.
At the same time, partially fix a refcounting issue that gvn introduces.
Currently, for instructions that produce a reference, it adds an IncRef for
every use of a replaced SSATmp. At most, it needs one IncRef for every
def of a replaced SSATmp, and this diff makes it do that. This is still
incorrect - there may be paths from the original instruction which need
fewer IncRefs (eg due to side exits, or replacements on mutually exclusive
paths). The result is that we leak such values to the end of the request.
I'll follow up with a proper ref-counting fix.
Reviewed By: swtaarrs
Differential Revision:
D6647793
fbshipit-source-id:
d8479097d6b595c95ddc5e2e00f8c06002591dd1