cgraph_edge::get_next_speculative_id ()
{
int max_id = -1;
- cgraph_edge *e;
- /* Iterate through all edges leaving this caller */
- for (e = caller->callees; e; e = e->next_callee)
+ /* If this edge is not yet speculative, there are no existing speculative
+ edges for this call site, so return 0. */
+ if (!speculative)
+ return 0;
+
+ /* Iterate only through speculative edges for this specific call site. */
+ for (cgraph_edge *e = first_speculative_call_target ();
+ e;
+ e = e->next_speculative_call_target ())
{
- /* Match the specific GIMPLE statement and check the
- speculative flag */
- if (e->call_stmt == call_stmt
- && e->lto_stmt_uid == lto_stmt_uid
- && e->speculative)
- {
- if (e->speculative_id > max_id)
- max_id = e->speculative_id;
- }
+ if (e->speculative_id > max_id)
+ max_id = e->speculative_id;
}
return max_id + 1;