Skip to content

Commit 43b8dcf

Browse files
authored
JIT: build pred lists before object allocation phase (#80891)
Move the pred list building up a bit further. Contributes to #80193.
1 parent 031177b commit 43b8dcf

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,21 +4467,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
44674467
// Record "start" values for post-inlining cycles and elapsed time.
44684468
RecordStateAtEndOfInlining();
44694469

4470-
// Transform each GT_ALLOCOBJ node into either an allocation helper call or
4471-
// local variable allocation on the stack.
4472-
ObjectAllocator objectAllocator(this); // PHASE_ALLOCATE_OBJECTS
4473-
4474-
if (compObjectStackAllocation() && opts.OptimizationEnabled())
4475-
{
4476-
objectAllocator.EnableObjectStackAllocation();
4477-
}
4478-
4479-
objectAllocator.Run();
4480-
4481-
// Add any internal blocks/trees we may need
4482-
//
4483-
DoPhase(this, PHASE_MORPH_ADD_INTERNAL, &Compiler::fgAddInternal);
4484-
44854470
// Compute bbNum, bbRefs and bbPreds
44864471
//
44874472
// This is the first time full (not cheap) preds will be computed.
@@ -4500,6 +4485,21 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
45004485
};
45014486
DoPhase(this, PHASE_COMPUTE_PREDS, computePredsPhase);
45024487

4488+
// Transform each GT_ALLOCOBJ node into either an allocation helper call or
4489+
// local variable allocation on the stack.
4490+
ObjectAllocator objectAllocator(this); // PHASE_ALLOCATE_OBJECTS
4491+
4492+
if (compObjectStackAllocation() && opts.OptimizationEnabled())
4493+
{
4494+
objectAllocator.EnableObjectStackAllocation();
4495+
}
4496+
4497+
objectAllocator.Run();
4498+
4499+
// Add any internal blocks/trees we may need
4500+
//
4501+
DoPhase(this, PHASE_MORPH_ADD_INTERNAL, &Compiler::fgAddInternal);
4502+
45034503
// Remove empty try regions
45044504
//
45054505
DoPhase(this, PHASE_EMPTY_TRY, &Compiler::fgRemoveEmptyTry);

src/coreclr/jit/flowgraph.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,8 @@ void Compiler::fgAddSyncMethodEnterExit()
15651565
// We need to do this transformation before funclets are created.
15661566
assert(!fgFuncletsCreated);
15671567

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

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

15971597
// Create a block for the fault.
1598+
// It gets an artificial ref count.
15981599

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

1607+
faultBB->bbRefs = 1;
1608+
16061609
{ // Scope the EH region creation
16071610

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

21902192
noway_assert(newReturnBB->bbNext == nullptr);
@@ -2344,6 +2346,7 @@ class MergedReturns
23442346
assert((comp->info.compFlags & CORINFO_FLG_SYNCH) == 0);
23452347
returnBlock->bbJumpKind = BBJ_ALWAYS;
23462348
returnBlock->bbJumpDest = constReturnBlock;
2349+
comp->fgAddRefPred(constReturnBlock, returnBlock);
23472350

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

0 commit comments

Comments
 (0)