diff --git a/src/spesh/facts.c b/src/spesh/facts.c index 3cbe02a8f8..1566d0707e 100644 --- a/src/spesh/facts.c +++ b/src/spesh/facts.c @@ -461,7 +461,7 @@ static void add_bb_facts(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshBB *bb, } ann = ann->next; } - if (ann_deopt_one && ann_logged) { + if (p && ann_deopt_one && ann_logged) { if (ins->info->opcode == MVM_OP_speshresolve) plugin_facts(tc, g, bb, ins, p, ann_deopt_one, ann_logged); else diff --git a/src/spesh/inline.c b/src/spesh/inline.c index 2756323adb..d89d9d355a 100644 --- a/src/spesh/inline.c +++ b/src/spesh/inline.c @@ -182,25 +182,9 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra * inline the graph. */ ig = MVM_spesh_graph_create_from_cand(tc, target_sf, cand, 0); if (is_graph_inlineable(tc, inliner, target_sf, invoke_ins, ig, no_inline_reason)) { - /* We can inline it. Bump usage counts and return the graph. */ - MVMSpeshBB *bb = ig->entry; - while (bb) { - MVMSpeshIns *ins = bb->first_ins; - while (ins) { - MVMint32 opcode = ins->info->opcode; - MVMint32 is_phi = opcode == MVM_SSA_PHI; - MVMuint8 i; - for (i = 0; i < ins->info->num_operands; i++) - if ((is_phi && i > 0) - || (!is_phi && (ins->info->operands[i] & MVM_operand_rw_mask) == MVM_operand_read_reg)) - ig->facts[ins->operands[i].reg.orig][ins->operands[i].reg.i].usages++; - if (opcode == MVM_OP_inc_i || opcode == MVM_OP_inc_u || - opcode == MVM_OP_dec_i || opcode == MVM_OP_dec_u) - ig->facts[ins->operands[0].reg.orig][ins->operands[0].reg.i - 1].usages++; - ins = ins->next; - } - bb = bb->linear_next; - } + /* We can inline it. Do facts discovery, which also sets usage counts, and + * return it. */ + MVM_spesh_facts_discover(tc, ig, NULL); return ig; } else { diff --git a/src/spesh/optimize.c b/src/spesh/optimize.c index bbda549ec1..3b0291a774 100644 --- a/src/spesh/optimize.c +++ b/src/spesh/optimize.c @@ -1746,7 +1746,6 @@ static void optimize_call(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshBB *bb MVMSpeshOperand code_ref_reg = ins->info->opcode == MVM_OP_invoke_v ? ins->operands[0] : ins->operands[1]; - MVM_spesh_facts_discover(tc, inline_graph, p); MVM_spesh_get_facts(tc, g, code_ref_reg)->usages++; MVM_spesh_inline(tc, g, arg_info, bb, ins, inline_graph, target_sf, code_ref_reg);