summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorIcenowy Zheng <uwu@icenowy.me>2024-07-17 01:46:46 +0800
committerEric Engestrom <eric@igalia.com>2024-08-14 16:06:34 +0200
commit27b64843175da254ea60111384d1d923f0320704 (patch)
tree1e37076dda68d738ce30ad9163264be79f59411c /src/gallium
parentdf083003ab525fecf3f4ec69bd87764bd7cebc8b (diff)
gallivm: orcjit: keep the ownership of tm for LPJit
The ownership of the TargetMachine object is released when LPJit singleton is constructed, leads to a slight memory loss detectable. Keep the ownership by saving the unique pointer as another class member named tm_unique. Signed-off-by: Icenowy Zheng <uwu@icenowy.me> Reviewed-by: Dave Airlie <airlied@redhat.com> (cherry picked from commit 3423e73cece2657e4e0008a60f2f9d0ade618fbe) 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.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
index e67814337db..86cb0e82390 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
@@ -279,6 +279,7 @@ private:
static LPJit* jit;
std::unique_ptr<llvm::orc::LLJIT> lljit;
+ std::unique_ptr<llvm::TargetMachine> tm_unique;
/* avoid name conflict */
unsigned jit_dylib_count;
@@ -318,7 +319,8 @@ LPJit::LPJit() :jit_dylib_count(0) {
init_native_targets();
JITTargetMachineBuilder JTMB = create_jtdb();
- tm = wrap(ExitOnErr(JTMB.createTargetMachine()).release());
+ tm_unique = ExitOnErr(JTMB.createTargetMachine());
+ tm = wrap(tm_unique.get());
/* Create an LLJIT instance with an ObjectLinkingLayer (JITLINK)
* or RuntimeDyld as the base layer.