Module: Mesa
Branch: staging/22.2
Commit: aa1df86867f10b49ba3e5b4343359c2d9956c7d3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa1df86867f10b49ba3e5b4343359c2d9956c7d3

Author: Dave Airlie <[email protected]>
Date:   Mon Sep 26 11:37:05 2022 +1000

gallivm: handle llvm coroutines for llvm > 15

LLVM 15 changed the coroutine presplit function attribute in

735e6c40b5e9 [Coroutines] Convert coroutine.presplit to enum attr

This needed to be updated in mesa.

Cc: mesa-stable
Acked-by: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18815>
(cherry picked from commit bcb136d548e607dbc9b72df0f575710ee03947ec)

Conflicts:
        src/gallium/auxiliary/gallivm/lp_bld_intr.h

---

 .pick_status.json                           |  2 +-
 src/gallium/auxiliary/draw/draw_llvm.c      |  2 +-
 src/gallium/auxiliary/gallivm/lp_bld_coro.h | 11 +++++++++++
 src/gallium/auxiliary/gallivm/lp_bld_intr.c |  1 +
 src/gallium/auxiliary/gallivm/lp_bld_intr.h |  2 ++
 src/gallium/drivers/llvmpipe/lp_state_cs.c  |  2 +-
 6 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index f7d6d52cfb4..d8997106407 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -7492,7 +7492,7 @@
         "description": "gallivm: handle llvm coroutines for llvm > 15",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 4ec2883c2dd..6809966b4ae 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -3381,7 +3381,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
 
    LLVMSetFunctionCallConv(variant_coro, LLVMCCallConv);
 
-   LLVMAddTargetDependentFunctionAttr(variant_coro, "coroutine.presplit", "0");
+   lp_build_coro_add_presplit(variant_coro);
 
    for (i = 0; i < ARRAY_SIZE(arg_types); ++i) {
       if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind) {
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_coro.h 
b/src/gallium/auxiliary/gallivm/lp_bld_coro.h
index 1853217ed77..e3cf415230e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_coro.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_coro.h
@@ -29,6 +29,7 @@
 #include <stdbool.h>
 #include "pipe/p_compiler.h"
 #include "gallivm/lp_bld.h"
+#include "gallivm/lp_bld_intr.h"
 
 struct gallivm_state;
 LLVMValueRef lp_build_coro_id(struct gallivm_state *gallivm);
@@ -73,4 +74,14 @@ void lp_build_coro_suspend_switch(struct gallivm_state 
*gallivm,
 
 void lp_build_coro_add_malloc_hooks(struct gallivm_state *gallivm);
 void lp_build_coro_declare_malloc_hooks(struct gallivm_state *gallivm);
+
+static inline void lp_build_coro_add_presplit(LLVMValueRef coro)
+{
+#if LLVM_VERSION_MAJOR >= 15
+   lp_add_function_attr(coro, -1, LP_FUNC_ATTR_PRESPLITCORO);
+#else
+   LLVMAddTargetDependentFunctionAttr(coro, "coroutine.presplit", "0");
+#endif
+}
+
 #endif
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c 
b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
index 99f5c77c4f0..d0ef1bc5d04 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
@@ -162,6 +162,7 @@ static const char *attr_to_str(enum lp_func_attr attr)
    case LP_FUNC_ATTR_WRITEONLY: return "writeonly";
    case LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY: return "inaccessiblememonly";
    case LP_FUNC_ATTR_CONVERGENT: return "convergent";
+   case LP_FUNC_ATTR_PRESPLITCORO: return "presplitcoroutine";
    default:
       _debug_printf("Unhandled function attribute: %x\n", attr);
       return 0;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.h 
b/src/gallium/auxiliary/gallivm/lp_bld_intr.h
index 98dfb0d0cb3..a4a8b1900d8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_intr.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.h
@@ -41,6 +41,7 @@
 #include "gallivm/lp_bld.h"
 #include "gallivm/lp_bld_init.h"
 
+struct lp_type;
 
 /**
  * Max number of arguments in an intrinsic.
@@ -57,6 +58,7 @@ enum lp_func_attr {
    LP_FUNC_ATTR_WRITEONLY    = LLVM_VERSION_MAJOR >= 4 ? (1 << 7) : 0,
    LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = LLVM_VERSION_MAJOR >= 4 ? (1 << 8) : 0,
    LP_FUNC_ATTR_CONVERGENT   = LLVM_VERSION_MAJOR >= 4 ? (1 << 9) : 0,
+   LP_FUNC_ATTR_PRESPLITCORO = (1 << 10),
 
    /* Legacy intrinsic that needs attributes on function declarations
     * and they must match the internal LLVM definition exactly, otherwise
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c 
b/src/gallium/drivers/llvmpipe/lp_state_cs.c
index 5b26bf7265f..111434a69ba 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c
@@ -133,7 +133,7 @@ generate_compute(struct llvmpipe_context *lp,
 
    coro = LLVMAddFunction(gallivm->module, func_name_coro, coro_func_type);
    LLVMSetFunctionCallConv(coro, LLVMCCallConv);
-   LLVMAddTargetDependentFunctionAttr(coro, "coroutine.presplit", "0");
+   lp_build_coro_add_presplit(coro);
 
    variant->function = function;
 

Reply via email to