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: have inliner use fgSplitBlockAfterStatement #80928

Merged
merged 1 commit into from
Jan 20, 2023
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
73 changes: 1 addition & 72 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,78 +1164,7 @@ void Compiler::fgInsertInlineeBlocks(InlineInfo* pInlineInfo)
//
// ======= Inserting inlinee's basic blocks ===============
//

bottomBlock = fgNewBBafter(topBlock->bbJumpKind, topBlock, true);
bottomBlock->bbRefs = 1;
bottomBlock->bbJumpDest = topBlock->bbJumpDest;
bottomBlock->inheritWeight(topBlock);

topBlock->bbJumpKind = BBJ_NONE;

// Update block flags
{
const BasicBlockFlags originalFlags = topBlock->bbFlags;
noway_assert((originalFlags & BBF_SPLIT_NONEXIST) == 0);
topBlock->bbFlags &= ~(BBF_SPLIT_LOST);
bottomBlock->bbFlags |= originalFlags & BBF_SPLIT_GAINED;
}

// Split statements between topBlock and bottomBlock.
// First figure out bottomBlock_Begin
Statement* bottomBlock_Begin;
bottomBlock_Begin = stmtAfter->GetNextStmt();

if (topBlock->bbStmtList == nullptr)
{
// topBlock is empty before the split.
// In this case, both topBlock and bottomBlock should be empty
noway_assert(bottomBlock_Begin == nullptr);
topBlock->bbStmtList = nullptr;
bottomBlock->bbStmtList = nullptr;
}
else if (topBlock->bbStmtList == bottomBlock_Begin)
{
noway_assert(bottomBlock_Begin != nullptr);

// topBlock contains at least one statement before the split.
// And the split is before the first statement.
// In this case, topBlock should be empty, and everything else should be moved to the bottomBlock.
bottomBlock->bbStmtList = topBlock->bbStmtList;
topBlock->bbStmtList = nullptr;
}
else if (bottomBlock_Begin == nullptr)
{
noway_assert(topBlock->bbStmtList != nullptr);

// topBlock contains at least one statement before the split.
// And the split is at the end of the topBlock.
// In this case, everything should be kept in the topBlock, and the bottomBlock should be empty

bottomBlock->bbStmtList = nullptr;
}
else
{
noway_assert(topBlock->bbStmtList != nullptr);
noway_assert(bottomBlock_Begin != nullptr);

// This is the normal case where both blocks should contain at least one statement.
Statement* topBlock_Begin = topBlock->firstStmt();
noway_assert(topBlock_Begin != nullptr);
Statement* topBlock_End = bottomBlock_Begin->GetPrevStmt();
noway_assert(topBlock_End != nullptr);
Statement* bottomBlock_End = topBlock->lastStmt();
noway_assert(bottomBlock_End != nullptr);

// Break the linkage between 2 blocks.
topBlock_End->SetNextStmt(nullptr);

// Fix up all the pointers.
topBlock->bbStmtList = topBlock_Begin;
topBlock->bbStmtList->SetPrevStmt(topBlock_End);

bottomBlock->bbStmtList = bottomBlock_Begin;
bottomBlock->bbStmtList->SetPrevStmt(bottomBlock_End);
}
bottomBlock = fgSplitBlockAfterStatement(topBlock, stmtAfter);

//
// Set the try and handler index and fix the jump types of inlinee's blocks.
Expand Down