From 8d952f719f623e2680599c5977c014b8e2c54934 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Mon, 11 Mar 2024 23:44:55 -0700 Subject: [PATCH] Don't inline methods with the DoesNotReturn attribute in interp, it's a waste of time to do so (#99550) Right now the mono interp will attempt to inline methods that have the DoesNotReturn attribute; this is a waste of time and resources, since it's not profitable to inline them and they are virtually always going to be unreachable code anyway. --- src/mono/mono/mini/interp/transform.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 96564d986bca9..a007007dfe290 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -2867,6 +2867,14 @@ interp_method_check_inlining (TransformData *td, MonoMethod *method, MonoMethodS if (td->prof_coverage) return FALSE; + /* + * doesnotreturn methods are not profitable to inline, since they almost certainly will not + * actually run during normal execution, and if they do they will only run once, so the + * upside to inlining them is effectively zero, and we'd waste time doing the inline + */ + if (has_doesnotreturn_attribute (method)) + return FALSE; + if (!is_metadata_update_disabled () && mono_metadata_update_no_inline (td->method, method)) return FALSE;