mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
llvm: Fix memory leak on jit destroy
Fix msvc build
This commit is contained in:
parent
62ad27d1e2
commit
79633a7740
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Emu/Cell/ErrorCodes.h"
|
#include "Emu/Cell/ErrorCodes.h"
|
||||||
#include "Emu/Memory/vm_ptr.h"
|
#include "Emu/Memory/vm_ptr.h"
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
// Return Codes
|
// Return Codes
|
||||||
enum
|
enum
|
||||||
|
|
|
||||||
|
|
@ -509,10 +509,10 @@ enum class thread_state : u32;
|
||||||
class jit_compiler final
|
class jit_compiler final
|
||||||
{
|
{
|
||||||
// Local LLVM context
|
// Local LLVM context
|
||||||
std::unique_ptr<llvm::LLVMContext> m_context{};
|
std::unique_ptr<llvm::LLVMContext, void (*)(llvm::LLVMContext*)> m_context{nullptr, [](llvm::LLVMContext*) {}};
|
||||||
|
|
||||||
// Execution instance
|
// Execution instance
|
||||||
std::unique_ptr<llvm::ExecutionEngine> m_engine{};
|
std::unique_ptr<llvm::ExecutionEngine, void (*)(llvm::ExecutionEngine*)> m_engine{nullptr, [](llvm::ExecutionEngine*) {}};
|
||||||
|
|
||||||
// Arch
|
// Arch
|
||||||
std::string m_cpu{};
|
std::string m_cpu{};
|
||||||
|
|
|
||||||
|
|
@ -640,7 +640,11 @@ bool jit_compiler::add_sub_disk_space(ssz space)
|
||||||
}
|
}
|
||||||
|
|
||||||
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags, std::function<u64(const std::string&)> symbols_cement) noexcept
|
jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags, std::function<u64(const std::string&)> symbols_cement) noexcept
|
||||||
: m_context(new llvm::LLVMContext), m_cpu(cpu(_cpu))
|
: m_context(new llvm::LLVMContext, [](llvm::LLVMContext* context)
|
||||||
|
{
|
||||||
|
delete context;
|
||||||
|
}),
|
||||||
|
m_cpu(cpu(_cpu))
|
||||||
{
|
{
|
||||||
[[maybe_unused]] static const bool s_install_llvm_error_handler = []()
|
[[maybe_unused]] static const bool s_install_llvm_error_handler = []()
|
||||||
{
|
{
|
||||||
|
|
@ -681,7 +685,9 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
m_engine.reset(llvm::EngineBuilder(std::move(null_mod))
|
|
||||||
|
m_engine = std::unique_ptr<llvm::ExecutionEngine, void (*)(llvm::ExecutionEngine*)>{
|
||||||
|
llvm::EngineBuilder(std::move(null_mod))
|
||||||
.setErrorStr(&result)
|
.setErrorStr(&result)
|
||||||
.setEngineKind(llvm::EngineKind::JIT)
|
.setEngineKind(llvm::EngineKind::JIT)
|
||||||
.setMCJITMemoryManager(std::move(mem))
|
.setMCJITMemoryManager(std::move(mem))
|
||||||
|
|
@ -692,7 +698,12 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
|
||||||
#endif
|
#endif
|
||||||
.setRelocationModel(llvm::Reloc::Model::PIC_)
|
.setRelocationModel(llvm::Reloc::Model::PIC_)
|
||||||
.setMCPU(m_cpu)
|
.setMCPU(m_cpu)
|
||||||
.create());
|
.create(),
|
||||||
|
[](llvm::ExecutionEngine* engine)
|
||||||
|
{
|
||||||
|
delete engine;
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_link.empty())
|
if (!_link.empty())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue