Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fixes for tracking struct field sequences #23932

Merged
merged 3 commits into from
Apr 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13478,35 +13478,38 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
// lclVar and must not extend beyond the end of the lclVar.
if ((ival1 >= 0) && ((ival1 + genTypeSize(typ)) <= varSize))
{
GenTreeLclFld* lclFld;

// We will turn a GT_LCL_VAR into a GT_LCL_FLD with an gtLclOffs of 'ival'
// or if we already have a GT_LCL_FLD we will adjust the gtLclOffs by adding 'ival'
// Then we change the type of the GT_LCL_FLD to match the orginal GT_IND type.
//
if (temp->OperGet() == GT_LCL_FLD)
{
temp->AsLclFld()->gtLclOffs += (unsigned short)ival1;
temp->AsLclFld()->gtFieldSeq =
GetFieldSeqStore()->Append(temp->AsLclFld()->gtFieldSeq, fieldSeq);
lclFld = temp->AsLclFld();
lclFld->gtLclOffs += (unsigned short)ival1;
lclFld->gtFieldSeq = GetFieldSeqStore()->Append(lclFld->gtFieldSeq, fieldSeq);
}
else // we have a GT_LCL_VAR
{
assert(temp->OperGet() == GT_LCL_VAR);
temp->ChangeOper(GT_LCL_FLD); // Note that this typically makes the gtFieldSeq "NotAField"...
temp->AsLclFld()->gtLclOffs = (unsigned short)ival1;
temp->ChangeOper(GT_LCL_FLD); // Note that this typically makes the gtFieldSeq "NotAField",
// unless there is a zero filed offset associated with 'temp'.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting here is weird, but it's not a big deal I guess.

lclFld = temp->AsLclFld();
lclFld->gtLclOffs = (unsigned short)ival1;

if (temp->AsLclFld()->gtFieldSeq == FieldSeqStore::NotAField())
if (lclFld->gtFieldSeq == FieldSeqStore::NotAField())
{
if (fieldSeq != nullptr)
{
// If it does represent a field, note that.
temp->AsLclFld()->gtFieldSeq = fieldSeq;
lclFld->gtFieldSeq = fieldSeq;
}
}
else
{
// Append 'fieldSeq' to the existing one
temp->AsLclFld()->gtFieldSeq =
GetFieldSeqStore()->Append(temp->AsLclFld()->gtFieldSeq, fieldSeq);
lclFld->gtFieldSeq = GetFieldSeqStore()->Append(lclFld->gtFieldSeq, fieldSeq);
}
}
temp->gtType = tree->gtType;
Expand Down