Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,9 @@ class Compiler
GenTreeBlk* gtNewStoreBlkNode(
ClassLayout* layout, GenTree* addr, GenTree* data, GenTreeFlags indirFlags = GTF_EMPTY);

GenTreeStoreDynBlk* gtNewStoreDynBlkNode(
GenTree* addr, GenTree* data, GenTree* dynamicSize, GenTreeFlags indirFlags = GTF_EMPTY);

GenTreeStoreInd* gtNewStoreIndNode(
var_types type, GenTree* addr, GenTree* data, GenTreeFlags indirFlags = GTF_EMPTY);

Expand Down
42 changes: 38 additions & 4 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8583,7 +8583,7 @@ GenTree* Compiler::gtNewLoadValueNode(var_types type, ClassLayout* layout, GenTr
//
// Arguments:
// layout - The struct layout
// addr - Destionation address
// addr - Destination address
// data - Value to store
// indirFlags - Indirection flags
//
Expand All @@ -8603,6 +8603,34 @@ GenTreeBlk* Compiler::gtNewStoreBlkNode(ClassLayout* layout, GenTree* addr, GenT
return store;
}

//------------------------------------------------------------------------------
// gtNewStoreDynBlkNode : Create a dynamic block store node.
//
// Arguments:
// addr - Destination address
// data - Value to store (init val or indirection representing a location)
// dynamicSize - Node that computes number of bytes to store
// indirFlags - Indirection flags
//
// Return Value:
// The created GT_STORE_DYN_BLK node.
//
GenTreeStoreDynBlk* Compiler::gtNewStoreDynBlkNode(GenTree* addr,
GenTree* data,
GenTree* dynamicSize,
GenTreeFlags indirFlags)
{
assert((indirFlags & GTF_IND_INVARIANT) == 0);
assert(data->IsInitVal() || data->OperIs(GT_IND));

GenTreeStoreDynBlk* store = new (this, GT_STORE_DYN_BLK) GenTreeStoreDynBlk(addr, data, dynamicSize);
store->gtFlags |= GTF_ASG;
Copy link
Member

Choose a reason for hiding this comment

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

nit: it's already set in GenTreeStoreDynBlk ctror

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed that in this PR (just to make it consistent with gtNewStoreBlkNode)

Copy link
Member

Choose a reason for hiding this comment

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

ah, I am blind

gtInitializeIndirNode(store, indirFlags);
gtInitializeStoreNode(store, data);

return store;
}

//------------------------------------------------------------------------------
// gtNewStoreIndNode : Create an indirect store node.
//
Expand Down Expand Up @@ -9663,7 +9691,7 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree)
assert(copy->gtOper == oper);

copy->gtVNPair = tree->gtVNPair; // A cloned tree gets the original's Value number pair
copy->gtFlags |= tree->gtFlags;
copy->gtFlags = tree->gtFlags;

#if defined(DEBUG)
// Non-node debug flags should be propagated from 'tree' to 'copy'
Expand Down Expand Up @@ -10706,7 +10734,7 @@ bool GenTree::Precedes(GenTree* other)
//
void GenTree::SetIndirExceptionFlags(Compiler* comp)
{
assert(OperIsIndirOrArrMetaData() && (OperIsSimple() || OperIs(GT_CMPXCHG)));
assert(OperIsIndirOrArrMetaData() && (OperIsSimple() || OperIs(GT_CMPXCHG, GT_STORE_DYN_BLK)));

if (IndirMayFault(comp))
{
Expand All @@ -10723,10 +10751,16 @@ void GenTree::SetIndirExceptionFlags(Compiler* comp)
{
gtFlags |= gtGetOp2()->gtFlags & GTF_EXCEPT;
}
if (OperIs(GT_CMPXCHG))
else if (OperIs(GT_CMPXCHG))
{
gtFlags |= AsCmpXchg()->Data()->gtFlags & GTF_EXCEPT;
gtFlags |= AsCmpXchg()->Comparand()->gtFlags & GTF_EXCEPT;
}
else if (OperIs(GT_STORE_DYN_BLK))
{
gtFlags |= AsStoreDynBlk()->Data()->gtFlags & GTF_EXCEPT;
gtFlags |= AsStoreDynBlk()->gtDynamicSize->gtFlags & GTF_EXCEPT;
}
}

#ifdef DEBUG
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -7481,10 +7481,7 @@ struct GenTreeStoreDynBlk : public GenTreeBlk
GenTreeStoreDynBlk(GenTree* dstAddr, GenTree* data, GenTree* dynamicSize)
: GenTreeBlk(GT_STORE_DYN_BLK, TYP_VOID, dstAddr, data, nullptr), gtDynamicSize(dynamicSize)
{
// Conservatively the 'dstAddr' could be null or point into the global heap.
// Likewise, this is a store and so must be marked with the GTF_ASG flag.
gtFlags |= (GTF_ASG | GTF_EXCEPT | GTF_GLOB_REF);
gtFlags |= (dynamicSize->gtFlags & GTF_ALL_EFFECT);
gtFlags |= dynamicSize->gtFlags & GTF_ALL_EFFECT;
}

#if DEBUGGABLE_GENTREE
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10296,8 +10296,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op3 = gtNewCastNode(TYP_I_IMPL, op3, /* fromUnsigned */ true, TYP_I_IMPL);
#endif

op1 = new (this, GT_STORE_DYN_BLK) GenTreeStoreDynBlk(op1, op2, op3);
op1->gtFlags |= indirFlags;
op1 = gtNewStoreDynBlkNode(op1, op2, op3, indirFlags);
}
goto SPILL_APPEND;
}
Expand Down