diff options
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index adef0bd..c2509ff 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -275,7 +275,7 @@ cgraph_edge (struct cgraph_node *node, tree call_expr) struct cgraph_edge * cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee, - tree call_expr) + tree call_expr, gcov_type count, int nest) { struct cgraph_edge *edge = ggc_alloc (sizeof (struct cgraph_edge)); #ifdef ENABLE_CHECKING @@ -312,6 +312,8 @@ cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee, caller->callees->prev_callee = edge; caller->callees = edge; callee->callers = edge; + edge->count = count; + edge->loop_nest = nest; return edge; } @@ -559,6 +561,9 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) fprintf (f, " (inline copy in %s/%i)", cgraph_node_name (node->global.inlined_to), node->global.inlined_to->uid); + if (node->count) + fprintf (f, " executed "HOST_WIDEST_INT_PRINT_DEC"x", + (HOST_WIDEST_INT)node->count); if (node->local.self_insns) fprintf (f, " %i insns", node->local.self_insns); if (node->global.insns && node->global.insns != node->local.self_insns) @@ -587,6 +592,9 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) { fprintf (f, "%s/%i ", cgraph_node_name (edge->caller), edge->caller->uid); + if (edge->count) + fprintf (f, "("HOST_WIDEST_INT_PRINT_DEC"x) ", + (HOST_WIDEST_INT)edge->count); if (!edge->inline_failed) fprintf(f, "(inlined) "); } @@ -829,20 +837,28 @@ cgraph_function_possibly_inlined_p (tree decl) /* Create clone of E in the node N represented by CALL_EXPR the callgraph. */ struct cgraph_edge * -cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n, tree call_expr) +cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n, + tree call_expr, int count_scale, int loop_nest) { - struct cgraph_edge *new = cgraph_create_edge (n, e->callee, call_expr); + struct cgraph_edge *new; + + new = cgraph_create_edge (n, e->callee, call_expr, + e->count * count_scale / REG_BR_PROB_BASE, + e->loop_nest + loop_nest); new->inline_failed = e->inline_failed; + e->count -= new->count; return new; } -/* Create node representing clone of N. */ +/* Create node representing clone of N executed COUNT times. Decrease + the execution counts from original node too. */ struct cgraph_node * -cgraph_clone_node (struct cgraph_node *n) +cgraph_clone_node (struct cgraph_node *n, gcov_type count, int loop_nest) { struct cgraph_node *new = cgraph_create_node (); struct cgraph_edge *e; + int count_scale; new->decl = n->decl; new->origin = n->origin; @@ -855,9 +871,15 @@ cgraph_clone_node (struct cgraph_node *n) new->local = n->local; new->global = n->global; new->rtl = n->rtl; + new->count = count; + if (n->count) + count_scale = new->count * REG_BR_PROB_BASE / n->count; + else + count_scale = 0; + n->count -= count; for (e = n->callees;e; e=e->next_callee) - cgraph_clone_edge (e, new, e->call_expr); + cgraph_clone_edge (e, new, e->call_expr, count_scale, loop_nest); new->next_clone = n->next_clone; new->prev_clone = n; |