ac/llvm: don't set unsupported xnack options to fix LLVM crashes on gfx6-8
authorMarek Olšák <marek.olsak@amd.com>
Sun, 28 Mar 2021 11:46:25 +0000 (07:46 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 2 Apr 2021 12:05:00 +0000 (12:05 +0000)
LLVM prints an error if xnack is unsupported and it uses a global stream
object that is not thread-safe. Since Mesa uses multiple threads to compile
shaders, there is a small chance that it will crash.

Just don't set any xnack options to use LLVM defaults.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4439

Cc: 20.3 21.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9795>

src/amd/llvm/ac_llvm_util.c
src/amd/llvm/ac_llvm_util.h
src/gallium/drivers/radeonsi/si_pipe.c

index d104b29..b820a55 100644 (file)
@@ -196,13 +196,11 @@ static LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family,
    const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? "amdgcn-mesa-mesa3d" : "amdgcn--";
    LLVMTargetRef target = ac_get_llvm_target(triple);
 
-   snprintf(features, sizeof(features), "+DumpCode%s%s%s%s%s",
+   snprintf(features, sizeof(features), "+DumpCode%s%s%s",
             LLVM_VERSION_MAJOR >= 11 ? "" : ",-fp32-denormals,+fp64-denormals",
             family >= CHIP_NAVI10 && !(tm_options & AC_TM_WAVE32)
                ? ",+wavefrontsize64,-wavefrontsize32"
                : "",
-            family <= CHIP_NAVI14 && tm_options & AC_TM_FORCE_ENABLE_XNACK ? ",+xnack" : "",
-            family <= CHIP_NAVI14 && tm_options & AC_TM_FORCE_DISABLE_XNACK ? ",-xnack" : "",
             tm_options & AC_TM_PROMOTE_ALLOCA_TO_SCRATCH ? ",-promote-alloca" : "");
 
    LLVMTargetMachineRef tm =
index 149478d..0e25bcc 100644 (file)
@@ -62,8 +62,6 @@ enum ac_func_attr
 enum ac_target_machine_options
 {
    AC_TM_SUPPORTS_SPILL = (1 << 0),
-   AC_TM_FORCE_ENABLE_XNACK = (1 << 1),
-   AC_TM_FORCE_DISABLE_XNACK = (1 << 2),
    AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 3),
    AC_TM_CHECK_IR = (1 << 4),
    AC_TM_ENABLE_GLOBAL_ISEL = (1 << 5),
index 86536aa..bbfcf42 100644 (file)
@@ -142,8 +142,6 @@ void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compil
 
    enum ac_target_machine_options tm_options =
       (sscreen->debug_flags & DBG(GISEL) ? AC_TM_ENABLE_GLOBAL_ISEL : 0) |
-      (sscreen->info.chip_class <= GFX8 ? AC_TM_FORCE_DISABLE_XNACK :
-       sscreen->info.chip_class <= GFX10 ? AC_TM_FORCE_ENABLE_XNACK : 0) |
       (!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0) |
       (sscreen->debug_flags & DBG(CHECK_IR) ? AC_TM_CHECK_IR : 0) |
       (create_low_opt_compiler ? AC_TM_CREATE_LOW_OPT : 0);