[llvm] Remove loaded llvm support, the startup perf penalty doesn't seem to exist...
authormonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 25 Feb 2020 01:34:47 +0000 (20:34 -0500)
committerGitHub <noreply@github.com>
Tue, 25 Feb 2020 01:34:47 +0000 (20:34 -0500)
Co-authored-by: Zoltan Varga <vargaz@gmail.com>
16 files changed:
src/mono/configure.ac
src/mono/mono/metadata/icall.c
src/mono/mono/metadata/jit-icall-reg.h
src/mono/mono/mini/CMakeLists.txt
src/mono/mono/mini/Makefile.am.in
src/mono/mono/mini/llvm-runtime.cpp
src/mono/mono/mini/mini-llvm-loaded.c [deleted file]
src/mono/mono/mini/mini-llvm.c
src/mono/mono/mini/mini-llvm.h
src/mono/mono/mini/mini-runtime.c
src/mono/mono/mini/mini.c
src/mono/mono/mini/xdebug.c
src/mono/mono/unit-tests/Makefile.am
src/mono/mono/utils/mono-compiler.h
src/mono/msvc/libmini-llvm.targets
src/mono/msvc/libmini-llvm.targets.filters

index 9ca1493..a790498 100644 (file)
@@ -4215,6 +4215,11 @@ if test "x$enable_llvm" = "xdefault"; then
    enable_llvm=$enable_llvm_default
 fi
 
+if test "x$enable_loadedllvm" = "xyes"; then
+   AC_MSG_WARN("Loadable LLVM is no longer supported. Enabling default LLVM support instead.")
+   enable_llvm=yes
+fi
+
 enable_llvm_msvc_only="no"
 if test "x$enable_llvm" = "xyes"; then
        if test "x$host_win32" = "xyes"; then
@@ -4229,10 +4234,6 @@ if test "x$enable_llvm" = "xyes"; then
                                ;;
                        esac
                fi
-               if test "x$enable_loadedllvm" = "xyes"; then
-                       AC_MSG_WARN("Loadable LLVM currently not supported on Windows. Disabling feature.")
-                       enable_loadedllvm=no
-               fi
        fi
 fi
 
@@ -4302,13 +4303,6 @@ fi
 
 AM_CONDITIONAL(ENABLE_LLVM, [test x$enable_llvm = xyes && test x$enable_llvm_msvc_only != xyes])
 
-AM_CONDITIONAL(LOADED_LLVM, [test x$enable_loadedllvm = xyes && test x$enable_llvm_msvc_only != xyes])
-if test "x$enable_loadedllvm" = "xyes"; then
-       if test "x$enable_llvm_msvc_only" != "xyes"; then
-               AC_DEFINE(MONO_LLVM_LOADED, 1, [The LLVM back end is dynamically loaded])
-       fi
-fi
-
 if test "x$enable_llvm" = "xyes"; then
        enable_llvm_runtime=yes
 fi
@@ -7030,7 +7024,7 @@ echo "
        Engine:        $jit_status
        BigArrays:     $enable_big_arrays
        DTrace:        $enable_dtrace
-       LLVM Back End: $enable_llvm (dynamically loaded: $enable_loadedllvm, built in-tree: $internal_llvm, assertions: $enable_llvm_asserts, msvc only: $enable_llvm_msvc_only)
+       LLVM Back End: $enable_llvm (built in-tree: $internal_llvm, assertions: $enable_llvm_asserts, msvc only: $enable_llvm_msvc_only)
        Spectre:       $spectre_mitigation_status
        Mono.Native:   $mono_native_text
 
index 41c91aa..efb3571 100644 (file)
@@ -183,23 +183,8 @@ mono_icall_get_file_path_prefix (const gchar *path)
 }
 #endif /* HOST_WIN32 */
 
-#if MONO_LLVM_LOADED
-
-static
-MonoJitICallInfos mono_jit_icall_info;
-
-MonoJitICallInfos*
-mono_get_jit_icall_info (void)
-{
-       return &mono_jit_icall_info;
-}
-
-#else
-
 MonoJitICallInfos mono_jit_icall_info;
 
-#endif
-
 MonoObjectHandle
 ves_icall_System_Array_GetValueImpl (MonoArrayHandle array, guint32 pos, MonoError *error)
 {
index 3b32a1b..d729040 100644 (file)
@@ -360,21 +360,10 @@ MONO_JIT_ICALLS
        MonoJitICallInfo array [MONO_JIT_ICALL_count];
 } MonoJitICallInfos;
 
