Skip to content

Instantly share code, notes, and snippets.

@timo
Created August 4, 2015 23:03
Show Gist options
  • Save timo/11512a307d720dd182e4 to your computer and use it in GitHub Desktop.
Save timo/11512a307d720dd182e4 to your computer and use it in GitHub Desktop.
verbose logging for what prevents an inlining from happening
diff --git a/src/spesh/inline.c b/src/spesh/inline.c
index cc58d2d..8c26bfc 100644
--- a/src/spesh/inline.c
+++ b/src/spesh/inline.c
@@ -46,6 +46,8 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra
MVMCode *target, MVMSpeshCandidate *cand) {
MVMSpeshGraph *ig;
MVMSpeshBB *bb;
+ char *frame1_name;
+ char *frame2_name;
/* Check inlining is enabled. */
if (!tc->instance->spesh_inline_enabled)
@@ -66,6 +68,9 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra
/* Build graph from the already-specialized bytecode. */
ig = MVM_spesh_graph_create_from_cand(tc, target->body.sf, cand, 0);
+ frame1_name = MVM_string_utf8_encode_C_string(tc, ig->sf->body.name);
+ frame2_name = MVM_string_utf8_encode_C_string(tc, target->body.sf->body.name);
+
/* Traverse graph, looking for anything that might prevent inlining and
* also building usage counts up. */
bb = ig->entry;
@@ -86,17 +91,23 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra
/* Instruction may be marked directly as not being inlinable, in
* which case we're done. */
- if (!is_phi && ins->info->no_inline)
+ if (!is_phi && ins->info->no_inline) {
+ fprintf(stderr, "%s prevented an inlining of %s into %s\n", ins->info->name, frame1_name, frame2_name);
goto not_inlinable;
+ }
/* If we have lexical access, make sure it's within the frame. */
if (ins->info->opcode == MVM_OP_getlex) {
- if (ins->operands[1].lex.outers > 0)
+ if (ins->operands[1].lex.outers > 0) {
+ fprintf(stderr, "an outer lexical for getlex prevented an inlining of %s into %s\n", ins->info->name, frame1_name, frame2_name);
goto not_inlinable;
+ }
}
else if (ins->info->opcode == MVM_OP_bindlex) {
- if (ins->operands[0].lex.outers > 0)
+ if (ins->operands[0].lex.outers > 0) {
+ fprintf(stderr, "an outer lexical for bindlex prevented an inlining of %s into %s\n", ins->info->name, frame1_name, frame2_name);
goto not_inlinable;
+ }
}
/* Check we don't have too many args for inlining to work out. */
@@ -104,8 +115,10 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra
ins->info->opcode == MVM_OP_sp_getarg_i ||
ins->info->opcode == MVM_OP_sp_getarg_n ||
ins->info->opcode == MVM_OP_sp_getarg_s) {
- if (ins->operands[1].lit_i16 >= MAX_ARGS_FOR_OPT)
+ if (ins->operands[1].lit_i16 >= MAX_ARGS_FOR_OPT) {
+ fprintf(stderr, "having too many args prevented an inlining of %s into %s\n", ins->info->name, frame1_name, frame2_name);
goto not_inlinable;
+ }
}
/* Ext-ops need special care in inter-comp-unit inlines. */
@@ -121,11 +134,17 @@ MVMSpeshGraph * MVM_spesh_inline_try_get_graph(MVMThreadContext *tc, MVMSpeshGra
bb = bb->linear_next;
}
+ MVM_free(frame1_name);
+ MVM_free(frame2_name);
+
/* If we found nothing we can't inline, inlining is fine. */
return ig;
/* If we can't find a way to inline, we end up here. */
not_inlinable:
+ MVM_free(frame1_name);
+ MVM_free(frame2_name);
+
MVM_spesh_graph_destroy(tc, ig);
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment