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>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30216>
This commit is contained in:
Icenowy Zheng 2024-07-17 01:46:46 +08:00 committed by Marge Bot
parent dc6e6d7a2b
commit 3423e73cec

View file

@ -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.