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

Fix maintenance of genReturnBB pointer #96935

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5354,6 +5354,8 @@ class Compiler
IL_OFFSET fgFindBlockILOffset(BasicBlock* block);
void fgFixEntryFlowForOSR();

void fgUpdateSingleReturnBlock(BasicBlock* block);

BasicBlock* fgSplitBlockAtBeginning(BasicBlock* curr);
BasicBlock* fgSplitBlockAtEnd(BasicBlock* curr);
BasicBlock* fgSplitBlockAfterStatement(BasicBlock* curr, Statement* stmt);
Expand Down
20 changes: 20 additions & 0 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4746,6 +4746,24 @@ IL_OFFSET Compiler::fgFindBlockILOffset(BasicBlock* block)
return BAD_IL_OFFSET;
}

//------------------------------------------------------------------------------
// fgUpdateSingleReturnBlock : A block has been split. If it was the single return
// block, then update the single return block pointer.
//
// Arguments:
// block - The block that was split
//
void Compiler::fgUpdateSingleReturnBlock(BasicBlock* block)
{
assert(block->KindIs(BBJ_ALWAYS));
if (genReturnBB == block)
{
assert(block->GetTarget()->KindIs(BBJ_RETURN));
JITDUMP("Updating genReturnBB from " FMT_BB " to " FMT_BB "\n", block->bbNum, block->GetTarget()->bbNum);
genReturnBB = block->GetTarget();
}
}

//------------------------------------------------------------------------------
// fgSplitBlockAtEnd - split the given block into two blocks.
// All code in the block stays in the original block.
Expand Down Expand Up @@ -4822,6 +4840,8 @@ BasicBlock* Compiler::fgSplitBlockAtEnd(BasicBlock* curr)

fgAddRefPred(newBlock, curr);

fgUpdateSingleReturnBlock(curr);

return newBlock;
}

Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,12 @@ void Compiler::fgTableDispBasicBlock(BasicBlock* block, int ibcColWidth /* = 0 *
}
}

// Indicate if it's the single return block
if (block == genReturnBB)
{
printf(" one-return");
}

printf("\n");
}

Expand Down Expand Up @@ -3239,6 +3245,7 @@ void Compiler::fgDebugCheckBBlist(bool checkBBNum /* = false */, bool checkBBRef
if (genReturnBB != nullptr)
{
assert(genReturnBB->GetFirstLIRNode() != nullptr || genReturnBB->bbStmtList != nullptr);
assert(genReturnBB->KindIs(BBJ_RETURN));
}

// If this is an inlinee, we're done checking.
Expand Down