Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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: 0 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6308,7 +6308,6 @@ class Compiler

static fgWalkPreFn fgStress64RsltMulCB;
void fgStress64RsltMul();
void fgDebugCheckUpdate();

void fgDebugCheckBBNumIncreasing();
void fgDebugCheckBBlist(bool checkBBNum = false, bool checkBBRefs = true);
Expand Down Expand Up @@ -10441,7 +10440,6 @@ class Compiler
/* don't care about performance at all */ \
\
STRESS_MODE(FORCE_INLINE) /* Treat every method as AggressiveInlining */ \
STRESS_MODE(CHK_FLOW_UPDATE) \
STRESS_MODE(EMITTER) \
STRESS_MODE(CHK_REIMPORT) \
STRESS_MODE(GENERIC_CHECK) \
Expand Down
98 changes: 0 additions & 98 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,104 +50,6 @@ void Compiler::fgPrintEdgeWeights()
}
#endif // DEBUG

/*****************************************************************************
* Check that the flow graph is really updated
*/

#ifdef DEBUG

void Compiler::fgDebugCheckUpdate()
{
if (!compStressCompile(STRESS_CHK_FLOW_UPDATE, 30))
{
return;
}

/* We check for these conditions:
* no unreachable blocks -> no blocks have countOfInEdges() = 0
* no empty blocks -> !block->isEmpty(), unless non-removable or multiple in-edges
* no un-imported blocks -> no blocks have BBF_IMPORTED not set (this is
* kind of redundant with the above, but to make sure)
* no un-compacted blocks -> BBJ_ALWAYS with jump to block with no other jumps to it (countOfInEdges() = 1)
*/

BasicBlock* prev;
BasicBlock* block;
for (prev = nullptr, block = fgFirstBB; block != nullptr; prev = block, block = block->Next())
{
/* no unreachable blocks */

if ((block->countOfInEdges() == 0) && !block->HasFlag(BBF_DONT_REMOVE))
{
noway_assert(!"Unreachable block not removed!");
}

/* no empty blocks */

if (block->isEmpty() && !block->HasFlag(BBF_DONT_REMOVE))
{
switch (block->GetKind())
{
case BBJ_CALLFINALLY:
case BBJ_EHFINALLYRET:
case BBJ_EHFAULTRET:
case BBJ_EHFILTERRET:
case BBJ_RETURN:
/* for BBJ_ALWAYS is probably just a GOTO, but will have to be treated */
case BBJ_ALWAYS:
case BBJ_EHCATCHRET:
/* These jump kinds are allowed to have empty tree lists */
break;

default:
/* it may be the case that the block had more than one reference to it
* so we couldn't remove it */

if (block->countOfInEdges() == 0)
{
noway_assert(!"Empty block not removed!");
}
break;
}
}

/* no un-imported blocks */

if (!block->HasFlag(BBF_IMPORTED))
{
/* internal blocks do not count */

if (!block->HasFlag(BBF_INTERNAL))
{
noway_assert(!"Non IMPORTED block not removed!");
}
}

// Check for an unnecessary jumps to the next block.
// A conditional branch should never jump to the next block as it can be folded into a BBJ_ALWAYS.
if (block->KindIs(BBJ_COND) && block->TrueEdgeIs(block->GetFalseEdge()))
{
noway_assert(!"Unnecessary jump to the next block!");
}

// For a BBJ_CALLFINALLY block we make sure that we are followed by a BBJ_CALLFINALLYRET block
// or that it's a BBF_RETLESS_CALL.
if (block->KindIs(BBJ_CALLFINALLY))
{
assert(block->HasFlag(BBF_RETLESS_CALL) || block->isBBCallFinallyPair());
}

/* no un-compacted blocks */

if (fgCanCompactBlock(block))
{
noway_assert(!"Found un-compacted blocks!");
}
}
}
Comment on lines 59 to 147
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Keep the fgDebugCheckUpdate function, but remove the STRESS_CHK_FLOW_UPDATE check, i.e. we can always run the code in debug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Revert this change, remove only the STRESS_CHK_FLOW_UPDATE check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 54e6058. The fgDebugCheckUpdate function now runs unconditionally in all debug builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are already correct in 54e6058. Only the STRESS_CHK_FLOW_UPDATE definition and stress check have been removed - the fgDebugCheckUpdate() function, its declaration, and call site remain intact.


#endif // DEBUG

#if DUMP_FLOWGRAPHS

struct escapeMapping_t
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4776,7 +4776,6 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh
fgVerifyHandlerTab();
// Make sure that the predecessor lists are accurate
fgDebugCheckBBlist();
fgDebugCheckUpdate();
}
#endif // DEBUG

Expand Down
Loading