-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: more bv-centric refactoring for escape analysis #115291
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
JIT: more bv-centric refactoring for escape analysis #115291
Conversation
Rework connection graph building in anticipation of having potentially different sorts of escapes happen as we walk up a tree and switch which resource we are tracking. For example we may discover that a local doesn't escape in this tree, but its fields can escape. Make the ancestor walk responsible for recording escapes, instead of deferring to its caller. Also address a few small things deferred from the previous refactor.
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 PR refactors the escape analysis in the JIT to be more bit-vector–centric, reworking the connection graph building and the handling of escapes when traversing the tree.
- Replaces the local escape checks with a new index-based approach
- Renames and refactors functions from CanLclVarEscapeViaParentStack to AnalyzeParentStack for clearer responsibility
- Updates related JIT diagnostic messages and connection graph edge additions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/coreclr/jit/objectalloc.h | Added new API CanIndexEscape with associated inline implementation |
src/coreclr/jit/objectalloc.cpp | Refactored escape analysis flow to use the new index-based methods |
Comments suppressed due to low confidence (1)
src/coreclr/jit/objectalloc.cpp:619
- The condition was changed from checking if the local can escape to verifying if the local is tracked. Please confirm that this inversion correctly reflects the intended logic for escape analysis.
if (!m_allocator->IsTrackedLocal(lclNum))
bool ObjectAllocator::CanLclVarEscapeViaParentStack(ArrayStack<GenTree*>* parentStack, | ||
unsigned int lclNum, | ||
BasicBlock* block) | ||
void ObjectAllocator::AnalyzeParentStack(ArrayStack<GenTree*>* parentStack, unsigned int lclIndex, BasicBlock* block) | ||
{ | ||
assert(parentStack != nullptr); |
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.
[nitpick] Consider adding a clarifying comment explaining why it is asserted that the local index must not already be marked as escaping at this point.
assert(parentStack != nullptr); | |
assert(parentStack != nullptr); | |
// At this point, it is guaranteed that the local index (lclIndex) has not been marked as escaping. | |
// This is because AnalyzeParentStack is only called for tracked, unescaped locals, and the logic | |
// leading to this point ensures that no escaping has occurred. The assertion acts as a safeguard | |
// to verify this invariant. |
Copilot uses AI. Check for mistakes.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@dotnet/jit-contrib PTAL Should be no diff, perhaps a tiny TP improvement. I also realized we can see GT_LCL_FLD early on in JIT IR, and we should handle it better. Will do that in a subsequent PR. |
/ba-g build analysis hanging |
Rework connection graph building in anticipation of having potentially different sorts of escapes happen as we walk up a tree and switch which resource we are tracking.
For example we may discover that a local doesn't escape in this tree, but its fields can escape.
Make the ancestor walk responsible for recording escapes, instead of deferring to its caller.
Also address a few small things deferred from the previous refactor.