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

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-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jun 9, 2025
Copy link
Contributor

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) {

@dotnet-policy-service
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
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2025
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 linkable-framework Issues associated with delivering a linker friendly framework

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