Skip to content

Commit

Permalink
Jit: Check for discarded registers when flushing
Browse files Browse the repository at this point in the history
This adds a check for the bug addressed by the previous commit.
  • Loading branch information
JosJuice committed Sep 10, 2023
1 parent 5902b5b commit 34b0a6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ void RegCache::Flush(BitSet32 pregs)
switch (m_regs[i].GetLocationType())
{
case PPCCachedReg::LocationType::Default:
break;
case PPCCachedReg::LocationType::Discarded:
ASSERT_MSG(DYNA_REC, false, "Attempted to flush discarded PPC reg {}", i);
break;
case PPCCachedReg::LocationType::SpeculativeImmediate:
// We can have a cached value without a host register through speculative constants.
Expand Down
10 changes: 8 additions & 2 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ void Arm64GPRCache::FlushRegisters(BitSet32 regs, bool maintain_state, ARM64Reg
{
if (regs[i])
{
ASSERT_MSG(DYNA_REC, m_guest_registers[GUEST_GPR_OFFSET + i].GetType() != RegType::Discarded,
"Attempted to flush discarded register");

if (i + 1 < GUEST_GPR_COUNT && regs[i + 1])
{
// We've got two guest registers in a row to store
OpArg& reg1 = m_guest_registers[i];
OpArg& reg2 = m_guest_registers[i + 1];
OpArg& reg1 = m_guest_registers[GUEST_GPR_OFFSET + i];
OpArg& reg2 = m_guest_registers[GUEST_GPR_OFFSET + i + 1];
if (reg1.IsDirty() && reg2.IsDirty() && reg1.GetType() == RegType::Register &&
reg2.GetType() == RegType::Register)
{
Expand Down Expand Up @@ -283,6 +286,9 @@ void Arm64GPRCache::FlushCRRegisters(BitSet32 regs, bool maintain_state, ARM64Re
{
if (regs[i])
{
ASSERT_MSG(DYNA_REC, m_guest_registers[GUEST_CR_OFFSET + i].GetType() != RegType::Discarded,
"Attempted to flush discarded register");

FlushRegister(GUEST_CR_OFFSET + i, maintain_state, tmp_reg);
}
}
Expand Down

0 comments on commit 34b0a6e

Please sign in to comment.