JIT: Continue profile consistency checks until after finally cloning (#109792)
Part of #107749. The next few opt phases alter flow substantially, such that we need to propagate new weight throughout the flowgraph. That will probably justify running profile synthesis after, in a later PR.
This commit is contained in:
Родитель
7eecb045f7
Коммит
1e3544ec04
|
@ -4609,11 +4609,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
|
|||
// Record "start" values for post-inlining cycles and elapsed time.
|
||||
RecordStateAtEndOfInlining();
|
||||
|
||||
// Drop back to just checking profile likelihoods.
|
||||
//
|
||||
activePhaseChecks &= ~PhaseChecks::CHECK_PROFILE;
|
||||
activePhaseChecks |= PhaseChecks::CHECK_LIKELIHOODS;
|
||||
|
||||
if (opts.OptimizationEnabled())
|
||||
{
|
||||
// Build post-order and remove dead blocks
|
||||
|
@ -4658,6 +4653,11 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
|
|||
//
|
||||
DoPhase(this, PHASE_CLONE_FINALLY, &Compiler::fgCloneFinally);
|
||||
|
||||
// Drop back to just checking profile likelihoods.
|
||||
//
|
||||
activePhaseChecks &= ~PhaseChecks::CHECK_PROFILE;
|
||||
activePhaseChecks |= PhaseChecks::CHECK_LIKELIHOODS;
|
||||
|
||||
// Do some flow-related optimizations
|
||||
//
|
||||
if (opts.OptimizationEnabled())
|
||||
|
|
|
@ -1038,8 +1038,27 @@ PhaseStatus Compiler::fgCloneFinally()
|
|||
const unsigned finallyTryIndex = firstBlock->bbTryIndex;
|
||||
BasicBlock* insertAfter = nullptr;
|
||||
BlockToBlockMap blockMap(getAllocator());
|
||||
unsigned cloneBBCount = 0;
|
||||
weight_t const originalWeight = firstBlock->hasProfileWeight() ? firstBlock->bbWeight : BB_ZERO_WEIGHT;
|
||||
unsigned cloneBBCount = 0;
|
||||
weight_t originalWeight;
|
||||
|
||||
// When distributing weight between the original and cloned regions,
|
||||
// ensure only weight from region entries is considered.
|
||||
// Flow from loop backedges within the region should not influence the weight distribution ratio.
|
||||
if (firstBlock->hasProfileWeight())
|
||||
{
|
||||
originalWeight = firstBlock->bbWeight;
|
||||
for (BasicBlock* const predBlock : firstBlock->PredBlocks())
|
||||
{
|
||||
if (!predBlock->KindIs(BBJ_CALLFINALLY))
|
||||
{
|
||||
originalWeight = max(0.0, originalWeight - predBlock->bbWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
originalWeight = BB_ZERO_WEIGHT;
|
||||
}
|
||||
|
||||
for (BasicBlock* block = firstBlock; block != nextBlock; block = block->Next())
|
||||
{
|
||||
|
|
|
@ -1401,15 +1401,8 @@ void Compiler::fgAddSyncMethodEnterExit()
|
|||
// Create a block for the start of the try region, where the monitor enter call
|
||||
// will go.
|
||||
BasicBlock* const tryBegBB = fgSplitBlockAtEnd(fgFirstBB);
|
||||
BasicBlock* const tryNextBB = tryBegBB->Next();
|
||||
BasicBlock* const tryLastBB = fgLastBB;
|
||||
|
||||
// If we have profile data the new block will inherit the next block's weight
|
||||
if (tryNextBB->hasProfileWeight())
|
||||
{
|
||||
tryBegBB->inheritWeight(tryNextBB);
|
||||
}
|
||||
|
||||
// Create a block for the fault.
|
||||
// It gets an artificial ref count.
|
||||
|
||||
|
|
|
@ -673,6 +673,9 @@ unsigned int ObjectAllocator::MorphAllocObjNodeIntoStackAlloc(
|
|||
if (predBlock->hasProfileWeight())
|
||||
{
|
||||
block->setBBProfileWeight(predBlock->bbWeight);
|
||||
JITDUMP("Profile weight into " FMT_BB " needs to be propagated to successors. Profile %s inconsistent.\n",
|
||||
block->bbNum, comp->fgPgoConsistent ? "is now" : "was already");
|
||||
comp->fgPgoConsistent = false;
|
||||
}
|
||||
|
||||
// Just lop off the JTRUE, the rest can clean up later
|
||||
|
|
Загрузка…
Ссылка в новой задаче