From 1507a597863230238825f767fbcf907711e4d71c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 31 May 2020 21:54:04 +0300 Subject: [PATCH] SPU LLVM: fix spu_cache dependency Should fix possible crash on exit. --- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 2 +- rpcs3/Emu/Cell/SPURecompiler.cpp | 15 ++++++++++++--- rpcs3/Emu/Cell/SPURecompiler.h | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 55baa2aa0e..587649ef66 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -74,7 +74,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func) return add_loc->compiled; } - if (auto cache = g_fxo->get(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1)) + if (auto cache = g_fxo->get(); *cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1)) { cache->add(func); } diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 841429d2e8..48ab1b1ea1 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -546,7 +546,10 @@ void spu_cache::initialize() } // Initialize global cache instance - g_fxo->init(std::move(cache)); + if (g_cfg.core.spu_cache) + { + *g_fxo->get() = std::move(cache); + } } bool spu_program::operator==(const spu_program& rhs) const noexcept @@ -4219,7 +4222,7 @@ public: std::string log; - if (auto cache = g_fxo->get(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1)) + if (auto cache = g_fxo->get(); *cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1)) { cache->add(func); } @@ -4814,7 +4817,7 @@ public: fs::file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append).write(log); } - if (g_fxo->get()) + if (*g_fxo->get()) { spu_log.success("New block compiled successfully"); } @@ -8585,6 +8588,12 @@ struct spu_llvm // Workload lf_queue> registered; + spu_llvm() + { + // Dependency + g_fxo->init(); + } + void operator()() { // To compile (hash -> item) diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index ce4ac19c90..fc33215157 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -16,6 +16,8 @@ class spu_cache fs::file m_file; public: + spu_cache() = default; + spu_cache(const std::string& loc); spu_cache(spu_cache&&) noexcept = default;