Skip to content

JIT: normalize edge likelihood when collapsing BBJ_COND to BBJ_ALWAYS#130907

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-130785-cond-collapse-likelihood
Open

JIT: normalize edge likelihood when collapsing BBJ_COND to BBJ_ALWAYS#130907
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-130785-cond-collapse-likelihood

Conversation

@AndyAyersMS

@AndyAyersMS AndyAyersMS commented Jul 16, 2026

Copy link
Copy Markdown
Member

Set the merged edge likelihood to 1.0 when a BBJ_COND degenerates so the profile stays consistent, and report the failing block when the check asserts.

Fixes #130785

Set the merged edge likelihood to 1.0 when a BBJ_COND degenerates so the
profile stays consistent, and report the failing block when the check asserts.

Fixes dotnet#130785

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9f8414be-99cb-492d-a7c0-091c8e7de191
Copilot AI review requested due to automatic review settings July 16, 2026 18:57
@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 Jul 16, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@EgorBo PTAL
fyi @dotnet/jit-contrib

@AndyAyersMS
AndyAyersMS requested a review from EgorBo July 16, 2026 18:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 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.

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

This PR adjusts CoreCLR JIT profile-consistency handling in two places: (1) it adds a “dump-only” mode to the debug profile-weight checker so it can log details before asserting, and (2) it ensures edge-likelihood invariants are maintained when conditional branches are collapsed to unconditional branches.

Changes:

  • Extend fgDebugCheckProfileWeights with a dump mode and re-run the check with verbose=true to emit diagnostics prior to asserting on inconsistent profile data.
  • Normalize the successor edge likelihood when converting a degenerate BBJ_COND to BBJ_ALWAYS.
  • Update the Compiler declaration to match the new fgDebugCheckProfileWeights signature.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/fgprofile.cpp Adds dump mode and a verbose re-run to print profile inconsistency details before asserting.
src/coreclr/jit/fgopt.cpp Adjusts edge likelihood handling when removing a conditional jump that always targets the same block.
src/coreclr/jit/compiler.h Updates the fgDebugCheckProfileWeights declaration to include the new optional dump parameter.
Comments suppressed due to low confidence (1)

src/coreclr/jit/fgprofile.cpp:4867

  • In dump mode, the unflaggedBlocks path is completely suppressed (no JITDUMP, no assert). This defeats the purpose of re-running with dump=true to log details before asserting, since missing BBF_PROF_WEIGHT flags will still assert without any diagnostic output when verbose was originally false. Consider always emitting the JITDUMP, and only gating the assert on !dump.
    if ((unflaggedBlocks > 0) && !dump)
    {
        JITDUMP("%d blocks are missing BBF_PROF_WEIGHT flag.\n", unflaggedBlocks);
        assert(!"Missing BBF_PROF_WEIGHT flag");
    }

Comment thread src/coreclr/jit/fgopt.cpp
Comment on lines +2548 to +2549
// The block is now a BBJ_ALWAYS, so its single edge must carry likelihood 1.0.
block->GetTargetEdge()->setLikelihood(1.0);
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.

JIT: Assertion failed '!"Inconsistent profile data"' in 'Lowering nodeinfo'

3 participants