-
Notifications
You must be signed in to change notification settings - Fork 5.1k
JIT: Preparatory refactoring to support multiple defs per single node #117662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace `GenTree::DefinesLocal` by a `GenTree::VisitLocalDefs` to prepare for being able to allow a single node to have multiple definitions. Update uses to use the new function.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
/azp run runtime-coreclr superpmi-diffs |
Azure Pipelines successfully started running 1 pipeline(s). |
cc @dotnet/jit-contrib PTAL @AndyAyersMS No diffs are expected, but the diffs run didn't succeed because of a JIT-EE GUID change. Kicked it off again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors how the JIT handles local variable definitions by replacing the single-definition method GenTree::DefinesLocal
with a visitor pattern method GenTree::VisitLocalDefs
. This change prepares the JIT infrastructure to support multiple definitions per node, which will be needed for async call optimizations where calls need to define both the return value and a suspension state indicator.
Key changes include:
- Introduces a new
LocalDef
struct to encapsulate definition metadata (local, entirety, offset, size) - Replaces
DefinesLocal
calls withVisitLocalDefs
throughout the codebase - Updates SSA builder, value numbering, liveness analysis, and other passes to use the visitor pattern
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/coreclr/jit/gentree.h | Defines LocalDef struct and VisitLocalDefs interface |
src/coreclr/jit/compiler.hpp | Implements VisitLocalDefs template method and HasAnyLocalDefs helper |
src/coreclr/jit/gentree.cpp | Removes old DefinesLocal method implementation |
src/coreclr/jit/valuenum.cpp | Updates value numbering to use visitor pattern for call definitions |
src/coreclr/jit/ssabuilder.cpp | Refactors SSA renaming to handle multiple definitions via visitor |
src/coreclr/jit/liveness.cpp | Updates liveness analysis to use visitor pattern for call definitions |
src/coreclr/jit/morph.cpp | Updates variable definition flagging to use visitor pattern |
src/coreclr/jit/copyprop.cpp | Updates copy propagation to use visitor pattern for definitions |
src/coreclr/jit/treelifeupdater.cpp | Updates tree life updater to use visitor for call definitions |
src/coreclr/jit/lower.cpp | Updates lowering to use visitor for tracking stored locals |
src/coreclr/jit/flowgraph.cpp | Updates flow graph analysis to use visitor pattern |
src/coreclr/jit/fgdiagnostic.cpp | Updates SSA diagnostics to use visitor pattern |
Some somewhat substantial TP regressions (~0.5%). Detailed TP diff shows:
Pushed a commit that mitigates it somewhat by introducing some slight duplication. There is now both a
That mostly seems like changes in inlining, so I think we should take it as is. |
/ba-g Android timeout and rest of failures are known |
Replace
GenTree::DefinesLocal
by aGenTree::VisitLocalDefs
to prepare for being able to allow a single node to have multiple definitions. Update uses to use the new function.I want to use this allow async calls to define a new value that represents whether the call suspended or not. This is necessary because runtime async calls should save and restore
Thread.CurrentThread._synchronizationContext
, but the restore should only happen when the call finishes synchronously (with an exception or not). I need a proper representation in the JIT IR of these conditions to properly be able to model these conditions in the face of inlining.In a future change I expect to add a
LCL_ADDR
node as a new well-known argument to async calls that will be a definition that works similar to ret buffers. The async transformation will later expand the definition out in the resumption path.