diff --git a/src/coreclr/interpreter/compiler.cpp b/src/coreclr/interpreter/compiler.cpp index 3b090273c6a68a..de3b5cbf88177b 100644 --- a/src/coreclr/interpreter/compiler.cpp +++ b/src/coreclr/interpreter/compiler.cpp @@ -2748,6 +2748,15 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re m_compHnd->getCallInfo(&resolvedCallToken, pConstrainedToken, m_methodInfo->ftn, flags, &callInfo); if (callInfo.methodFlags & CORINFO_FLG_INTRINSIC) { + NamedIntrinsic ni = GetNamedIntrinsic(m_compHnd, m_methodHnd, callInfo.hMethod); + if ((ni == NI_System_StubHelpers_NextCallReturnAddress) && (m_ip[5] == CEE_POP)) + { + // Call to System.StubHelpers.NextCallReturnAddress followed by CEE_POP is a special case that we handle + // as a no-op. + m_ip += 6; // Skip the call and the CEE_POP + return; + } + // If we are being asked explicitly to compile an intrinsic for interpreting, we need to forcibly enable // intrinsics for the recursive call. Otherwise we will just recurse infinitely and overflow stack. // This expansion can produce value that is inconsistent with the value seen by JIT/R2R code that can @@ -2755,7 +2764,6 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re bool isMustExpand = (callInfo.hMethod == m_methodHnd); if ((InterpConfig.InterpMode() == 3) || isMustExpand) { - NamedIntrinsic ni = GetNamedIntrinsic(m_compHnd, m_methodHnd, callInfo.hMethod); if (EmitNamedIntrinsicCall(ni, resolvedCallToken.hClass, callInfo.hMethod, callInfo.sig)) { m_ip += 5; diff --git a/src/coreclr/interpreter/intrinsics.cpp b/src/coreclr/interpreter/intrinsics.cpp index c6bc8b05613b36..af57f45c414d4a 100644 --- a/src/coreclr/interpreter/intrinsics.cpp +++ b/src/coreclr/interpreter/intrinsics.cpp @@ -38,6 +38,14 @@ NamedIntrinsic GetNamedIntrinsic(COMP_HANDLE compHnd, CORINFO_METHOD_HANDLE comp return NI_System_Math_ReciprocalSqrtEstimate; } } + else if (!strcmp(namespaceName, "System.StubHelpers")) + { + if (!strcmp(className, "StubHelpers")) + { + if (!strcmp(methodName, "NextCallReturnAddress")) + return NI_System_StubHelpers_NextCallReturnAddress; + } + } else if (!strcmp(namespaceName, "System.Numerics")) { if (!strcmp(className, "Vector") && !strcmp(methodName, "get_IsHardwareAccelerated"))