Skip to content

Fix HFA treatment of floating-point-based enums. #115591

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

Merged
merged 2 commits into from
May 15, 2025

Conversation

jkoritzinsky
Copy link
Member

@jkoritzinsky jkoritzinsky commented May 14, 2025

Treat enums of floating point types (something that's only possible in IL) as an HFA in crossgen2 like we do for CoreCLR.

Fixes failure in https://dev.azure.com/dnceng-public/public/_build/results?buildId=1041124&view=results.

Fixes #104927

…n IL) as an HFA in crossgen2 like we do for CoreCLR.
@Copilot Copilot AI review requested due to automatic review settings May 14, 2025 22:37
@jkoritzinsky
Copy link
Member Author

/azp run runtime-coreclr crossgen2 outerloop

Copy link
Contributor

@Copilot Copilot AI left a 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 pull request fixes the handling of floating-point-based enums for HFA computation, aligning the behavior with CoreCLR.

  • Adjusts the enum type handling to use the underlying type instead of the enum type itself.
  • Adds a clarifying comment explaining the rationale behind the change.
Comments suppressed due to low confidence (2)

src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs:1084

  • Add unit tests to validate that floating-point-based enums are correctly treated as HFAs.
MetadataType metadataType = (MetadataType)type.UnderlyingType;

src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs:1084

  • Consider verifying or asserting that 'type' is indeed an enum before accessing its 'UnderlyingType' to ensure that the cast is always safe.
MetadataType metadataType = (MetadataType)type.UnderlyingType;

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkoritzinsky
Copy link
Member Author

Crossgen-comparison failure is an infra issue in main. Merging this in.

@jkoritzinsky jkoritzinsky enabled auto-merge (squash) May 15, 2025 20:51
@jkoritzinsky
Copy link
Member Author

/ba-g iOS failure is unrelated

@jkoritzinsky jkoritzinsky merged commit 41ffdd7 into dotnet:main May 15, 2025
95 of 99 checks passed
@jkoritzinsky jkoritzinsky deleted the double-enum-layout branch May 15, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: JIT/opt/Devirtualization/Comparer_get_Default/Comparer_get_Default.dll
2 participants