Commit 82338059 by Martin Jambor Committed by Martin Jambor

re PR tree-optimization/57294 (ice in remove_described_reference)

2013-05-24  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/57294
	* cgraph.h (ipa_record_stmt_references): Declare.
	* cgraphbuild.c (ipa_record_stmt_references): New function.
	(build_cgraph_edges): Use ipa_record_stmt_references.
	(rebuild_cgraph_edges): Likewise.
	(cgraph_rebuild_references): Likewise.
	* ipa-prop.c (ipa_modify_call_arguments): Discard references
	associated with the old statement and build references from the
	newly built statements.
	* ipa-ref.c (ipa_remove_stmt_references): New function.
	* ipa-ref.h (ipa_remove_stmt_references): Declare.

testsuite/
	* gcc.dg/ipa/pr57294.c: New test.

From-SVN: r199299
parent 1ccd4874
2013-05-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/57294
* cgraph.h (ipa_record_stmt_references): Declare.
* cgraphbuild.c (ipa_record_stmt_references): New function.
(build_cgraph_edges): Use ipa_record_stmt_references.
(rebuild_cgraph_edges): Likewise.
(cgraph_rebuild_references): Likewise.
* ipa-prop.c (ipa_modify_call_arguments): Discard references
associated with the old statement and build references from the
newly built statements.
* ipa-ref.c (ipa_remove_stmt_references): New function.
* ipa-ref.h (ipa_remove_stmt_references): Declare.
2013-05-24 Vladimir Makarov <vmakarov@redhat.com> 2013-05-24 Vladimir Makarov <vmakarov@redhat.com>
* lra-constraints.c (emit_spill_move): Use smaller mode for * lra-constraints.c (emit_spill_move): Use smaller mode for
......
...@@ -705,6 +705,7 @@ unsigned int rebuild_cgraph_edges (void); ...@@ -705,6 +705,7 @@ unsigned int rebuild_cgraph_edges (void);
void cgraph_rebuild_references (void); void cgraph_rebuild_references (void);
int compute_call_stmt_bb_frequency (tree, basic_block bb); int compute_call_stmt_bb_frequency (tree, basic_block bb);
void record_references_in_initializer (tree, bool); void record_references_in_initializer (tree, bool);
void ipa_record_stmt_references (struct cgraph_node *, gimple);
/* In ipa.c */ /* In ipa.c */
bool symtab_remove_unreachable_nodes (bool, FILE *); bool symtab_remove_unreachable_nodes (bool, FILE *);
......
...@@ -288,6 +288,14 @@ mark_store (gimple stmt, tree t, void *data) ...@@ -288,6 +288,14 @@ mark_store (gimple stmt, tree t, void *data)
return false; return false;
} }
/* Record all references from NODE that are taken in statement STMT. */
void
ipa_record_stmt_references (struct cgraph_node *node, gimple stmt)
{
walk_stmt_load_store_addr_ops (stmt, node, mark_load, mark_store,
mark_address);
}
/* Create cgraph edges for function calls. /* Create cgraph edges for function calls.
Also look for functions and variables having addresses taken. */ Also look for functions and variables having addresses taken. */
...@@ -323,8 +331,7 @@ build_cgraph_edges (void) ...@@ -323,8 +331,7 @@ build_cgraph_edges (void)
gimple_call_flags (stmt), gimple_call_flags (stmt),
bb->count, freq); bb->count, freq);
} }
walk_stmt_load_store_addr_ops (stmt, node, mark_load, ipa_record_stmt_references (node, stmt);
mark_store, mark_address);
if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
&& gimple_omp_parallel_child_fn (stmt)) && gimple_omp_parallel_child_fn (stmt))
{ {
...@@ -348,8 +355,7 @@ build_cgraph_edges (void) ...@@ -348,8 +355,7 @@ build_cgraph_edges (void)
} }
} }
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node, ipa_record_stmt_references (node, gsi_stmt (gsi));
mark_load, mark_store, mark_address);
} }
/* Look for initializers of constant variables and private statics. */ /* Look for initializers of constant variables and private statics. */
...@@ -437,13 +443,10 @@ rebuild_cgraph_edges (void) ...@@ -437,13 +443,10 @@ rebuild_cgraph_edges (void)
gimple_call_flags (stmt), gimple_call_flags (stmt),
bb->count, freq); bb->count, freq);
} }
walk_stmt_load_store_addr_ops (stmt, node, mark_load, ipa_record_stmt_references (node, stmt);
mark_store, mark_address);
} }
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node, ipa_record_stmt_references (node, gsi_stmt (gsi));
mark_load, mark_store, mark_address);
} }
record_eh_tables (node, cfun); record_eh_tables (node, cfun);
gcc_assert (!node->global.inlined_to); gcc_assert (!node->global.inlined_to);
...@@ -468,16 +471,9 @@ cgraph_rebuild_references (void) ...@@ -468,16 +471,9 @@ cgraph_rebuild_references (void)
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{ ipa_record_stmt_references (node, gsi_stmt (gsi));
gimple stmt = gsi_stmt (gsi);
walk_stmt_load_store_addr_ops (stmt, node, mark_load,
mark_store, mark_address);
}
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node, ipa_record_stmt_references (node, gsi_stmt (gsi));
mark_load, mark_store, mark_address);
} }
record_eh_tables (node, cfun); record_eh_tables (node, cfun);
} }
......
...@@ -3219,18 +3219,22 @@ void ...@@ -3219,18 +3219,22 @@ void
ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
ipa_parm_adjustment_vec adjustments) ipa_parm_adjustment_vec adjustments)
{ {
struct cgraph_node *current_node = cgraph_get_node (current_function_decl);
vec<tree> vargs; vec<tree> vargs;
vec<tree, va_gc> **debug_args = NULL; vec<tree, va_gc> **debug_args = NULL;
gimple new_stmt; gimple new_stmt;
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi, prev_gsi;
tree callee_decl; tree callee_decl;
int i, len; int i, len;
len = adjustments.length (); len = adjustments.length ();
vargs.create (len); vargs.create (len);
callee_decl = !cs ? gimple_call_fndecl (stmt) : cs->callee->symbol.decl; callee_decl = !cs ? gimple_call_fndecl (stmt) : cs->callee->symbol.decl;
ipa_remove_stmt_references ((symtab_node) current_node, stmt);
gsi = gsi_for_stmt (stmt); gsi = gsi_for_stmt (stmt);
prev_gsi = gsi;
gsi_prev (&prev_gsi);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
struct ipa_parm_adjustment *adj; struct ipa_parm_adjustment *adj;
...@@ -3425,6 +3429,14 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt, ...@@ -3425,6 +3429,14 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
gsi_replace (&gsi, new_stmt, true); gsi_replace (&gsi, new_stmt, true);
if (cs) if (cs)
cgraph_set_call_stmt (cs, new_stmt); cgraph_set_call_stmt (cs, new_stmt);
do
{
ipa_record_stmt_references (current_node, gsi_stmt (gsi));
gsi_prev (&gsi);
}
while ((gsi_end_p (prev_gsi) && !gsi_end_p (gsi))
|| (!gsi_end_p (prev_gsi) && gsi_stmt (gsi) == gsi_stmt (prev_gsi)));
update_ssa (TODO_update_ssa); update_ssa (TODO_update_ssa);
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
} }
......
...@@ -215,3 +215,17 @@ ipa_find_reference (symtab_node referring_node, symtab_node referred_node, ...@@ -215,3 +215,17 @@ ipa_find_reference (symtab_node referring_node, symtab_node referred_node,
return r; return r;
return NULL; return NULL;
} }
/* Remove all references from REFERRING_NODE that are associated with statement
STMT. */
void
ipa_remove_stmt_references (symtab_node referring_node, gimple stmt)
{
struct ipa_ref *r = NULL;
int i;
FOR_EACH_VEC_SAFE_ELT (referring_node->symbol.ref_list.references, i, r)
if (r->stmt == stmt)
ipa_remove_reference (r);
}
...@@ -72,3 +72,4 @@ void ipa_clone_referring (symtab_node, struct ipa_ref_list *); ...@@ -72,3 +72,4 @@ void ipa_clone_referring (symtab_node, struct ipa_ref_list *);
bool ipa_ref_cannot_lead_to_return (struct ipa_ref *); bool ipa_ref_cannot_lead_to_return (struct ipa_ref *);
bool ipa_ref_has_aliases_p (struct ipa_ref_list *); bool ipa_ref_has_aliases_p (struct ipa_ref_list *);
struct ipa_ref * ipa_find_reference (symtab_node, symtab_node, gimple); struct ipa_ref * ipa_find_reference (symtab_node, symtab_node, gimple);
void ipa_remove_stmt_references (symtab_node, gimple);
2013-05-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/57294
* gcc.dg/ipa/pr57294.c: New test.
2013-05-24 Ian Bolton <ian.bolton@arm.com> 2013-05-24 Ian Bolton <ian.bolton@arm.com>
* gcc.target/aarch64/scalar_intrinsics.c * gcc.target/aarch64/scalar_intrinsics.c
......
/* { dg-do compile } */
/* { dg-options "-O3" } */
void baz (void);
int func ();
static void
bar (int a, int foo (void))
{
baz ();
foo ();
}
void
baz (void)
{
bar (0, func);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment