From ac78b12e2307565adff436e101b5a8dba61a64b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 28 Mar 2021 07:46:25 -0400 Subject: [PATCH] ac/llvm: don't set unsupported xnack options to fix LLVM crashes on gfx6-8 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 Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/llvm/ac_llvm_util.c | 4 +--- src/amd/llvm/ac_llvm_util.h | 2 -- src/gallium/drivers/radeonsi/si_pipe.c | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/amd/llvm/ac_llvm_util.c b/src/amd/llvm/ac_llvm_util.c index d104b29..b820a55 100644 --- a/src/amd/llvm/ac_llvm_util.c +++ b/src/amd/llvm/ac_llvm_util.c @@ -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 = diff --git a/src/amd/llvm/ac_llvm_util.h b/src/amd/llvm/ac_llvm_util.h index 149478d..0e25bcc 100644 --- a/src/amd/llvm/ac_llvm_util.h +++ b/src/amd/llvm/ac_llvm_util.h @@ -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), diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 86536aa..bbfcf42 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -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); -- 2.7.4