Skip to content

Commit

Permalink
Most static initialization data fields are of a structure type, but i…
Browse files Browse the repository at this point in the history
…t is legal for them to be of a primitive type. Fix the CreateSpan intrinsic to handle that case (#60525)
  • Loading branch information
davidwrighton authored Oct 17, 2021
1 parent 5e6dafe commit 2a07030
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3650,9 +3650,17 @@ GenTree* Compiler::impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig)

CORINFO_CLASS_HANDLE fieldClsHnd;
var_types fieldElementType = JITtype2varType(info.compCompHnd->getFieldType(fieldToken, &fieldClsHnd, fieldOwnerHnd));
assert(fieldElementType == var_types::TYP_STRUCT);
unsigned totalFieldSize;

const unsigned totalFieldSize = info.compCompHnd->getClassSize(fieldClsHnd);
// Most static initialization data fields are of some structure, but it is possible for them to be of various primitive types as well
if (fieldElementType == var_types::TYP_STRUCT)
{
totalFieldSize = info.compCompHnd->getClassSize(fieldClsHnd);
}
else
{
totalFieldSize = genTypeSize(fieldElementType);
}

// Limit to primitive or enum type - see ArrayNative::GetSpanDataFrom()
CORINFO_CLASS_HANDLE targetElemHnd = sig->sigInst.methInst[0];
Expand Down

0 comments on commit 2a07030

Please sign in to comment.