Skip to content

Commit

Permalink
Add zero field offsets where it was missed.
Browse files Browse the repository at this point in the history
And don't add it as `ADD(,0)` in another.
  • Loading branch information
Sergey Andreenko committed Feb 13, 2020
1 parent 04a9f02 commit e3f0fe0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/coreclr/src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10347,11 +10347,20 @@ GenTree* Compiler::fgMorphCopyBlock(GenTree* tree)
CORINFO_CLASS_HANDLE classHnd = srcVarDsc->lvVerTypeInfo.GetClassHandle();
CORINFO_FIELD_HANDLE fieldHnd =
info.compCompHnd->getFieldInClass(classHnd, srcFieldVarDsc->lvFldOrdinal);
FieldSeqNode* curFieldSeq = GetFieldSeqStore()->CreateSingleton(fieldHnd);
unsigned srcFieldOffset = lvaGetDesc(srcFieldLclNum)->lvFldOffset;
GenTree* fieldOffsetNode = gtNewIconNode(srcFieldVarDsc->lvFldOffset, curFieldSeq);
FieldSeqNode* curFieldSeq = GetFieldSeqStore()->CreateSingleton(fieldHnd);

unsigned srcFieldOffset = lvaGetDesc(srcFieldLclNum)->lvFldOffset;

if (srcFieldOffset == 0)
{
fgAddFieldSeqForZeroOffset(dstFld, curFieldSeq);
}
else
{
GenTree* fieldOffsetNode = gtNewIconNode(srcFieldVarDsc->lvFldOffset, curFieldSeq);
dstFld = gtNewOperNode(GT_ADD, TYP_BYREF, dstFld, fieldOffsetNode);
}

dstFld = gtNewOperNode(GT_ADD, TYP_BYREF, dstFld, fieldOffsetNode);
dstFld = gtNewIndir(srcFieldVarDsc->TypeGet(), dstFld);

// !!! The destination could be on stack. !!!
Expand Down Expand Up @@ -10427,15 +10436,18 @@ GenTree* Compiler::fgMorphCopyBlock(GenTree* tree)
}
}
}
else // if (lvaGetDesc(fieldLclNum)->lvFldOffset != 0)
{
srcFld = gtNewOperNode(GT_ADD, TYP_BYREF, srcFld,
new (this, GT_CNS_INT)
GenTreeIntCon(TYP_I_IMPL, lvaGetDesc(dstFieldLclNum)->lvFldOffset,
curFieldSeq));
}
if (!done)
{
unsigned fldOffset = lvaGetDesc(dstFieldLclNum)->lvFldOffset;
if (fldOffset == 0)
{
fgAddFieldSeqForZeroOffset(srcFld, curFieldSeq);
}
else
{
GenTreeIntCon* fldOffsetNode = gtNewIconNode(fldOffset, curFieldSeq);
srcFld = gtNewOperNode(GT_ADD, TYP_BYREF, srcFld, fldOffsetNode);
}
srcFld = gtNewIndir(destType, srcFld);
}
}
Expand Down

0 comments on commit e3f0fe0

Please sign in to comment.