}
}
-/* Register HOOK to be called with DATA on each removed node. */
+/* Register HOOK to be called with DATA on each inserted node. */
struct cgraph_node_hook_list *
cgraph_add_function_insertion_hook (cgraph_node_hook hook, void *data)
{
return entry;
}
-/* Remove ENTRY from the list of hooks called on removing nodes. */
+/* Remove ENTRY from the list of hooks called on inserted nodes. */
void
cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *entry)
{
free (entry);
}
-/* Call all node removal hooks. */
+/* Call all node insertion hooks. */
void
cgraph_call_function_insertion_hooks (struct cgraph_node *node)
{
cgraph_nodes->previous = node;
node->previous = NULL;
node->global.estimated_growth = INT_MIN;
+ node->frequency = NODE_FREQUENCY_NORMAL;
cgraph_nodes = node;
cgraph_n_nodes++;
return node;
struct cgraph_node *n = (struct cgraph_node *) *slot;
if (!n->clones && !n->clone_of && !n->global.inlined_to
&& (cgraph_global_info_ready
- && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl))))
+ && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl)
+ || n->in_other_partition)))
kill_body = true;
}
if (assembler_name_hash)
fprintf (f, "%s/%i(%i)", cgraph_node_name (node), node->uid,
node->pid);
dump_addr (f, " @", (void *)node);
+ if (DECL_ASSEMBLER_NAME_SET_P (node->decl))
+ fprintf (f, " (asm: %s)", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)));
if (node->global.inlined_to)
fprintf (f, " (inline copy in %s/%i)",
cgraph_node_name (node->global.inlined_to),
if (cgraph_function_flags_ready)
fprintf (f, " availability:%s",
cgraph_availability_names [cgraph_function_body_availability (node)]);
+ if (node->analyzed)
+ fprintf (f, " analyzed");
+ if (node->in_other_partition)
+ fprintf (f, " in_other_partition");
if (node->count)
fprintf (f, " executed "HOST_WIDEST_INT_PRINT_DEC"x",
(HOST_WIDEST_INT)node->count);
fprintf (f, " address_taken");
else if (node->reachable)
fprintf (f, " reachable");
+ else if (node->reachable_from_other_partition)
+ fprintf (f, " reachable_from_other_partition");
if (gimple_has_body_p (node->decl))
fprintf (f, " body");
if (node->process)
new_node->analyzed = n->analyzed;
new_node->local = n->local;
new_node->local.externally_visible = false;
+ new_node->local.local = true;
+ new_node->local.vtable_method = false;
new_node->global = n->global;
new_node->rtl = n->rtl;
new_node->count = count;
+ new_node->frequency = n->frequency;
new_node->clone = n->clone;
new_node->clone.tree_map = 0;
if (n->count)
DECL_LOOPING_CONST_OR_PURE_P (alias->decl) = looping_const_or_pure;
}
+/* See if the frequency of NODE can be updated based on frequencies of its
+ callers. */
+bool
+cgraph_propagate_frequency (struct cgraph_node *node)
+{
+ bool maybe_unlikely_executed = true, maybe_executed_once = true;
+ struct cgraph_edge *edge;
+ if (!node->local.local)
+ return false;
+ gcc_assert (node->analyzed);
+ if (node->frequency == NODE_FREQUENCY_HOT)
+ return false;
+ if (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)
+ return false;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Processing frequency %s\n", cgraph_node_name (node));
+ for (edge = node->callers;
+ edge && (maybe_unlikely_executed || maybe_executed_once);
+ edge = edge->next_caller)
+ {
+ if (!edge->frequency)
+ continue;
+ switch (edge->caller->frequency)
+ {
+ case NODE_FREQUENCY_UNLIKELY_EXECUTED:
+ break;
+ case NODE_FREQUENCY_EXECUTED_ONCE:
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " Called by %s that is executed once\n", cgraph_node_name (node));
+ maybe_unlikely_executed = false;
+ if (edge->loop_nest)
+ {
+ maybe_executed_once = false;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " Called in loop\n");
+ }
+ break;
+ case NODE_FREQUENCY_HOT:
+ case NODE_FREQUENCY_NORMAL:
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, " Called by %s that is normal or hot\n", cgraph_node_name (node));
+ maybe_unlikely_executed = false;
+ maybe_executed_once = false;
+ break;
+ }
+ }
+ if (maybe_unlikely_executed)
+ {
+ node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
+ if (dump_file)
+ fprintf (dump_file, "Node %s promoted to unlikely executed.\n", cgraph_node_name (node));
+ return true;
+ }
+ if (maybe_executed_once && node->frequency != NODE_FREQUENCY_EXECUTED_ONCE)
+ {
+ node->frequency = NODE_FREQUENCY_EXECUTED_ONCE;
+ if (dump_file)
+ fprintf (dump_file, "Node %s promoted to executed once.\n", cgraph_node_name (node));
+ return true;
+ }
+ return false;
+}
+
#include "gt-cgraph.h"