diff options
author | Icenowy Zheng <uwu@icenowy.me> | 2024-07-18 12:09:28 +0800 |
---|---|---|
committer | Eric Engestrom <eric@igalia.com> | 2024-08-14 16:06:41 +0200 |
commit | b01adb2118ee14860a60e5cb2d736b2abb76ba20 (patch) | |
tree | df6eab1738bbcfca3c4ad69651d76a48b277aefa /src/gallium | |
parent | 27b64843175da254ea60111384d1d923f0320704 (diff) |
gallivm: orcjit: use atexit to release LPJit singleton at exit
Valgrind will report some memory possibly lost because of this singleton
(it's dynamically allocated when it is first accessed).
Use atexit() to register a handler that releases this singleton.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Reviewed-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 5f22e152ade956fdce1b0cba8097d76aac085c92)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30645>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp index 86cb0e82390..f38db3a57fb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp @@ -10,6 +10,7 @@ #include <string> #include <vector> #include <mutex> +#include <cstdlib> #include "lp_bld.h" #include "lp_bld_debug.h" #include "lp_bld_init.h" @@ -102,6 +103,8 @@ public: class LPJit; +void lpjit_exit(); + class LLVMEnsureMultithreaded { public: LLVMEnsureMultithreaded() @@ -270,11 +273,14 @@ private: LPJit(const LPJit&) = delete; LPJit& operator=(const LPJit&) = delete; + friend void lpjit_exit(); + static void init_native_targets(); llvm::orc::JITTargetMachineBuilder create_jtdb(); static void init_lpjit() { jit = new LPJit; + std::atexit(lpjit_exit); } static LPJit* jit; @@ -293,6 +299,11 @@ private: LPJit* LPJit::jit = NULL; +void lpjit_exit() +{ + delete LPJit::jit; +} + LLVMErrorRef module_transform(void *Ctx, LLVMModuleRef mod) { struct lp_passmgr *mgr; |