From 86678379d9865a31f29b0ecb98e3a6557f5cf898 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Sun, 19 Nov 2017 15:21:59 +0100 Subject: [PATCH] Turn inline_end annotated pointless gotos into no_ops We can't remove them completely as that causes weird deopt issues. But turning them into no_ops should give almost the same benefits without the cost. --- src/spesh/optimize.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/spesh/optimize.c b/src/spesh/optimize.c index 6dddc45fea..6b1237ba2c 100644 --- a/src/spesh/optimize.c +++ b/src/spesh/optimize.c @@ -2422,9 +2422,15 @@ static void eliminate_pointless_gotos(MVMThreadContext *tc, MVMSpeshGraph *g) { && last_ins->info->opcode == MVM_OP_goto && last_ins->operands[0].ins_bb == cur_bb->linear_next && ! any_deopt_annotations(last_ins->annotations) - && (! any_inline_end_annotations(last_ins->annotations)) - ) - MVM_spesh_manipulate_delete_ins(tc, g, cur_bb, last_ins); + ) { + if ( + any_inline_end_annotations(last_ins->annotations) + || last_ins == cur_bb->first_ins // May not throw away the only instruction + ) + last_ins->info = MVM_op_get_op(MVM_OP_no_op); + else + MVM_spesh_manipulate_delete_ins(tc, g, cur_bb, last_ins); + } } cur_bb = cur_bb->linear_next; }