Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Add simple late layout pass #107483

Merged
merged 2 commits into from
Sep 10, 2024
Merged
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
26 changes: 22 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5238,11 +5238,12 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
m_pLowering->FinalizeOutgoingArgSpace();

// We can not add any new tracked variables after this point.
lvaTrackedFixed = true;
lvaTrackedFixed = true;
const unsigned numBlocksBeforeLSRA = fgBBcount;

// Now that lowering is completed we can proceed to perform register allocation
//
auto linearScanPhase = [this]() {
auto linearScanPhase = [this] {
m_pLinearScan->doLinearScan();
};
DoPhase(this, PHASE_LINEAR_SCAN, linearScanPhase);
Expand All @@ -5252,8 +5253,25 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl

if (opts.OptimizationEnabled())
{
// LSRA and stack level setting can modify the flowgraph.
// Now that it won't change, run post-layout optimizations.
// LSRA may introduce new blocks. If it does, rerun layout.
if ((fgBBcount != numBlocksBeforeLSRA) && JitConfig.JitDoReversePostOrderLayout())
{
auto lateLayoutPhase = [this] {
fgDoReversePostOrderLayout();
fgMoveColdBlocks();
return PhaseStatus::MODIFIED_EVERYTHING;
};

DoPhase(this, PHASE_OPTIMIZE_LAYOUT, lateLayoutPhase);

if (fgFirstColdBlock != nullptr)
{
fgFirstColdBlock = nullptr;
DoPhase(this, PHASE_DETERMINE_FIRST_COLD_BLOCK, &Compiler::fgDetermineFirstColdBlock);
}
}

// Now that the flowgraph is finalized, run post-layout optimizations.
DoPhase(this, PHASE_OPTIMIZE_POST_LAYOUT, &Compiler::optOptimizePostLayout);
}

Expand Down
Loading