-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: update layout of BLK nodes during escape analysis #115845
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
If we retype a struct local we also need to retype any BLK operations on those locals. Fixes dotnet#115832.
@dotnet/jit-contrib PTAL No diffs but a lot of missed contexts. |
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 fixes a JIT assertion by propagating updated struct layouts to BLK nodes during escape analysis retyping.
- Extended
UpdateAncestorTypes
to accept a newClassLayout* newLayout
parameter. - Added
SetLayout
calls forGT_STORE_BLK
andGT_BLK
nodes whenretypeFields
is true. - Introduced a new repro test (
Runtime_115832
) to catch the original assertion.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/tests/JIT/opt/ObjectStackAllocation/*.csproj | Added optimized test project for repro case |
src/tests/JIT/opt/ObjectStackAllocation/Runtime_115832.cs | New fuzz-generated test reproducing the JIT assert |
src/coreclr/jit/objectalloc.h | Updated UpdateAncestorTypes signature to include newLayout |
src/coreclr/jit/objectalloc.cpp | Implemented layout propagation to BLK nodes |
src/coreclr/jit/gentree.h | Added GenTreeBlk::SetLayout to allow runtime layout updates |
Comments suppressed due to low confidence (2)
src/coreclr/jit/objectalloc.cpp:2196
- Consider adding a unit test that exercises the
GT_STORE_BLK
retype path to ensureSetLayout
is correctly applied and prevent future regressions.
if (retypeFields && parent->OperIs(GT_STORE_BLK))
src/coreclr/jit/objectalloc.cpp:2189
- The removal of the
addr->OperIs(GT_FIELD_ADDR)
check broadens theSTOREIND
retyping logic beyond struct field stores, which conflicts with the existing comment. Consider restoring that guard or updating the comment to reflect the intended behavior.
if (parent->OperIs(GT_STOREIND) && varTypeIsGC(parent->TypeGet()))
@@ -2007,6 +2007,7 @@ void ObjectAllocator::AnalyzeParentStack(ArrayStack<GenTree*>* parentStack, unsi | |||
// tree - Possibly-stack-pointing tree | |||
// parentStack - Parent stack of the possibly-stack-pointing tree | |||
// newType - New type of the possibly-stack-pointing tree | |||
// newLayout - Layout for a retyped local struct |
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.
You added a description for newLayout
in the implementation comments; please update the corresponding declaration comment in objectalloc.h
so the header and implementation stay in sync.
Copilot uses AI. Check for mistakes.
@dotnet/jit-contrib ping |
If we retype a struct local we also need to retype any BLK operations on those locals. Fixes #115832.
If we retype a struct local we also need to retype any BLK operations on those locals.
Fixes #115832.