Merge pull request #19189 from hrydgard/star-ocean

IRInterpreter: Fix issue where we could accidentally optimize out CallReplacement ops.
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2024-05-26 00:46:35 +02:00
commit 2a3f8af650
2 files changed
+15 -10

No files matched your search

+1 -1
View File
@@ -1656,7 +1656,7 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) {
std::vector<int> 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) {
+14 -9
View File
@@ -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;