This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/54735] [4.8 Regression] Segmentation fault in walk_aliased_vdefs_1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54735

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tom at codesourcery dot com

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-10-02 11:17:08 UTC ---
Actually it's tail-merge.  Thus, -fno-tree-tail-merge fixes it as well.  We
enter update-ssa with

  <bb 9>:
  # .MEM_62 = VDEF <.MEM_60>
  D.2632.m_col = 0;
  if (a_32(D) == 0)
    goto <bb 10>;
  else
    goto <bb 34>;
...

  <bb 10>:
  # VUSE <.MEM_62>
  __assert_fail (0);
...

  <bb 18>:
  # .MEM_69 = VDEF <.MEM_67>
  D.2632.m_col = 0;
  # .MEM_70 = VDEF <.MEM_69>
  D.2632.m_currentBlockRows = 1;
  if (a_39(D) == 0)
    goto <bb 10>;
  else
    goto <bb 38>;

thus the .MEM_64 use is not dominated by its definition.  That's an
expected result from running tail-merge and is supposed to be fixed
by inserting a PHI node in bb 10 - and it does that.

What's the case is that:

static inline void
maybe_replace_use (use_operand_p use_p)
{
  tree rdef = NULL_TREE;
  tree use = USE_FROM_PTR (use_p);
  tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);

  if (marked_for_renaming (sym))
    rdef = get_reaching_def (sym);
  else if (is_old_name (use))
    rdef = get_reaching_def (use);

  if (rdef && rdef != use)
    SET_USE (use_p, rdef);
}

"optimizes" the rdef == use case but the reaching definition now is

  <bb 8>:
  # .MEM_62 = PHI <.MEM_74(23), .MEM_70(15), .MEM_74(22)>
  # VUSE <.MEM_62>
  __assert_fail (0);

and the use operand still has the old value (full SSA rewrite doesn't
require us to substitute .MEM everywhere).  But it isn't in the immediate
use list because the name got just re-defined.

Patch:

Index: gcc/tree-into-ssa.c
===================================================================
--- gcc/tree-into-ssa.c (revision 191969)
+++ gcc/tree-into-ssa.c (working copy)
@@ -1770,12 +1770,20 @@ maybe_replace_use (use_operand_p use_p)
   tree sym = DECL_P (use) ? use : SSA_NAME_VAR (use);

   if (marked_for_renaming (sym))
-    rdef = get_reaching_def (sym);
+    {
+      rdef = get_reaching_def (sym);
+      /* The operand slot may still contain an SSA name but it will
+         be not in the immediate use list as all SSA names were
+        re-defined.  Do not shortcut the rdef == use case.  */
+      if (rdef)
+       SET_USE (use_p, rdef);
+    }
   else if (is_old_name (use))
-    rdef = get_reaching_def (use);
-
-  if (rdef && rdef != use)
-    SET_USE (use_p, rdef);
+    {
+      rdef = get_reaching_def (use);
+      if (rdef && rdef != use)
+       SET_USE (use_p, rdef);
+    }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]