-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove base DAM mismatch warning on types #119419
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
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @dotnet/illink |
Moving this warning is more complicated than that for base types because we would either need to warn on conversion to interfaces, or warn on every constructor (for kept interface implementations).
- Move new constraint processing to generic dataflow - Take new constraint into account for requires dataflow check
MethodBodyScanner tracks known stacks by IL offset, so these need to be correct when analyzing IL. We can't just wait for cecil to update offsets for us when writing to disk.
There was a problem hiding this 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 issues related to Dynamically Accessed Members (DAM) annotation mismatch warnings on base types of type declarations. The changes remove these warnings for base type mismatches since warnings are already produced at construction of derived types. This enables the use of static methods on such types. Additionally, it includes a fix for an ILLink bug around branch removal that affects IL offset tracking during method body scanning.
Key changes include:
- Removal of DAM mismatch warnings for base types in type declarations
- Fix for IL offset handling during unreachable block optimization
- Updates to test expectations reflecting the warning removal
- Refactoring of analyzer context to better handle trim analyzer instances
Reviewed Changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | Comments out debug logging for test message matching |
src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs | Removes expected warnings for base type DAM mismatches |
src/tools/illink/test/Mono.Linker.Tests.Cases/Generics/GenericConstraints.cs | Adds test case for new constraint on methods |
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterWarningLocation.cs | Updates warning expectations and adds constructor calls |
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlowMarking.cs | Updates test expectations and changes class to interface |
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs | Removes base type DAM mismatch warnings from tests |
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/GenericsTests.cs | Adds test method for generic constraints |
src/tools/illink/src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs | Fixes IL offset tracking during instruction replacement |
src/tools/illink/src/linker/Linker.Steps/MarkStep.cs | Removes base type generic argument data flow processing |
src/tools/illink/src/linker/Linker.Dataflow/GenericArgumentDataFlow.cs | Adds new constraint handling and updates parameter processing |
src/tools/illink/src/linker/Linker.Dataflow/FlowAnnotations.cs | Adds methods to check for generic parameter new constraints |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/TrimAnalysisVisitor.cs | Updates analyzer context usage |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/TrimAnalysisReflectionAccessPattern.cs | Updates trim analyzer reference |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/TrimAnalysisMethodCallPattern.cs | Updates trim analyzer reference |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/TrimAnalysisGenericInstantiationPattern.cs | Updates analyzer iteration |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/TrimAnalysisAssignmentPattern.cs | Updates trim analyzer reference |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/RequireDynamicallyAccessedMembersAction.cs | Updates constructor to use specific analyzer |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/HandleCallAction.cs | Updates constructor parameter |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/GenericArgumentDataFlow.cs | Refactors to use specific analyzer instances |
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/FeatureCheckReturnValuePattern.cs | Updates trim analyzer reference |
src/tools/illink/src/ILLink.RoslynAnalyzer/RequiresUnreferencedCodeAnalyzer.cs | Adds generic instantiation processing |
src/tools/illink/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs | Adds generic instantiation processing base functionality |
src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs | Removes base type processing |
src/tools/illink/src/ILLink.RoslynAnalyzer/DataFlowAnalyzerContext.cs | Changes from boolean flag to specific analyzer instance |
src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs | Comments out debug logging for test message matching |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedTypeDefinitionNode.cs | Removes base type generic argument data flow processing |
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/GenericArgumentDataFlow.cs | Adds comments about new constraint handling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit awkward to be passing around the instances of the analyzers, but I don't have a better solution.
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests.Cases/Generics/GenericConstraints.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterWarningLocation.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/GenericArgumentDataFlow.cs
Outdated
Show resolved
Hide resolved
- Use interface for generic dataflow - Remove outdated comment - Clarify expected warning reason - Add Kept attributes for clarity
Fixes #118713
(analyzer only for now)Fixes #119290
This removes the warning for DAM annotation mismatch in the base types of a type declaration. This doesn't cause holes because we produce warnings on the construction of the derived type. Removing the warning enables the use of static methods on such a type.
While implementing this I ran into an ILLink bug around branch removal. We weren't fixing up IL offsets during branch removal, but we were using the offsets as a dictionary key when tracking known stacks during method body scanning. This includes a change to fix up IL offsets during the IL rewrite when we remove unreachable blocks.
Depends on #119291