diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index f730703fb19..bf3bdb36870 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -3374,7 +3374,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 #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 1a78312afff..e52ce3713ae 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c @@ -143,6 +143,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 82716eabe31..a73f64c0d91 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 = (1 << 7), LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY = (1 << 8), LP_FUNC_ATTR_CONVERGENT = (1 << 9), + 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 a2df0f1c555..f32bd539b93 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;