public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [vta, graphite?] propagate degenerate phi nodes into debug stmts
@ 2009-11-08  8:07 Alexandre Oliva
  2009-11-08  9:57 ` Richard Guenther
  0 siblings, 1 reply; 20+ messages in thread
From: Alexandre Oliva @ 2009-11-08  8:07 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

This patch arranges for PHI nodes to be propagated into debug stmts upon
release, if possible.  This improves debug info quality a bit, for
without this change we'd end up resetting the debug stmt.

It's not clear to me how this helped (if at all) graphite failures with
VTA, but it helped retain debug annotations that enabled me to validate
the fix for PR 41926 in a C testcase.  But that's something for another
patch.

Bootstrapped on x86_64-linux-gnu; regstrapping on that and
ia64-linux-gnu.  Ok to install?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vta-ssa-dom-prop-degenerate.patch --]
[-- Type: text/x-diff, Size: 3185 bytes --]

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree-ssa.c (find_released_ssa_name): Handle NULL wi.
	(insert_debug_temp_for_var_def): Handle degenerate PHI nodes.
	Fix handling of released SSA names.
	(insert_debug_temps_for_defs): Handle PHI nodes.

Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c.orig	2009-11-08 05:09:36.000000000 -0200
+++ gcc/tree-ssa.c	2009-11-08 05:34:12.000000000 -0200
@@ -279,7 +279,7 @@ find_released_ssa_name (tree *tp, int *w
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data_;
 
-  if (wi->is_lhs)
+  if (wi && wi->is_lhs)
     return NULL_TREE;
 
   if (TREE_CODE (*tp) == SSA_NAME)
@@ -346,11 +346,30 @@ insert_debug_temp_for_var_def (gimple_st
   /* If we didn't get an insertion point, and the stmt has already
      been removed, we won't be able to insert the debug bind stmt, so
      we'll have to drop debug information.  */
-  if (is_gimple_assign (def_stmt))
+  if (gimple_code (def_stmt) == GIMPLE_PHI || is_gimple_assign (def_stmt))
     {
       bool no_value = false;
 
-      if (!dom_info_available_p (CDI_DOMINATORS))
+      if (gimple_code (def_stmt) == GIMPLE_PHI)
+	{
+	  struct walk_stmt_info wi;
+	  size_t i;
+
+	  memset (&wi, 0, sizeof (wi));
+
+	  for (i = 0; i < gimple_phi_num_args (def_stmt); i++)
+	    {
+	      tree *argp = gimple_phi_arg_def_ptr (def_stmt, i);
+
+	      if (!*argp
+		  || walk_tree (argp, find_released_ssa_name, NULL, NULL))
+		{
+		  no_value = true;
+		  break;
+		}
+	    }
+	}
+      else if (!dom_info_available_p (CDI_DOMINATORS))
 	{
 	  struct walk_stmt_info wi;
 
@@ -383,13 +402,22 @@ insert_debug_temp_for_var_def (gimple_st
 	     dead SSA NAMEs.  SSA verification shall catch any
 	     errors.  */
 	  if ((!gsi && !gimple_bb (def_stmt))
-	      || !walk_gimple_op (def_stmt, find_released_ssa_name,
-				  &wi))
+	      || walk_gimple_op (def_stmt, find_released_ssa_name, &wi))
 	    no_value = true;
 	}
 
       if (!no_value)
-	value = gimple_assign_rhs_to_tree (def_stmt);
+	{
+	  if (gimple_code (def_stmt) == GIMPLE_PHI)
+	    /* ??? We could handle at least some non-generate PHI
+	       nodes by inserting debug temps on every edge.  It's
+	       not clear how much this would improve debug info.  */
+	    value = degenerate_phi_result (def_stmt);
+	  else if (is_gimple_assign (def_stmt))
+	    value = gimple_assign_rhs_to_tree (def_stmt);
+	  else
+	    gcc_unreachable ();
+	}
     }
 
   if (value)
@@ -409,6 +437,7 @@ insert_debug_temp_for_var_def (gimple_st
 	 at the expense of duplication of expressions.  */
 
       if (CONSTANT_CLASS_P (value)
+	  || gimple_code (def_stmt) == GIMPLE_PHI
 	  || (usecount == 1
 	      && (!gimple_assign_single_p (def_stmt)
 		  || is_gimple_min_invariant (value)))
@@ -479,6 +508,13 @@ insert_debug_temps_for_defs (gimple_stmt
 
   stmt = gsi_stmt (*gsi);
 
+  if (gimple_code (stmt) == GIMPLE_PHI)
+    {
+      tree var = gimple_phi_result (stmt);
+      insert_debug_temp_for_var_def (gsi, var);
+      return;
+    }
+
   FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, op_iter, SSA_OP_DEF)
     {
       tree var = DEF_FROM_PTR (def_p);

[-- Attachment #3: Type: text/plain, Size: 257 bytes --]


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-06-07 12:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-08  8:07 [vta, graphite?] propagate degenerate phi nodes into debug stmts Alexandre Oliva
2009-11-08  9:57 ` Richard Guenther
2009-11-16 20:35   ` Alexandre Oliva
2009-11-16 20:48   ` Alexandre Oliva
2009-11-17 15:47     ` Richard Guenther
2009-11-19  4:18       ` Alexandre Oliva
2009-11-19 10:56         ` Richard Guenther
2009-11-20  9:37           ` Alexandre Oliva
2009-11-20 10:47             ` Richard Guenther
2009-11-21  5:22               ` Alexandre Oliva
2011-06-03 14:38           ` Alexandre Oliva
2011-06-06  9:37             ` Richard Guenther
2011-06-07 10:38               ` Alexandre Oliva
2011-06-07 12:04                 ` Richard Guenther
2009-11-19  4:28       ` Alexandre Oliva
2009-11-19 10:59         ` Richard Guenther
2009-11-20  9:26           ` Alexandre Oliva
2009-12-05 16:04             ` H.J. Lu
2009-12-23  8:58               ` H.J. Lu
2010-01-29 17:02                 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).