Skip to content

JIT: build pred lists before object allocation phase #80891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4467,21 +4467,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
// Record "start" values for post-inlining cycles and elapsed time.
RecordStateAtEndOfInlining();

// Transform each GT_ALLOCOBJ node into either an allocation helper call or
// local variable allocation on the stack.
ObjectAllocator objectAllocator(this); // PHASE_ALLOCATE_OBJECTS

if (compObjectStackAllocation() && opts.OptimizationEnabled())
{
objectAllocator.EnableObjectStackAllocation();
}

objectAllocator.Run();

// Add any internal blocks/trees we may need
//
DoPhase(this, PHASE_MORPH_ADD_INTERNAL, &Compiler::fgAddInternal);

// Compute bbNum, bbRefs and bbPreds
//
// This is the first time full (not cheap) preds will be computed.
Expand All @@ -4500,6 +4485,21 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
};
DoPhase(this, PHASE_COMPUTE_PREDS, computePredsPhase);

// Transform each GT_ALLOCOBJ node into either an allocation helper call or
// local variable allocation on the stack.
ObjectAllocator objectAllocator(this); // PHASE_ALLOCATE_OBJECTS

if (compObjectStackAllocation() && opts.OptimizationEnabled())
{
objectAllocator.EnableObjectStackAllocation();
}

objectAllocator.Run();

// Add any internal blocks/trees we may need
//
DoPhase(this, PHASE_MORPH_ADD_INTERNAL, &Compiler::fgAddInternal);

// Remove empty try regions
//
DoPhase(this, PHASE_EMPTY_TRY, &Compiler::fgRemoveEmptyTry);
Expand Down
9 changes: 6 additions & 3 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,8 @@ void Compiler::fgAddSyncMethodEnterExit()
// We need to do this transformation before funclets are created.
assert(!fgFuncletsCreated);

// Assume we don't need to update the bbPreds lists.
assert(!fgComputePredsDone);
// We need to update the bbPreds lists.
assert(fgComputePredsDone);

#if !FEATURE_EH
// If we don't support EH, we can't add the EH needed by synchronized methods.
Expand Down Expand Up @@ -1595,6 +1595,7 @@ void Compiler::fgAddSyncMethodEnterExit()
}

// Create a block for the fault.
// It gets an artificial ref count.

assert(!tryLastBB->bbFallsThrough());
BasicBlock* faultBB = fgNewBBafter(BBJ_EHFINALLYRET, tryLastBB, false);
Expand All @@ -1603,6 +1604,8 @@ void Compiler::fgAddSyncMethodEnterExit()
assert(faultBB->bbNext == nullptr);
assert(faultBB == fgLastBB);

faultBB->bbRefs = 1;

{ // Scope the EH region creation

// Add the new EH region at the end, since it is the least nested,
Expand Down Expand Up @@ -2184,7 +2187,6 @@ class MergedReturns
BasicBlock* CreateReturnBB(unsigned index, GenTreeIntConCommon* returnConst = nullptr)
{
BasicBlock* newReturnBB = comp->fgNewBBinRegion(BBJ_RETURN);
newReturnBB->bbRefs = 1; // bbRefs gets update later, for now it should be 1
comp->fgReturnCount++;

noway_assert(newReturnBB->bbNext == nullptr);
Expand Down Expand Up @@ -2344,6 +2346,7 @@ class MergedReturns
assert((comp->info.compFlags & CORINFO_FLG_SYNCH) == 0);
returnBlock->bbJumpKind = BBJ_ALWAYS;
returnBlock->bbJumpDest = constReturnBlock;
comp->fgAddRefPred(constReturnBlock, returnBlock);

// Remove GT_RETURN since constReturnBlock returns the constant.
assert(returnBlock->lastStmt()->GetRootNode()->OperIs(GT_RETURN));
Expand Down