Description
This issue captures the planned work items for .NET 9 with respect to struct improvements. This list is expected to change throughout the release cycle according to ongoing planning and discussions, with possible additions and subtractions to the scope.
Expanding the scope of physical promotion
.NET 8 added physical promotion, which removes many of the limitations of the existing promotion pass. Physical promotion has the following pros over the regular promotion pass:
- It can partially promote only the struct fields that are used in the function
- It can promote structs with arbitrary number of fields
- It supports recursive promotion of structs
- Physically promoted fields are always normalize-on-load
- Physically promoted fields can always be enregistered; it does not have the notion of dependent promotion
Long term, we would like physical promotion to replace the regular promotion pass entirely. We do NOT expect this to happen in .NET 9. However, we do expect to make progress towards this goal in .NET 9.
ABI handling
The main limitation that stops physical promotion from replacing regular promotion is currently that it lacks the support around ABI boundaries that regular promotion has. This comes out of the fact that our multireg support is tied very directly into the existing promotion mechanism.
Thus, we expect to work on some of the following items in .NET 9:
- ('24) Support producing FIELD_LIST in physical promotion for call arguments, allowing physically promoted arguments to stay in registers (JIT: Transform multi-reg args to FIELD_LIST in physical promotion #104370)
- ('24) Support producing FIELD_LIST in physical promotion for returned values, allowing physically promoted return values to stay in registers (JIT: More elaborate store forwarding patterns with physical promotion #86665)
- ('24) Support FIELD_LIST for returns in the backend
- (Stretch) Allow struct fields of physically promoted parameters to stay in registers (experiment: JIT: [experiment] Add an explicit IR representation for parameter definitions #92026)
- (Stretch) Allow struct fields of physically promoted call returns to stay in registers
The FIELD_LIST
items are expected to be easier than the last two items (this is related to the fact that we do not have a good way of representing multiply-defined things in JIT IR).
Reducing scope of dependent promotion
We also expect to switch some cases where we can predict dependent promotion to be handled by physical promotion instead. This is generally expected to have good CQ benefits as it allows fields to stay in registers.
- ('24) Handle retbuf definitions via physical promotion (JIT: Skip old promotion for retbuf defined locals #104439)
- ('24) Handle structs with significant padding via physical promotion (JIT: Disable old promotion for structs with significant padding #104438)
Miscellaneous work items
- JIT: Propagate
LCL_ADDR
nodes during local morph #102808 - JIT: Support retbuf optimization for non 'lvIsTemp' locals #104467
Moved out of .NET 9
Struct copy propagation
The JIT has to create a temporary when constructing structs on the off chance that the constructor observes address of this
. However, practically no struct constructor depends on this
, and we are typically able to prove this after inlining. In many cases, however, we still end up with subpar CQ due to the copy.
This work item is about introducing a pass to get rid of copies in the common case where we inlined and proved them to be unnecessary.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status