Comments
Patch
===================================================================
@@ -2113,7 +2113,8 @@ cgraph_materialize_clone (struct cgraph_
}
/* If necessary, change the function declaration in the call statement
- associated with E so that it corresponds to the edge callee. */
+ associated with E so that it corresponds to the edge callee. Return the new
+ statement or NULL if nothing was changed. */
gimple
cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
@@ -2128,7 +2129,7 @@ cgraph_redirect_edge_call_stmt_to_callee
|| decl == e->callee->decl
/* Don't update call from same body alias to the real function. */
|| (decl && cgraph_get_node (decl) == cgraph_get_node (e->callee->decl)))
- return e->call_stmt;
+ return NULL;
#ifdef ENABLE_CHECKING
if (decl)
===================================================================
@@ -2161,7 +2161,8 @@ inline_transform (struct cgraph_node *no
for (e = node->callees; e; e = e->next_callee)
{
- cgraph_redirect_edge_call_stmt_to_callee (e);
+ if (cgraph_redirect_edge_call_stmt_to_callee (e))
+ todo = TODO_update_ssa;
if (!e->inline_failed || warn_inline)
inline_p = true;
}
@@ -2169,7 +2170,7 @@ inline_transform (struct cgraph_node *no
if (inline_p)
{
timevar_push (TV_INTEGRATION);
- todo = optimize_inline_calls (current_function_decl);
+ todo |= optimize_inline_calls (current_function_decl);
timevar_pop (TV_INTEGRATION);
}
cfun->always_inline_functions_inlined = true;
===================================================================
@@ -1679,6 +1679,7 @@ copy_bb (copy_body_data *id, basic_block
if (edge)
{
int edge_freq = edge->frequency;
+ gimple n_stmt;
edge = cgraph_clone_edge (edge, id->dst_node, stmt,
gimple_uid (stmt),
REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
@@ -1704,7 +1705,9 @@ copy_bb (copy_body_data *id, basic_block
bb->frequency,
copy_basic_block->frequency);
}
- stmt = cgraph_redirect_edge_call_stmt_to_callee (edge);
+ n_stmt = cgraph_redirect_edge_call_stmt_to_callee (edge);
+ if (n_stmt)
+ stmt = n_stmt;
}
break;
===================================================================
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-O -fno-toplevel-reorder -fno-inline -fipa-cp -fipa-cp-clone -fkeep-inline-functions" }
+
+template < typename Derived > struct AnyMatrixBase
+{
+};
+
+struct Matrix Random ();
+
+struct Matrix:AnyMatrixBase < Matrix >
+{
+ void bar ()
+ {
+ throw;
+ }
+ void foo (Matrix other)
+ {
+ bar ();
+ Matrix (AnyMatrixBase < Matrix > (Random ()));
+ }
+ template
+ < typename OtherDerived > Matrix (AnyMatrixBase < OtherDerived > other)
+ {
+ foo (other);
+ }
+};
+
+Matrix x (Random ());