return edge;
}
-/* Remove the edge from the list of the callers of the callee. */
-
-void
-cgraph_edge::remove_callee (void)
-{
- gcc_assert (!indirect_unknown_callee);
- if (prev_caller)
- prev_caller->next_caller = next_caller;
- if (next_caller)
- next_caller->prev_caller = prev_caller;
- if (!prev_caller)
- callee->callers = next_caller;
-}
-
/* Remove the edge from the list of the callees of the caller. */
void
symtab->free_edge (this);
}
-/* Set callee of call graph edge E and add it to the corresponding set of
- callers. */
-
-static void
-cgraph_set_edge_callee (cgraph_edge *e, cgraph_node *n)
-{
- e->prev_caller = NULL;
- if (n->callers)
- n->callers->prev_caller = e;
- e->next_caller = n->callers;
- n->callers = e;
- e->callee = n;
-}
-
/* Turn edge into speculative call calling N2. Update
the profile so the direct call is taken COUNT times
with FREQUENCY.
gcc_assert (e && e2 && ref);
}
-/* Redirect callee of the edge to N. The function does not update underlying
- call expression. */
-
-void
-cgraph_edge::redirect_callee (cgraph_node *n)
-{
- /* Remove from callers list of the current callee. */
- remove_callee ();
-
- /* Insert to callers list of the new callee. */
- cgraph_set_edge_callee (this, n);
-}
-
/* Speculative call edge turned out to be direct call to CALLE_DECL.
Remove the speculative call sequence and return edge representing the call.
It is up to caller to redirect the call as appropriate. */
caller->callees = edge;
/* Insert to callers list of the new callee. */
- cgraph_set_edge_callee (edge, callee);
+ edge->set_callee (callee);
if (call_stmt)
call_stmt_cannot_inline_p
const char * const cgraph_availability_names[] =
{"unset", "not_available", "overwritable", "available", "local"};
-/* Output flags of edge E. */
+/* Output flags of edge to a file F. */
-static void
-dump_edge_flags (FILE *f, struct cgraph_edge *edge)
+void
+cgraph_edge::dump_edge_flags (FILE *f)
{
- if (edge->speculative)
+ if (speculative)
fprintf (f, "(speculative) ");
- if (!edge->inline_failed)
+ if (!inline_failed)
fprintf (f, "(inlined) ");
- if (edge->indirect_inlining_edge)
+ if (indirect_inlining_edge)
fprintf (f, "(indirect_inlining) ");
- if (edge->count)
- fprintf (f, "(%"PRId64"x) ",
- (int64_t)edge->count);
- if (edge->frequency)
- fprintf (f, "(%.2f per call) ",
- edge->frequency / (double)CGRAPH_FREQ_BASE);
- if (edge->can_throw_external)
+ if (count)
+ fprintf (f, "(%"PRId64"x) ", (int64_t)count);
+ if (frequency)
+ fprintf (f, "(%.2f per call) ", frequency / (double)CGRAPH_FREQ_BASE);
+ if (can_throw_external)
fprintf (f, "(can throw external) ");
}
{
fprintf (f, "%s/%i ", edge->caller->asm_name (),
edge->caller->order);
- dump_edge_flags (f, edge);
+ edge->dump_edge_flags (f);
}
fprintf (f, "\n Calls: ");
{
fprintf (f, "%s/%i ", edge->callee->asm_name (),
edge->callee->order);
- dump_edge_flags (f, edge);
+ edge->dump_edge_flags (f);
}
fprintf (f, "\n");
}
else
fprintf (f, " Indirect call");
- dump_edge_flags (f, edge);
+ edge->dump_edge_flags (f);
if (edge->indirect_info->param_index != -1)
{
fprintf (f, " of param:%i", edge->indirect_info->param_index);
return node2 != NULL;
}
-/* Verify edge E count and frequency. */
+/* Verify edge count and frequency. */
-static bool
-verify_edge_count_and_frequency (cgraph_edge *e)
+bool
+cgraph_edge::verify_count_and_frequency ()
{
bool error_found = false;
- if (e->count < 0)
+ if (count < 0)
{
error ("caller edge count is negative");
error_found = true;
}
- if (e->frequency < 0)
+ if (frequency < 0)
{
error ("caller edge frequency is negative");
error_found = true;
}
- if (e->frequency > CGRAPH_FREQ_MAX)
+ if (frequency > CGRAPH_FREQ_MAX)
{
error ("caller edge frequency is too large");
error_found = true;
}
- if (gimple_has_body_p (e->caller->decl)
- && !e->caller->global.inlined_to
- && !e->speculative
+ if (gimple_has_body_p (caller->decl)
+ && !caller->global.inlined_to
+ && !speculative
/* FIXME: Inline-analysis sets frequency to 0 when edge is optimized out.
Remove this once edges are actually removed from the function at that time. */
- && (e->frequency
+ && (frequency
|| (inline_edge_summary_vec.exists ()
- && ((inline_edge_summary_vec.length () <= (unsigned) e->uid)
- || !inline_edge_summary (e)->predicate)))
- && (e->frequency
- != compute_call_stmt_bb_frequency (e->caller->decl,
- gimple_bb (e->call_stmt))))
+ && ((inline_edge_summary_vec.length () <= (unsigned) uid)
+ || !inline_edge_summary (this)->predicate)))
+ && (frequency
+ != compute_call_stmt_bb_frequency (caller->decl,
+ gimple_bb (call_stmt))))
{
error ("caller edge frequency %i does not match BB frequency %i",
- e->frequency,
- compute_call_stmt_bb_frequency (e->caller->decl,
- gimple_bb (e->call_stmt)));
+ frequency,
+ compute_call_stmt_bb_frequency (caller->decl,
+ gimple_bb (call_stmt)));
error_found = true;
}
return error_found;
current_function_decl = NULL;
}
-/* Verify that call graph edge E corresponds to DECL from the associated
+/* Verify that call graph edge corresponds to DECL from the associated
statement. Return true if the verification should fail. */
-static bool
-verify_edge_corresponds_to_fndecl (cgraph_edge *e, tree decl)
+bool
+cgraph_edge::verify_corresponds_to_fndecl (tree decl)
{
cgraph_node *node;
- if (!decl || e->callee->global.inlined_to)
+ if (!decl || callee->global.inlined_to)
return false;
if (symtab->state == LTO_STREAMING)
return false;
|| node->body_removed
|| node->in_other_partition
|| node->icf_merged
- || e->callee->in_other_partition)
+ || callee->in_other_partition)
return false;
node = node->ultimate_alias_target ();
/* Optimizers can redirect unreachable calls or calls triggering undefined
behaviour to builtin_unreachable. */
- if (DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE)
+ if (DECL_BUILT_IN_CLASS (callee->decl) == BUILT_IN_NORMAL
+ && DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE)
return false;
- if (e->callee->former_clone_of != node->decl
- && (node != e->callee->ultimate_alias_target ())
- && !clone_of_p (node, e->callee))
+ if (callee->former_clone_of != node->decl
+ && (node != callee->ultimate_alias_target ())
+ && !clone_of_p (node, callee))
return true;
else
return false;
bool check_comdat = comdat_local_p ();
for (e = callers; e; e = e->next_caller)
{
- if (verify_edge_count_and_frequency (e))
+ if (e->verify_count_and_frequency ())
error_found = true;
if (check_comdat
&& !in_same_comdat_group_p (e->caller))
}
}
for (e = indirect_calls; e; e = e->next_callee)
- if (verify_edge_count_and_frequency (e))
+ if (e->verify_count_and_frequency ())
error_found = true;
if (!callers && global.inlined_to)
{
}
if (!e->indirect_unknown_callee)
{
- if (verify_edge_corresponds_to_fndecl (e, decl))
+ if (e->verify_corresponds_to_fndecl (decl))
{
error ("edge points to wrong declaration:");
debug_tree (e->callee->decl);
cgraph_edge * clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
gcov_type count_scale, int freq_scale, bool update_original);
+ /* Verify edge count and frequency. */
+ bool verify_count_and_frequency ();
+
/* Return true when call of edge can not lead to return from caller
and thus it is safe to ignore its side effects for IPA analysis
when computing side effects of the caller. */
/* Remove the edge from the list of the callees of the caller. */
void remove_callee (void);
+
+ /* Set callee N of call graph edge and add it to the corresponding set of
+ callers. */
+ void set_callee (cgraph_node *n);
+
+ /* Output flags of edge to a file F. */
+ void dump_edge_flags (FILE *f);
+
+ /* Verify that call graph edge corresponds to DECL from the associated
+ statement. Return true if the verification should fail. */
+ bool verify_corresponds_to_fndecl (tree decl);
};
#define CGRAPH_FREQ_BASE 1000
return n;
}
+/* Set callee N of call graph edge and add it to the corresponding set of
+ callers. */
+
+inline void
+cgraph_edge::set_callee (cgraph_node *n)
+{
+ prev_caller = NULL;
+ if (n->callers)
+ n->callers->prev_caller = this;
+ next_caller = n->callers;
+ n->callers = this;
+ callee = n;
+}
+
+/* Redirect callee of the edge to N. The function does not update underlying
+ call expression. */
+
+inline void
+cgraph_edge::redirect_callee (cgraph_node *n)
+{
+ /* Remove from callers list of the current callee. */
+ remove_callee ();
+
+ /* Insert to callers list of the new callee. */
+ set_callee (n);
+}
+
/* Return true when the edge represents a direct recursion. */
inline bool
cgraph_edge::recursive_p (void)
return caller->decl == c->decl;
}
+/* Remove the edge from the list of the callers of the callee. */
+
+inline void
+cgraph_edge::remove_callee (void)
+{
+ gcc_assert (!indirect_unknown_callee);
+ if (prev_caller)
+ prev_caller->next_caller = next_caller;
+ if (next_caller)
+ next_caller->prev_caller = prev_caller;
+ if (!prev_caller)
+ callee->callers = next_caller;
+}
+
/* Return true if the TM_CLONE bit is set for a given FNDECL. */
static inline bool
decl_is_tm_clone (const_tree fndecl)