Mono DISABLE_SIMD define still emits OP codes depending on SIMD support. (#33717)
authorJohan Lorensson <lateralusx.github@gmail.com>
Thu, 19 Mar 2020 03:31:29 +0000 (04:31 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Mar 2020 03:31:29 +0000 (23:31 -0400)
Fix makes sure runtime checks also report that SIMD has been disabled.
Returning FALSE from is_simd_supported will turn of MONO_OPT_SIMD and
disable all SSE/AVX cpu features will prevent code checking cpu
capabilities to emit SIMD instructions.

src/mono/mono/mini/mini-runtime.c
src/mono/mono/mini/mini.c

index 60d5860..a0ab6c4 100644 (file)
@@ -130,7 +130,12 @@ gboolean mono_use_fast_math = FALSE;
 
 // Lists of whitelisted and blacklisted CPU features 
 MonoCPUFeatures mono_cpu_features_enabled = (MonoCPUFeatures)0;
+
+#ifdef DISABLE_SIMD
+MonoCPUFeatures mono_cpu_features_disabled = MONO_CPU_X86_FULL_SSEAVX_COMBINED;
+#else
 MonoCPUFeatures mono_cpu_features_disabled = (MonoCPUFeatures)0;
+#endif
 
 gboolean mono_use_interpreter = FALSE;
 const char *mono_interp_opts_string = NULL;
index e9c35f9..3afab1f 100644 (file)
@@ -3049,6 +3049,9 @@ init_backend (MonoBackend *backend)
 static gboolean
 is_simd_supported (MonoCompile *cfg)
 {
+#ifdef DISABLE_SIMD
+    return FALSE;
+#endif
        // FIXME: Clean this up
 #ifdef TARGET_WASM
        if ((mini_get_cpu_features (cfg) & MONO_CPU_WASM_SIMD) == 0)