diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 1d2541775063..86ac30ef1cd2 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -1656,7 +1656,7 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) { std::vector indexes = GetReplacementFuncIndexes(hash, size); for (int index : indexes) { bool didReplace = false; - auto entry = GetReplacementFunc(index); + const ReplacementTableEntry *entry = GetReplacementFunc(index); if (entry->flags & REPFLAG_HOOKEXIT) { // When hooking func exit, we search for jr ra, and replace those. for (u32 offset = 0; offset < (u32)size; offset += 4) { diff --git a/Core/MIPS/IR/IRPassSimplify.cpp b/Core/MIPS/IR/IRPassSimplify.cpp index 2d368d019139..16ac30cb1003 100644 --- a/Core/MIPS/IR/IRPassSimplify.cpp +++ b/Core/MIPS/IR/IRPassSimplify.cpp @@ -1175,16 +1175,21 @@ bool PurgeTemps(const IRWriter &in, IRWriter &out, const IROptions &opts) { case IRTEMP_LR_VALUE: case IRTEMP_LR_MASK: case IRTEMP_LR_SHIFT: - // Unlike other registers, these don't need to persist between blocks. - // So we consider them not read unless proven read. - lastWrittenTo[dest] = i; - // If this is a copy, we might be able to optimize out the copy. - if (inst.op == IROp::Mov) { - Check check(dest, i, false); - check.srcReg = inst.src1; - checks.push_back(check); + // Check that it's not a barrier instruction (like CallReplacement). Don't want to even consider optimizing those. + if (!(inst.m.flags & IRFLAG_BARRIER)) { + // Unlike other registers, these don't need to persist between blocks. + // So we consider them not read unless proven read. + lastWrittenTo[dest] = i; + // If this is a copy, we might be able to optimize out the copy. + if (inst.op == IROp::Mov) { + Check check(dest, i, false); + check.srcReg = inst.src1; + checks.push_back(check); + } else { + checks.push_back(Check(dest, i, false)); + } } else { - checks.push_back(Check(dest, i, false)); + lastWrittenTo[dest] = i; } break;