Keep proxy type map entries that could be created dynamically#123031
Keep proxy type map entries that could be created dynamically#123031MichalStrehovsky merged 1 commit intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where proxy type map entries for generic types that could be instantiated at runtime were being incorrectly trimmed. The fix ensures that when a generic type in a proxy type map has a canonical form (indicating it could be created dynamically by the type loader), the compiler creates a dependency to preserve the necessary type instantiation.
- Adds logic to detect generic proxy type map entries that could be loaded at runtime
- Creates conditional dependencies to ensure type loader templates are available
- Adds comprehensive test coverage for the trimming behavior with both used and unused generic proxy types
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ProxyTypeMapNode.cs | Adds logic to create conditional dependencies for generic types with canonical forms in proxy type maps, ensuring the type loader template is available for runtime instantiation |
| src/tests/nativeaot/SmokeTests/TrimmingBehaviors/DeadCodeElimination.cs | Adds test cases with generic types in proxy type maps to validate that used generic instantiations are preserved while unused ones are trimmed |
jtschuster
left a comment
There was a problem hiding this comment.
Do we need a correspoding change in ILLink?
I don't think so. ILLink doesn't analyze instantiated generic code, everything works off definitions. My expectation is that if |
Fixes #122598.
Cc @dotnet/ilc-contrib