From 3673427f31d1d4f8a2508cae0c0495863f0130c0 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 1 Jul 2024 00:19:53 +0200 Subject: [PATCH] static init for RVA's holder in CreateSpan intrinsic --- src/coreclr/jit/importercalls.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index e7889ed79fccd..012d3c500a306 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -2815,6 +2815,10 @@ GenTree* Compiler::impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig) CORINFO_CLASS_HANDLE fieldOwnerHnd = info.compCompHnd->getFieldClass(fieldToken); + // We're expanding RuntimeHelpers.CreateSpan((RuntimeFieldHandle)0x...), thus, we need to + // statically initialize the class containing that RuntimeFieldHandle + info.compCompHnd->initClass(fieldToken, info.compMethodHnd, impTokenLookupContextHandle); + CORINFO_CLASS_HANDLE fieldClsHnd; var_types fieldElementType = JITtype2varType(info.compCompHnd->getFieldType(fieldToken, &fieldClsHnd, fieldOwnerHnd));