Skip to content

JIT: Disallow partial compilation of runtime async functions#125267

Open
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
jakobbotsch:fix-125247
Open

JIT: Disallow partial compilation of runtime async functions#125267
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
jakobbotsch:fix-125247

Conversation

@jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Mar 6, 2026

Partial compilation removes the IR of the blocks being partially compiled. That makes the liveness computed by runtime async inaccurate, meaning that we will fail to capture variables needed after the OSR transition.

We could make this work by keeping the uses inside TransformPartialCompilation, for example adding them as arguments to CORINFO_HELP_PATCHPOINT_FORCED. If we ever decide to enable partial compilation by default that seems like a better solution.

Fix #125247

Partial compilation removes the IR of the blocks being partially
compiled. That makes the liveness computed by runtime async inaccurate,
meaning that we will fail to capture variables needed after the OSR
transition.

We could make this work by keeping the uses inside
`TransformPartialCompilation`, for example adding them as arguments to
`CORINFO_HELP_PATCHPOINT_FORCED`. If we ever decide to enable partial
compilation by default that seems like a better solution.
Copilot AI review requested due to automatic review settings March 6, 2026 12:46
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 6, 2026
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 prevents Tier0 partial compilation from being applied to runtime async methods, because partial compilation can drop IR from deferred blocks and make runtime-async liveness analysis inaccurate across OSR transitions.

Changes:

  • Split Tier0 OSR enablement vs partial compilation enablement into separate booleans (enableOSR, enablePartialCompilation).
  • Disallow marking partial compilation patchpoints when compIsAsync() is true.

@jakobbotsch jakobbotsch changed the title JIT: Disallow partial compilation of runtime async function JIT: Disallow partial compilation of runtime async functions Mar 6, 2026
@AndyAyersMS
Copy link
Member

You could also go back to assuming everything is live?

@jakobbotsch
Copy link
Member Author

You could also go back to assuming everything is live?

Yes, that would work too. I suppose it is a question of what is best for throughput overall. But it would require some more special casing in the async transformation than the change here.

@jakobbotsch jakobbotsch marked this pull request as ready for review March 6, 2026 21:31
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

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

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Failure: _simple_eh::Async2SimpleEH.TestThrowAfterYield()

3 participants