Skip to content

Add crossgen2 --strip-il-bodies runtime-async regression test#130075

Open
kotlarmilos wants to merge 1 commit into
dotnet:mainfrom
kotlarmilos:dev/crossgen2-strip-il-bodies-test
Open

Add crossgen2 --strip-il-bodies runtime-async regression test#130075
kotlarmilos wants to merge 1 commit into
dotnet:mainfrom
kotlarmilos:dev/crossgen2-strip-il-bodies-test

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented Jul 1, 2026

Copy link
Copy Markdown
Member

Description

The --strip-il-bodies optimization in crossgen2 is applied when building the composite ReadyToRun images that ship in the Apple mobile runtime packs, and in #129813 it regressed by stripping the IL of non-async Task/ValueTask-returning methods. That IL is still needed, because with runtime-async enabled the runtime compiles a runtime-async variant of such a method from its IL, so replacing it with a ldnull throw stub threw NullReferenceException on the mobile packs until #129884 narrowed the pass via MayNeedILAtRuntime.

This PR adds a deterministic ILCompiler.ReadyToRun.Tests tests that inspect the emitted component MSIL to assert every branch of the strip logic. Non-async Task<T>/ValueTask<T>/Task/ValueTask-returning methods, a generic method, and a method on a generic type keep their IL, while plain methods and async Task<T>/ValueTask methods are still stripped.

TODO: This PR should be aligned with #130025

Copilot AI review requested due to automatic review settings July 1, 2026 11:35
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label Jul 1, 2026

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.

Pull request overview

Adds a new ILCompiler.ReadyToRun.Tests regression test that validates crossgen2 --strip-il-bodies behavior under runtime-async, by inspecting the emitted component MSIL and asserting which methods should keep vs. lose their IL.

Changes:

  • Extend the R2R test runner option model to include --strip-il-bodies.
  • Add MSIL IL-body inspection helpers (MethodILIsStripped / MethodILIsPresent) and a new runtime-async test case (StripILBodies.cs) plus an xUnit test that asserts strip/preserve decisions.
  • Modify global UseMonoRuntime behavior in Directory.Build.props for *-android/ios/tvos/maccatalyst TFMs when TargetsMobile != true.
Show a summary per file
File Description
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/R2RResultChecker.cs Adds helpers to read method IL from the component MSIL and assert stripped vs present bodies.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCasesRunner/R2RDriver.cs Adds a new modeled crossgen2 option mapping for --strip-il-bodies.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/RuntimeAsync/StripILBodies.cs New embedded test input assembly with a mix of async, non-async Task/ValueTask, and generic cases.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs New [Fact] that runs a composite crossgen2 compile with runtime-async + --strip-il-bodies and asserts IL preservation/stripping.
Directory.Build.props Changes global defaulting of UseMonoRuntime for mobile-suffixed TFMs when not TargetsMobile.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 4

Comment thread Directory.Build.props Outdated
@kotlarmilos kotlarmilos force-pushed the dev/crossgen2-strip-il-bodies-test branch from 427550e to c61119e Compare July 1, 2026 11:50
Adds an ILCompiler.ReadyToRun.Tests case that crossgen2-composites a small
runtime-async assembly with --strip-il-bodies and inspects the emitted
component MSIL to assert every branch of the strip decision, covering the
regression from dotnet#129813 fixed by dotnet#129884.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 11:52
@kotlarmilos kotlarmilos force-pushed the dev/crossgen2-strip-il-bodies-test branch from c61119e to 50c77f3 Compare July 1, 2026 11:52

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.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@jakobbotsch jakobbotsch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr only use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants