Skip to content

Fix Wasm SCC profile weights for #133120 - #133132

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/133120-wasm-scc-profile
Sep 3, 2026
Merged

Fix Wasm SCC profile weights for #133120#133132
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/133120-wasm-scc-profile

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Fixes #133120.

The Wasm SCC switch-dispatch transformation routes all entry flow through an enclosing try header, but previously left that header's profile weight unchanged. This produced inconsistent profile weights and CrossGen2 assertions for ReadyToRun/PGO compilation.

This change updates the try header to the aggregate SCC entry weight after rewiring and adds a regression test covering the async validator/catch control-flow shape.

Validation performed:

  • Checked browser-wasm CoreCLR/JIT rebuild
  • Original Microsoft.Extensions.Options CrossGen2 repro
  • Single-method and reduced synthetic-profile repros
  • Browser-wasm regression test CrossGen2/R2R generation

End-to-end Node.js execution was unavailable because Node.js is not installed in the environment.

Note

This pull request description was generated with GitHub Copilot.

Update the try header profile weight after Wasm SCC switch-dispatch transformation so the transformed CFG remains profile-consistent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 22:14
@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 Sep 2, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).
10 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.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@lewing alternative fix for #133120
@adamperlin PTAL

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.

🔵 Needs a closer look

Although the change is small, it touches JIT CFG/profile invariants in the Wasm SCC transform and warrants final human validation of correctness and test effectiveness on the relevant browser-wasm R2R/PGO scenarios.

Pull request overview

Adjusts the Wasm SCC switch-dispatch transformation to keep block profile weights self-consistent after rerouting entry flow through a try header, and adds a JIT regression test intended to exercise the affected async try/catch control-flow shape under browser-wasm CrossGen2.

Changes:

  • Update Scc::TransformViaSwitchDispatch() to set the try header’s profile weight to the SCC’s aggregate entry weight after rewiring.
  • Add a new JitBlue regression project/test that runs on browser-wasm with CrossGen2 and passes --codegenopt:JitSynthesizeCounts=1.
File summaries
File Description
src/coreclr/jit/fgwasm.cpp Updates the try header profile weight after SCC entry-flow rerouting to avoid stale/inconsistent weights.
src/tests/JIT/Regression/JitBlue/Runtime_133120/Runtime_133120.csproj Adds a new JitBlue regression project with browser CrossGen2 settings and extra CrossGen2 args.
src/tests/JIT/Regression/JitBlue/Runtime_133120/Runtime_133120.cs Adds an async try/catch-based test body intended to trigger the SCC transform scenario.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

@lewing lewing 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.

verified that this passes the failed check from the original issue

@adamperlin adamperlin 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.

LGTM, pending the comments about the regression test.

@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Sep 3, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

/ba-g one of the build monitors is confused

@AndyAyersMS
AndyAyersMS merged commit 334cc5c into dotnet:main Sep 3, 2026
150 of 152 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture 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.

Wasm R2R crossgen2 asserts with inconsistent profile data during SCC transform

6 participants