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: Consolidate layout passes into one phase #112004

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0a70d2a
Reorder block list only once after 3-opt
amanasifkhalid Jan 29, 2025
25389c9
Fix block insertion
amanasifkhalid Jan 30, 2025
df25317
Run 3-opt once for all regions
amanasifkhalid Jan 30, 2025
46539d5
Remove some EH checks
amanasifkhalid Jan 30, 2025
84600ec
Remove unused layout methods
amanasifkhalid Jan 30, 2025
289134a
Relax EH invariants; better stress mode
amanasifkhalid Jan 30, 2025
94d4f84
Place cold blocks in RPO
amanasifkhalid Jan 30, 2025
38b3700
Merge from main
amanasifkhalid Feb 5, 2025
a2774e0
Clean up 3-opt driver a bit
amanasifkhalid Feb 5, 2025
1262dd6
Clean up 3-opt driver a bit
amanasifkhalid Feb 6, 2025
918c557
Merge from main
amanasifkhalid Feb 6, 2025
1404f80
Cold code motion working
amanasifkhalid Feb 6, 2025
26359c4
Move try regions
amanasifkhalid Feb 7, 2025
f062f0b
Ensure method entry is considered hot by 3-opt
amanasifkhalid Feb 7, 2025
ce79655
Always invalidate DFS tree after layout
amanasifkhalid Feb 7, 2025
2520f7a
Revert "Always invalidate DFS tree after layout"
amanasifkhalid Feb 7, 2025
e54dbb5
Fix DFS tree invalidation logic
amanasifkhalid Feb 7, 2025
2f5f342
Merge from main
amanasifkhalid Feb 20, 2025
f08a756
Style; use bbPreorderNum for ordinal
amanasifkhalid Feb 20, 2025
447b2dd
Cleanup
amanasifkhalid Feb 20, 2025
6f7ec57
Fix call-finally motion
amanasifkhalid Feb 20, 2025
5d32277
fgFindEHRegionEnds -> fgFindTryRegionEnds
amanasifkhalid Feb 20, 2025
52536be
Style
amanasifkhalid Feb 21, 2025
60303ad
Recompute try region ends only when necessary
amanasifkhalid Feb 21, 2025
2497d6b
Merge branch 'main' into one-layout-phase
amanasifkhalid Feb 21, 2025
c3b78a3
Merge branch 'main' into one-layout-phase
amanasifkhalid Feb 21, 2025
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
25 changes: 1 addition & 24 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5246,30 +5246,7 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
//
if (JitConfig.JitDoReversePostOrderLayout())
{
auto lateLayoutPhase = [this] {
// Skip preliminary reordering passes to create more work for 3-opt layout
if (compStressCompile(STRESS_THREE_OPT_LAYOUT, 10))
{
m_dfsTree = fgComputeDfs</* useProfile */ true>();
}
else
{
fgDoReversePostOrderLayout();
fgMoveColdBlocks();
}

fgSearchImprovedLayout();
fgInvalidateDfsTree();

if (compHndBBtabCount != 0)
{
fgRebuildEHRegions();
}

return PhaseStatus::MODIFIED_EVERYTHING;
};

DoPhase(this, PHASE_OPTIMIZE_LAYOUT, lateLayoutPhase);
DoPhase(this, PHASE_OPTIMIZE_LAYOUT, &Compiler::fgSearchImprovedLayout);
}
else
{
Expand Down
15 changes: 7 additions & 8 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,7 @@ class Compiler

void fgSetHndEnd(EHblkDsc* handlerTab, BasicBlock* newHndLast);

void fgRebuildEHRegions();
void fgFindTryRegionEnds();

void fgSkipRmvdBlocks(EHblkDsc* handlerTab);

Expand Down Expand Up @@ -6352,9 +6352,7 @@ class Compiler
bool fgComputeMissingBlockWeights();

bool fgReorderBlocks(bool useProfile);
void fgDoReversePostOrderLayout();
void fgMoveColdBlocks();
void fgSearchImprovedLayout();
PhaseStatus fgSearchImprovedLayout();

class ThreeOptLayout
{
Expand All @@ -6381,12 +6379,13 @@ class Compiler
void AddNonFallthroughPreds(unsigned blockPos);
bool RunGreedyThreeOptPass(unsigned startPos, unsigned endPos);

bool CompactHotJumps();
bool RunThreeOpt();
void RunThreeOpt();
void CompactHotJumps();
bool ReorderBlockList();

public:
ThreeOptLayout(Compiler* comp);
void Run();
ThreeOptLayout(Compiler* comp, BasicBlock** initialLayout, unsigned numHotBlocks);
bool Run();
};

bool fgFuncletsAreCold();
Expand Down
Loading
Loading