diff --git a/.pick_status.json b/.pick_status.json index fffc0853488..a49d0a62ef9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -14,7 +14,7 @@ "description": "gallivm: orcjit: remember Context in addition to ThreadSafeContext", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "cd129dbf8af2d16b1243f2ce287ff69c6a5dc557", "notes": null diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index 29b5db92410..5bdd1a25e95 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -88,10 +88,9 @@ #define LLVMCreateBuilder ILLEGAL_LLVM_FUNCTION typedef struct lp_context_ref { -#if GALLIVM_USE_ORCJIT - LLVMOrcThreadSafeContextRef ref; -#else LLVMContextRef ref; +#if GALLIVM_USE_ORCJIT + LLVMOrcThreadSafeContextRef tsref; #endif bool owned; } lp_context_ref; @@ -101,18 +100,21 @@ lp_context_create(lp_context_ref *context) { assert(context != NULL); #if GALLIVM_USE_ORCJIT - context->ref = LLVMOrcCreateNewThreadSafeContext(); +#if LLVM_VERSION_MAJOR >= 21 + context->ref = LLVMContextCreate(); + /* Ownership of ref is then transferred to tsref */ + context->tsref = LLVMOrcCreateNewThreadSafeContextFromLLVMContext(context->ref); +#else + context->tsref = LLVMOrcCreateNewThreadSafeContext(); + context->ref = LLVMOrcThreadSafeContextGetContext(context->tsref); +#endif #else context->ref = LLVMContextCreate(); #endif context->owned = true; #if LLVM_VERSION_MAJOR == 15 if (context->ref) { -#if GALLIVM_USE_ORCJIT - LLVMContextSetOpaquePointers(LLVMOrcThreadSafeContextGetContext(context->ref), false); -#else LLVMContextSetOpaquePointers(context->ref, false); -#endif } #endif } @@ -123,7 +125,7 @@ lp_context_destroy(lp_context_ref *context) assert(context != NULL); if (context->owned) { #if GALLIVM_USE_ORCJIT - LLVMOrcDisposeThreadSafeContext(context->ref); + LLVMOrcDisposeThreadSafeContext(context->tsref); #else LLVMContextDispose(context->ref); #endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp index e5d8e461dd6..d2a435c0512 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp @@ -555,8 +555,8 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name, gallivm->cache = cache; - gallivm->_ts_context = context->ref; - gallivm->context = LLVMContextCreate(); + gallivm->_ts_context = context->tsref; + gallivm->context = context->ref; gallivm->module_name = LPJit::get_unique_name(name); gallivm->module = LLVMModuleCreateWithNameInContext(gallivm->module_name,