This is the mail archive of the gcc-patches@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]

Re: VTA merge - ssa compare-debug


ssa-compare-debug (22K) - fix -fcompare-debug errors that showed up in
the presence of debug bind stmts

Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-ssa-forwprop.c	2009-06-05 05:07:56.000000000 -0300
@@ -926,6 +926,7 @@ forward_propagate_addr_expr (tree name, 
   gimple use_stmt;
   bool all = true;
   bool single_use_p = has_single_use (name);
+  bool debug = false;
 
   FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
     {
@@ -936,7 +937,10 @@ forward_propagate_addr_expr (tree name, 
 	 there is nothing we can do.  */
       if (gimple_code (use_stmt) != GIMPLE_ASSIGN)
 	{
-	  all = false;
+	  if (IS_DEBUG_STMT (use_stmt))
+	    debug = true;
+	  else
+	    all = false;
 	  continue;
 	}
 
@@ -978,6 +982,9 @@ forward_propagate_addr_expr (tree name, 
 	}
     }
 
+  if (all && debug)
+    adjust_debug_stmts_for_var_def_move (name, NULL, NULL);
+
   return all;
 }
 
Index: gcc/tree-dfa.c
===================================================================
--- gcc/tree-dfa.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-dfa.c	2009-06-05 05:07:56.000000000 -0300
@@ -88,7 +88,12 @@ find_referenced_vars (void)
   FOR_EACH_BB (bb)
     {
       for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
-	find_referenced_vars_in (gsi_stmt (si));
+	{
+	  gimple stmt = gsi_stmt (si);
+	  if (IS_DEBUG_STMT (stmt))
+	    continue;
+	  find_referenced_vars_in (gsi_stmt (si));
+	}
 
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
 	find_referenced_vars_in (gsi_stmt (si));
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-vect-loop.c	2009-06-05 05:07:56.000000000 -0300
@@ -1531,6 +1531,8 @@ vect_is_simple_reduction (loop_vec_info 
   FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
     {
       gimple use_stmt = USE_STMT (use_p);
+      if (IS_DEBUG_STMT (use_stmt))
+	continue;
       if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
 	  && vinfo_for_stmt (use_stmt)
 	  && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
@@ -1573,6 +1575,8 @@ vect_is_simple_reduction (loop_vec_info 
   FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
     {
       gimple use_stmt = USE_STMT (use_p);
+      if (IS_DEBUG_STMT (use_stmt))
+	continue;
       if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
 	  && vinfo_for_stmt (use_stmt)
 	  && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c.orig	2009-06-05 04:56:43.000000000 -0300
+++ gcc/tree-vrp.c	2009-06-05 05:03:03.000000000 -0300
@@ -4651,6 +4651,9 @@ find_assert_locations_1 (basic_block bb,
 
       stmt = gsi_stmt (si);
 
+      if (IS_DEBUG_STMT (stmt))
+	continue;
+
       /* See if we can derive an assertion for any of STMT's operands.  */
       FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_USE)
 	{
Index: gcc/tree-ssa-threadupdate.c
===================================================================
--- gcc/tree-ssa-threadupdate.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-threadupdate.c	2009-06-05 05:07:56.000000000 -0300
@@ -476,6 +476,7 @@ redirection_block_p (basic_block bb)
   gsi = gsi_start_bb (bb);
   while (!gsi_end_p (gsi)
          && (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL
+	     || IS_DEBUG_STMT (gsi_stmt (gsi))
              || gimple_nop_p (gsi_stmt (gsi))))
     gsi_next (&gsi);
   
Index: gcc/tree-ssa-loop-manip.c
===================================================================
--- gcc/tree-ssa-loop-manip.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-loop-manip.c	2009-06-05 05:07:56.000000000 -0300
@@ -278,6 +278,9 @@ find_uses_to_rename_stmt (gimple stmt, b
   tree var;
   basic_block bb = gimple_bb (stmt);
 
+  if (IS_DEBUG_STMT (stmt))
+    return;
+
   FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES)
     find_uses_to_rename_use (bb, var, use_blocks, need_phis);
 }
@@ -428,6 +431,9 @@ check_loop_closed_ssa_stmt (basic_block 
   ssa_op_iter iter;
   tree var;
 
+  if (IS_DEBUG_STMT (stmt))
+    return;
+
   FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES)
     check_loop_closed_ssa_use (bb, var);
 }
Index: gcc/tree-tailcall.c
===================================================================
--- gcc/tree-tailcall.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-tailcall.c	2009-06-05 05:07:56.000000000 -0300
@@ -395,7 +395,7 @@ find_tail_calls (basic_block bb, struct 
       stmt = gsi_stmt (gsi);
 
       /* Ignore labels.  */
-      if (gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_code (stmt) == GIMPLE_LABEL || IS_DEBUG_STMT (stmt))
 	continue;
 
       /* Check for a call.  */
@@ -501,6 +501,9 @@ find_tail_calls (basic_block bb, struct 
       if (gimple_code (stmt) == GIMPLE_RETURN)
 	break;
 
+      if (IS_DEBUG_STMT (stmt))
+	continue;
+
       if (gimple_code (stmt) != GIMPLE_ASSIGN)
 	return;
 
Index: gcc/tree-ssa-loop-ch.c
===================================================================
--- gcc/tree-ssa-loop-ch.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-loop-ch.c	2009-06-05 05:07:56.000000000 -0300
@@ -90,6 +90,9 @@ should_duplicate_loop_header_p (basic_bl
       if (gimple_code (last) == GIMPLE_LABEL)
 	continue;
 
+      if (IS_DEBUG_STMT (last))
+	continue;
+
       if (is_gimple_call (last))
 	return false;
 
Index: gcc/ipa-reference.c
===================================================================
--- gcc/ipa-reference.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/ipa-reference.c	2009-06-05 05:07:56.000000000 -0300
@@ -442,6 +442,9 @@ scan_stmt_for_static_refs (gimple_stmt_i
   gimple stmt = gsi_stmt (*gsip);
   ipa_reference_local_vars_info_t local = NULL;
 
+  if (IS_DEBUG_STMT (stmt))
+    return NULL;
+
   if (fn)
     local = get_reference_vars_info (fn)->local;
 
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-loop-ivopts.c	2009-06-05 05:07:56.000000000 -0300
@@ -1837,6 +1837,7 @@ find_interesting_uses (struct ivopts_dat
       for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	find_interesting_uses_stmt (data, gsi_stmt (bsi));
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	if (!IS_DEBUG_STMT (gsi_stmt (bsi)))
 	find_interesting_uses_stmt (data, gsi_stmt (bsi));
     }
 
@@ -5413,7 +5414,24 @@ remove_unused_ivs (struct ivopts_data *d
 	  && !info->inv_id
 	  && !info->iv->have_use_for
 	  && !info->preserve_biv)
-	remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true);
+	{
+	  if (MAY_HAVE_DEBUG_STMTS)
+	    {
+	      gimple stmt;
+	      imm_use_iterator iter;
+
+	      FOR_EACH_IMM_USE_STMT (stmt, iter, info->iv->ssa_name)
+		{
+		  if (!IS_DEBUG_BIND (stmt))
+		    continue;
+
+		  /* ??? We can probably do better than this.  */
+		  VAR_DEBUG_VALUE_VALUE (stmt) = VAR_DEBUG_VALUE_NOVALUE;
+		  update_stmt (stmt);
+		}
+	    }
+	  remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true);
+	}
     }
 }
 
Index: gcc/tree-stdarg.c
===================================================================
--- gcc/tree-stdarg.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-stdarg.c	2009-06-05 05:07:56.000000000 -0300
@@ -496,6 +496,9 @@ check_all_va_list_escapes (struct stdarg
 	  tree use;
 	  ssa_op_iter iter;
 
+	  if (IS_DEBUG_STMT (stmt))
+	    continue;
+
 	  FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_ALL_USES)
 	    {
 	      if (! bitmap_bit_p (si->va_list_escape_vars,
@@ -837,6 +840,8 @@ execute_optimize_stdarg (void)
 		    continue;
 		}
 	    }
+	  else if (IS_DEBUG_STMT (stmt))
+	    continue;
 
 	  /* All other uses of va_list are either va_copy (that is not handled
 	     in this optimization), taking address of va_list variable or
Index: gcc/tree-ssa-dom.c
===================================================================
--- gcc/tree-ssa-dom.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-dom.c	2009-06-05 05:07:56.000000000 -0300
@@ -2590,6 +2590,8 @@ propagate_rhs_into_lhs (gimple stmt, tre
 
 	      continue;
 	    }
+	  else if (IS_DEBUG_BIND (use_stmt))
+	    check_and_update_debug_stmt (use_stmt, NULL);
 
 	  /* From this point onward we are propagating into a 
 	     real statement.  Folding may (or may not) be possible,
Index: gcc/tree-ssa-propagate.c
===================================================================
--- gcc/tree-ssa-propagate.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-propagate.c	2009-06-05 05:07:56.000000000 -0300
@@ -1170,7 +1170,8 @@ substitute_and_fold (prop_value_t *prop_
 
 	      /* Determine what needs to be done to update the SSA form.  */
 	      update_stmt (stmt);
-	      something_changed = true;
+	      if (!IS_DEBUG_STMT (stmt))
+		something_changed = true;
 	    }
 
 	  if (dump_file && (dump_flags & TDF_DETAILS))
Index: gcc/tree-ssa-sink.c
===================================================================
--- gcc/tree-ssa-sink.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-sink.c	2009-06-05 05:07:56.000000000 -0300
@@ -120,6 +120,8 @@ all_immediate_uses_same_place (gimple st
     {
       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, var)
         {
+	  if (IS_DEBUG_STMT (USE_STMT (use_p)))
+	    continue;
 	  if (firstuse == NULL)
 	    firstuse = USE_STMT (use_p);
 	  else
@@ -202,7 +204,7 @@ is_hidden_global_store (gimple stmt)
 /* Find the nearest common dominator of all of the immediate uses in IMM.  */
 
 static basic_block
-nearest_common_dominator_of_uses (gimple stmt)
+nearest_common_dominator_of_uses (gimple stmt, bool *debug_stmts)
 {  
   bitmap blocks = BITMAP_ALLOC (NULL);
   basic_block commondom;
@@ -227,6 +229,11 @@ nearest_common_dominator_of_uses (gimple
 
 	      useblock = gimple_phi_arg_edge (usestmt, idx)->src;
 	    }
+	  else if (IS_DEBUG_STMT (usestmt))
+	    {
+	      *debug_stmts = true;
+	      continue;
+	    }
 	  else
 	    {
 	      useblock = gimple_bb (usestmt);
@@ -272,6 +279,9 @@ statement_sink_location (gimple stmt, ba
     {
       FOR_EACH_IMM_USE_FAST (one_use, imm_iter, def)
 	{
+	  if (IS_DEBUG_STMT (USE_STMT (one_use)))
+	    continue;
+
 	  break;
 	}
       if (one_use != NULL_USE_OPERAND_P)
@@ -343,7 +353,9 @@ statement_sink_location (gimple stmt, ba
      that is where insertion would have to take place.  */
   if (!all_immediate_uses_same_place (stmt))
     {
-      basic_block commondom = nearest_common_dominator_of_uses (stmt);
+      bool debug_stmts = false;
+      basic_block commondom = nearest_common_dominator_of_uses (stmt,
+								&debug_stmts);
      
       if (commondom == frombb)
 	return false;
@@ -372,7 +384,12 @@ statement_sink_location (gimple stmt, ba
 	  fprintf (dump_file, "Common dominator of all uses is %d\n",
 		   commondom->index);
 	}
+
       *togsi = gsi_after_labels (commondom);
+
+      if (debug_stmts)
+	adjust_debug_stmts_for_move (stmt, commondom, togsi);
+
       return true;
     }
 
@@ -385,6 +402,9 @@ statement_sink_location (gimple stmt, ba
 	return false;
 
       *togsi = gsi_for_stmt (use);
+
+      adjust_debug_stmts_for_move (stmt, sinkbb, togsi);
+
       return true;
     }
 
@@ -413,6 +433,8 @@ statement_sink_location (gimple stmt, ba
 
   *togsi = gsi_after_labels (sinkbb);
 
+  adjust_debug_stmts_for_move (stmt, sinkbb, togsi);
+
   return true;
 }
 
Index: gcc/tree-flow-inline.h
===================================================================
--- gcc/tree-flow-inline.h.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-flow-inline.h	2009-06-05 05:07:56.000000000 -0300
@@ -362,18 +362,48 @@ next_readonly_imm_use (imm_use_iterator 
 static inline bool
 has_zero_uses (const_tree var)
 {
-  const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
+  const ssa_use_operand_t *ptr, *start;
+  bool ret;
+
+  ptr = &(SSA_NAME_IMM_USE_NODE (var));
   /* A single use means there is no items in the list.  */
-  return (ptr == ptr->next);
+  ret = (ptr == ptr->next);
+
+  if (ret || !MAY_HAVE_DEBUG_STMTS)
+    return ret;
+
+  start = ptr;
+  for (ptr = start->next; ptr != start; ptr = ptr->next)
+    if (!IS_DEBUG_STMT (USE_STMT (ptr)))
+      return false;
+  return true;
 }
 
 /* Return true if VAR has a single use.  */
 static inline bool
 has_single_use (const_tree var)
 {
-  const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
+  const ssa_use_operand_t *ptr, *start;
+  bool ret;
+
+  ptr = &(SSA_NAME_IMM_USE_NODE (var));
   /* A single use means there is one item in the list.  */
-  return (ptr != ptr->next && ptr == ptr->next->next);
+  ret = (ptr != ptr->next && ptr == ptr->next->next);
+
+  if (ret)
+    return !IS_DEBUG_STMT (USE_STMT (ptr->next));
+  else if (!MAY_HAVE_DEBUG_STMTS)
+    return ret;
+
+  start = ptr;
+  for (ptr = start->next; ptr != start; ptr = ptr->next)
+    if (!IS_DEBUG_STMT (USE_STMT (ptr)))
+      {
+	if (ret)
+	  return false;
+	ret = true;
+      }
+  return ret;
 }
 
 
@@ -382,8 +412,35 @@ has_single_use (const_tree var)
 static inline bool
 single_imm_use (const_tree var, use_operand_p *use_p, gimple *stmt)
 {
-  const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
-  if (ptr != ptr->next && ptr == ptr->next->next)
+  const ssa_use_operand_t *ptr;
+  bool ret;
+
+  ptr = &(SSA_NAME_IMM_USE_NODE (var));
+
+  ret = ptr != ptr->next && ptr == ptr->next->next;
+
+  if (ret)
+    ret = !IS_DEBUG_STMT (USE_STMT (ptr->next));
+  else if (MAY_HAVE_DEBUG_STMTS)
+    {
+      const ssa_use_operand_t *start = ptr, *prev = ptr, *single_use_prev = 0;
+
+      for (ptr = start->next; ptr != start; prev = ptr, ptr = ptr->next)
+	if (!IS_DEBUG_STMT (USE_STMT (ptr)))
+	  {
+	    if (ret)
+	      {
+		ret = false;
+		break;
+	      }
+	    ret = true;
+	    single_use_prev = prev;
+	  }
+
+      ptr = single_use_prev;
+    }
+
+  if (ret)
     {
       *use_p = ptr->next;
       *stmt = ptr->next->loc.stmt;
@@ -402,8 +459,13 @@ num_imm_uses (const_tree var)
   const ssa_use_operand_t *ptr;
   unsigned int num = 0;
 
-  for (ptr = start->next; ptr != start; ptr = ptr->next)
-     num++;
+  if (!MAY_HAVE_DEBUG_STMTS)
+    for (ptr = start->next; ptr != start; ptr = ptr->next)
+      num++;
+  else
+    for (ptr = start->next; ptr != start; ptr = ptr->next)
+      if (!IS_DEBUG_STMT (USE_STMT (ptr)))
+	num++;
 
   return num;
 }
Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-phiopt.c	2009-06-05 05:07:56.000000000 -0300
@@ -384,7 +384,12 @@ bool
 empty_block_p (basic_block bb)
 {
   /* BB must have no executable statements.  */
-  return gsi_end_p (gsi_after_labels (bb));
+  gimple_stmt_iterator gsi = gsi_after_labels (bb);
+  if (gsi_end_p (gsi))
+    return true;
+  if (IS_DEBUG_STMT (gsi_stmt (gsi)))
+    gsi_next_nondebug (&gsi);
+  return gsi_end_p (gsi);
 }
 
 /* Replace PHI node element whose edge is E in block BB with variable NEW.
Index: gcc/tree-ssa-coalesce.c
===================================================================
--- gcc/tree-ssa-coalesce.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-coalesce.c	2009-06-05 05:07:56.000000000 -0300
@@ -884,6 +884,8 @@ build_ssa_conflict_graph (tree_live_info
                   && TREE_CODE (rhs1) == SSA_NAME)
 		live_track_clear_var (live, rhs1);
 	    }
+	  else if (IS_DEBUG_STMT (stmt))
+	    continue;
 
 	  FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_DEF)
 	    live_track_process_def (live, var, graph);
@@ -1048,6 +1050,9 @@ create_outofssa_var_map (coalesce_list_p
         {
 	  stmt = gsi_stmt (gsi);
 
+	  if (IS_DEBUG_STMT (stmt))
+	    continue;
+
 	  /* Register USE and DEF operands in each statement.  */
 	  FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE))
 	    register_ssa_partition (map, var);
Index: gcc/tree-ssa-live.c
===================================================================
--- gcc/tree-ssa-live.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-ssa-live.c	2009-06-05 05:07:56.000000000 -0300
@@ -676,6 +676,9 @@ remove_unused_locals (void)
 	  gimple stmt = gsi_stmt (gsi);
 	  tree b = gimple_block (stmt);
 
+	  if (IS_DEBUG_STMT (stmt))
+	    continue;
+
 	  if (b)
 	    TREE_USED (b) = true;
 
@@ -960,6 +963,8 @@ set_var_live_on_entry (tree ssa_name, tr
 		add_block = e->src;
 	    }
 	}
+      else if (IS_DEBUG_STMT (use_stmt))
+	continue;
       else
         {
 	  /* If its not defined in this block, its live on entry.  */
Index: gcc/tree-ssa-ter.c
===================================================================
--- gcc/tree-ssa-ter.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-ssa-ter.c	2009-06-05 05:07:56.000000000 -0300
@@ -585,6 +585,9 @@ find_replaceable_in_bb (temp_expr_table_
     {
       stmt = gsi_stmt (bsi);
 
+      if (IS_DEBUG_STMT (stmt))
+	continue;
+
       stmt_replaceable = is_replaceable_p (stmt);
 
       /* Determine if this stmt finishes an existing expression.  */
Index: gcc/tree-outof-ssa.c
===================================================================
--- gcc/tree-outof-ssa.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-outof-ssa.c	2009-06-05 05:07:56.000000000 -0300
@@ -1,5 +1,6 @@
 /* Convert a program in SSA form into Normal form.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    Contributed by Andrew Macleod <amacleod@redhat.com>
 
 This file is part of GCC.
@@ -110,6 +111,8 @@ set_location_for_edge (edge e)
 	  for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
 	    {
 	      gimple stmt = gsi_stmt (gsi);
+	      if (IS_DEBUG_STMT (stmt))
+		continue;
 	      if (gimple_has_location (stmt) || gimple_block (stmt))
 		{
 		  set_curr_insn_source_location (gimple_location (stmt));
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-cfg.c	2009-06-05 05:07:56.000000000 -0300
@@ -2802,7 +2802,14 @@ gimple
 first_stmt (basic_block bb)
 {
   gimple_stmt_iterator i = gsi_start_bb (bb);
-  return !gsi_end_p (i) ? gsi_stmt (i) : NULL;
+  gimple stmt = NULL;
+
+  while (!gsi_end_p (i) && IS_DEBUG_STMT ((stmt = gsi_stmt (i))))
+    {
+      gsi_next (&i);
+      stmt = NULL;
+    }
+  return stmt;
 }
 
 /* Return the first non-label statement in basic block BB.  */
@@ -2821,8 +2828,15 @@ first_non_label_stmt (basic_block bb)
 gimple
 last_stmt (basic_block bb)
 {
-  gimple_stmt_iterator b = gsi_last_bb (bb);
-  return !gsi_end_p (b) ? gsi_stmt (b) : NULL;
+  gimple_stmt_iterator i = gsi_last_bb (bb);
+  gimple stmt = NULL;
+
+  while (!gsi_end_p (i) && IS_DEBUG_STMT ((stmt = gsi_stmt (i))))
+    {
+      gsi_prev (&i);
+      stmt = NULL;
+    }
+  return stmt;
 }
 
 /* Return the last statement of an otherwise empty block.  Return NULL
@@ -2832,14 +2846,14 @@ last_stmt (basic_block bb)
 gimple
 last_and_only_stmt (basic_block bb)
 {
-  gimple_stmt_iterator i = gsi_last_bb (bb);
+  gimple_stmt_iterator i = gsi_last_nondebug_bb (bb);
   gimple last, prev;
 
   if (gsi_end_p (i))
     return NULL;
 
   last = gsi_stmt (i);
-  gsi_prev (&i);
+  gsi_prev_nondebug (&i);
   if (gsi_end_p (i))
     return last;
 
@@ -4103,6 +4117,17 @@ verify_gimple_phi (gimple stmt)
 }
 
 
+/* Verify a gimple debug statement STMT.
+   Returns true if anything is wrong.  */
+
+static bool
+verify_gimple_debug (gimple stmt ATTRIBUTE_UNUSED)
+{
+  /* ??? FIXME.  */
+  return false;
+}
+
+
 /* Verify the GIMPLE statement STMT.  Returns true if there is an
    error, otherwise false.  */
 
@@ -4157,6 +4182,9 @@ verify_types_in_gimple_stmt (gimple stmt
     case GIMPLE_PREDICT:
       return false;
 
+    case GIMPLE_DEBUG:
+      return verify_gimple_debug (stmt);
+
     default:
       gcc_unreachable ();
     }
@@ -4263,6 +4291,12 @@ verify_stmt (gimple_stmt_iterator *gsi)
 	}
     }
 
+  if (IS_DEBUG_STMT (stmt))
+    {
+      check_and_update_debug_stmt (stmt, NULL);
+      return false;
+    }
+
   memset (&wi, 0, sizeof (wi));
   addr = walk_gimple_op (gsi_stmt (*gsi), verify_expr, &wi);
   if (addr)
@@ -6609,7 +6643,7 @@ debug_loop_num (unsigned num, int verbos
 static bool
 gimple_block_ends_with_call_p (basic_block bb)
 {
-  gimple_stmt_iterator gsi = gsi_last_bb (bb);
+  gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb);
   return is_gimple_call (gsi_stmt (gsi));
 }
 
Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c.orig	2009-06-05 05:07:48.000000000 -0300
+++ gcc/tree-ssa-reassoc.c	2009-06-05 05:07:56.000000000 -0300
@@ -1405,6 +1405,7 @@ rewrite_expr_tree (gimple stmt, unsigned
 	    {
 	      stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt1));
 	      gsirhs1 = gsi_for_stmt (stmt2);
+	      adjust_debug_stmts_for_move (stmt2, gimple_bb (stmt), &gsinow);
 	      gsi_move_before (&gsirhs1, &gsinow);
 	      gsi_prev (&gsinow);
 	      stmt1 = stmt2;
@@ -1451,6 +1452,7 @@ linearize_expr (gimple stmt)
 
   gsinow = gsi_for_stmt (stmt);
   gsirhs = gsi_for_stmt (binrhs);
+  adjust_debug_stmts_for_move (binrhs, gimple_bb (stmt), &gsinow);
   gsi_move_before (&gsirhs, &gsinow);
 
   gimple_assign_set_rhs2 (stmt, gimple_assign_rhs1 (binrhs));
Index: gcc/tree-ssa-threadedge.c
===================================================================
--- gcc/tree-ssa-threadedge.c.orig	2009-06-05 05:07:49.000000000 -0300
+++ gcc/tree-ssa-threadedge.c	2009-06-05 05:07:56.000000000 -0300
@@ -309,7 +309,9 @@ record_temporary_equivalences_from_stmts
       stmt = gsi_stmt (gsi);
 
       /* Ignore empty statements and labels.  */
-      if (gimple_code (stmt) == GIMPLE_NOP || gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_code (stmt) == GIMPLE_NOP
+	  || gimple_code (stmt) == GIMPLE_LABEL
+	  || IS_DEBUG_STMT (stmt))
 	continue;
 
       /* If the statement has volatile operands, then we assume we
-- 
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

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