@@ -3410,49 +3410,64 @@ PhaseStatus Compiler::fgDetermineFirstColdBlock()
34103410 BasicBlock* block;
34113411 BasicBlock* lblk;
34123412
3413- for (lblk = nullptr , block = fgFirstBB; block != nullptr ; lblk = block, block = block->bbNext )
3414- {
3415- bool blockMustBeInHotSection = false ;
3413+ bool forceSplit = false ;
34163414
3417- #if HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION
3418- if (bbIsHandlerBeg (block))
3419- {
3420- blockMustBeInHotSection = true ;
3421- }
3422- #endif // HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION
3415+ #ifdef DEBUG
3416+ // If stress-splitting, split right after the first block; don't handle functions with EH
3417+ forceSplit = JitConfig.JitStressProcedureSplitting () && (compHndBBtabCount == 0 );
3418+ #endif
34233419
3424- // Do we have a candidate for the first cold block?
3425- if (firstColdBlock != nullptr )
3420+ if (forceSplit)
3421+ {
3422+ firstColdBlock = fgFirstBB->bbNext ;
3423+ prevToFirstColdBlock = fgFirstBB;
3424+ }
3425+ else
3426+ {
3427+ for (lblk = nullptr , block = fgFirstBB; block != nullptr ; lblk = block, block = block->bbNext )
34263428 {
3427- // We have a candidate for first cold block
3429+ bool blockMustBeInHotSection = false ;
34283430
3429- // Is this a hot block?
3430- if (blockMustBeInHotSection || (block-> isRunRarely () == false ))
3431+ # if HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION
3432+ if (bbIsHandlerBeg (block))
34313433 {
3432- // We have to restart the search for the first cold block
3433- firstColdBlock = nullptr ;
3434- prevToFirstColdBlock = nullptr ;
3434+ blockMustBeInHotSection = true ;
34353435 }
3436- }
3437- else // (firstColdBlock == NULL)
3438- {
3439- // We don't have a candidate for first cold block
3436+ #endif // HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION
34403437
3441- // Is this a cold block?
3442- if (!blockMustBeInHotSection && (block-> isRunRarely () == true ) )
3438+ // Do we have a candidate for the first cold block?
3439+ if (firstColdBlock != nullptr )
34433440 {
3444- //
3445- // If the last block that was hot was a BBJ_COND
3446- // then we will have to add an unconditional jump
3447- // so the code size for block needs be large
3448- // enough to make it worth our while
3449- //
3450- if ((lblk == nullptr ) || (lblk->bbJumpKind != BBJ_COND) || (fgGetCodeEstimate (block) >= 8 ))
3441+ // We have a candidate for first cold block
3442+
3443+ // Is this a hot block?
3444+ if (blockMustBeInHotSection || (block->isRunRarely () == false ))
34513445 {
3452- // This block is now a candidate for first cold block
3453- // Also remember the predecessor to this block
3454- firstColdBlock = block;
3455- prevToFirstColdBlock = lblk;
3446+ // We have to restart the search for the first cold block
3447+ firstColdBlock = nullptr ;
3448+ prevToFirstColdBlock = nullptr ;
3449+ }
3450+ }
3451+ else // (firstColdBlock == NULL)
3452+ {
3453+ // We don't have a candidate for first cold block
3454+
3455+ // Is this a cold block?
3456+ if (!blockMustBeInHotSection && (block->isRunRarely () == true ))
3457+ {
3458+ //
3459+ // If the last block that was hot was a BBJ_COND
3460+ // then we will have to add an unconditional jump
3461+ // so the code size for block needs be large
3462+ // enough to make it worth our while
3463+ //
3464+ if ((lblk == nullptr ) || (lblk->bbJumpKind != BBJ_COND) || (fgGetCodeEstimate (block) >= 8 ))
3465+ {
3466+ // This block is now a candidate for first cold block
3467+ // Also remember the predecessor to this block
3468+ firstColdBlock = block;
3469+ prevToFirstColdBlock = lblk;
3470+ }
34563471 }
34573472 }
34583473 }
@@ -3479,8 +3494,9 @@ PhaseStatus Compiler::fgDetermineFirstColdBlock()
34793494 // then it may not be worth it to move it
34803495 // into the Cold section as a jump to the
34813496 // Cold section is 5 bytes in size.
3497+ // Ignore if stress-splitting.
34823498 //
3483- if (firstColdBlock->bbNext == nullptr )
3499+ if (!forceSplit && firstColdBlock->bbNext == nullptr )
34843500 {
34853501 // If the size of the cold block is 7 or less
34863502 // then we will keep it in the Hot section.
@@ -3553,6 +3569,7 @@ PhaseStatus Compiler::fgDetermineFirstColdBlock()
35533569 for (block = firstColdBlock; block != nullptr ; block = block->bbNext )
35543570 {
35553571 block->bbFlags |= BBF_COLD;
3572+ block->unmarkLoopAlign (this DEBUG_ARG (" Loop alignment disabled for cold blocks" ));
35563573 }
35573574
35583575EXIT:;
0 commit comments