Skip to content

Commit 861a886

Browse files
authored
JIT: have inliner use fgSplitBlockAfterStatement (#80928)
In anticipation of moving pred list building before inlining, use the common block split utility instead of custom code. This does a better job of propagating IL offsets, and automatically handles pred list maintenance. Contributes to #80193.
1 parent 31e4f40 commit 861a886

1 file changed

Lines changed: 1 addition & 72 deletions

File tree

src/coreclr/jit/fginline.cpp

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,78 +1164,7 @@ void Compiler::fgInsertInlineeBlocks(InlineInfo* pInlineInfo)
11641164
//
11651165
// ======= Inserting inlinee's basic blocks ===============
11661166
//
1167-
1168-
bottomBlock = fgNewBBafter(topBlock->bbJumpKind, topBlock, true);
1169-
bottomBlock->bbRefs = 1;
1170-
bottomBlock->bbJumpDest = topBlock->bbJumpDest;
1171-
bottomBlock->inheritWeight(topBlock);
1172-
1173-
topBlock->bbJumpKind = BBJ_NONE;
1174-
1175-
// Update block flags
1176-
{
1177-
const BasicBlockFlags originalFlags = topBlock->bbFlags;
1178-
noway_assert((originalFlags & BBF_SPLIT_NONEXIST) == 0);
1179-
topBlock->bbFlags &= ~(BBF_SPLIT_LOST);
1180-
bottomBlock->bbFlags |= originalFlags & BBF_SPLIT_GAINED;
1181-
}
1182-
1183-
// Split statements between topBlock and bottomBlock.
1184-
// First figure out bottomBlock_Begin
1185-
Statement* bottomBlock_Begin;
1186-
bottomBlock_Begin = stmtAfter->GetNextStmt();
1187-
1188-
if (topBlock->bbStmtList == nullptr)
1189-
{
1190-
// topBlock is empty before the split.
1191-
// In this case, both topBlock and bottomBlock should be empty
1192-
noway_assert(bottomBlock_Begin == nullptr);
1193-
topBlock->bbStmtList = nullptr;
1194-
bottomBlock->bbStmtList = nullptr;
1195-
}
1196-
else if (topBlock->bbStmtList == bottomBlock_Begin)
1197-
{
1198-
noway_assert(bottomBlock_Begin != nullptr);
1199-
1200-
// topBlock contains at least one statement before the split.
1201-
// And the split is before the first statement.
1202-
// In this case, topBlock should be empty, and everything else should be moved to the bottomBlock.
1203-
bottomBlock->bbStmtList = topBlock->bbStmtList;
1204-
topBlock->bbStmtList = nullptr;
1205-
}
1206-
else if (bottomBlock_Begin == nullptr)
1207-
{
1208-
noway_assert(topBlock->bbStmtList != nullptr);
1209-
1210-
// topBlock contains at least one statement before the split.
1211-
// And the split is at the end of the topBlock.
1212-
// In this case, everything should be kept in the topBlock, and the bottomBlock should be empty
1213-
1214-
bottomBlock->bbStmtList = nullptr;
1215-
}
1216-
else
1217-
{
1218-
noway_assert(topBlock->bbStmtList != nullptr);
1219-
noway_assert(bottomBlock_Begin != nullptr);
1220-
1221-
// This is the normal case where both blocks should contain at least one statement.
1222-
Statement* topBlock_Begin = topBlock->firstStmt();
1223-
noway_assert(topBlock_Begin != nullptr);
1224-
Statement* topBlock_End = bottomBlock_Begin->GetPrevStmt();
1225-
noway_assert(topBlock_End != nullptr);
1226-
Statement* bottomBlock_End = topBlock->lastStmt();
1227-
noway_assert(bottomBlock_End != nullptr);
1228-
1229-
// Break the linkage between 2 blocks.
1230-
topBlock_End->SetNextStmt(nullptr);
1231-
1232-
// Fix up all the pointers.
1233-
topBlock->bbStmtList = topBlock_Begin;
1234-
topBlock->bbStmtList->SetPrevStmt(topBlock_End);
1235-
1236-
bottomBlock->bbStmtList = bottomBlock_Begin;
1237-
bottomBlock->bbStmtList->SetPrevStmt(bottomBlock_End);
1238-
}
1167+
bottomBlock = fgSplitBlockAfterStatement(topBlock, stmtAfter);
12391168

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

0 commit comments

Comments
 (0)