Skip to content

Commit ea9edef

Browse files
authored
[mono][llvm] Fix handling of compare when last instruction in bblock (#106233)
Compare opcodes are logically meant to set compare flags and they are always followed by a conditional instruction (that either branches or loads the comparison result in a register). When handling this instruction, if the next instruction was a nop or not a conditional instruction, then we can make the assumption that the conditional instruction was optimized out so there is no need to generate the compare instruction. We were missing the scenario when the conditional instruction was optimized out and the compare was left as the last instruction of the bblock, in which case we were crashing.
1 parent 05abb76 commit ea9edef

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/mono/mono/mini/mini-llvm.c

+3
Original file line numberDiff line numberDiff line change
@@ -6299,6 +6299,9 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
62996299
gboolean likely = (ins->flags & MONO_INST_LIKELY) != 0;
63006300
gboolean unlikely = FALSE;
63016301

6302+
if (!ins->next)
6303+
break;
6304+
63026305
if (MONO_IS_COND_BRANCH_OP (ins->next)) {
63036306
if (ins->next->inst_false_bb->out_of_line)
63046307
likely = TRUE;

0 commit comments

Comments
 (0)