JIT: look through GT_RET_EXPR when forming inline candidates
authorAndy Ayers <andya@microsoft.com>
Fri, 10 Nov 2017 01:07:12 +0000 (17:07 -0800)
committerAndy Ayers <andya@microsoft.com>
Tue, 14 Nov 2017 23:40:22 +0000 (15:40 -0800)
commitf1d3282f27009c9c213365f70f6ae2e5b69872a9
tree32854ca3e57c34f9418d58153ce02b8e222fc890
parent9369b2791ae0d3080651682d97ac116c271c7975
JIT: look through GT_RET_EXPR when forming inline candidates

If an inline candidate has args that come from calls that are inline
candidates, the arg trees for the candidate may be GT_RET_EXPRs. Since
the jit inlines in preorder, any arg inlines will have been resolved
by the time we get to the candidate. So, the jit can look back through
the GT_RET_EXPR to get a better handle on the actual arg tree.

Doing this has several small benefits:
* It short-circuits parts of the subsequent GT_RET_EXPR update and so
saves a little bit of throughput.
* It potentially allows for more streamlined arg passing since the actual
node side effects may be less constraining than the placeholder effects on
the GT_RET_EXPR (which must be "worst case").
* It may unblock inlines as actual arg values can be seen when evaluating
the candidate for profitability.

During testing I found cases where looking at the actual arg seemed to
degrade information. This turned out to be a misuse of `argHasLdargaOp`
to indicate that a caller-supplied argument was potentially locally
aliased.

This misuse was blocking type propagation when the actual arg tree was seen to
be an aliasable local reference instead of the formerly opaque GT_RET_EXPR.
To fix this, I split out the aliased arg case with a different flag. All
that the jit needs to ensure in the aliased case is that it does not directly
substitute the arg; the arg must be evaluated at the point of the call. The
type of the actual can safely propagate to the arg as long as the arg itself
is not modifiable.

Added a utility for walking back through GT_RET_EXPRs and updated the
other case where the jit was doing this to use the utility as well.

Closes #14174.
src/jit/flowgraph.cpp
src/jit/gentree.h
src/jit/importer.cpp
src/jit/inline.h