Skip to content

Commit 2a3f8af

Browse files
authored
Merge pull request #19189 from hrydgard/star-ocean
IRInterpreter: Fix issue where we could accidentally optimize out CallReplacement ops.
2 parents f2b36f0 + bdf7f5f commit 2a3f8af

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Core/HLE/ReplaceTables.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) {
16561656
std::vector<int> indexes = GetReplacementFuncIndexes(hash, size);
16571657
for (int index : indexes) {
16581658
bool didReplace = false;
1659-
auto entry = GetReplacementFunc(index);
1659+
const ReplacementTableEntry *entry = GetReplacementFunc(index);
16601660
if (entry->flags & REPFLAG_HOOKEXIT) {
16611661
// When hooking func exit, we search for jr ra, and replace those.
16621662
for (u32 offset = 0; offset < (u32)size; offset += 4) {

Core/MIPS/IR/IRPassSimplify.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -1175,16 +1175,21 @@ bool PurgeTemps(const IRWriter &in, IRWriter &out, const IROptions &opts) {
11751175
case IRTEMP_LR_VALUE:
11761176
case IRTEMP_LR_MASK:
11771177
case IRTEMP_LR_SHIFT:
1178-
// Unlike other registers, these don't need to persist between blocks.
1179-
// So we consider them not read unless proven read.
1180-
lastWrittenTo[dest] = i;
1181-
// If this is a copy, we might be able to optimize out the copy.
1182-
if (inst.op == IROp::Mov) {
1183-
Check check(dest, i, false);
1184-
check.srcReg = inst.src1;
1185-
checks.push_back(check);
1178+
// Check that it's not a barrier instruction (like CallReplacement). Don't want to even consider optimizing those.
1179+
if (!(inst.m.flags & IRFLAG_BARRIER)) {
1180+
// Unlike other registers, these don't need to persist between blocks.
1181+
// So we consider them not read unless proven read.
1182+
lastWrittenTo[dest] = i;
1183+
// If this is a copy, we might be able to optimize out the copy.
1184+
if (inst.op == IROp::Mov) {
1185+
Check check(dest, i, false);
1186+
check.srcReg = inst.src1;
1187+
checks.push_back(check);
1188+
} else {
1189+
checks.push_back(Check(dest, i, false));
1190+
}
11861191
} else {
1187-
checks.push_back(Check(dest, i, false));
1192+
lastWrittenTo[dest] = i;
11881193
}
11891194
break;
11901195

0 commit comments

Comments
 (0)