Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6947,7 +6947,7 @@ class Compiler
void fgDebugCheckFlagsHelper(GenTree* tree, GenTreeFlags actualFlags, GenTreeFlags expectedFlags);
void fgDebugCheckTryFinallyExits();
void fgDebugCheckProfile(PhaseChecks checks = PhaseChecks::CHECK_NONE);
bool fgDebugCheckProfileWeights(ProfileChecks checks);
bool fgDebugCheckProfileWeights(ProfileChecks checks, bool dump = false);
bool fgDebugCheckIncomingProfileData(BasicBlock* block, ProfileChecks checks);
bool fgDebugCheckOutgoingProfileData(BasicBlock* block, ProfileChecks checks);

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,9 @@ void Compiler::fgRemoveConditionalJump(BasicBlock* block)

noway_assert(target->countOfInEdges() > 1);
fgRemoveRefPred(block->GetTargetEdge());

// The block is now a BBJ_ALWAYS, so its single edge must carry likelihood 1.0.
block->GetTargetEdge()->setLikelihood(1.0);
Comment on lines +2548 to +2549
}

//-------------------------------------------------------------
Expand Down
15 changes: 12 additions & 3 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4595,6 +4595,8 @@ void Compiler::fgDebugCheckProfile(PhaseChecks checks)
//
// Arguments:
// checks - checker options
// dump - if true, report inconsistencies via JITDUMP without asserting (used by the
// re-run below to log details before the initial pass asserts)
//
// Returns:
// True if all enabled checks pass
Expand All @@ -4610,7 +4612,7 @@ void Compiler::fgDebugCheckProfile(PhaseChecks checks)
// There's no point checking until we've built pred lists, as
// we can't easily reason about consistency without them.
//
bool Compiler::fgDebugCheckProfileWeights(ProfileChecks checks)
bool Compiler::fgDebugCheckProfileWeights(ProfileChecks checks, bool dump)
{
// We can check classic (min/max, late computed) weights
// and/or
Expand Down Expand Up @@ -4845,13 +4847,20 @@ bool Compiler::fgDebugCheckProfileWeights(ProfileChecks checks)

// Note we only assert when we think the profile data should be consistent.
//
if (assertOnFailure)
if (assertOnFailure && !dump)
{
// Re-run with dumping forced on so the offending blocks are logged before we assert.
//
const bool wasVerbose = verbose;
verbose = true;
fgDebugCheckProfileWeights(checks, /* dump */ true);
verbose = wasVerbose;

assert(!"Inconsistent profile data");
}
}

if (unflaggedBlocks > 0)
if ((unflaggedBlocks > 0) && !dump)
{
JITDUMP("%d blocks are missing BBF_PROF_WEIGHT flag.\n", unflaggedBlocks);
assert(!"Missing BBF_PROF_WEIGHT flag");
Expand Down
Loading