Skip to content

JIT: fix inverted check when placing OSR patchpoints at backedge targets - #135836

Closed
EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:fix/jit-135818-osr-target
Closed

EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:fix/jit-135818-osr-target

Conversation

@EgorBo

@EgorBo EgorBo commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

When a backedge source can't have a patchpoint (non-empty IL stack or in a handler), the importer should place one at the backedge target instead, but the check was inverted so it only fired when the target already had a patchpoint. Loops like 'while (i < (flag ? a : b))' got no patchpoint and stayed in Tier0.

Fix the check. Since the target's entry stack may not be known yet when the source is imported, also drop the patchpoint when the target turns out to have a non-empty entry stack.

Fixes #135818

Several diffs (OSR patchpoints; SPMI replay failures)

When a backedge source can't have a patchpoint (non-empty IL stack or in a handler), the importer
should place one at the backedge target instead, but the check was inverted so it only fired when the
target already had a patchpoint. Loops like 'while (i < (flag ? a : b))' got no patchpoint and stayed in Tier0.

Fix the check. Since the target's entry stack may not be known yet when the source is imported,
also drop the patchpoint when the target turns out to have a non-empty entry stack.

Fixes dotnet#135818

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 6ec7c151-8b7f-4bf9-8b1a-8c601a2965ec
@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 Oct 15, 2026
@EgorBo
EgorBo requested a balanced review from Copilot October 15, 2026 01:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 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: @JulieLeeMSFT, @jakobbotsch
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.

🟡 Changes recommended

The regression assertion verifies arithmetic but cannot detect missing OSR patchpoints.

1 open finding
What changed in this PR

Fixes fallback OSR patchpoint placement so affected loops can leave Tier0.

Changes:

  • Corrects the inverted check for backedge-target patchpoints.
  • Removes requested patchpoints when the target’s entry stack is non-empty.
  • Adds a regression scenario for a conditional loop bound.

Builds and tests were not run.

File Description
src/​tests/​JIT/​Regression_ro_2/​Runtime_135818.cs Adds the conditional-loop regression scenario.
src/​coreclr/​jit/​importer.cpp Corrects target patchpoint placement and entry-stack validation.

🧠 Review effort: Balanced

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

Labels

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

Projects

None yet

2 participants