From 4fdd455eeb7cffadee86f06c685005a3b64ce94b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 6 Sep 2019 09:29:23 +0200 Subject: gallium: Require LLVM >= 3.4 Reviewed-by: Timothy Arceri Reviewed-by: Jose Fonseca --- meson.build | 2 +- scons/llvm.py | 2 +- src/gallium/auxiliary/gallivm/lp_bld.h | 19 ---- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 7 +- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 9 -- src/gallium/auxiliary/gallivm/lp_bld_init.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 133 +------------------------ src/gallium/drivers/llvmpipe/lp_jit.c | 4 - 8 files changed, 8 insertions(+), 170 deletions(-) diff --git a/meson.build b/meson.build index f268c81b44b..483404404f7 100644 --- a/meson.build +++ b/meson.build @@ -1264,7 +1264,7 @@ elif with_gallium_swr elif with_gallium_opencl or with_gallium_r600 _llvm_version = '>= 3.9.0' else - _llvm_version = '>= 3.3.0' + _llvm_version = '>= 3.4.0' endif _shared_llvm = get_option('shared-llvm') diff --git a/scons/llvm.py b/scons/llvm.py index 22412d2aee5..2f65365060f 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -37,7 +37,7 @@ import SCons.Errors import SCons.Util -required_llvm_version = '3.3' +required_llvm_version = '3.4' def generate(env): diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index 2fb638ceda4..9144428c8e1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -51,13 +51,6 @@ #include -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 3 -/* We won't actually use LLVMMCJITMemoryManagerRef, just create a dummy - * typedef to simplify things elsewhere. - */ -typedef void *LLVMMCJITMemoryManagerRef; -#endif - /** * Redefine these LLVM entrypoints as invalid macros to make sure we @@ -94,16 +87,4 @@ typedef void *LLVMMCJITMemoryManagerRef; #define GALLIVM_HAVE_CORO 0 #endif -/* - * Before LLVM 3.4 LLVMSetAlignment only supported GlobalValue, not - * LoadInst/StoreInst as we need. - */ -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 -# ifdef __cplusplus - extern "C" -# endif - void LLVMSetAlignmentBackport(LLVMValueRef V, unsigned Bytes); -# define LLVMSetAlignment LLVMSetAlignmentBackport -#endif - #endif /* LP_BLD_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index ede15cf75c5..1cb81f258aa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -287,12 +287,7 @@ lp_build_fmuladd(LLVMBuilderRef builder, LLVMTypeRef type = LLVMTypeOf(a); assert(type == LLVMTypeOf(b)); assert(type == LLVMTypeOf(c)); - if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) { - /* XXX: LLVM 3.3 does not breakdown llvm.fmuladd into mul+add when FMA is - * not supported, and instead it falls-back to a C function. - */ - return LLVMBuildFAdd(builder, LLVMBuildFMul(builder, a, b, ""), c, ""); - } + char intrinsic[32]; lp_format_intrinsic(intrinsic, sizeof intrinsic, "llvm.fmuladd", type); LLVMValueRef args[] = { a, b, c }; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index 67b10093e8a..dda4c7d4273 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -72,20 +72,11 @@ lp_check_alignment(const void *ptr, unsigned alignment) extern "C" void lp_debug_dump_value(LLVMValueRef value) { -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) char *str = LLVMPrintValueToString(value); if (str) { os_log_message(str); LLVMDisposeMessage(str); } -#elif defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_EMBEDDED) - std::string str; - llvm::raw_string_ostream os(str); - llvm::unwrap(value)->print(os); - os_log_message(str.c_str()); -#else - LLVMDumpValue(value); -#endif } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index ed919c48838..d534f0236b6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -505,7 +505,7 @@ lp_build_init(void) util_cpu_caps.has_f16c = 0; util_cpu_caps.has_fma = 0; } - if ((LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4) || !use_mcjit) { + if (!use_mcjit) { /* AVX2 support has only been tested with LLVM 3.4, and it requires * MCJIT. */ util_cpu_caps.has_avx2 = 0; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index deffe207e04..f0f7edefffa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -153,15 +153,6 @@ static void init_native_targets() extern "C" void lp_set_target_options(void) { -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - /* - * By default LLVM adds a signal handler to output a pretty stack trace. - * This signal handler is never removed, causing problems when unloading the - * shared object where the gallium driver resides. - */ - llvm::DisablePrettyStackTrace = true; -#endif - /* The llvm target registry is not thread-safe, so drivers and state-trackers * that want to initialize targets should use the lp_set_target_options() * function to safely initialize targets. @@ -199,29 +190,6 @@ gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info) } -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - -extern "C" -void -LLVMSetAlignmentBackport(LLVMValueRef V, - unsigned Bytes) -{ - switch (LLVMGetInstructionOpcode(V)) { - case LLVMLoad: - llvm::unwrap(V)->setAlignment(Bytes); - break; - case LLVMStore: - llvm::unwrap(V)->setAlignment(Bytes); - break; - default: - assert(0); - break; - } -} - -#endif - - #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 typedef llvm::JITMemoryManager BaseMemoryManager; #else @@ -287,22 +255,6 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { virtual void deallocateFunctionBody(void *Body) { mgr()->deallocateFunctionBody(Body); } -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - virtual uint8_t *startExceptionTable(const llvm::Function *F, - uintptr_t &ActualSize) { - return mgr()->startExceptionTable(F, ActualSize); - } - virtual void endExceptionTable(const llvm::Function *F, - uint8_t *TableStart, - uint8_t *TableEnd, - uint8_t *FrameRegister) { - mgr()->endExceptionTable(F, TableStart, TableEnd, - FrameRegister); - } - virtual void deallocateExceptionTable(void *ET) { - mgr()->deallocateExceptionTable(ET); - } -#endif virtual bool CheckInvariants(std::string &s) { return mgr()->CheckInvariants(s); } @@ -329,7 +281,6 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { /* * From RTDyldMemoryManager */ -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, @@ -337,40 +288,23 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { return mgr()->allocateCodeSection(Size, Alignment, SectionID, SectionName); } -#else - virtual uint8_t *allocateCodeSection(uintptr_t Size, - unsigned Alignment, - unsigned SectionID) { - return mgr()->allocateCodeSection(Size, Alignment, SectionID); - } -#endif virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) llvm::StringRef SectionName, -#endif bool IsReadOnly) { return mgr()->allocateDataSection(Size, Alignment, SectionID, -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) SectionName, -#endif IsReadOnly); } -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { mgr()->registerEHFrames(Addr, LoadAddr, Size); } -#else - virtual void registerEHFrames(llvm::StringRef SectionData) { - mgr()->registerEHFrames(SectionData); - } -#endif #if LLVM_VERSION_MAJOR >= 5 virtual void deregisterEHFrames() { mgr()->deregisterEHFrames(); } -#elif LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) +#else virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { mgr()->deregisterEHFrames(Addr, LoadAddr, Size); } @@ -379,15 +313,9 @@ class DelegatingJITMemoryManager : public BaseMemoryManager { bool AbortOnFailure=true) { return mgr()->getPointerToNamedFunction(Name, AbortOnFailure); } -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 3 - virtual bool applyPermissions(std::string *ErrMsg = 0) { - return mgr()->applyPermissions(ErrMsg); - } -#else virtual bool finalizeMemory(std::string *ErrMsg = 0) { return mgr()->finalizeMemory(ErrMsg); } -#endif }; @@ -426,11 +354,7 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { assert(TheMM); for ( i = FunctionBody.begin(); i != FunctionBody.end(); ++i ) TheMM->deallocateFunctionBody(*i); -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i ) - TheMM->deallocateExceptionTable(*i); -#endif /* LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 */ -#endif /* LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 */ +#endif } }; @@ -462,13 +386,6 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { delete (GeneratedCode *) code; } -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - virtual void deallocateExceptionTable(void *ET) { - // remember for later deallocation - code->ExceptionTable.push_back(ET); - } -#endif - virtual void deallocateFunctionBody(void *Body) { // remember for later deallocation code->FunctionBody.push_back(Body); @@ -512,9 +429,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, TargetOptions options; #if defined(PIPE_ARCH_X86) options.StackAlignmentOverride = 4; -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - options.RealignStack = true; -#endif #endif #if defined(DEBUG) && (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7) @@ -523,9 +437,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, /* XXX: Workaround http://llvm.org/PR21435 */ #if defined(DEBUG) || defined(PROFILE) || defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) -#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 4 - options.NoFramePointerElimNonLeaf = true; -#endif #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 7 options.NoFramePointerElim = true; #endif @@ -586,16 +497,8 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, MAttrs.push_back(util_cpu_caps.has_sse2 ? "+sse2" : "-sse2" ); MAttrs.push_back(util_cpu_caps.has_sse3 ? "+sse3" : "-sse3" ); MAttrs.push_back(util_cpu_caps.has_ssse3 ? "+ssse3" : "-ssse3" ); -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) MAttrs.push_back(util_cpu_caps.has_sse4_1 ? "+sse4.1" : "-sse4.1"); -#else - MAttrs.push_back(util_cpu_caps.has_sse4_1 ? "+sse41" : "-sse41" ); -#endif -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) MAttrs.push_back(util_cpu_caps.has_sse4_2 ? "+sse4.2" : "-sse4.2"); -#else - MAttrs.push_back(util_cpu_caps.has_sse4_2 ? "+sse42" : "-sse42" ); -#endif /* * AVX feature is not automatically detected from CPUID by the X86 target * yet, because the old (yet default) JIT engine is not capable of @@ -604,23 +507,13 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, */ MAttrs.push_back(util_cpu_caps.has_avx ? "+avx" : "-avx"); MAttrs.push_back(util_cpu_caps.has_f16c ? "+f16c" : "-f16c"); - if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)) { - MAttrs.push_back(util_cpu_caps.has_fma ? "+fma" : "-fma"); - } else { - /* - * The old JIT in LLVM 3.3 has a bug encoding llvm.fmuladd.f32 and - * llvm.fmuladd.v2f32 intrinsics when FMA is available. - */ - MAttrs.push_back("-fma"); - } + MAttrs.push_back(util_cpu_caps.has_fma ? "+fma" : "-fma"); MAttrs.push_back(util_cpu_caps.has_avx2 ? "+avx2" : "-avx2"); /* disable avx512 and all subvariants */ -#if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4) MAttrs.push_back("-avx512cd"); MAttrs.push_back("-avx512er"); MAttrs.push_back("-avx512f"); MAttrs.push_back("-avx512pf"); -#endif #if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5) MAttrs.push_back("-avx512bw"); MAttrs.push_back("-avx512dq"); @@ -637,7 +530,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if defined(PIPE_ARCH_PPC) MAttrs.push_back(util_cpu_caps.has_altivec ? "+altivec" : "-altivec"); -#if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)) #if (LLVM_VERSION_MAJOR < 4) /* * Make sure VSX instructions are disabled @@ -650,21 +542,6 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, if (util_cpu_caps.has_altivec) { MAttrs.push_back("-vsx"); } -#else - /* - * Bug 25503 is fixed, by the same fix that fixed - * bug 26775, in versions of LLVM later than 3.8 (starting with 3.8.1). - * BZ 33531 actually comprises more than one bug, all of - * which are fixed in LLVM 4.0. - * - * With LLVM 4.0 or higher: - * Make sure VSX instructions are ENABLED (if supported), unless - * VSX instructions are explicitly enabled/disabled via GALLIVM_VSX=1 or 0. - */ - if (util_cpu_caps.has_altivec) { - MAttrs.push_back(util_cpu_caps.has_vsx ? "+vsx" : "-vsx"); - } -#endif #endif #endif @@ -722,10 +599,8 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6) builder.setMCJITMemoryManager(std::unique_ptr(MM)); MM = NULL; // ownership taken by std::unique_ptr -#elif LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 3) - builder.setMCJITMemoryManager(MM); #else - builder.setJITMemoryManager(MM); + builder.setMCJITMemoryManager(MM); #endif } else { #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 6 diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 381c2610249..649f1ea0148 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -286,13 +286,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) } if (gallivm_debug & GALLIVM_DEBUG_IR) { -#if (LLVM_VERSION_MAJOR > 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 4)) char *str = LLVMPrintModuleToString(gallivm->module); fprintf(stderr, "%s", str); LLVMDisposeMessage(str); -#else - LLVMDumpModule(gallivm->module); -#endif } } -- cgit v1.2.3