From 46d3a202c99a70ee988f805fd7dc61037047abb5 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Thu, 22 Jan 2026 13:04:39 -0800 Subject: [PATCH] [clr-interp] Cause compilation to be skipped when using function only used by tail-call helper --- src/coreclr/interpreter/compiler.cpp | 7 +++++++ src/coreclr/interpreter/eeinterp.cpp | 7 +++++++ src/coreclr/interpreter/failures.h | 1 + 3 files changed, 15 insertions(+) diff --git a/src/coreclr/interpreter/compiler.cpp b/src/coreclr/interpreter/compiler.cpp index 94020d040f325c..46ec3ece8ba322 100644 --- a/src/coreclr/interpreter/compiler.cpp +++ b/src/coreclr/interpreter/compiler.cpp @@ -3668,6 +3668,13 @@ bool InterpCompiler::EmitNamedIntrinsicCall(NamedIntrinsic ni, bool nonVirtualCa // These intrinsics are handled in the il peeps path, and do not need to produce warnings here. return false; + case NI_System_StubHelpers_NextCallReturnAddress: + // This intrinsic can only reach here if it is not followed by a POP, and in that case it is not supported by the interpreter. + // So we must skip compiling it. It should only appear in the case of tail-call stubs, and those are currently only supported by the JIT, so + // we presumably have a JIT available to implement this intrinsic. + SKIPCODE("NextCallReturnAddress intrinsic not supported in interpreter when not followed by POP"); + return false; + default: { FAIL_TO_EXPAND_INTRINSIC: diff --git a/src/coreclr/interpreter/eeinterp.cpp b/src/coreclr/interpreter/eeinterp.cpp index c22b909d969e2a..8fd06223a06887 100644 --- a/src/coreclr/interpreter/eeinterp.cpp +++ b/src/coreclr/interpreter/eeinterp.cpp @@ -187,6 +187,13 @@ INTERPRETER_NORETURN void BADCODE(const char* message) throw InterpException(message, CORJIT_BADCODE); } +INTERPRETER_NORETURN void SKIPCODE(const char* message) +{ + if (IsInterpDumpActive()) + printf("Skip during interpreter method compilation: %s\n", message ? message : "unknown error"); + throw InterpException(message, CORJIT_SKIPPED); +} + INTERPRETER_NORETURN void NOMEM() { throw InterpException(NULL, CORJIT_OUTOFMEM); diff --git a/src/coreclr/interpreter/failures.h b/src/coreclr/interpreter/failures.h index 9532b7bfba0c45..690aa3f2b201d0 100644 --- a/src/coreclr/interpreter/failures.h +++ b/src/coreclr/interpreter/failures.h @@ -13,5 +13,6 @@ INTERPRETER_NORETURN void NO_WAY(const char* message); INTERPRETER_NORETURN void BADCODE(const char* message); INTERPRETER_NORETURN void NOMEM(); +INTERPRETER_NORETURN void SKIPCODE(const char* message); #endif