Skip to content

Commit

Permalink
JIT: Always aggressively compact blocks (#109521)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanasifkhalid authored Dec 5, 2024
1 parent 223dea5 commit 052ad42
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6286,7 +6286,7 @@ class Compiler

bool fgIsForwardBranch(BasicBlock* bJump, BasicBlock* bDest, BasicBlock* bSrc = nullptr);

bool fgUpdateFlowGraph(bool doTailDup = false, bool isPhase = false, bool doAggressiveCompaction = true);
bool fgUpdateFlowGraph(bool doTailDup = false, bool isPhase = false);
PhaseStatus fgUpdateFlowGraphPhase();

PhaseStatus fgDfsBlocksAndRemove();
Expand Down Expand Up @@ -6354,7 +6354,7 @@ class Compiler

static fgWalkPreFn fgStress64RsltMulCB;
void fgStress64RsltMul();
void fgDebugCheckUpdate(const bool doAggressiveCompaction);
void fgDebugCheckUpdate();

void fgDebugCheckBBNumIncreasing();
void fgDebugCheckBBlist(bool checkBBNum = false, bool checkBBRefs = true);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void Compiler::fgPrintEdgeWeights()

#ifdef DEBUG

void Compiler::fgDebugCheckUpdate(const bool doAggressiveCompaction)
void Compiler::fgDebugCheckUpdate()
{
if (!compStressCompile(STRESS_CHK_FLOW_UPDATE, 30))
{
Expand Down Expand Up @@ -139,7 +139,7 @@ void Compiler::fgDebugCheckUpdate(const bool doAggressiveCompaction)

/* no un-compacted blocks */

if (fgCanCompactBlock(block) && (doAggressiveCompaction || block->JumpsToNext()))
if (fgCanCompactBlock(block))
{
noway_assert(!"Found un-compacted blocks!");
}
Expand Down
10 changes: 3 additions & 7 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5586,18 +5586,14 @@ PhaseStatus Compiler::fgUpdateFlowGraphPhase()
// Arguments:
// doTailDuplication - true to attempt tail duplication optimization
// isPhase - true if being run as the only thing in a phase
// doAggressiveCompaction - if false, only compact blocks that jump to the next block
// to prevent modifying the flowgraph; else, compact as much as possible
//
// Returns: true if the flowgraph has been modified
//
// Notes:
// Debuggable code and Min Optimization JIT also introduces basic blocks
// but we do not optimize those!
//
bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */,
bool isPhase /* = false */,
bool doAggressiveCompaction /* = true */)
bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPhase /* = false */)
{
#ifdef DEBUG
if (verbose && !isPhase)
Expand Down Expand Up @@ -5981,7 +5977,7 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */,

/* COMPACT blocks if possible */

if (fgCanCompactBlock(block) && (doAggressiveCompaction || block->JumpsToNext()))
if (fgCanCompactBlock(block))
{
fgCompactBlock(block);

Expand Down Expand Up @@ -6115,7 +6111,7 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */,
fgVerifyHandlerTab();
// Make sure that the predecessor lists are accurate
fgDebugCheckBBlist();
fgDebugCheckUpdate(doAggressiveCompaction);
fgDebugCheckUpdate();
}
#endif // DEBUG

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7885,9 +7885,7 @@ PhaseStatus Lowering::DoPhase()

comp->fgLocalVarLiveness();
// local var liveness can delete code, which may create empty blocks
// Don't churn the flowgraph with aggressive compaction since we've already run block layout
bool modified = comp->fgUpdateFlowGraph(/* doTailDuplication */ false, /* isPhase */ false,
/* doAggressiveCompaction */ false);
bool modified = comp->fgUpdateFlowGraph(/* doTailDuplication */ false, /* isPhase */ false);

if (modified)
{
Expand Down

0 comments on commit 052ad42

Please sign in to comment.