Closed
Description
When we lower arguments to calls we create PUTARG_*
nodes and insert them right after their corresponding argument definitions:
runtime/src/coreclr/jit/lower.cpp
Lines 1510 to 1511 in d06fb08
This insertion location does not make sense, since conceptually the definitions of the argument nodes can be arbitrarily far away from the call and there can even be interfering calls between the argument and consuming call.
The choice was probably made because the argument placement order is decided during morph when the call is in tree order, and the expectation is that args are placed in the early/late order decided there.
A few potential fixes:
- Insert
PUTARG
nodes during rationalization when we can depend on tree order and the early/late args call invariant. Seems to move something that is conceptually ABI lowering into rationalization which is unfortunate. - Insert the
PUTARG
nodes right before the call node. Unfortunately has large regressions. - Check for call interference between the arg and call and place the argument early on no interference and late on interference. Probably costs some TP.
- Move arg lowering from morph to lowering with appropriate interference checking (similar to what morph has to do today anyway). Probably best long term solution, but takes the most work.
cc @dotnet/jit-contrib