From 2c3fa8da288878f0664499997cd503de06b71e80 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 28 Aug 2015 14:36:14 -0500 Subject: [PATCH] [AArch64] Fix a bug in the register caches. This is a bug that crops if BindToRegister() is called multiple times in a row without a R() function call between them. How to reproduce the bug: 1) Have a completely filled cache with no host register remaining 2) Call BindToRegister() with different guest registers 3) Don't call R() between the BindToRegister() calls. This issue typically wouldn't be seen for a couple of reasons. Typically we have /plenty/ of registers in the cache, and in most cases we only call BindToRegister() once per instruction. In the off chance that it is called multiple times, it wouldn't update the last used counts and would flush the same register as the previous call to it. --- Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp index 27b021cf8a..c58a3cee46 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp @@ -206,6 +206,8 @@ void Arm64GPRCache::BindToRegister(u32 preg, bool do_load) { OpArg& reg = m_guest_registers[preg]; + reg.ResetLastUsed(); + reg.SetDirty(true); if (reg.GetType() == REG_NOTLOADED) { @@ -331,6 +333,9 @@ void Arm64FPRCache::BindToRegister(u32 preg, bool do_load, bool only_lower) OpArg& reg = m_guest_registers[preg]; bool was_dirty = reg.IsDirty(); + + reg.ResetLastUsed(); + reg.SetDirty(true); switch (reg.GetType()) {