Skip to content

ILTrim: Remove unused beforefieldinit constructors - #133900

Merged
jtschuster merged 1 commit into
dotnet:mainfrom
jtschuster:iltrim-failures
Sep 14, 2026
Merged

jtschuster merged 1 commit into
dotnet:mainfrom
jtschuster:iltrim-failures

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Summary

Fix ILTrim's static-constructor dependency tracking so unused beforefieldinit static constructors and their unused static fields can be removed, while preserving explicit static constructors and constructors required by retained static fields.

This fixes Generics.GenericConstraints and clears three additional stale expected-failure entries exposed by the same correction.

Validation

  • ./build.sh clr.toolstests -test

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4b4a86d7-8e66-47b9-a80c-e85663683aba
Copilot AI lite review requested due to automatic review settings September 14, 2026 17:49
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No unresolved review issues remain.

Pull request overview

Fixes ILTrim dependency tracking so unused beforefieldinit constructors and static fields can be removed safely.

Changes:

  • Adjusts static-constructor retention rules.
  • Tracks dependencies from retained static fields.
  • Removes resolved expected failures.
File summaries
File Summary
src/coreclr/tools/ILTrim.Tests/ILTrimExpectedFailures.txt Removes resolved expected failures.
src/coreclr/tools/ILTrim.Core/DependencyAnalysis/TokenBased/TypeDefinitionNode.cs Applies BeforeFieldInit optimization when retaining static constructors.
src/coreclr/tools/ILTrim.Core/DependencyAnalysis/TokenBased/FieldDefinitionNode.cs Links retained static fields to their type initializer.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

@jtschuster

Copy link
Copy Markdown
Member Author

/ba-g Build analysis is hanging but the only failure is known.

@jtschuster
jtschuster enabled auto-merge (squash) September 14, 2026 23:39
@jtschuster
jtschuster merged commit 8477f81 into dotnet:main Sep 14, 2026
111 of 113 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Sep 14, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 15, 2026
jtschuster added a commit to jtschuster/runtime that referenced this pull request Sep 18, 2026
## Summary

Fix ILTrim's static-constructor dependency tracking so unused
`beforefieldinit` static constructors and their unused static fields can
be removed, while preserving explicit static constructors and
constructors required by retained static fields.

This fixes `Generics.GenericConstraints` and clears three additional
stale expected-failure entries exposed by the same correction.

> [!NOTE]
> This pull request description was generated with GitHub Copilot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants