JIT: Defer physical promotion readbacks across basic blocks - #134048
Draft
jakobbotsch wants to merge 9 commits into
Draft
jakobbotsch wants to merge 9 commits into
jakobbotsch wants to merge 9 commits into
Conversation
Generalize the existing FindInducedParameterRegisterLocals transformation from entry-block-only rewriting in lowering to all-block rewriting during rationalization. Record parameter field reads, stores, and address uses in the existing execution-order visitor rather than adding a separate IR walk. After rationalization, propagate parameter kills through normal and EH successors, including loop backedges. Rewrite field reads only when every reaching path still observes the incoming parameter value, respecting read-before-kill ordering within each block. Reuse the existing extraction logic and parameter-register target mappings. Remove the entry-block discovery and unused reuse helper from lowering, while retaining mappings for independently promoted parameters. Account for the earlier parameter-register targets in async default-value analysis and invalidate recorded uses when rationalization discards their nodes. Physical promotion's eager readbacks remain unchanged; profitability of keeping packed values live across calls is follow-up work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c28b3c3-cf6c-4149-8eb1-964831492011
Visit blocks in reverse postorder and track pending field readbacks at block exits instead of eagerly initializing parameter replacements or materializing every pending readback at each block boundary. Keep replacement locals current by default. Carry the special pending state into a successor only when all reachable predecessors agree. At mixed joins, materialize readbacks on the pending predecessors rather than loading a potentially stale struct home in the successor. Require already-read-back locals at loop/backedge targets and handler entries. Retain regular-successor traversal and explicit EH barriers, including the existing materialization before throwing operations. Readbacks otherwise occur at uses, allowing generalized rationalization to extract parameter fields in the blocks that actually need them. This changes readback placement, not promotion selection or its costing. It avoids unnecessary eager extractions on early-return paths such as Guid.CompareTo while leaving broader profitability tuning as follow-up. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c28b3c3-cf6c-4149-8eb1-964831492011
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Keep upstream's merged parameter-register rewriting implementation and preserve the lazy physical-promotion readback changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c28b3c3-cf6c-4149-8eb1-964831492011
Index lazy-readback state by DFS postorder and use postorder bitsets for block flags. Track original-field currency across forward joins to avoid writing back replacements that have only been read, retaining conservative loop and handler entry state. Remove the low-weight parameter extraction costing heuristic now that readbacks can be deferred. Keep the existing pending-readback intersection policy at joins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c28b3c3-cf6c-4149-8eb1-964831492011
3 tasks
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 628eb6b2-f468-4a67-b2c9-f8de24969633
This was referenced Sep 24, 2026
Estimate lazy readback and reconciliation sites from liveness use/def sets. Let replacement materialize planned readbacks using its exact state, removing post-replacement commoning and may-definition tracking. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 628eb6b2-f468-4a67-b2c9-f8de24969633
Cache materialization boundaries for planning and replacement, short-circuit successor traversal, skip planning without eligible incoming fields, and avoid unnecessary definition queries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 628eb6b2-f468-4a67-b2c9-f8de24969633
Move field tracking setup, boundary computation, and planning into PrepareReadBacks, called after constructing ReplaceVisitor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 628eb6b2-f468-4a67-b2c9-f8de24969633
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defer physical-promotion readbacks across basic blocks instead of eagerly initializing parameter replacements and materializing pending fields at every block boundary.
Visit blocks in reverse postorder, carrying pending readbacks when all predecessors agree. At mixed joins, materialize on pending predecessors; retain conservative loop/EH boundaries and preserve whether the struct home is current to avoid redundant writebacks.
Before replacement, use the existing field-liveness use/def sets to estimate readback and reconciliation sites. Plan a shared readback in their common dominator when block weights predict fewer executions. Replacement materializes it only if still pending, preserving its exact handling of uses, writes, and exceptional control flow.