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: Avoid relying on bbNum to find lexical loop boundaries #101714

Merged
merged 1 commit into from
Apr 30, 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
30 changes: 16 additions & 14 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5555,20 +5555,21 @@ bool FlowGraphNaturalLoop::InitBlockEntersLoopOnTrue(BasicBlock* initBlock)
// the loop.
//
// Returns:
// Block with highest bbNum.
// First block in block order contained in the loop.
//
// Remarks:
// Mostly exists as a quirk while transitioning from the old loop
// representation to the new one.
//
BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock()
{
BasicBlock* top = m_header;
VisitLoopBlocks([&top](BasicBlock* loopBlock) {
if (loopBlock->bbNum < top->bbNum)
top = loopBlock;
return BasicBlockVisit::Continue;
});
BasicBlock* top = m_dfsTree->GetCompiler()->fgFirstBB;

while (!ContainsBlock(top))
{
top = top->Next();
assert(top != nullptr);
}

return top;
}
Expand All @@ -5578,20 +5579,21 @@ BasicBlock* FlowGraphNaturalLoop::GetLexicallyTopMostBlock()
// within the loop.
//
// Returns:
// Block with highest bbNum.
// Last block in block order contained in the loop.
//
// Remarks:
// Mostly exists as a quirk while transitioning from the old loop
// representation to the new one.
//
BasicBlock* FlowGraphNaturalLoop::GetLexicallyBottomMostBlock()
{
BasicBlock* bottom = m_header;
VisitLoopBlocks([&bottom](BasicBlock* loopBlock) {
if (loopBlock->bbNum > bottom->bbNum)
bottom = loopBlock;
return BasicBlockVisit::Continue;
});
BasicBlock* bottom = m_dfsTree->GetCompiler()->fgLastBB;

while (!ContainsBlock(bottom))
{
bottom = bottom->Prev();
assert(bottom != nullptr);
}

return bottom;
}
Expand Down
Loading