Skip to content
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

Implement support for InlineArray in the trimmer #92060

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

vitek-karas
Copy link
Member

Types annotated with InlineArray need to preserve all of their fields, even if otherwise this would not be the case. It's possible to have a struct with LayoutKind.Auto and with InlineArray - trimmer would normally trim fields on such struct. This leads to corruption since the field is never accessed directly.

This changes the marking to preserve all fields on a type with InlineArray attribute just like we would for explicit layout struct and similar other types.

Adds tests to cover both the explicit usage of InlineArray attribute as well as the compiler generate usage via collection literals.

This should resolve the trimming part of #92022
And it also adds tests for #88684

Types annotated with `InlineArray` need to preserve all of their fields, even if otherwise this would not be the case. It's possible to have a struct with `LayoutKind.Auto` and with `InlineArray` - trimmer would normally trim fields on such struct. This leads to corruption since the field is never accessed directly.

This changes the marking to preserve all fields on a type with `InlineArray` attribute just like we would for explicit layout struct and similar other types.

Adds tests to cover both the explicit usage of `InlineArray` attribute as well as the compiler generate usage via collection literals.
@vitek-karas vitek-karas added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 14, 2023
@vitek-karas vitek-karas self-assigned this Sep 14, 2023
@ghost
Copy link

ghost commented Sep 14, 2023

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

Types annotated with InlineArray need to preserve all of their fields, even if otherwise this would not be the case. It's possible to have a struct with LayoutKind.Auto and with InlineArray - trimmer would normally trim fields on such struct. This leads to corruption since the field is never accessed directly.

This changes the marking to preserve all fields on a type with InlineArray attribute just like we would for explicit layout struct and similar other types.

Adds tests to cover both the explicit usage of InlineArray attribute as well as the compiler generate usage via collection literals.

This should resolve the trimming part of #92022
And it also adds tests for #88684

Author: vitek-karas
Assignees: vitek-karas
Labels:

area-Tools-ILLink

Milestone: -

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

…rrayDataflow.cs

Co-authored-by: Sven Boemer <sbomer@gmail.com>
@vitek-karas vitek-karas merged commit d40f90c into dotnet:main Sep 15, 2023
132 checks passed
@vitek-karas vitek-karas deleted the InlineArrayTrim branch September 15, 2023 08:45
@vitek-karas
Copy link
Member Author

/backport to release/8.0

@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6195934219

@ghost ghost locked as resolved and limited conversation to collaborators Oct 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants