On Mon, 18 Mar 2019, Richard Biener wrote:

> 
> 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).

Needed to rip out some other old redundant-with-verify-SSA stuff.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

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.
        * tree-outof-ssa.c (eliminate_useless_phis): Remove redundant checking.

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);
     }
Index: gcc/tree-outof-ssa.c
===================================================================
--- gcc/tree-outof-ssa.c        (revision 269754)
+++ gcc/tree-outof-ssa.c        (working copy)
@@ -809,26 +809,7 @@ eliminate_useless_phis (void)
          gphi *phi = gsi.phi ();
          result = gimple_phi_result (phi);
          if (virtual_operand_p (result))
-           {
-             /* There should be no arguments which are not virtual, or the
-                results will be incorrect.  */
-             if (flag_checking)
-               for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
-                 {
-                   tree arg = PHI_ARG_DEF (phi, i);
-                   if (TREE_CODE (arg) == SSA_NAME
-                       && !virtual_operand_p (arg))
-                     {
-                       fprintf (stderr, "Argument of PHI is not virtual (");
-                       print_generic_expr (stderr, arg, TDF_SLIM);
-                       fprintf (stderr, "), but the result is :");
-                       print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
-                       internal_error ("SSA corruption");
-                     }
-                 }
-
-             remove_phi_node (&gsi, true);
-           }
+           remove_phi_node (&gsi, true);
           else
            {
              /* Also remove real PHIs with no uses.  */

Reply via email to