Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86jit: Fix flush for special-purpose reg #18165

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Core/MIPS/IR/IRFrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ void IRFrontend::CheckBreakpoint(u32 addr) {
if (CBreakPoints::IsAddressBreakPoint(addr)) {
FlushAll();

if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// Can't skip this even at the start of a block, might impact block linking.
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));

RestoreRoundingMode();
// At this point, downcount HAS the delay slot, but not the instruction itself.
Expand Down Expand Up @@ -370,8 +370,8 @@ void IRFrontend::CheckMemoryBreakpoint(int rs, int offset) {
if (CBreakPoints::HasMemChecks()) {
FlushAll();

if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// Can't skip this even at the start of a block, might impact block linking.
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));

RestoreRoundingMode();
// At this point, downcount HAS the delay slot, but not the instruction itself.
Expand Down
19 changes: 15 additions & 4 deletions Core/MIPS/x86/X64IRRegCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,25 @@ void X64IRRegCache::MapWithFlags(IRInst inst, X64Map destFlags, X64Map src1Flags
mapping[2].flags = mapping[2].flags | src2Flags;

auto flushReg = [&](IRNativeReg nreg) {
bool mustKeep = false;
bool canDiscard = false;
for (int i = 0; i < 3; ++i) {
if (mapping[i].reg == nr[nreg].mipsReg && (mapping[i].flags & MIPSMap::NOINIT) == MIPSMap::NOINIT) {
DiscardNativeReg(nreg);
return;
if (mapping[i].reg != nr[nreg].mipsReg)
continue;

if ((mapping[i].flags & MIPSMap::NOINIT) != MIPSMap::NOINIT) {
mustKeep = true;
break;
} else {
canDiscard = true;
}
}

FlushNativeReg(nreg);
if (mustKeep || !canDiscard) {
FlushNativeReg(nreg);
} else {
DiscardNativeReg(nreg);
}
};

// If there are any special rules, we might need to spill.
Expand Down