Skip to content

Commit 1434eee

Browse files
JIT: Run new block layout only in backend (#107634)
1 parent e195258 commit 1434eee

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5235,8 +5235,7 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
52355235
m_pLowering->FinalizeOutgoingArgSpace();
52365236

52375237
// We can not add any new tracked variables after this point.
5238-
lvaTrackedFixed = true;
5239-
const unsigned numBlocksBeforeLSRA = fgBBcount;
5238+
lvaTrackedFixed = true;
52405239

52415240
// Now that lowering is completed we can proceed to perform register allocation
52425241
//
@@ -5250,8 +5249,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
52505249

52515250
if (opts.OptimizationEnabled())
52525251
{
5253-
// LSRA may introduce new blocks. If it does, rerun layout.
5254-
if ((fgBBcount != numBlocksBeforeLSRA) && JitConfig.JitDoReversePostOrderLayout())
5252+
// We won't introduce new blocks from here on out,
5253+
// so run the new block layout.
5254+
//
5255+
if (JitConfig.JitDoReversePostOrderLayout())
52555256
{
52565257
auto lateLayoutPhase = [this] {
52575258
fgDoReversePostOrderLayout();
@@ -5272,7 +5273,12 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
52725273
DoPhase(this, PHASE_DETERMINE_FIRST_COLD_BLOCK, &Compiler::fgDetermineFirstColdBlock);
52735274

52745275
// Now that the flowgraph is finalized, run post-layout optimizations.
5276+
//
52755277
DoPhase(this, PHASE_OPTIMIZE_POST_LAYOUT, &Compiler::optOptimizePostLayout);
5278+
5279+
// Determine start of cold region if we are hot/cold splitting
5280+
//
5281+
DoPhase(this, PHASE_DETERMINE_FIRST_COLD_BLOCK, &Compiler::fgDetermineFirstColdBlock);
52765282
}
52775283

52785284
#if FEATURE_LOOP_ALIGN

src/coreclr/jit/fgopt.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,22 +3341,12 @@ bool Compiler::fgReorderBlocks(bool useProfile)
33413341

33423342
if (useProfile)
33433343
{
3344+
// Don't run the new layout until we get to the backend,
3345+
// since LSRA can introduce new blocks, and lowering can churn the flowgraph.
3346+
//
33443347
if (JitConfig.JitDoReversePostOrderLayout())
33453348
{
3346-
fgDoReversePostOrderLayout();
3347-
fgMoveColdBlocks();
3348-
3349-
if (compHndBBtabCount != 0)
3350-
{
3351-
fgRebuildEHRegions();
3352-
}
3353-
3354-
// Renumber blocks to facilitate LSRA's order of block visitation
3355-
// TODO: Consider removing this, and using traversal order in lSRA
3356-
//
3357-
fgRenumberBlocks();
3358-
3359-
return true;
3349+
return (newRarelyRun || movedBlocks || optimizedSwitches);
33603350
}
33613351

33623352
// We will be reordering blocks, so ensure the false target of a BBJ_COND block is its next block

0 commit comments

Comments
 (0)