Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31658c6

Browse files
authored
JIT: Fix new helper calls for some block copies involving promoted locals (#86246)
The change in #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.
1 parent 239fca5 commit 31658c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/coreclr/jit/morphblock.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,13 @@ void MorphCopyBlockHelper::MorphStructCases()
830830
// A simple heuristic when field by field copy is preferred:
831831
// - if fields can be enregistered;
832832
// - if the struct has only one field.
833+
// - if the copy involves GC pointers and the destination isn't stack (backend uses a helper for these block
834+
// copies)
833835
bool dstFldIsProfitable =
834836
((m_dstVarDsc != nullptr) && (!m_dstVarDsc->lvDoNotEnregister || (m_dstVarDsc->lvFieldCnt == 1)));
835-
bool srcFldIsProfitable =
836-
((m_srcVarDsc != nullptr) && (!m_srcVarDsc->lvDoNotEnregister || (m_srcVarDsc->lvFieldCnt == 1)));
837+
bool srcFldIsProfitable = ((m_srcVarDsc != nullptr) && (!m_srcVarDsc->lvDoNotEnregister ||
838+
(m_srcVarDsc->HasGCPtr() && (m_dstVarDsc == nullptr)) ||
839+
(m_srcVarDsc->lvFieldCnt == 1)));
837840
// Are both dest and src promoted structs?
838841
if (m_dstDoFldAsg && m_srcDoFldAsg && (dstFldIsProfitable || srcFldIsProfitable))
839842
{

0 commit comments

Comments
 (0)