Skip to content

Commit ace3a9d

Browse files
committed
Simpler fix
1 parent f88ba03 commit ace3a9d

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

src/coreclr/jit/compiler.h

+1
Original file line numberDiff line numberDiff line change
@@ -8166,6 +8166,7 @@ class Compiler
81668166
// Get the flags
81678167

81688168
bool eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd);
8169+
bool eeIsByrefLike(CORINFO_CLASS_HANDLE clsHnd);
81698170
bool eeIsIntrinsic(CORINFO_METHOD_HANDLE ftn);
81708171
bool eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd);
81718172

src/coreclr/jit/ee_il_dll.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ bool Compiler::eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd)
5353
return info.compCompHnd->isValueClass(clsHnd);
5454
}
5555

56+
FORCEINLINE
57+
bool Compiler::eeIsByrefLike(CORINFO_CLASS_HANDLE clsHnd)
58+
{
59+
return (info.compCompHnd->getClassAttribs(clsHnd) & CORINFO_FLG_BYREF_LIKE) != 0;
60+
}
61+
5662
FORCEINLINE
5763
bool Compiler::eeIsIntrinsic(CORINFO_METHOD_HANDLE ftn)
5864
{

src/coreclr/jit/importer.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2672,8 +2672,7 @@ bool Compiler::verCheckTailCallConstraint(OPCODE opcode,
26722672
}
26732673

26742674
// Check that the argument is not a byref-like for tailcalls.
2675-
if ((ciType == CORINFO_TYPE_VALUECLASS) &&
2676-
((info.compCompHnd->getClassAttribs(classHandle) & CORINFO_FLG_BYREF_LIKE) != 0))
2675+
if ((ciType == CORINFO_TYPE_VALUECLASS) && eeIsByrefLike(classHandle))
26772676
{
26782677
return false;
26792678
}
@@ -10121,8 +10120,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1012110120
break;
1012210121
}
1012310122

10124-
bool isByRefLike =
10125-
(info.compCompHnd->getClassAttribs(resolvedToken.hClass) & CORINFO_FLG_BYREF_LIKE) != 0;
10123+
bool isByRefLike = eeIsByrefLike(resolvedToken.hClass);
1012610124
if (isByRefLike)
1012710125
{
1012810126
// For ByRefLike types we are required to either fold the

src/coreclr/jit/importercalls.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3885,8 +3885,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
38853885
retNode = gtNewIconNode(eeIsValueClass(hClass) ? 1 : 0);
38863886
break;
38873887
case NI_System_Type_get_IsByRefLike:
3888-
retNode = gtNewIconNode(
3889-
(info.compCompHnd->getClassAttribs(hClass) & CORINFO_FLG_BYREF_LIKE) ? 1 : 0);
3888+
retNode = gtNewIconNode(eeIsByrefLike(hClass) ? 1 : 0);
38903889
break;
38913890
case NI_System_Type_get_IsPrimitive:
38923891
// getTypeForPrimitiveValueClass returns underlying type for enums, so we check it first

src/coreclr/jit/layout.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ void ClassLayout::InitializeGCPtrs(Compiler* compiler)
432432
bool ClassLayout::IsStackOnly(Compiler* comp) const
433433
{
434434
// Byref-like structs are stack only
435-
if ((m_classHandle != NO_CLASS_HANDLE) &&
436-
(((comp->info.compCompHnd->getClassAttribs(m_classHandle)) & CORINFO_FLG_BYREF_LIKE) != 0))
435+
if ((m_classHandle != NO_CLASS_HANDLE) && comp->eeIsByrefLike(m_classHandle))
437436
{
438437
return true;
439438
}

src/coreclr/jit/morph.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -7735,6 +7735,19 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
77357735
}
77367736
break;
77377737

7738+
case GT_STOREIND:
7739+
if (op1->OperIs(GT_FIELD_ADDR) && varTypeIsGC(tree))
7740+
{
7741+
CORINFO_FIELD_HANDLE fieldHandle = tree->AsFieldAddr()->gtFldHnd;
7742+
if (eeIsByrefLike(info.compCompHnd->getFieldClass(fieldHandle)))
7743+
{
7744+
JITDUMP("Marking [%06u] STOREIND as GTF_IND_TGT_NOT_HEAP: field's owner is a byref-like struct\n",
7745+
dspTreeID(tree));
7746+
tree->gtFlags |= GTF_IND_TGT_NOT_HEAP;
7747+
}
7748+
}
7749+
break;
7750+
77387751
case GT_DIV:
77397752
// Replace "val / dcon" with "val * (1.0 / dcon)" if dcon is a power of two.
77407753
// Powers of two within range are always exactly represented,

0 commit comments

Comments
 (0)