Skip to content

Commit 3665779

Browse files
authored
Fix GC Poll inlining. (#39881)
* Don't inline GC polls in cold basic blocks. * Allow GC poll inlining in basic blocks with `BBF_LOOP_PREHEADER` or `BBF_RETLESS_CALL` set. This fixes one of the assert seen in #39474 (comment) Contributes to resolving #39726.
1 parent 7abd114 commit 3665779

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/coreclr/src/jit/flowgraph.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,18 @@ PhaseStatus Compiler::fgInsertGCPolls()
36993699
// We don't want to deal with all the outgoing edges of a switch block.
37003700
pollType = GCPOLL_CALL;
37013701
}
3702+
else if ((block->bbFlags & BBF_COLD) != 0)
3703+
{
3704+
#ifdef DEBUG
3705+
if (verbose)
3706+
{
3707+
printf("Selecting CALL poll in block " FMT_BB " because it is a cold block\n", block->bbNum);
3708+
}
3709+
#endif // DEBUG
3710+
3711+
// We don't want to split a cold block.
3712+
pollType = GCPOLL_CALL;
3713+
}
37023714

37033715
BasicBlock* curBasicBlock = fgCreateGCPoll(pollType, block);
37043716
createdPollBlocks |= (block != curBasicBlock);
@@ -4141,9 +4153,12 @@ BasicBlock* Compiler::fgCreateGCPoll(GCPollType pollType, BasicBlock* block)
41414153

41424154
// We are allowed to split loops and we need to keep a few other flags...
41434155
//
4144-
noway_assert((originalFlags & (BBF_SPLIT_NONEXIST & ~(BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1))) == 0);
4145-
top->bbFlags = originalFlags & (~BBF_SPLIT_LOST | BBF_GC_SAFE_POINT);
4146-
bottom->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT);
4156+
noway_assert((originalFlags & (BBF_SPLIT_NONEXIST &
4157+
~(BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1 | BBF_LOOP_PREHEADER |
4158+
BBF_RETLESS_CALL))) == 0);
4159+
top->bbFlags = originalFlags & (~(BBF_SPLIT_LOST | BBF_LOOP_PREHEADER | BBF_RETLESS_CALL) | BBF_GC_SAFE_POINT);
4160+
bottom->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT | BBF_LOOP_PREHEADER |
4161+
BBF_RETLESS_CALL);
41474162
bottom->inheritWeight(top);
41484163
poll->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT);
41494164

0 commit comments

Comments
 (0)