Skip to content

Commit c43f436

Browse files
committed
Remove successor when optional named arg passed.
Meaning that the default code becomes dead and gets removed properly, as was the case for the positional args.
1 parent 61f70fa commit c43f436

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/spesh/args.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
543543
named_ins[i]->operands[1].lit_i16 = found_idx + 1;
544544
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i],
545545
named_ins[i]->operands[2].ins_bb);
546+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
547+
named_bb[i]->linear_next);
546548
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i], cur_named);
547549
named_used++;
548550
}
@@ -552,6 +554,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
552554
pos_unbox(tc, g, named_bb[i], named_ins[i], MVM_op_get_op(MVM_OP_unbox_i));
553555
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i]->next,
554556
named_ins[i]->operands[2].ins_bb);
557+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
558+
named_bb[i]->linear_next);
555559
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i]->next, cur_named);
556560
named_used++;
557561
}
@@ -566,6 +570,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
566570
named_ins[i]->operands[1].lit_i16 = found_idx + 1;
567571
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i],
568572
named_ins[i]->operands[2].ins_bb);
573+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
574+
named_bb[i]->linear_next);
569575
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i], cur_named);
570576
named_used++;
571577
}
@@ -575,6 +581,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
575581
pos_unbox(tc, g, named_bb[i], named_ins[i], MVM_op_get_op(MVM_OP_unbox_n));
576582
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i]->next,
577583
named_ins[i]->operands[2].ins_bb);
584+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
585+
named_bb[i]->linear_next);
578586
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i]->next, cur_named);
579587
named_used++;
580588
}
@@ -589,6 +597,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
589597
named_ins[i]->operands[1].lit_i16 = found_idx + 1;
590598
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i],
591599
named_ins[i]->operands[2].ins_bb);
600+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
601+
named_bb[i]->linear_next);
592602
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i], cur_named);
593603
named_used++;
594604
}
@@ -598,6 +608,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
598608
pos_unbox(tc, g, named_bb[i], named_ins[i], MVM_op_get_op(MVM_OP_unbox_s));
599609
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i]->next,
600610
named_ins[i]->operands[2].ins_bb);
611+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
612+
named_bb[i]->linear_next);
601613
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i]->next, cur_named);
602614
named_used++;
603615
}
@@ -613,6 +625,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
613625
named_ins[i]->operands[1].lit_i16 = arg_idx;
614626
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i],
615627
named_ins[i]->operands[2].ins_bb);
628+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
629+
named_bb[i]->linear_next);
616630
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i], cur_named);
617631
if (args[arg_idx].o)
618632
add_guards_and_facts(tc, g, arg_idx, args[arg_idx].o, named_ins[i]);
@@ -635,6 +649,8 @@ void MVM_spesh_args(MVMThreadContext *tc, MVMSpeshGraph *g, MVMCallsite *cs, MVM
635649
MVM_op_get_op(MVM_OP_sp_getarg_s), MVM_reg_str);
636650
MVM_spesh_manipulate_insert_goto(tc, g, named_bb[i], named_ins[i]->next->next,
637651
named_ins[i]->operands[2].ins_bb);
652+
MVM_spesh_manipulate_remove_successor(tc, named_bb[i],
653+
named_bb[i]->linear_next);
638654
used_ins[i] = add_named_used_ins(tc, g, named_bb[i], named_ins[i]->next->next, cur_named);
639655
named_used++;
640656
}

0 commit comments

Comments
 (0)