-// Indirect mono_jit_icall_info access through a function or macro due to loaded LLVM.
-//
-#if MONO_LLVM_LOADED
-
-MONO_LLVM_INTERNAL MonoJitICallInfos*
-mono_get_jit_icall_info (void);
-
-#else
-
 extern MonoJitICallInfos mono_jit_icall_info;
 
 #define mono_get_jit_icall_info() (&mono_jit_icall_info)
 
-#endif
-
 // Convert MonoJitICallInfo* to an int or enum.
 //
 #define mono_jit_icall_info_index(x) ((x) - mono_get_jit_icall_info ()->array)
index 7d943e6..5080958 100644 (file)
@@ -732,17 +732,11 @@ set (interp_sources
 endif()
 
 if (ENABLE_LLVM)
-if (LOADED_LLVM)
-set (llvm_sources
-       mini-llvm-loaded.c)
-else ()
 set (llvm_sources
        mini-llvm.c
-       mini-llvm-loaded.c
        mini-llvm-cpp.cpp
        llvm-jit.cpp)
 endif()
-endif()
 
 if (ENABLE_LLVM)
 set (llvm_runtime_sources
index b80aa14..13dcf6f 100755 (executable)
@@ -210,17 +210,6 @@ libmain_a_SOURCES += main.c
 endif
 libmain_a_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@
 
-if LOADED_LLVM
-lib_LTLIBRARIES += libmono-llvm.la
-libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp llvm-jit.cpp
-libmono_llvm_la_LIBADD = $(glib_libs) $(LLVM_LIBS) $(LLVM_LDFLAGS)
-libmono_llvm_la_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@
-
-if HOST_DARWIN
-libmono_llvm_la_LDFLAGS=-Wl,-undefined -Wl,suppress -Wl,-flat_namespace 
-endif
-endif
-
 # we need this to prevent automake from generating a default mono_SOURCES = mono.c
 mono_SOURCES =
 
@@ -267,11 +256,7 @@ MONO_LIB=libmonoboehm-2.0.la
 MONO_SGEN_LIB=libmonosgen-2.0.la
 endif
 
-if LOADED_LLVM
-LLVMMONOF=
-else
 LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)
-endif
 
 mono_boehm_LDADD = \
        libmain_a-main.$(OBJEXT) \
@@ -427,17 +412,11 @@ posix_sources = \
        mini-posix.c
 
 if ENABLE_LLVM
-if LOADED_LLVM
-llvm_sources = \
-       mini-llvm-loaded.c
-else
 llvm_sources = \
        mini-llvm.c             \
-       mini-llvm-loaded.c \
        mini-llvm-cpp.cpp \
        llvm-jit.cpp
 endif
-endif
 
 interp_sources =       \
        interp/interp.h \
index 69e9bc0..9982ccc 100644 (file)
@@ -8,14 +8,10 @@ extern "C" {
 void
 mono_llvm_cpp_throw_exception (void)
 {
-#ifdef MONO_LLVM_LOADED
-       g_assert_not_reached ();
-#else
        gint32 *ex = NULL;
 
        /* The generated code catches an int32* */
        throw ex;
-#endif
 }
 
 void
diff --git a/src/mono/mono/mini/mini-llvm-loaded.c b/src/mono/mono/mini/mini-llvm-loaded.c
deleted file mode 100644 (file)
index 9d21ae8..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * \file
- * Handle the differences between the llvm backend beeing embedded
- * or loaded at runtime.
- */
-
-#include "mini.h"
-#include "mini-llvm.h"
-
-#ifdef MONO_LLVM_LOADED
-
-typedef struct {
-       void (*init)(gboolean);
-       void (*cleanup)(void);
-       void (*emit_method)(MonoCompile *cfg);
-       void (*emit_call)(MonoCompile *cfg, MonoCallInst *call);
-       void (*create_aot_module)(MonoAssembly *assembly, const char *global_prefix, int initial_got_size, LLVMModuleFlags flags);
-       void (*fixup_aot_module)(void);
-       void (*emit_aot_module)(const char *filename, const char *cu_name);
-       void (*check_method_supported)(MonoCompile *cfg);
-       void (*emit_aot_file_info)(MonoAotFileInfo *info, gboolean has_jitted_code);
-       void (*emit_aot_data)(const char *symbol, guint8 *data, int data_len);
-       void (*free_domain_info)(MonoDomain *domain);
-       void (*create_vars)(MonoCompile *cfg);
-       MonoCPUFeatures (*get_cpu_features)(void);
-} LoadedBackend;
-
-static LoadedBackend backend;
-
-void
-mono_llvm_init (gboolean enable_jit)
-{
-       backend.init (enable_jit);
-}
-
-void
-mono_llvm_cleanup (void)
-{
-       backend.cleanup ();
-}
-
-void
-mono_llvm_emit_method (MonoCompile *cfg)
-{
-       backend.emit_method (cfg);
-}
-
-void
-mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
-{
-       backend.emit_call (cfg, call);
-}
-
-void
-mono_llvm_create_aot_module (MonoAssembly *assembly, const char *global_prefix, int initial_got_size, LLVMModuleFlags flags)
-{
-       backend.create_aot_module (assembly, global_prefix, initial_got_size, flags);
-}
-
-void
-mono_llvm_emit_aot_module (const char *filename, const char *cu_name)
-{
-       backend.emit_aot_module (filename, cu_name);
-}
-
-void
-mono_llvm_fixup_aot_module (void)
-{
-       backend.fixup_aot_module ();
-}
-
-void
-mono_llvm_check_method_supported (MonoCompile *cfg)
-{
-       backend.check_method_supported (cfg);
-}
-
-void
-mono_llvm_free_domain_info (MonoDomain *domain)
-{
-       /* This is called even when llvm is not enabled */
-       if (backend.free_domain_info)
-               backend.free_domain_info (domain);
-}
-
-void
-mono_llvm_emit_aot_file_info (MonoAotFileInfo *info, gboolean has_jitted_code)
-{
-       backend.emit_aot_file_info (info, has_jitted_code);
-}
-
-void
-mono_llvm_emit_aot_data (const char *symbol, guint8 *data, int data_len)
-{
-       backend.emit_aot_data (symbol, data, data_len);
-}
-
-void
-mono_llvm_create_vars (MonoCompile *cfg)
-{
-       backend.create_vars (cfg);
-}
-
-int
-mono_llvm_load (const char* bpath)
-{
-       char *err = NULL;
-       MonoDl *llvm_lib = mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY, &err);
-
-       if (!llvm_lib) {
-               g_warning ("llvm load failed: %s\n", err);
-               g_free (err);
-               return FALSE;
-       }
-
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_init", (void**)&backend.init);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_cleanup", (void**)&backend.cleanup);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_method", (void**)&backend.emit_method);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_call", (void**)&backend.emit_call);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_create_aot_module", (void**)&backend.create_aot_module);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_module", (void**)&backend.emit_aot_module);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_fixup_aot_module", (void**)&backend.fixup_aot_module);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_check_method_supported", (void**)&backend.check_method_supported);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_free_domain_info", (void**)&backend.free_domain_info);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_file_info", (void**)&backend.emit_aot_file_info);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_data", (void**)&backend.emit_aot_data);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_create_vars", (void**)&backend.create_vars);
-       if (err) goto symbol_error;
-       err = mono_dl_symbol (llvm_lib, "mono_llvm_get_cpu_features", (void**)&backend.get_cpu_features);
-       if (err) goto symbol_error;
-       return TRUE;
-symbol_error:
-       g_warning ("llvm symbol load failed: %s\n", err);
-       g_free (err);
-       return FALSE;
-}
-
-MonoCPUFeatures mono_llvm_get_cpu_features (void)
-{
-       return backend.get_cpu_features ();
-}
-
-#else
-
-int
-mono_llvm_load (const char* bpath)
-{
-       return TRUE;
-}
-
-#endif /* MONO_LLVM_LOADED */
-
index c06200e..7a0bef6 100644 (file)
@@ -8640,7 +8640,6 @@ emit_method_inner (EmitContext *ctx)
        }
        ctx->has_safepoints = requires_safepoint;
 
