mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 09:30:11 +01:00
gallivm: orcjit: remember Context in addition to ThreadSafeContext
The llvm::orc::ThreadSafeContext object wraps an llvm::Context and keeps its reference. As we are no longer able to squeeze out Context from ThreadSafeContext in LLVM 21, do not let ThreadSafeContext create Context implicitly for LLVM 21, instead explicitly create Context and then remember it. This also eliminates the code creating a Context that is never disposed. Fixes:cd129dbf8a("gallivm: support LLVM 21") Signed-off-by: Icenowy Zheng <uwu@icenowy.me> (cherry picked from commitcc60a7a39d) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
This commit is contained in:
parent
1e885e7a88
commit
12c82aaa82
3 changed files with 14 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue