diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index b56069e2273a8f..c68ab7ac460770 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -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.