Blame SOURCES/0001-llvmpipe-use-ppc64le-ppc64-Large-code-model-for-JIT-.patch

26614e
From d0ff02e567541468309923fed2320da6cbd81779 Mon Sep 17 00:00:00 2001
26614e
From: Ben Crocker <bcrocker@redhat.com>
26614e
Date: Thu, 21 Nov 2019 17:33:31 -0500
26614e
Subject: [PATCH] llvmpipe: use ppc64le/ppc64 Large code model for JIT-compiled
26614e
 shaders
26614e
26614e
Large programs, e.g. gnome-shell and firefox, may tax the
26614e
addressability of the Medium code model once a (potentially unbounded)
26614e
number of dynamically generated JIT-compiled shader programs are
26614e
linked in and relocated.  Yet the default code model as of LLVM 8 is
26614e
Medium or even Small.
26614e
26614e
The cost of changing from Medium to Large is negligible:
26614e
- an additional 8-byte pointer stored immediately before the shader entrypoint;
26614e
- change an add-immediate (addis) instruction to a load (ld).
26614e
26614e
Testing with WebGL Conformance
26614e
(https://www.khronos.org/registry/webgl/sdk/tests/webgl-conformance-tests.html)
26614e
yields clean runs with this change (and crashes without it).
26614e
26614e
Testing with glxgears shows no detectable performance difference.
26614e
26614e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1753327, 1543572, 1747110, and 1582226
26614e
26614e
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/223
26614e
26614e
Co-authored by: Nemanja Ivanovic <nemanjai@ca.ibm.com>, Tom Stellard <tstellar@redhat.com>
26614e
26614e
CC: mesa-stable@lists.freedesktop.org
26614e
26614e
Signed-off-by: Ben Crocker <bcrocker@redhat.com>
26614e
Reviewed-by: Adam Jackson <ajax@redhat.com>
26614e
---
26614e
 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 15 ++++++++++++++-
26614e
 1 file changed, 14 insertions(+), 1 deletion(-)
26614e
26614e
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
26614e
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
26614e
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
26614e
@@ -686,7 +686,19 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
26614e
     * when not using MCJIT so no instructions are generated which the old JIT
26614e
     * can't handle. Not entirely sure if we really need to do anything yet.
26614e
     */
26614e
-#if defined(PIPE_ARCH_LITTLE_ENDIAN)  && defined(PIPE_ARCH_PPC_64)
26614e
+#ifdef PIPE_ARCH_PPC_64
26614e
+   /*
26614e
+    * Large programs, e.g. gnome-shell and firefox, may tax the addressability
26614e
+    * of the Medium code model once dynamically generated JIT-compiled shader
26614e
+    * programs are linked in and relocated.  Yet the default code model as of
26614e
+    * LLVM 8 is Medium or even Small.
26614e
+    * The cost of changing from Medium to Large is negligible:
26614e
+    * - an additional 8-byte pointer stored immediately before the shader entrypoint;
26614e
+    * - change an add-immediate (addis) instruction to a load (ld).
26614e
+    */
26614e
+   builder.setCodeModel(CodeModel::Large);
26614e
+
26614e
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
26614e
    /*
26614e
     * Versions of LLVM prior to 4.0 lacked a table entry for "POWER8NVL",
26614e
     * resulting in (big-endian) "generic" being returned on
26614e
@@ -698,6 +710,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
26614e
     */
26614e
    if (MCPU == "generic")
26614e
       MCPU = "pwr8";
26614e
+#endif
26614e
 #endif
26614e
    builder.setMCPU(MCPU);
26614e
    if (gallivm_debug & (GALLIVM_DEBUG_IR | GALLIVM_DEBUG_ASM | GALLIVM_DEBUG_DUMP_BC)) {
26614e
-- 
26614e
2.21.0
26614e