diff --git a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp index 83b91d160f..2874f1ea60 100644 --- a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp @@ -4495,11 +4495,10 @@ struct spu_llvm_worker void operator()() { // SPU LLVM Recompiler instance - const auto compiler = spu_recompiler_base::make_llvm_recompiler(); - compiler->init(); + std::unique_ptr compiler; // Fake LS - std::vector> ls(0x10000); + std::vector> ls; bool set_relax_flag = false; @@ -4542,6 +4541,15 @@ struct spu_llvm_worker break; } + if (!compiler) + { + // Postponed initialization + compiler = spu_recompiler_base::make_llvm_recompiler(); + compiler->init(); + + ls.resize(SPU_LS_SIZE / sizeof(be_t)); + } + if (!set_relax_flag) { spu_thread::g_spu_work_count++; @@ -4624,6 +4632,17 @@ struct spu_llvm return; } + while (!registered && thread_ctrl::state() != thread_state::aborting) + { + // Wait for the first SPU block before launching any thread + thread_ctrl::wait_on(utils::bless>(®istered)[1], 0); + } + + if (thread_ctrl::state() == thread_state::aborting) + { + return; + } + // To compile (hash -> item) std::unordered_multimap> enqueued;