Skip to content

Commit ddf67a7

Browse files
authored
[mono][interp] Fix broken code attempting to reapply superinstruction optimization (#116069)
For each instruction in a basic block we check for patterns. In a certain case, once we replaced the instruction with a new one, we were attempting to do a loop reiteration by setting `ins = ins->prev` so after the loop reincrements with `ins = ins->next` we check super instruction patterns again for the current instruction. This is broken if `ins` was the first instruction in a basic block, aka `ins->prev` is NULL. This used to be impossible before SSA optimizations, since super instruction pass was applying optimizations in a single basic block only.
1 parent a8bc637 commit ddf67a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/mono/mono/mini/interp/transform-opt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3403,9 +3403,11 @@ interp_super_instructions (TransformData *td)
34033403
current_liveness.bb_dfs_index = bb->dfs_index;
34043404
current_liveness.ins_index = 0;
34053405
for (InterpInst *ins = bb->first_ins; ins != NULL; ins = ins->next) {
3406-
int opcode = ins->opcode;
3406+
int opcode;
34073407
if (bb->dfs_index >= td->bblocks_count_no_eh || bb->dfs_index == -1 || (ins->flags & INTERP_INST_FLAG_LIVENESS_MARKER))
34083408
current_liveness.ins_index++;
3409+
retry_ins:
3410+
opcode = ins->opcode;
34093411
if (MINT_IS_NOP (opcode))
34103412
continue;
34113413

@@ -3804,9 +3806,7 @@ interp_super_instructions (TransformData *td)
38043806
g_print ("superins: ");
38053807
interp_dump_ins (ins, td->data_items);
38063808
}
3807-
// The newly added opcode could be part of further superinstructions. Retry
3808-
ins = ins->prev;
3809-
continue;
3809+
goto retry_ins;
38103810
}
38113811
}
38123812
}

0 commit comments

Comments
 (0)