Skip to content

Commit

Permalink
JIT: Remove some fgRenumberBlocks calls (dotnet#110026)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanasifkhalid authored and mikelle-rogers committed Dec 4, 2024
1 parent 0173fec commit 94477eb
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 57 deletions.
9 changes: 0 additions & 9 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4761,13 +4761,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
};
DoPhase(this, PHASE_POST_MORPH, postMorphPhase);

// If we needed to create any new BasicBlocks then renumber the blocks
//
if (fgBBcount > preMorphBBCount)
{
fgRenumberBlocks();
}

// GS security checks for unsafe buffers
//
DoPhase(this, PHASE_GS_COOKIE, &Compiler::gsPhase);
Expand Down Expand Up @@ -5888,8 +5881,6 @@ void Compiler::RecomputeFlowGraphAnnotations()
// Recompute reachability sets, dominators, and loops.
optResetLoopInfo();

fgRenumberBlocks();
fgInvalidateDfsTree();
fgDfsBlocksAndRemove();
optFindLoops();

Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,14 +913,6 @@ PhaseStatus Compiler::fgInline()

#endif // DEBUG

if (madeChanges)
{
// Optional quirk to keep this as zero diff. Some downstream phases are bbNum sensitive
// but rely on the ambient bbNums.
//
fgRenumberBlocks();
}

if (fgPgoConsistent)
{
Metrics.ProfileConsistentAfterInline++;
Expand Down
14 changes: 1 addition & 13 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,25 +752,13 @@ PhaseStatus Compiler::fgPostImportationCleanup()
}
}

// Did we alter any flow or EH?
//
const bool madeFlowChanges = (addedBlocks > 0) || (delCnt > 0) || (removedBlks > 0);

// Renumber the basic blocks if so.
//
if (madeFlowChanges)
{
JITDUMP("\nRenumbering the basic blocks for fgPostImportationCleanup\n");
fgRenumberBlocks();
}

#ifdef DEBUG
fgVerifyHandlerTab();
#endif // DEBUG

// Did we make any changes?
//
const bool madeChanges = madeFlowChanges || addedTemps;
const bool madeChanges = (addedBlocks > 0) || (delCnt > 0) || (removedBlks > 0) || addedTemps;

// Note that we have now run post importation cleanup,
// so we can enable more stringent checking.
Expand Down
7 changes: 1 addition & 6 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,8 @@ PhaseStatus Compiler::fgInsertGCPolls()
block = curBasicBlock;
}

// If we split a block to create a GC Poll, call fgUpdateChangedFlowGraph.
// We should never split blocks unless we're optimizing.
if (createdPollBlocks)
{
noway_assert(opts.OptimizationEnabled());
fgRenumberBlocks();
}
assert(!createdPollBlocks || opts.OptimizationEnabled());

return result;
}
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/jit/gschecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ PhaseStatus Compiler::gsPhase()
gsCopyShadowParams();
}

// If we needed to create any new BasicBlocks then renumber the blocks
if (fgBBcount > prevBBCount)
{
fgRenumberBlocks();
}

madeChanges = true;
}
else
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/helperexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,11 +1225,6 @@ PhaseStatus Compiler::fgExpandHelper(bool skipRarelyRunBlocks)
if (result == PhaseStatus::MODIFIED_EVERYTHING)
{
fgInvalidateDfsTree();

if (opts.OptimizationEnabled())
{
fgRenumberBlocks();
}
}

return result;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/jiteh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2123,8 +2123,8 @@ void Compiler::fgNormalizeEH()
if (modified)
{
JITDUMP("Added at least one basic block in fgNormalizeEH.\n");
fgRenumberBlocks();
// fgRenumberBlocks() will dump all the blocks and the handler table, so we don't need to do it here.
JITDUMPEXEC(fgDispBasicBlocks());
JITDUMPEXEC(fgDispHandlerTab());
INDEBUG(fgVerifyHandlerTab());
}
else
Expand Down
11 changes: 3 additions & 8 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ DataFlow::DataFlow(Compiler* pCompiler)
PhaseStatus Compiler::optSetBlockWeights()
{
noway_assert(opts.OptimizationEnabled());
bool madeChanges = false;

assert(m_dfsTree != nullptr);
if (m_domTree == nullptr)
Expand All @@ -53,11 +54,11 @@ PhaseStatus Compiler::optSetBlockWeights()

if (m_dfsTree->HasCycle())
{
madeChanges = fgRenumberBlocks();
optMarkLoopHeads();
optFindAndScaleGeneralLoopBlocks();
}

bool madeChanges = false;
bool firstBBDominatesAllReturns = true;
const bool usingProfileWeights = fgIsUsingProfileWeights();

Expand Down Expand Up @@ -1335,13 +1336,11 @@ PhaseStatus Compiler::optUnrollLoops()
m_loops = FlowGraphNaturalLoops::Find(m_dfsTree);
}

fgRenumberBlocks();

DBEXEC(verbose, fgDispBasicBlocks());
}

#ifdef DEBUG
fgDebugCheckBBlist(true);
fgDebugCheckBBlist();
#endif // DEBUG

return anyIRchange ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
Expand Down Expand Up @@ -2687,8 +2686,6 @@ PhaseStatus Compiler::optFindLoopsPhase()
}
#endif

fgRenumberBlocks();

assert(m_dfsTree != nullptr);
optFindLoops();

Expand All @@ -2713,8 +2710,6 @@ void Compiler::optFindLoops()
m_loops = FlowGraphNaturalLoops::Find(m_dfsTree);
}

fgRenumberBlocks();

// Starting now we require all loops to be in canonical form.
optLoopsCanonical = true;

Expand Down

0 comments on commit 94477eb

Please sign in to comment.