-#ifndef MONO_LLVM_LOADED
        if (!cfg->llvm_only && mono_threads_are_safepoints_enabled () && requires_safepoint) {
                if (!cfg->compile_aot && cfg->method->wrapper_type != MONO_WRAPPER_ALLOC) {
                        LLVMSetGC (method, "coreclr");
@@ -8649,7 +8648,6 @@ emit_method_inner (EmitContext *ctx)
                        LLVMSetGC (method, "coreclr");
                }
        }
-#endif
        LLVMSetLinkage (method, LLVMPrivateLinkage);
 
        mono_llvm_add_func_attr (method, LLVM_ATTR_UW_TABLE);
index 048812c..5b26bda 100644 (file)
@@ -18,7 +18,6 @@ typedef enum {
        LLVM_MODULE_FLAG_INTERP = (1 << 4)
 } LLVMModuleFlags;
 
-/* KEEP THIS IN SYNCH WITH mini-llvm-loaded.c */
 MONO_LLVM_INTERNAL void mono_llvm_init                     (gboolean enable_jit);
 MONO_LLVM_INTERNAL void mono_llvm_cleanup                  (void);
 MONO_LLVM_INTERNAL void mono_llvm_emit_method              (MonoCompile *cfg);
@@ -30,7 +29,6 @@ MONO_LLVM_INTERNAL void mono_llvm_emit_aot_data            (const char *symbol,
 MONO_LLVM_INTERNAL void mono_llvm_check_method_supported   (MonoCompile *cfg);
 MONO_LLVM_INTERNAL void mono_llvm_free_domain_info         (MonoDomain *domain);
 MONO_API void mono_personality              (void);
-int      mono_llvm_load                     (const char* bpath);
 MONO_LLVM_INTERNAL void     mono_llvm_create_vars (MonoCompile *cfg);
 MONO_LLVM_INTERNAL void     mono_llvm_fixup_aot_module         (void);
 
index 778ee13..0c11906 100644 (file)
@@ -4010,9 +4010,6 @@ mini_free_jit_domain_info (MonoDomain *domain)
 static gboolean
 llvm_init_inner (void)
 {
-       if (!mono_llvm_load (NULL))
-               return FALSE;
-
        mono_llvm_init (!mono_compile_aot);
        return TRUE;
 }
@@ -4261,12 +4258,6 @@ mini_init (const char *filename, const char *runtime_version)
 #endif
 
 #ifdef ENABLE_LLVM
-       if (mono_use_llvm) {
-               if (!mono_llvm_load (NULL)) {
-                       mono_use_llvm = FALSE;
-                       fprintf (stderr, "Mono Warning: llvm support could not be loaded.\n");
-               }
-       }
        if (mono_use_llvm)
                mono_llvm_init (!mono_compile_aot);
 #endif
@@ -4449,7 +4440,7 @@ register_icalls (void)
        register_icall (mono_llvm_clear_exception, NULL, TRUE);
        register_icall (mono_llvm_load_exception, mono_icall_sig_object, TRUE);
        register_icall (mono_llvm_throw_corlib_exception, mono_icall_sig_void_int, TRUE);
-#if defined(ENABLE_LLVM) && !defined(MONO_LLVM_LOADED) && defined(HAVE_UNWIND_H)
+#if defined(ENABLE_LLVM) && defined(HAVE_UNWIND_H)
        register_icall (mono_llvm_set_unhandled_exception_handler, NULL, TRUE);
 
        // FIXME: This is broken
index a3f8f7f..145c140 100644 (file)
@@ -2866,7 +2866,6 @@ insert_safepoints (MonoCompile *cfg)
 
        g_assert (mini_safepoints_enabled ());
 
-#ifndef MONO_LLVM_LOADED
        if (COMPILE_LLVM (cfg)) {
                if (!cfg->llvm_only) {
                        /* We rely on LLVM's safepoints insertion capabilities. */
@@ -2875,7 +2874,6 @@ insert_safepoints (MonoCompile *cfg)
                        return;
                }
        }
-#endif
 
        if (cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) {
                WrapperInfo *info = mono_marshal_get_wrapper_info (cfg->method);
@@ -4335,7 +4333,7 @@ mini_get_cpu_features (MonoCompile* cfg)
 #if !defined(MONO_CROSS_COMPILE)
        if (!cfg->compile_aot || cfg->use_current_cpu) {
                // detect current CPU features if we are in JIT mode or AOT with use_current_cpu flag.
-#if defined(ENABLE_LLVM) && !defined(MONO_LLVM_LOADED)
+#if defined(ENABLE_LLVM)
                features = mono_llvm_get_cpu_features (); // llvm has a nice built-in API to detect features
 #elif defined(TARGET_AMD64)
                features = mono_arch_get_cpu_features ();
index 607db2e..868acaa 100644 (file)
@@ -109,7 +109,7 @@ G_BEGIN_DECLS
 /* GDB puts a breakpoint in this function.  */
 void MONO_NEVER_INLINE __jit_debug_register_code(void);
 
-#if !defined(MONO_LLVM_LOADED) && defined(ENABLE_LLVM) && !defined(MONO_CROSS_COMPILE)
+#if defined(ENABLE_LLVM) && !defined(MONO_CROSS_COMPILE)
 
 /* LLVM already defines these */
 
index 85fff69..530a52f 100644 (file)
@@ -15,11 +15,7 @@ MCS_NO_LIB = $(MCS_NO_UNSAFE) -unsafe
 
 MCS = $(MCS_NO_LIB)
 
-if LOADED_LLVM
-LLVMMONOF=
-else
 LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)
-endif
 
 glib_libs = $(top_builddir)/mono/eglib/libeglib.la
 
@@ -154,7 +150,7 @@ clean-local:
 
 test-embed.exe: $(top_srcdir)/samples/embed/test.cs
        $(MCS) -r:$(CLASS)/System.dll -r:$(CLASS)/System.Xml.dll -r:$(CLASS)/System.Core.dll -out:$@ $<
-       
+
 test-embed-invoke-cs.exe: $(top_srcdir)/samples/embed/invoke.cs
        $(MCS) -r:$(CLASS)/System.dll -r:$(CLASS)/System.Xml.dll -r:$(CLASS)/System.Core.dll  -out:$@ $<
 
index ebd9dfe..dbdf006 100644 (file)
@@ -75,23 +75,10 @@ typedef ptrdiff_t ssize_t;
 #define MONO_RESTORE_WARNING
 #endif
 
-// If MONO_LLVM_INTERNAL changes, update mono_debug_method_lookup_location declaration.
-#if !defined(_MSC_VER) && !defined(HOST_SOLARIS) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MONOTOUCH) && HAVE_VISIBILITY_HIDDEN && MONO_LLVM_LOADED
-
-// Normally use this.
-#define MONO_LLVM_INTERNAL                     MONO_API
-
-// Use these for extern data.
-#define MONO_LLVM_INTERNAL_NO_EXTERN_C         MONO_API_NO_EXTERN_C
-#define MONO_LLVM_INTERNAL_EXTERN_C_BEGIN      G_BEGIN_DECLS
-#define MONO_LLVM_INTERNAL_EXTERN_C_END                G_END_DECLS
-
-#else
 #define MONO_LLVM_INTERNAL                     /* nothing */
 #define MONO_LLVM_INTERNAL_NO_EXTERN_C         /* nothing */
 #define MONO_LLVM_INTERNAL_EXTERN_C_BEGIN      /* nothing */
 #define MONO_LLVM_INTERNAL_EXTERN_C_END                /* nothing */
-#endif
 
 /* Used to mark internal functions used by the profiler modules */
 #define MONO_PROFILER_API MONO_API
index f5f2f1d..4b035e9 100644 (file)
@@ -5,10 +5,6 @@
     <ExcludeLLVMFromWindowsBuild Condition="'$(MONO_ENABLE_LLVM)'=='' Or '$(MONO_ENABLE_LLVM)'!='true'">true</ExcludeLLVMFromWindowsBuild>
   </PropertyGroup>
   <ItemGroup Label="llvm_sources">
-    <ClCompile Include="$(MonoSourceLocation)\mono\mini\mini-llvm-loaded.c">
-      <ExcludedFromBuild>$(ExcludeLLVMFromWindowsBuild)</ExcludedFromBuild>
-      <_MonoLLVMSourceFile>true</_MonoLLVMSourceFile>
-    </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\mini\mini-llvm.c">
       <ExcludedFromBuild>$(ExcludeLLVMFromWindowsBuild)</ExcludedFromBuild>
       <_MonoLLVMSourceFile>true</_MonoLLVMSourceFile>
index 8bbf121..a4e9915 100644 (file)
@@ -1,9 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="llvm_sources">
-    <ClCompile Include="$(MonoSourceLocation)\mono\mini\mini-llvm-loaded.c">
-      <Filter>Source Files$(MonoMiniFilterSubFolder)\llvm</Filter>
-    </ClCompile>
     <ClCompile Include="$(MonoSourceLocation)\mono\mini\mini-llvm.c">
       <Filter>Source Files$(MonoMiniFilterSubFolder)\llvm</Filter>
     </ClCompile>