From 7c7107778f16c2db6e97e73fdec6d6606b619864 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 29 Jan 2020 12:43:10 +0100 Subject: ipa: Fix removal of multi-target speculation. * cgraph.c (cgraph_edge::resolve_speculation): Only lookup direct edge if called on indirect edge. (cgraph_edge::redirect_call_stmt_to_callee): Lookup indirect edge of speculative call if needed. * gcc.dg/tree-prof/indir-call-prof-2.c: New testcase. --- gcc/cgraph.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/cgraph.c') diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 3e50b0b..294b2d3 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1189,7 +1189,10 @@ cgraph_edge::resolve_speculation (cgraph_edge *edge, tree callee_decl) ipa_ref *ref; gcc_assert (edge->speculative && (!callee_decl || edge->callee)); - e2 = edge->first_speculative_call_target (); + if (!edge->callee) + e2 = edge->first_speculative_call_target (); + else + e2 = edge; ref = e2->speculative_call_target_ref (); edge = edge->speculative_call_indirect_edge (); if (!callee_decl @@ -1364,7 +1367,8 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e) /* If there already is an direct call (i.e. as a result of inliner's substitution), forget about speculating. */ if (decl) - e = make_direct (e, cgraph_node::get (decl)); + e = make_direct (e->speculative_call_indirect_edge (), + cgraph_node::get (decl)); else { /* Be sure we redirect all speculative targets before poking -- cgit v1.1