Fix PHI IDs in LTO streaming
Jan Hubicka
hubicka@ucw.cz
Thu Aug 8 22:59:00 GMT 2013
Hi,
LTO streaming renumbers gimple statements. It however forgets about PHIs that causes
duplicated gimple ids and later fun everywhere (especially for me when I want to
use them for reference streaming).
This patch assign numbers to SSA names too. Since virtual PHIs are not stored, we
have to ignore them on stream-out time. I do not think it is cool that they get
duplicated ids so I just renumber them afterwards.
Bootstrapped/regtested x86_64-linux, comitted as obvious.
Honza
* lto-streamer-out.c (output_function): Renumber PHIs.
* lto-streamer-in.c (input_function): Likewise.
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c (revision 201568)
+++ lto-streamer-out.c (working copy)
@@ -1792,12 +1792,32 @@ output_function (struct cgraph_node *nod
FOR_ALL_BB (bb)
{
gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+
+ /* 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 (cfun));
+ }
for (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 (cfun));
}
}
+ /* To avoid keeping duplicate gimple IDs in the statements, renumber
+ virtual phis now. */
+ FOR_ALL_BB (bb)
+ {
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ if (virtual_operand_p (gimple_phi_result (stmt)))
+ gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
+ }
+ }
/* Output the code for the function. */
FOR_ALL_BB_FN (bb, fn)
Index: lto-streamer-in.c
===================================================================
--- lto-streamer-in.c (revision 201568)
+++ lto-streamer-in.c (working copy)
@@ -908,6 +908,11 @@ input_function (tree fn_decl, struct dat
FOR_ALL_BB (bb)
{
gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
+ }
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
@@ -917,7 +922,14 @@ input_function (tree fn_decl, struct dat
stmts = (gimple *) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple));
FOR_ALL_BB (bb)
{
- gimple_stmt_iterator bsi = gsi_start_bb (bb);
+ gimple_stmt_iterator bsi = gsi_start_phis (bb);
+ while (!gsi_end_p (bsi))
+ {
+ gimple stmt = gsi_stmt (bsi);
+ gsi_next (&bsi);
+ stmts[gimple_uid (stmt)] = stmt;
+ }
+ bsi = gsi_start_bb (bb);
while (!gsi_end_p (bsi))
{
gimple stmt = gsi_stmt (bsi);
More information about the Gcc-patches
mailing list