From e1579584efeb3411bbc5f98d5d96bdaeba1c7693 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 13 Nov 2020 21:46:17 +1000 Subject: [PATCH] CPU/Recompiler: Fix PGXP values getting corrupted if cached in caller-saved reg --- src/core/cpu_recompiler_code_generator.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp index 1cddef27c..e2ab9bc9c 100644 --- a/src/core/cpu_recompiler_code_generator.cpp +++ b/src/core/cpu_recompiler_code_generator.cpp @@ -1324,13 +1324,14 @@ bool CodeGenerator::Compile_Store(const CodeBlockInstruction& cbi) { case InstructionOp::sb: { - EmitStoreGuestMemory(cbi, address, address_spec, value.ViewAsSize(RegSize_8)); if (g_settings.gpu_pgxp_enable) { EmitFunctionCall(nullptr, PGXP::CPU_SB, Value::FromConstantU32(cbi.instruction.bits), value.ViewAsSize(RegSize_8), address); } + EmitStoreGuestMemory(cbi, address, address_spec, value.ViewAsSize(RegSize_8)); + if (address_spec) { const VirtualMemoryAddress aligned_addr = (*address_spec & ~3u); @@ -1354,13 +1355,14 @@ bool CodeGenerator::Compile_Store(const CodeBlockInstruction& cbi) case InstructionOp::sh: { - EmitStoreGuestMemory(cbi, address, address_spec, value.ViewAsSize(RegSize_16)); if (g_settings.gpu_pgxp_enable) { EmitFunctionCall(nullptr, PGXP::CPU_SH, Value::FromConstantU32(cbi.instruction.bits), value.ViewAsSize(RegSize_16), address); } + EmitStoreGuestMemory(cbi, address, address_spec, value.ViewAsSize(RegSize_16)); + if (address_spec) { const VirtualMemoryAddress aligned_addr = (*address_spec & ~3u); @@ -1384,10 +1386,11 @@ bool CodeGenerator::Compile_Store(const CodeBlockInstruction& cbi) case InstructionOp::sw: { - EmitStoreGuestMemory(cbi, address, address_spec, value); if (g_settings.gpu_pgxp_enable) EmitFunctionCall(nullptr, PGXP::CPU_SW, Value::FromConstantU32(cbi.instruction.bits), value, address); + EmitStoreGuestMemory(cbi, address, address_spec, value); + if (address_spec) SpeculativeWriteMemory(*address_spec, value_spec); }