Skip to content

Commit

Permalink
Fix GC Poll inlining. (dotnet#39881)
Browse files Browse the repository at this point in the history
* 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 dotnet#39474 (comment)

Contributes to resolving dotnet#39726.
  • Loading branch information
erozenfeld authored and Jacksondr5 committed Aug 10, 2020
1 parent 26331af commit 0c45c49
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/coreclr/src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3699,6 +3699,18 @@ PhaseStatus Compiler::fgInsertGCPolls()
// We don't want to deal with all the outgoing edges of a switch block.
pollType = GCPOLL_CALL;
}
else if ((block->bbFlags & BBF_COLD) != 0)
{
#ifdef DEBUG
if (verbose)
{
printf("Selecting CALL poll in block " FMT_BB " because it is a cold block\n", block->bbNum);
}
#endif // DEBUG

// We don't want to split a cold block.
pollType = GCPOLL_CALL;
}

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

// We are allowed to split loops and we need to keep a few other flags...
//
noway_assert((originalFlags & (BBF_SPLIT_NONEXIST & ~(BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1))) == 0);
top->bbFlags = originalFlags & (~BBF_SPLIT_LOST | BBF_GC_SAFE_POINT);
bottom->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT);
noway_assert((originalFlags & (BBF_SPLIT_NONEXIST &
~(BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1 | BBF_LOOP_PREHEADER |
BBF_RETLESS_CALL))) == 0);
top->bbFlags = originalFlags & (~(BBF_SPLIT_LOST | BBF_LOOP_PREHEADER | BBF_RETLESS_CALL) | BBF_GC_SAFE_POINT);
bottom->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT | BBF_LOOP_PREHEADER |
BBF_RETLESS_CALL);
bottom->inheritWeight(top);
poll->bbFlags |= originalFlags & (BBF_SPLIT_GAINED | BBF_IMPORTED | BBF_GC_SAFE_POINT);

Expand Down

0 comments on commit 0c45c49

Please sign in to comment.