-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: revise may/must point to stack analysis #115080
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
Keep track of locals that may point to the heap as well as locals that may point to the stack. The set of definitely stack-pointing locals is then the difference in these two sets. This handles the "cyclic" case where stack pointing locals are assigned to one another. Fixes dotnet#115017
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 improves JIT analysis by tracking locals that may point to both the heap and the stack to better compute the set of definitely stack-pointing locals, addressing an issue with cyclic assignments.
- Added a new test case to verify the updated connection cycles behavior.
- Updated object allocation logic in objectalloc.cpp to compute stack-pointing locals based on the difference with heap-pointing locals and added corresponding logging.
- Enhanced logging in assertionprop.cpp for better cross-block table insights.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/tests/JIT/opt/ObjectStackAllocation/ConnectionCycles.cs | Added tests for verifying connection cycles via local pointer assignments. |
src/coreclr/jit/objectalloc.cpp | Updated logic to distinguish stack- and heap-pointing locals with new logging messages. |
src/coreclr/jit/assertionprop.cpp | Added a logging statement to report cross-block table size details. |
Files not reviewed (1)
- src/tests/JIT/opt/ObjectStackAllocation/ConnectionCycles.csproj: Language not supported
Comments suppressed due to low confidence (1)
src/tests/JIT/opt/ObjectStackAllocation/ConnectionCycles.cs:20
- [nitpick] Consider renaming the test method 'Problem' to a more descriptive name that reflects the scenario under test, improving clarity for future readers.
public static int Problem()
|
||
// If a local is possibly stack pointing and not possibly heap pointing, then it is definitely stack pointing. | ||
// | ||
BitVec newDefinitelyStackPointingPointers = BitVecOps::UninitVal(); |
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.
Consider adding an inline comment to clarify that subtracting the possibly heap-pointing pointers from the possibly stack-pointing pointers isolates the definitely stack-pointing locals, especially to support future maintenance.
Copilot uses AI. Check for mistakes.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@jakobbotsch PTAL This reduces the number of ambient byrefs, and can also improve code quality. Two bad diffs in x64 windows libraries SPMI ( |
arm failure is related, there are diffs in
|
We are missing a connection graph edge for the case where a local doesn't escape but we decide not to stack allocate it (say because the allocation site is in a loop). |
BitVec newDefinitelyStackPointingPointers = BitVecOps::UninitVal(); | ||
BitVecOps::Assign(bitVecTraits, newDefinitelyStackPointingPointers, m_PossiblyStackPointingPointers); | ||
BitVecOps::DiffD(bitVecTraits, newDefinitelyStackPointingPointers, possiblyHeapPointingPointers); |
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.
I think you can use BitVecOps::Diff
directly here to avoid manually writing the copy.
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.
Good point. Will clean this up in a future escape PR.
Keep track of locals that may point to the heap as well as locals that may point to the stack.
The set of definitely stack-pointing locals is then the difference in these two sets. This handles the "cyclic" case where stack pointing locals are assigned to one another.
Fixes #115017