-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove condition that forbids promotion of HFAs with CUSTOMLAYOUT flag #64863
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
Closed
echesakov
wants to merge
10
commits into
dotnet:main
from
echesakov:Remove-CustomLayout-HFA-Condition
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
23ab417
Replace CORINFO_FLG_CUSTOMLAYOUT with CORINFO_FLG_OPAQUE_BLOB and add…
echesakov a17a472
Remove .customLayout from lvaStructPromotionInfo struct in src/corecl…
echesakov d51e30d
Stop using .lvCustomLayout and .customLayout in src/coreclr/jit/compi…
echesakov 9b83723
Don't promote struct types with CORINFO_FLG_OPAQUE_BLOB in src/corecl…
echesakov b0435d2
Update fgComputeLifeUntrackedLocal() to not use .lvCustomLayout in sr…
echesakov ea46602
Rename CORINFO_FLG_CUSTOMLAYOUT to CORINFO_FLG_OPAQUE_BLOB in src/cor…
echesakov 6c0083c
Rename CORINFO_FLG_CUSTOMLAYOUT to CORINFO_FLG_OPAQUE_BLOB in src/cor…
echesakov 71334fd
Update condition for CORINFO_FLG_OPAQUE_BLOB in src/coreclr/tools/Com…
echesakov 0201d09
Treat structs with ExplicitSize as opaque blob of bytes in src/corecl…
echesakov f07c170
Pass opaqueBlob information in lvOpaqueBlob from struct promotion to …
echesakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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.
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.
Would it make sense to delete or replace the other use
StructHasCustomLayoutas well?The
CORINFO_FLG_CUSTOMLAYOUTflag on JIT/EE interface has always been very poorly defined. It would be nice to get rid of it, and replace it with well-defined type property or type properties as necessary.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 it does. The only other user of
StructHasCustomLayoutisruntime/src/coreclr/jit/lclvars.cpp
Line 1773 in ebcd332
StructLayout(LayoutKind.Explicit, Size=...). However, in my local testing I found that structs marked withStructLayout(LayoutKind.Auto)also returnstrueforStructHasCustomLayout(e.g.ValueTuple).Let me do more debugging here.
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've been looking at the this and it seems that the original intent for
StructHasCustomLayoutwas to identifyLayoutKind.Explicitand prevent such structures from promoting (i.e. enregistering their fields).I believe this is done to be able to properly copy such structs with explicitlayout attribute (incl. gaps between fields).
However, the way this is implemented in VM has interesting consequences.
For example, suppose we have
On Arm64
DefLayoutreturn type would be promotablewhile
AutoLayoutreturn type would not:Maybe, I misunderstand what ECMA-335 says but isn't
[StructLayout(LayoutKind.Auto)]implied by default?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.
Wrt ECMA-335, there is always a StructLayout value written in metadata. This value is not optional.
The C# default for this value is StructLayout.Sequential for structs. So C# writes StructLayout.Sequential into metadata by default, unless it gets overridden by StructLayout attribute.
Feel free to adjust the VM and JIT contract as needed. The existing CUSTOMLAYOUT flag is not very well defined. It would be great if we get something that well defined and easy to understand.
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.
Thanks for the explanation. I guess I confused the default value per ECMA
and what C# and other compilers specify https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.layoutkind?view=net-6.0.
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.
FWIW, the JIT primarily checks for combination of
lvContainsHoles && lvCustomLayoutin the code - looks that the intent was to check "a value type is not tightly packed and the "holes" are due to the layout being explicit". The assumption is that the "holes" can contain some information? If the "holes" are due to padding then the JIT can discard the information (as inDefLayoutcase in my example).Looking at another example
this seems to be the case