Skip to content

Commit 1c91f56

Browse files
[MIPS] Mark jalr[.hb] $zero, $ra as a return instruction
1 parent 9e83ea1 commit 1c91f56

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/mips/arch_mips.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,12 @@ class MipsArchitecture: public Architecture
332332
result.AddBranch(CallDestination, instr.operands[0].immediate, nullptr, hasBranchDelay);
333333
break;
334334

335-
//Jmp to register register value is unknown
336335
case MIPS_JALR:
337336
case MIPS_JALR_HB:
338-
result.delaySlots = 1;
337+
if (instr.operands[0].reg == REG_ZERO && instr.operands[1].reg == REG_RA)
338+
result.AddBranch(FunctionReturn, 0, nullptr, hasBranchDelay);
339+
else
340+
result.AddBranch(UnresolvedBranch, 0, nullptr, hasBranchDelay);
339341
break;
340342

341343
case MIPS_BGEZAL:

0 commit comments

Comments
 (0)