diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index fa52e9dd7521c..139dcfbbdd5b4 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -7607,6 +7607,8 @@ emit_method_info (MonoAotCompile *acfg, MonoCompile *cfg) flags |= MONO_AOT_METHOD_FLAG_HAS_CTX; if (cfg->interp_entry_only) flags |= MONO_AOT_METHOD_FLAG_INTERP_ENTRY_ONLY; + if (cfg->uses_simd_intrinsics && cfg->compile_llvm) + flags |= MONO_AOT_METHOD_FLAG_HAS_LLVM_INTRINSICS; /* Saved into another table so it can be accessed without having access to this data */ cfg->aot_method_flags = flags; diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index d4c29ed26cdf2..11c8888d17b03 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -4441,16 +4441,15 @@ load_method (MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint g_free (full_name); } - if (mono_llvm_only) { - guint8 flags = amodule->method_flags_table [method_index]; - /* The caller needs to looks this up, but its hard to do without constructing the full MonoJitInfo, so save it here */ - if (flags & (MONO_AOT_METHOD_FLAG_GSHAREDVT_VARIABLE | MONO_AOT_METHOD_FLAG_INTERP_ENTRY_ONLY)) { - mono_aot_lock (); - if (!code_to_method_flags) - code_to_method_flags = g_hash_table_new (NULL, NULL); - g_hash_table_insert (code_to_method_flags, code, GUINT_TO_POINTER (flags)); - mono_aot_unlock (); - } + guint8 flags = amodule->method_flags_table [method_index]; + /* The caller needs to looks this up, but its hard to do without constructing the full MonoJitInfo, so save it here */ + if ((mono_llvm_only && (flags & (MONO_AOT_METHOD_FLAG_GSHAREDVT_VARIABLE | MONO_AOT_METHOD_FLAG_INTERP_ENTRY_ONLY))) || + (flags & MONO_AOT_METHOD_FLAG_HAS_LLVM_INTRINSICS)) { + mono_aot_lock (); + if (!code_to_method_flags) + code_to_method_flags = g_hash_table_new (NULL, NULL); + g_hash_table_insert (code_to_method_flags, code, GUINT_TO_POINTER (flags)); + mono_aot_unlock (); } init_plt (amodule); diff --git a/src/mono/mono/mini/aot-runtime.h b/src/mono/mono/mini/aot-runtime.h index b2d30cdae2680..13690e31904d4 100644 --- a/src/mono/mono/mini/aot-runtime.h +++ b/src/mono/mono/mini/aot-runtime.h @@ -84,6 +84,7 @@ typedef enum { MONO_AOT_METHOD_FLAG_HAS_PATCHES = 4, MONO_AOT_METHOD_FLAG_HAS_CTX = 8, MONO_AOT_METHOD_FLAG_INTERP_ENTRY_ONLY = 16, + MONO_AOT_METHOD_FLAG_HAS_LLVM_INTRINSICS = 32, } MonoAotMethodFlags; #undef DEBUG_AOT_NAME_TABLE diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index 164adfcdc18cc..d9432fd5510de 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -4180,13 +4180,17 @@ mono_method_check_inlining (MonoCompile *cfg, MonoMethod *method) return FALSE; MonoAotModule *amodule = m_class_get_image (method->klass)->aot_module; + // If method is present in aot image compiled with llvm and it uses hw intrinsics we don't inline it, + // since we might not have support for those intrinsics with JIT if (amodule && (amodule != AOT_MODULE_NOT_FOUND) && (mono_aot_get_module_flags (amodule) & MONO_AOT_FILE_FLAG_WITH_LLVM)) { ERROR_DECL (error); mono_class_init_internal (method->klass); gpointer addr = mono_aot_get_method (method, error); - // If method is present in aot image compiled with llvm, we don't inline it - if (addr && is_ok (error)) - return FALSE; + if (addr && is_ok (error)) { + MonoAotMethodFlags flags = mono_aot_get_method_flags (addr); + if (flags & MONO_AOT_METHOD_FLAG_HAS_LLVM_INTRINSICS) + return FALSE; + } } return TRUE;