diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index 2fd7e201cc99a..1d809cbee2402 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -2206,35 +2206,6 @@ unsigned Compiler::fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, F curBBdesc->bbCodeOffs = curBBoffs; curBBdesc->bbCodeOffsEnd = nxtBBoffs; - BasicBlock::weight_t profileWeight; - - if (fgGetProfileWeightForBasicBlock(curBBoffs, &profileWeight)) - { - if (compIsForInlining()) - { - if (impInlineInfo->profileScaleState == InlineInfo::ProfileScaleState::KNOWN) - { - double scaledWeight = impInlineInfo->profileScaleFactor * profileWeight; - profileWeight = (BasicBlock::weight_t)scaledWeight; - } - } - - curBBdesc->setBBProfileWeight(profileWeight); - - if (profileWeight == 0) - { - curBBdesc->bbSetRunRarely(); - } - else - { - // Note that bbNewBasicBlock (called from fgNewBasicBlock) may have - // already marked the block as rarely run. In that case (and when we know - // that the block profile weight is non-zero) we want to unmark that. - - curBBdesc->bbFlags &= ~BBF_RUN_RARELY; - } - } - switch (jmpKind) { case BBJ_SWITCH: diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index 807c98a777540..3d768985bdf2d 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -932,25 +932,24 @@ PhaseStatus Compiler::fgIncorporateProfileData() // Notes: // Count data for inlinees is scaled (usually down). // +// Since we are now running before the importer, we do not know which +// blocks will be imported, and we should not see any internal blocks. +// // Todo: // Normalize counts. // // Take advantage of the (likely) correspondence between block order // and schema order? // +// Find some other mechanism for handling cases where handler entry +// blocks must be in the hot section. +// void Compiler::fgIncorporateBlockCounts() { for (BasicBlock* block = fgFirstBB; block != nullptr; block = block->bbNext) { BasicBlock::weight_t profileWeight; - // Skip internal and un-imported blocks. - // - if ((block->bbFlags & (BBF_INTERNAL | BBF_IMPORTED)) != BBF_IMPORTED) - { - continue; - } - if (fgGetProfileWeightForBasicBlock(block->bbCodeOffs, &profileWeight)) { if (compIsForInlining()) @@ -972,6 +971,16 @@ void Compiler::fgIncorporateBlockCounts() { block->bbFlags &= ~BBF_RUN_RARELY; } + +#if HANDLER_ENTRY_MUST_BE_IN_HOT_SECTION + // Handle a special case -- some handler entries can't have zero profile count. + // + if (this->bbIsHandlerBeg(block) && block->isRunRarely()) + { + JITDUMP("Suppressing zero count for " FMT_BB " as it is a handler entry\n", block->bbNum); + block->makeBlockHot(); + } +#endif } } }