[mono][aot] Pass -mattr=crc32 to opt/llc when sse4.2 is enabled and using llvm 14...
authorZoltan Varga <vargaz@gmail.com>
Thu, 21 Jul 2022 21:14:58 +0000 (17:14 -0400)
committerGitHub <noreply@github.com>
Thu, 21 Jul 2022 21:14:58 +0000 (17:14 -0400)
src/mono/mono/mini/aot-compiler.c

index aaae993..8b40d1f 100644 (file)
@@ -10189,6 +10189,16 @@ emit_llvm_file (MonoAotCompile *acfg)
 
        if (acfg->aot_opts.no_opt)
                return TRUE;
+
+#if (defined(TARGET_X86) || defined(TARGET_AMD64)) && LLVM_API_VERSION >= 1400
+       if (acfg->aot_opts.llvm_cpu_attr && strstr (acfg->aot_opts.llvm_cpu_attr, "sse4.2"))
+               /*
+                * LLVM 14 added a 'crc32' mattr which needs to be explicitly enabled to
+                * add support for the crc32 sse instructions.
+                */
+               acfg->aot_opts.llvm_cpu_attr = g_strdup_printf ("%s,crc32", acfg->aot_opts.llvm_cpu_attr);
+#endif
+
        /*
         * FIXME: Experiment with adding optimizations, the -std-compile-opts set takes
         * a lot of time, and doesn't seem to save much space.