This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix duplicated renumbering of statements during streaming
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 13 Oct 2019 12:12:15 +0200
- Subject: Fix duplicated renumbering of statements during streaming
Hi,
currently we renumber statements during streaming twice - once using
renumber_gimple_stmt_uids and second inside output_function.
The numbering only differs by fact that first one does mix normal and
virtual PHI sets while the second doesn't. This patch reduces
renumbering to only one per streaming.
Honza
* lto.c (lto_wpa_write_files): Do not update bodies of clones.
* lto-streamer-out.c (collect_block_tree_leafs): Renumber statements
so non-virutal are before virutals.
(output_function): Avoid body modifications.
Index: lto/lto.c
===================================================================
--- lto/lto.c (revision 276870)
+++ lto/lto.c (working copy)
@@ -308,7 +308,7 @@ lto_wpa_write_files (void)
/* Do body modifications needed for streaming before we fork out
worker processes. */
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
- if (gimple_has_body_p (node->decl))
+ if (!node->clone_of && gimple_has_body_p (node->decl))
lto_prepare_function_for_streaming (node);
/* Generate a prefix for the LTRANS unit files. */
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c (revision 276870)
+++ lto-streamer-out.c (working copy)
@@ -2066,14 +2066,54 @@ collect_block_tree_leafs (tree root, vec
void
lto_prepare_function_for_streaming (struct cgraph_node *node)
{
- if (number_of_loops (DECL_STRUCT_FUNCTION (node->decl)))
+ struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
+ basic_block bb;
+
+ if (number_of_loops (fn))
{
- push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ push_cfun (fn);
loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
loop_optimizer_finalize ();
pop_cfun ();
}
- renumber_gimple_stmt_uids (DECL_STRUCT_FUNCTION (node->decl));
+ /* We will renumber the statements. The code that does this uses
+ the same ordering that we use for serializing them so we can use
+ the same code on the other end and not have to write out the
+ statement numbers. We do not assign UIDs to PHIs here because
+ virtual PHIs get re-computed on-the-fly which would make numbers
+ inconsistent. */
+ set_gimple_stmt_max_uid (fn, 0);
+ FOR_ALL_BB_FN (bb, fn)
+ {
+ for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gphi *stmt = gsi.phi ();
+
+ /* Virtual PHIs are not going to be streamed. */
+ if (!virtual_operand_p (gimple_phi_result (stmt)))
+ gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
+ }
+ for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gimple *stmt = gsi_stmt (gsi);
+ gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
+ }
+ }
+ /* To avoid keeping duplicate gimple IDs in the statements, renumber
+ virtual phis now. */
+ FOR_ALL_BB_FN (bb, fn)
+ {
+ for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gphi *stmt = gsi.phi ();
+ if (virtual_operand_p (gimple_phi_result (stmt)))
+ gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
+ }
+ }
+
}
/* Output the body of function NODE->DECL. */
@@ -2144,45 +2184,6 @@ output_function (struct cgraph_node *nod
/* Output any exception handling regions. */
output_eh_regions (ob, fn);
-
- /* We will renumber the statements. The code that does this uses
- the same ordering that we use for serializing them so we can use
- the same code on the other end and not have to write out the
- statement numbers. We do not assign UIDs to PHIs here because
- virtual PHIs get re-computed on-the-fly which would make numbers
- inconsistent. */
- set_gimple_stmt_max_uid (fn, 0);
- FOR_ALL_BB_FN (bb, fn)
- {
- for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gphi *stmt = gsi.phi ();
-
- /* Virtual PHIs are not going to be streamed. */
- if (!virtual_operand_p (gimple_phi_result (stmt)))
- gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
- }
- for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
- gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
- }
- }
- /* To avoid keeping duplicate gimple IDs in the statements, renumber
- virtual phis now. */
- FOR_ALL_BB_FN (bb, fn)
- {
- for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gphi *stmt = gsi.phi ();
- if (virtual_operand_p (gimple_phi_result (stmt)))
- gimple_set_uid (stmt, inc_gimple_stmt_max_uid (fn));
- }
- }
-
/* Output the code for the function. */
FOR_ALL_BB_FN (bb, fn)
output_bb (ob, bb, fn);