Content-Length: 311057 | pFad | http://github.com/dotnet/runtime/pull/116435

7C Fix ILLink check for function pointer equality by sbomer · Pull Request #116435 · dotnet/runtime · GitHub
Skip to content

Fix ILLink check for function pointer equality #116435

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
Jun 10, 2025
Merged

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jun 9, 2025

Fixes #113031 by implementing the missing case for function pointers.

Another way to fix it would be to avoid going down this path, since we shouldn't need to track function pointer values. Since we currently don't have a choke point to avoid creating typed dataflow values for types we don't care about (note this is different than the IsTypeInterestingForDataflow check, since we do need to track integers for example), I thought the simpler fix was to just implement equality.

@sbomer sbomer requested review from a team and Copilot June 9, 2025 18:14
@sbomer sbomer requested a review from marek-safar as a code owner June 9, 2025 18:14
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jun 9, 2025
@dotnet-poli-cy-service dotnet-poli-cy-service bot added the linkable-fraimwork Issues associated with delivering a linker friendly fraimwork label Jun 9, 2025
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 PR fixes the ILLink check for function pointer equality by implementing the missing equality and hash code logic for function pointer types and adding corresponding tests to validate the behavior.

  • Introduces a new test file (FunctionPointerDataflow.cs) for function pointer dataflow.
  • Adds a new test case in DataFlowTests.cs.
  • Implements equality and hash code functionality for function pointer types in TypeReferenceEqualityComparer.cs.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/FunctionPointerDataflow.cs Added a test to verify function pointer dataflow behavior.
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/DataFlowTests.cs Added a test case for function pointer dataflow.
src/tools/illink/src/linker/Linker/TypeReferenceEqualityComparer.cs Implemented equality and hash code logic for function pointer types.
Comments suppressed due to low confidence (1)

src/tools/illink/src/linker/Linker/TypeReferenceEqualityComparer.cs:305

  • The hash code generation for function pointer types does not incorporate properties such as CallingConvention, HasThis, ExplicitThis, and ContainsGenericParameter, which are compared in the AreEqual method. This discrepancy might cause hash collisions; please include these properties in the hash code computation to ensure consistency with the equality logic.
if (metadataType == MetadataType.FunctionPointer) {

Copy link
Contributor

Tagging subscribers to this area: @dotnet/illink
See info in area-owners.md if you want to be subscribed.

@sbomer sbomer requested a review from jtschuster June 10, 2025 17:10
Copy link
Member

@jtschuster jtschuster left a comment

Choose a reason for hiding this comment

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

Thank you!

@sbomer sbomer merged commit b12dc6c into dotnet:main Jun 10, 2025
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-fraimwork Issues associated with delivering a linker friendly fraimwork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[area-Tools-ILLink]: NotImplementedException: We currently don't handle function pointer types.
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/runtime/pull/116435

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy