The following adjusts release_ssa_name to not clear TREE_TYPE but set
it to error_mark_node instead.  This avoids ICEs when dumping stmts
with released SSA names which can easily happen when doing -details
dumps and blocks being removed during the PRE-order CFG cleanup
phase which runs before SSA updating.

It also removes restoring SSA_NAME_VAR in exchange.  Not sure
what that new incremental SSA update code was - the code is
this way since forever, we now handle anonymous SSA names
with NULL SSA_NAME_VAR just fine and SSA_NAME_VAR is set
at allocation time (plus we delay releasing when a name is
registered for update).

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2019-03-18  Richard Biener  <rguent...@suse.de>

        PR middle-end/88945
        * tree-ssanames.c (release_ssa_name_fn): For released SSA names
        use a TREE_TYPE of error_mark_node to avoid ICEs when dumping
        basic-blocks that are removed.  Remove restoring SSA_NAME_VAR.

Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c (revision 269754)
+++ gcc/tree-ssanames.c (working copy)
@@ -595,7 +595,6 @@ release_ssa_name_fn (struct function *fn
      defining statement.  */
   if (! SSA_NAME_IN_FREE_LIST (var))
     {
-      tree saved_ssa_name_var = SSA_NAME_VAR (var);
       int saved_ssa_name_version = SSA_NAME_VERSION (var);
       use_operand_p imm = &(SSA_NAME_IMM_USE_NODE (var));
 
@@ -621,13 +620,14 @@ release_ssa_name_fn (struct function *fn
       /* Restore the version number.  */
       SSA_NAME_VERSION (var) = saved_ssa_name_version;
 
-      /* Hopefully this can go away once we have the new incremental
-         SSA updating code installed.  */
-      SET_SSA_NAME_VAR_OR_IDENTIFIER (var, saved_ssa_name_var);
-
       /* Note this SSA_NAME is now in the first list.  */
       SSA_NAME_IN_FREE_LIST (var) = 1;
 
+      /* Put in a non-NULL TREE_TYPE so dumping code will not ICE
+         if it happens to come along a released SSA name and tries
+        to inspect its type.  */
+      TREE_TYPE (var) = error_mark_node;
+
       /* And finally queue it so that it will be put on the free list.  */
       vec_safe_push (FREE_SSANAMES_QUEUE (fn), var);
     }

Reply via email to