/[pkg-src]/trunk/mesa/patches/mesa-10.2.7-gallivm-set-mcpu-when-initializing-llvm-execution-en.patch |
Annotation of /trunk/mesa/patches/mesa-10.2.7-gallivm-set-mcpu-when-initializing-llvm-execution-en.patch
Parent Directory | Revision Log
Revision 2500 -
(hide annotations)
(download)
Mon Sep 15 07:25:06 2014 UTC (9 years, 8 months ago) by niro
File size: 3360 byte(s)
Mon Sep 15 07:25:06 2014 UTC (9 years, 8 months ago) by niro
File size: 3360 byte(s)
-llvm fixes
1 | niro | 2500 | From ebe30fd4d4a90219431b6947f233473b2cf518a5 Mon Sep 17 00:00:00 2001 |
2 | From: Roland Scheidegger <sroland@vmware.com> | ||
3 | Date: Thu, 19 Jun 2014 03:27:26 +0200 | ||
4 | Subject: [PATCH 2/2] gallivm: set mcpu when initializing llvm execution engine | ||
5 | |||
6 | Previously llvm detected cpu features automatically when the execution engine | ||
7 | was created (based on host cpu). This is no longer the case, which meant llvm | ||
8 | was then not able to emit some of the intrinsics we used as we didn't specify | ||
9 | any sse attributes (only on avx supporting systems this was not a problem since | ||
10 | despite at least some llvm versions enabling it anyway we always set this | ||
11 | manually). So, instead of trying to figure out which MAttrs to set just set | ||
12 | MCPU. | ||
13 | |||
14 | This fixes https://bugs.freedesktop.org/show_bug.cgi?id=77493. | ||
15 | |||
16 | Reviewed-by: Jose Fonseca <jfonseca@vmware.com> | ||
17 | Tested-by: Vinson Lee <vlee@freedesktop.org> | ||
18 | (cherry picked from commit cad60420d5ea36a4b6fa2e6c91317f71423aa63e) | ||
19 | --- | ||
20 | src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 24 ++++++++++++++++++++++-- | ||
21 | 1 file changed, 22 insertions(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | ||
24 | index 45c985d..395ac7b 100644 | ||
25 | --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | ||
26 | +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | ||
27 | @@ -59,6 +59,7 @@ | ||
28 | #include <llvm/ExecutionEngine/JITMemoryManager.h> | ||
29 | #endif | ||
30 | #include <llvm/Support/CommandLine.h> | ||
31 | +#include <llvm/Support/Host.h> | ||
32 | #include <llvm/Support/PrettyStackTrace.h> | ||
33 | |||
34 | #if HAVE_LLVM >= 0x0300 | ||
35 | @@ -309,8 +310,8 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, | ||
36 | /* | ||
37 | * AVX feature is not automatically detected from CPUID by the X86 target | ||
38 | * yet, because the old (yet default) JIT engine is not capable of | ||
39 | - * emitting the opcodes. But as we're using MCJIT here, it is safe to | ||
40 | - * add set this attribute. | ||
41 | + * emitting the opcodes. On newer llvm versions it is and at least some | ||
42 | + * versions (tested with 3.3) will emit avx opcodes without this anyway. | ||
43 | */ | ||
44 | MAttrs.push_back("+avx"); | ||
45 | if (util_cpu_caps.has_f16c) { | ||
46 | @@ -318,9 +319,28 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, | ||
47 | } | ||
48 | builder.setMAttrs(MAttrs); | ||
49 | } | ||
50 | + | ||
51 | +#if HAVE_LLVM >= 0x0305 | ||
52 | + StringRef MCPU = llvm::sys::getHostCPUName(); | ||
53 | + /* | ||
54 | + * The cpu bits are no longer set automatically, so need to set mcpu manually. | ||
55 | + * Note that the MAttrs set above will be sort of ignored (since we should | ||
56 | + * not set any which would not be set by specifying the cpu anyway). | ||
57 | + * It ought to be safe though since getHostCPUName() should include bits | ||
58 | + * not only from the cpu but environment as well (for instance if it's safe | ||
59 | + * to use avx instructions which need OS support). According to | ||
60 | + * http://llvm.org/bugs/show_bug.cgi?id=19429 however if I understand this | ||
61 | + * right it may be necessary to specify older cpu (or disable mattrs) though | ||
62 | + * when not using MCJIT so no instructions are generated which the old JIT | ||
63 | + * can't handle. Not entirely sure if we really need to do anything yet. | ||
64 | + */ | ||
65 | + builder.setMCPU(MCPU); | ||
66 | +#endif | ||
67 | + | ||
68 | builder.setJITMemoryManager(JITMemoryManager::CreateDefaultMemManager()); | ||
69 | |||
70 | ExecutionEngine *JIT; | ||
71 | + | ||
72 | #if HAVE_LLVM >= 0x0302 | ||
73 | JIT = builder.create(); | ||
74 | #else | ||
75 | -- | ||
76 | 2.1.0 | ||
77 |