JIT: normalize edge likelihood when collapsing BBJ_COND to BBJ_ALWAYS#130907
Open
AndyAyersMS wants to merge 1 commit into
Open
JIT: normalize edge likelihood when collapsing BBJ_COND to BBJ_ALWAYS#130907AndyAyersMS wants to merge 1 commit into
AndyAyersMS wants to merge 1 commit into
Conversation
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
Member
Author
|
@EgorBo PTAL |
|
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. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
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
fgDebugCheckProfileWeightswith adumpmode and re-run the check withverbose=trueto emit diagnostics prior to asserting on inconsistent profile data. - Normalize the successor edge likelihood when converting a degenerate
BBJ_CONDtoBBJ_ALWAYS. - Update the
Compilerdeclaration to match the newfgDebugCheckProfileWeightssignature.
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
unflaggedBlockspath is completely suppressed (no JITDUMP, no assert). This defeats the purpose of re-running withdump=trueto log details before asserting, since missingBBF_PROF_WEIGHTflags will still assert without any diagnostic output whenverbosewas 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 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); |
tannergooding
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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