Mandatorily remove non-DefConst constants in HHIR
commitd948b8fcb9d120afbbad5f26a74aa477caad99b0
authorRick Lavoie <rlavoie@fb.com>
Thu, 16 Sep 2021 04:38:16 +0000 (15 21:38 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 16 Sep 2021 04:40:18 +0000 (15 21:40 -0700)
tree7f13917bd21a5debaa2c4c917412eee1a1e44e4d
parent780f1b6fdcdffd7cccb0a3c3d2ae4488511c3af3
Mandatorily remove non-DefConst constants in HHIR

Summary:
In HHIR, a SSATmp can be a constant (hasConstVal() true), but it's
source is not a DefConst. An example would be a function call which is
known to return a constant.

We try to const-prop all of these non-DefConst constants. That is, any
instruction which takes one of these constants is changed instead to
take the DefConst equivalent. This is important, as a SSATmp constant
might not have any Vrefs defined (in the function call example, we
don't write to %rax if the return value is known). This can lead to
assertions being triggered.

The simplifier can perform this const-prop. However, it was failing to
retype dst SSATmp types, meaning it would miss some cases. Add a call
to retypeDests to fix this.

Also, in some situations we may not call the simplifier. In this case,
we still need to do this "mandatory propagation", so do so.

Reviewed By: oulgen

Differential Revision: D30905689

fbshipit-source-id: c1f35639950fb0bb926ad9b3b5d49e2ac3df177f
hphp/runtime/vm/jit/opt.cpp
hphp/runtime/vm/jit/simplify.cpp