Skip to content

Commit b700018

Browse files
[release/6.0-rc2] Fix gtCloneExpr when cloning during R2R compilation a GT_ALLOCOBJ node (#59438)
* Fix gtCloneExpr when cloning during R2R compilation a GT_ALLOCOBJ node - Without this fix cloned expressions with allocations will fail - This is most common in profile guided code around devirtualization, but I believe it can occur in other where gtCloneExpr is used - Symptom of the failure is a compilation failure during crossgen2 * Jit formatting * 6.0 branch uses FEATURE_READYTORUN_COMPILER instead of FEATURE_READYTORUN Co-authored-by: David Wrighton <davidwr@microsoft.com>
1 parent b813392 commit b700018

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/coreclr/jit/gentree.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,6 +7475,7 @@ GenTreeAllocObj* Compiler::gtNewAllocObjNode(CORINFO_RESOLVED_TOKEN* pResolvedTo
74757475
#ifdef FEATURE_READYTORUN_COMPILER
74767476
if (usingReadyToRunHelper)
74777477
{
7478+
assert(lookup.addr != nullptr);
74787479
allocObj->gtEntryPoint = lookup;
74797480
}
74807481
#endif
@@ -7879,6 +7880,9 @@ GenTree* Compiler::gtCloneExpr(
78797880
copy = new (this, GT_ALLOCOBJ)
78807881
GenTreeAllocObj(tree->TypeGet(), asAllocObj->gtNewHelper, asAllocObj->gtHelperHasSideEffects,
78817882
asAllocObj->gtAllocObjClsHnd, asAllocObj->gtOp1);
7883+
#ifdef FEATURE_READYTORUN_COMPILER
7884+
copy->AsAllocObj()->gtEntryPoint = asAllocObj->gtEntryPoint;
7885+
#endif
78827886
}
78837887
break;
78847888

src/coreclr/jit/objectalloc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,11 @@ GenTree* ObjectAllocator::MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* alloc
481481
assert(comp->opts.IsReadyToRun());
482482
helperCall->AsCall()->setEntryPoint(entryPoint);
483483
}
484+
else
485+
{
486+
assert(helper != CORINFO_HELP_READYTORUN_NEW); // If this is true, then we should have collected a non-null
487+
// entrypoint above
488+
}
484489
#endif
485490

486491
return helperCall;

0 commit comments

Comments
 (0)