Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 0 additions & 24 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5258,30 +5258,6 @@ static GCInfo::WriteBarrierForm GetWriteBarrierForm(Compiler* comp, ValueNum vn)
return GetWriteBarrierForm(comp, funcApp.m_args[0]);
}
}
if (funcApp.m_func == VNF_InitVal)
{
unsigned lclNum = vnStore->CoercedConstantValue<unsigned>(funcApp.m_args[0]);
assert(lclNum != BAD_VAR_NUM);
CORINFO_CLASS_HANDLE srcCls = NO_CLASS_HANDLE;

if (comp->compMethodHasRetVal() && (lclNum == comp->info.compRetBuffArg))
{
// See if the address is in current method's return buffer
// while the return type is a byref-like type.
srcCls = comp->info.compMethodInfo->args.retTypeClass;
}
else if (lclNum == comp->info.compThisArg)
{
// Same for implicit "this" parameter
assert(!comp->info.compIsStatic);
srcCls = comp->info.compClassHnd;
}

if ((srcCls != NO_CLASS_HANDLE) && comp->eeIsByrefLike(srcCls))
{
return GCInfo::WriteBarrierForm::WBF_NoBarrier;
}
}
}
return GCInfo::WriteBarrierForm::WBF_BarrierUnknown;
}
Expand Down
15 changes: 15 additions & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9548,6 +9548,21 @@ void Compiler::impImportBlockCode(BasicBlock* block)
{
indirFlags |= GTF_IND_TGT_HEAP;
}
else if ((lclTyp == TYP_STRUCT) && (fieldInfo.structType != NO_CLASS_HANDLE) &&
eeIsByrefLike(fieldInfo.structType))
{
// Field's type is a byref-like struct -> address is not on the heap.
indirFlags |= GTF_IND_TGT_NOT_HEAP;
}
else
{
// Field's owner is a byref-like struct -> address is not on the heap.
CORINFO_CLASS_HANDLE fldOwner = info.compCompHnd->getFieldClass(resolvedToken.hField);
if ((fldOwner != NO_CLASS_HANDLE) && eeIsByrefLike(fldOwner))
{
indirFlags |= GTF_IND_TGT_NOT_HEAP;
}
}

assert(varTypeIsI(op1));
op1 = (lclTyp == TYP_STRUCT) ? gtNewStoreBlkNode(layout, op1, op2, indirFlags)->AsIndir()
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/jit/promotiondecomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,16 +523,17 @@ class DecompositionPlan
target_ssize_t addrBaseOffs = 0;
FieldSeq* addrBaseOffsFldSeq = nullptr;
GenTreeFlags indirFlags = GTF_EMPTY;

GenTreeFlags flagsToPropagate = GTF_IND_COPYABLE_FLAGS;
if (m_store->OperIs(GT_STORE_BLK))
{
flagsToPropagate |= GTF_IND_TGT_NOT_HEAP | GTF_IND_TGT_HEAP;
addr = m_store->AsIndir()->Addr();
indirFlags = m_store->gtFlags & GTF_IND_COPYABLE_FLAGS;
indirFlags = m_store->gtFlags & flagsToPropagate;
Copy link
Member

Choose a reason for hiding this comment

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

Is there any benefit to adding something like

if (m_store->AsBlk()->GetLayout()->IsStackOnly())
  indirFlags |= GTF_IND_TGT_NOT_HEAP;

here (and in morphblock.cpp)? Or will m_store already have this flag set for this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jakobbotsch I don't see diffs, but this PR already produces too many missing contexts 🙂
Presumably, this is not enough, because some GT_STORE_BLK have this flag without its layout being IsStackOnly. E.g. when we store a non-byreflike struct to byreflike-struct's field

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it makes sense to me to propagate the flags, but it also makes sense to me to set the flags anew here, since the decomposition is "losing" the information at this point. I will leave it up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added. Looks like MihuBot found a few diffs with it

}
else if (m_src->OperIs(GT_BLK))
{
addr = m_src->AsIndir()->Addr();
indirFlags = m_src->gtFlags & GTF_IND_COPYABLE_FLAGS;
indirFlags = m_src->gtFlags & flagsToPropagate;
}

int numAddrUses = 0;
Expand Down
Loading