Skip to content

Commit

Permalink
JIT: Fix new helper calls for some block copies involving promoted lo…
Browse files Browse the repository at this point in the history
…cals

The change in dotnet#85620 was missing a check for the case where the
destination is not on stack but the source is. The backend still uses a
helper call for this case.

The field-by-field case would also usually involve helper calls since it
would normally need write barriers; however, the exception were for
byref fields, so Span<T>/ReadOnlySpan<T> were particularly affected.
  • Loading branch information
jakobbotsch committed May 15, 2023
1 parent ff65075 commit 1b84464
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/coreclr/jit/morphblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,13 @@ void MorphCopyBlockHelper::MorphStructCases()
// A simple heuristic when field by field copy is preferred:
// - if fields can be enregistered;
// - if the struct has only one field.
// - if the copy involves GC pointers and the destination isn't stack (backend uses a helper for these block
// copies)
bool dstFldIsProfitable =
((m_dstVarDsc != nullptr) && (!m_dstVarDsc->lvDoNotEnregister || (m_dstVarDsc->lvFieldCnt == 1)));
bool srcFldIsProfitable =
((m_srcVarDsc != nullptr) && (!m_srcVarDsc->lvDoNotEnregister || (m_srcVarDsc->lvFieldCnt == 1)));
bool srcFldIsProfitable = ((m_srcVarDsc != nullptr) && (!m_srcVarDsc->lvDoNotEnregister ||
(m_srcVarDsc->HasGCPtr() && (m_dstVarDsc == nullptr)) ||
(m_srcVarDsc->lvFieldCnt == 1)));
// Are both dest and src promoted structs?
if (m_dstDoFldAsg && m_srcDoFldAsg && (dstFldIsProfitable || srcFldIsProfitable))
{
Expand Down

0 comments on commit 1b84464

Please sign in to comment.