From f92cadccc65128fdaa54e59ba40dcf75e90a25dd Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 24 Aug 2022 01:20:43 +0800 Subject: [PATCH] llvmpipe: Always using util_get_cpu_caps to get cpu caps for llvm on x86 As we can override cpu features with environment variables, so always using util_get_cpu_caps instead llvm::sys::getHostCPUFeatures to get cpu features is a better option Signed-off-by: Yonggang Luo Reviewed-by: Jose Fonseca Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 2c993685b08..3b912761efa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -379,11 +379,10 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, llvm::SmallVector MAttrs; -#if LLVM_VERSION_MAJOR >= 4 && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM)) - /* llvm-3.3+ implements sys::getHostCPUFeatures for Arm - * and llvm-3.7+ for x86, which allows us to enable/disable - * code generation based on the results of cpuid on these - * architectures. +#if defined(PIPE_ARCH_ARM) + /* llvm-3.3+ implements sys::getHostCPUFeatures for Arm, + * which allows us to enable/disable code generation based + * on the results of cpuid on these architectures. */ llvm::StringMap features; llvm::sys::getHostCPUFeatures(features); @@ -395,13 +394,9 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, } #elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) /* - * We need to unset attributes because sometimes LLVM mistakenly assumes - * certain features are present given the processor name. - * - * https://bugs.freedesktop.org/show_bug.cgi?id=92214 - * http://llvm.org/PR25021 - * http://llvm.org/PR19429 - * http://llvm.org/PR16721 + * Because we can override cpu caps with environment variables, + * so we do not use llvm::sys::getHostCPUFeatures to detect cpu features + * but using util_get_cpu_caps() instead. */ MAttrs.push_back(util_get_cpu_caps()->has_sse ? "+sse" : "-sse" ); MAttrs.push_back(util_get_cpu_caps()->has_sse2 ? "+sse2" : "-sse2" );