Commit d0b66480 by Jan Hubicka Committed by Jan Hubicka

cgraph.c (cgraph_speculative_call_info): Fix parameter order and formating; add sanity check.

	* cgraph.c (cgraph_speculative_call_info): Fix parameter order and formating;
	add sanity check.
	(cgraph_resolve_speculation): Add FIXME about scaling profiles.
	(cgraph_redirect_edge_call_stmt_to_callee): Fix ICE in debug dump.
	* ipa-inline.c (heap_edge_removal_hook): Reset node growth cache.
	(resolve_noninline_speculation): Update callee keys, too.

From-SVN: r201996
parent 0f9aaac7
2013-08-26 Jan Hubicka <jh@suse.cz> 2013-08-26 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_speculative_call_info): Fix parameter order and formating;
add sanity check.
(cgraph_resolve_speculation): Add FIXME about scaling profiles.
(cgraph_redirect_edge_call_stmt_to_callee): Fix ICE in debug dump.
* ipa-inline.c (heap_edge_removal_hook): Reset node growth cache.
(resolve_noninline_speculation): Update callee keys, too.
2013-08-26 Jan Hubicka <jh@suse.cz>
* tree.h (tree_decl_with_vis): Add cxx_constructor, cxx_destructor. * tree.h (tree_decl_with_vis): Add cxx_constructor, cxx_destructor.
(DECL_CXX_CONSTRUCTOR_P, DECL_CXX_DESTRUCTOR_P): New macros. (DECL_CXX_CONSTRUCTOR_P, DECL_CXX_DESTRUCTOR_P): New macros.
......
...@@ -1113,8 +1113,8 @@ cgraph_turn_edge_to_speculative (struct cgraph_edge *e, ...@@ -1113,8 +1113,8 @@ cgraph_turn_edge_to_speculative (struct cgraph_edge *e,
void void
cgraph_speculative_call_info (struct cgraph_edge *e, cgraph_speculative_call_info (struct cgraph_edge *e,
struct cgraph_edge *&indirect,
struct cgraph_edge *&direct, struct cgraph_edge *&direct,
struct cgraph_edge *&indirect,
struct ipa_ref *&reference) struct ipa_ref *&reference)
{ {
struct ipa_ref *ref; struct ipa_ref *ref;
...@@ -1137,16 +1137,18 @@ cgraph_speculative_call_info (struct cgraph_edge *e, ...@@ -1137,16 +1137,18 @@ cgraph_speculative_call_info (struct cgraph_edge *e,
} }
else else
for (e = e->caller->callees; for (e = e->caller->callees;
e2->call_stmt != e->call_stmt || e2->lto_stmt_uid != e->lto_stmt_uid; e2->call_stmt != e->call_stmt
|| e2->lto_stmt_uid != e->lto_stmt_uid;
e = e->next_callee) e = e->next_callee)
; ;
} }
gcc_assert (e->speculative && e2->speculative); gcc_assert (e->speculative && e2->speculative);
indirect = e; direct = e;
direct = e2; indirect = e2;
reference = NULL; reference = NULL;
for (i = 0; ipa_ref_list_reference_iterate (&e->caller->symbol.ref_list, i, ref); i++) for (i = 0; ipa_ref_list_reference_iterate (&e->caller->symbol.ref_list,
i, ref); i++)
if (ref->speculative if (ref->speculative
&& ((ref->stmt && ref->stmt == e->call_stmt) && ((ref->stmt && ref->stmt == e->call_stmt)
|| (ref->lto_stmt_uid == e->lto_stmt_uid))) || (ref->lto_stmt_uid == e->lto_stmt_uid)))
...@@ -1154,6 +1156,11 @@ cgraph_speculative_call_info (struct cgraph_edge *e, ...@@ -1154,6 +1156,11 @@ cgraph_speculative_call_info (struct cgraph_edge *e,
reference = ref; reference = ref;
break; break;
} }
/* Speculative edge always consist of all three components - direct edge,
indirect and reference. */
gcc_assert (e && e2 && ref);
} }
/* Redirect callee of E to N. The function does not update underlying /* Redirect callee of E to N. The function does not update underlying
...@@ -1209,6 +1216,8 @@ cgraph_resolve_speculation (struct cgraph_edge *edge, tree callee_decl) ...@@ -1209,6 +1216,8 @@ cgraph_resolve_speculation (struct cgraph_edge *edge, tree callee_decl)
fprintf (dump_file, "Speculative call turned into direct call.\n"); fprintf (dump_file, "Speculative call turned into direct call.\n");
edge = e2; edge = e2;
e2 = tmp; e2 = tmp;
/* FIXME: If EDGE is inlined, we should scale up the frequencies and counts
in the functions inlined through it. */
} }
edge->count += e2->count; edge->count += e2->count;
edge->frequency += e2->frequency; edge->frequency += e2->frequency;
...@@ -1305,12 +1314,12 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) ...@@ -1305,12 +1314,12 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
else if (!gimple_check_call_matching_types (e->call_stmt, e->callee->symbol.decl, else if (!gimple_check_call_matching_types (e->call_stmt, e->callee->symbol.decl,
true)) true))
{ {
e = cgraph_resolve_speculation (e, NULL);
if (dump_file) if (dump_file)
fprintf (dump_file, "Not expanding speculative call of %s/%i -> %s/%i\n" fprintf (dump_file, "Not expanding speculative call of %s/%i -> %s/%i\n"
"Type mismatch.\n", "Type mismatch.\n",
xstrdup (cgraph_node_name (e->caller)), e->caller->symbol.order, xstrdup (cgraph_node_name (e->caller)), e->caller->symbol.order,
xstrdup (cgraph_node_name (e->callee)), e->callee->symbol.order); xstrdup (cgraph_node_name (e->callee)), e->callee->symbol.order);
e = cgraph_resolve_speculation (e, NULL);
} }
/* Expand speculation into GIMPLE code. */ /* Expand speculation into GIMPLE code. */
else else
......
...@@ -1397,6 +1397,8 @@ add_new_edges_to_heap (fibheap_t heap, vec<cgraph_edge_p> new_edges) ...@@ -1397,6 +1397,8 @@ add_new_edges_to_heap (fibheap_t heap, vec<cgraph_edge_p> new_edges)
static void static void
heap_edge_removal_hook (struct cgraph_edge *e, void *data) heap_edge_removal_hook (struct cgraph_edge *e, void *data)
{ {
if (e->callee)
reset_node_growth_cache (e->callee);
if (e->aux) if (e->aux)
{ {
fibheap_delete_node ((fibheap_t)data, (fibnode_t)e->aux); fibheap_delete_node ((fibheap_t)data, (fibnode_t)e->aux);
...@@ -1467,12 +1469,12 @@ resolve_noninline_speculation (fibheap_t edge_heap, struct cgraph_edge *edge) ...@@ -1467,12 +1469,12 @@ resolve_noninline_speculation (fibheap_t edge_heap, struct cgraph_edge *edge)
bitmap updated_nodes = BITMAP_ALLOC (NULL); bitmap updated_nodes = BITMAP_ALLOC (NULL);
cgraph_resolve_speculation (edge, NULL); cgraph_resolve_speculation (edge, NULL);
reset_node_growth_cache (where);
reset_edge_caches (where); reset_edge_caches (where);
inline_update_overall_summary (where); inline_update_overall_summary (where);
update_caller_keys (edge_heap, where, update_caller_keys (edge_heap, where,
updated_nodes, NULL); updated_nodes, NULL);
reset_node_growth_cache (where); update_callee_keys (edge_heap, where,
updated_nodes);
BITMAP_FREE (updated_nodes); BITMAP_FREE (updated_nodes);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment