-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix several issues with CreateSpan support #65919
Conversation
1. It turns out we can't use the system types (short, int, long) for data fields when there's an alignment requirement, as those types have .pack 1 and thus a rewriter (e.g. illink) might not align fields using those types appropriately. 2. We weren't incorporating the alignment into the name of the ExplicitSizeStruct created, so we could end up with two types both for the same size but for different alignments and with the same name. 3. In looking at the code again, I realized we could simplify it so that EmitArrayBlockInitializer doesn't take an alignment at all, since for array purposes, we always want to use alignment 1. Because it took an alignment, we were unnecessarily specifying one even for the no-CreateSpan fallback. This was functionally correct but unnecessary and resulting in a bit more complicated IL, especially once (1) above was fixed.
src/Compilers/Core/Portable/CodeGen/PrivateImplementationDetails.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 1) |
Thanks. Feedback addressed. |
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.
LGTM Thanks (iteration 2)
@stephentoub It looks like there are legitimate test failures |
src/Compilers/Core/Portable/CodeGen/PrivateImplementationDetails.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/CodeGen/PrivateImplementationDetails.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 2) |
It's some Windows vs Unix difference. |
Apparently we expect different output / blob addresses based on OS, e. g. roslyn/src/Compilers/CSharp/Test/Semantic/Semantics/Utf8StringsLiteralsTests.cs Lines 3333 to 3335 in 42f323d
Why is that? I'll work around it, but doesn't that go against deterministic builds? |
b987713
to
f90cce2
Compare
I found @jaredpar's comment in #51437 (comment) about no guarantees of determinism across OS. |
Tests passed now. |
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.
LGTM (commit 3)
Thank you, @stephentoub. |
It turns out we can't use the system types (short, int, long) for data fields when there's an alignment requirement, as those types have .pack 1 and thus a rewriter (e.g. illink) might not align fields using those types appropriately.
We weren't incorporating the alignment into the name of the ExplicitSizeStruct created, so we could end up with two types both for the same size but for different alignments and with the same name.
In looking at the code again, I realized we could simplify it so that EmitArrayBlockInitializer doesn't take an alignment at all, since for array purposes, we always want to use alignment 1. Because it took an alignment, we were unnecessarily specifying one even for the no-CreateSpan fallback. This was functionally correct but unnecessary and resulting in a bit more complicated IL, especially once (1) above was fixed.
The telltale sign of the problem is "System.ArgumentException : Value does not fall within the expected range." in
CreateSpan
call.cc: @jcouv
Contributes to dotnet/runtime#79477
Follow-up on #61414