diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 4251b7c0c6cf1..033ea50dc20e2 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -3384,17 +3384,27 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, if (IsTargetAbi(CORINFO_NATIVEAOT_ABI)) { - // Intrinsics that we should make every effort to expand for NativeAOT. - // If the intrinsic cannot possibly be expanded, it's fine, but - // if it can be, it should expand. switch (ni) { + // Intrinsics that we should make every effort to expand for NativeAOT. + // If the intrinsic cannot possibly be expanded, it's fine, but + // if it can be, it should expand. case NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan: case NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray: + betterToExpand = true; + break; + + // Intrinsics that we should always expand for NativeAOT. These are + // required to be expanded due to ILScanner assumptions. case NI_Internal_Runtime_MethodTable_Of: case NI_System_Activator_AllocatorOf: case NI_System_Activator_DefaultConstructorOf: - betterToExpand = true; + case NI_System_Runtime_CompilerServices_RuntimeHelpers_IsReferenceOrContainsReferences: + mustExpand = true; + break; + + case NI_System_Runtime_InteropService_MemoryMarshal_GetArrayDataReference: + mustExpand |= sig->sigInst.methInstCount == 1; break; default: