This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto][patch] Fix reading of cgraph when multiple files are passed to lto1
> There are other loops that go over the whole call graph here. Those
> also need adjusting. If anything, to save doing superfluous work.
Taking a better look at it, there is a deeper problem: If we read
files A and B and B has a prevailing decl and A has a corresponding
preempted decl, we must update the call graph in A after reading B. I
will try to fix that in my next patch
Is the attached patch OK if it has no regressions or should I fix the
cgraph update and commit the two together?
>
> Diego.
>
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index 52872fa..7c4f27e 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -1292,7 +1292,6 @@ input_cgraph_1 (struct lto_file_decl_data* file_data,
{
enum LTO_cgraph_tags tag;
VEC(cgraph_node_ptr, heap) *nodes = NULL;
- VEC(cgraph_node_ptr, heap) *del_list = NULL;
struct cgraph_node *node;
unsigned i;
@@ -1317,7 +1316,7 @@ input_cgraph_1 (struct lto_file_decl_data* file_data,
if (flag_ltrans)
{
- for (node = cgraph_nodes; node; node = node->next)
+ for (i = 0; VEC_iterate (cgraph_node_ptr, nodes, i, node); i++)
{
const int ref = (int) (intptr_t) node->global.inlined_to;
@@ -1329,20 +1328,20 @@ input_cgraph_1 (struct lto_file_decl_data* file_data,
}
}
- for (node = cgraph_nodes; node; node = node->next)
+ for (i = 0; VEC_iterate (cgraph_node_ptr, nodes, i, node); i++)
{
tree prevailing = lto_symtab_prevailing_decl (node->decl);
if (prevailing != node->decl)
- VEC_safe_push (cgraph_node_ptr, heap, del_list, node);
+ {
+ cgraph_remove_node (node);
+ VEC_replace (cgraph_node_ptr, nodes, i, NULL);
+ }
}
- for (i = 0; VEC_iterate (cgraph_node_ptr, del_list, i, node); i++)
- cgraph_remove_node (node);
-
- for (node = cgraph_nodes; node; node = node->next)
- if (cgraph_decide_is_function_needed (node))
- cgraph_mark_needed_node (node);
+ for (i = 0; VEC_iterate (cgraph_node_ptr, nodes, i, node); i++)
+ if (node && cgraph_decide_is_function_needed (node))
+ cgraph_mark_needed_node (node);
VEC_free (cgraph_node_ptr, heap, nodes);
VEC_free (cgraph_node_ptr, heap, del_list);