From b3c1cec1976b912c3e18c6a53784edb3fd4f3ea1 Mon Sep 17 00:00:00 2001 From: Fiora Date: Sat, 6 Sep 2014 12:50:16 -0700 Subject: [PATCH] JIT: fix memcheck with stXx --- Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index fe7f94e8eb..bf44c1ecbc 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -435,10 +435,11 @@ void Jit64::stXx(UGeckoInstruction inst) int a = inst.RA, b = inst.RB, s = inst.RS; FALLBACK_IF(!a || a == s || a == b); + bool update = !!(inst.SUBOP10 & 32); gpr.Lock(a, b, s); - if (inst.SUBOP10 & 32) + if (update) { gpr.BindToRegister(a, true, true); ADD(32, gpr.R(a), gpr.R(b)); @@ -485,6 +486,14 @@ void Jit64::stXx(UGeckoInstruction inst) } SafeWriteRegToReg(reg_value, RSCRATCH2, accessSize, 0, CallerSavedRegistersInUse()); + if (update && js.memcheck) + { + // revert the address change if an exception occurred + MEMCHECK_START(true) + SUB(32, gpr.R(a), gpr.R(b)); + MEMCHECK_END; + } + gpr.UnlockAll(); gpr.UnlockAllX(); }