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]

[tuples] change walk_gimple_stmt interface


Hi folks!

In a few places we need to modify the entire statement while walking it.
In the original walk_tree interface we would pass the address of the
tree.  For gimple, Diego had suggested passing a gimple_stmt_iterator
instead and using gsi_replace() when necessary.  The patch below
accomplishes this.

While hacking this I found a few places where we iterate SSA operands
with FOR_EACH_*USE* where we don't have a GSI, or a pointer.  Since all
these places were interested in the operands, not the statement, I have
abstracted a function to walk tree operands out of a statement
(walk_gimple_op).  This behaves just like walk_tree, but for the
operands in a tuple.

Tested on x86-64 with no regressions.

p.s. Diego, I have also documented walk_gimple_op in the API document.

	* cgraphbuild.c (build_cgraph_edges): Use walk_gimple_op instead of
	walk_gimple_stmt.
	* tree-ssa-alias-warnings.c (find_references_in_function): Same.
	* tree-ssa-ccp.c (fold_stmt): Change walk_gimple_stmt call to
	walk_gimple_op.
	* tree-nrv.c (tree_nrv): Same.
	* tree-ssa-alias.c (count_uses_and_derefs): Same.
	* cfgexpand.c (discover_nonconstant_array_refs_r): Same.
	* tree-nested.c (convert_nonlocal_reference_stmt): Make first
	argument a GSI.
	(convert_local_reference_op): Same.
	(convert_nl_goto_reference): Same.
	(convert_tramp_reference_stmt): Same.
	(convert_gimple_call): Same.
	* tree-inline.c (inline_forbidden_p_stmt): Same.
	* tree-ssa.c (execute_early_warn_uninitialized): Change
	walk_gimple_stmt call to walk_gimple_op.
	* gimple.c (walk_gimple_seq): Pass GSI to walk_gimple_stmt.
	(walk_gimple_stmt): Move operand walking code to...
	(walk_gimple_op): ...here.
	(walk_gimple_stmt): First argument is now a GSI.
	* gimple.h: Change walk_stmt_fn argument to a GSI.
	(walk_gimple_stmt): Make first argument is a GSI.
	(walk_gimple_op): New prototype.
	* tree-cfg.c (verify_stmt): Change argument to a GSI.  Adjust
	accordingly.

Index: cgraphbuild.c
===================================================================
--- cgraphbuild.c	(revision 132745)
+++ cgraphbuild.c	(working copy)
@@ -153,7 +153,7 @@ build_cgraph_edges (void)
 	    memset (&wi, 0, sizeof (wi));
 	    wi.info = node;
 	    wi.pset = visited_nodes;
-	    walk_gimple_stmt (stmt, NULL, record_reference, &wi);
+	    walk_gimple_op (stmt, record_reference, &wi);
 	  }
       }
 
Index: tree-ssa-alias-warnings.c
===================================================================
--- tree-ssa-alias-warnings.c	(revision 132745)
+++ tree-ssa-alias-warnings.c	(working copy)
@@ -564,8 +564,7 @@ find_references_in_function (void)
 	struct walk_stmt_info wi;
 	memset (&wi, 0, sizeof (wi));
 	wi.info = (void *) gsi_stmt (i);
-	walk_gimple_stmt (gsi_stmt (i), NULL, find_references_in_tree_helper,
-	                  &wi);
+	walk_gimple_op (gsi_stmt (i), find_references_in_tree_helper, &wi);
       }
 }
 
Index: tree-ssa-ccp.c
===================================================================
--- tree-ssa-ccp.c	(revision 132745)
+++ tree-ssa-ccp.c	(working copy)
@@ -2853,7 +2853,7 @@ fold_stmt (gimple_stmt_iterator *gsi)
 
   /* Fold the individual operands.
      For example, fold instances of *&VAR into VAR, etc.  */
-  gcc_assert (!walk_gimple_stmt (stmt, NULL, fold_stmt_r, &wi));
+  gcc_assert (!walk_gimple_op (stmt, fold_stmt_r, &wi));
 
   /* Fold the main computation performed by the statement.  */
   switch (gimple_code (stmt))
@@ -2920,8 +2920,7 @@ fold_stmt_inplace (gimple stmt)
      signal that the entire statement should be replaced with
      a call to _builtin_trap.  This functionality is currently
      disabled, as noted in a FIXME, and cannot be supported here.  */
-
-  gcc_assert (!walk_gimple_stmt (stmt, NULL, fold_stmt_r, &wi));
+  walk_gimple_op (stmt, fold_stmt_r, &wi);
 
   /* Fold the main computation performed by the statement.  */
   switch (gimple_code (stmt))
Index: tree-nrv.c
===================================================================
--- tree-nrv.c	(revision 132745)
+++ tree-nrv.c	(working copy)
@@ -208,19 +208,18 @@ tree_nrv (void)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
 	{
-	  gimple *tp = gsi_stmt_ptr (&gsi);
+	  gimple stmt = gsi_stmt (gsi);
 	  /* If this is a copy from VAR to RESULT, remove it.  */
-	  if (gimple_assign_copy_p (*tp)
-	      && gimple_assign_lhs (*tp) == result
-	      && gimple_assign_rhs1 (*tp) == found)
+	  if (gimple_assign_copy_p (stmt)
+	      && gimple_assign_lhs (stmt) == result
+	      && gimple_assign_rhs1 (stmt) == found)
 	    gsi_remove (&gsi, true);
 	  else
 	    {
 	      struct walk_stmt_info wi;
 	      memset (&wi, 0, sizeof (wi));
 	      wi.info = &data;
-	      walk_gimple_stmt (*tp, NULL,
-				finalize_nrv_r, &wi);
+	      walk_gimple_op (stmt, finalize_nrv_r, &wi);
 	      gsi_next (&gsi);
 	    }
 	}
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c	(revision 132745)
+++ tree-ssa-alias.c	(working copy)
@@ -1949,7 +1949,7 @@ count_uses_and_derefs (tree ptr, gimple 
 
       memset (&wi, 0, sizeof (wi));
       wi.info = &count;
-      walk_gimple_stmt (stmt, NULL, count_ptr_derefs, &wi);
+      walk_gimple_op (stmt, count_ptr_derefs, &wi);
 
       *num_stores_p = count.num_stores;
       *num_loads_p = count.num_loads;
Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 132745)
+++ cfgexpand.c	(working copy)
@@ -2019,8 +2019,10 @@ discover_nonconstant_array_refs (void)
 
   FOR_EACH_BB (bb)
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      walk_gimple_stmt (gsi_stmt (gsi), NULL, discover_nonconstant_array_refs_r,
-                        NULL);
+      {
+	gimple stmt = gsi_stmt (gsi);
+	walk_gimple_op (stmt, discover_nonconstant_array_refs_r, NULL);
+      }
 }
 
 /* Translate the intermediate representation contained in the CFG
Index: tree-nested.c
===================================================================
--- tree-nested.c	(revision 132745)
+++ tree-nested.c	(working copy)
@@ -1089,12 +1089,13 @@ convert_nonlocal_omp_clauses (tree *pcla
    have been handled by this function.  */
 
 static bool
-convert_nonlocal_reference_stmt (gimple stmt, void *data)
+convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, void *data)
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
   struct nesting_info *info = wi->info;
   tree save_local_var_chain;
   bitmap save_suppress;
+  gimple stmt = gsi_stmt (*gsi);
 
   switch (gimple_code (stmt))
     {
@@ -1444,12 +1445,13 @@ convert_local_omp_clauses (tree *pclause
    The rewrite will be a structure reference to the local frame variable.  */
 
 static bool
-convert_local_reference_stmt (gimple stmt, void *data)
+convert_local_reference_stmt (gimple_stmt_iterator *gsi, void *data)
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
   struct nesting_info *info = wi->info;
   tree save_local_var_chain;
   bitmap save_suppress;
+  gimple stmt = gsi_stmt (*gsi);
 
   switch (gimple_code (stmt))
     {
@@ -1531,13 +1533,14 @@ convert_local_reference_stmt (gimple stm
    call to __builtin_nonlocal_goto.  */
 
 static bool
-convert_nl_goto_reference (gimple stmt, void *data)
+convert_nl_goto_reference (gimple_stmt_iterator *gsi, void *data)
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
   struct nesting_info *info = wi->info, *i;
   tree label, new_label, target_context, x, field;
   void **slot;
   gimple call;
+  gimple stmt = gsi_stmt (*gsi);
 
   if (gimple_code (stmt) != GIMPLE_GOTO)
     return false;
@@ -1703,9 +1706,10 @@ convert_tramp_reference_op (tree *tp, in
    generated for the occasion.  */
 
 static bool
-convert_tramp_reference_stmt (gimple stmt, void *data)
+convert_tramp_reference_stmt (gimple_stmt_iterator *gsi, void *data)
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
+  gimple stmt = gsi_stmt (*gsi);
 
   switch (gimple_code (stmt))
     {
@@ -1735,13 +1739,14 @@ convert_tramp_reference_stmt (gimple stm
    is set up properly for the call.  */
 
 static bool
-convert_gimple_call (gimple stmt, void *data)
+convert_gimple_call (gimple_stmt_iterator *gsi, void *data)
 {
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
   struct nesting_info *info = wi->info;
   tree decl, target_context;
   char save_static_chain_added;
   int i;
+  gimple stmt = gsi_stmt (*gsi);
 
   switch (gimple_code (stmt))
     {
Index: tree-ssa.c
===================================================================
--- tree-ssa.c	(revision 132745)
+++ tree-ssa.c	(working copy)
@@ -1515,8 +1515,7 @@ execute_early_warn_uninitialized (void)
 	struct walk_stmt_info wi;
 	memset (&wi, 0, sizeof (wi));
 	wi.info = context;
-	walk_gimple_stmt (gsi_stmt (gsi), NULL, warn_uninitialized_var,
-			  &wi);
+	walk_gimple_op (gsi_stmt (gsi), warn_uninitialized_var, &wi);
       }
   return 0;
 }
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 132745)
+++ tree-inline.c	(working copy)
@@ -1935,11 +1935,12 @@ inline_forbidden_p_op (tree *nodep, int 
    function can not be inlined. Also sets the reason why. */
 
 static bool
-inline_forbidden_p_stmt (gimple stmt, void *wip)
+inline_forbidden_p_stmt (gimple_stmt_iterator *gsi, void *wip)
 {
   struct walk_stmt_info wi = *(struct walk_stmt_info *) wip;
   tree fn = (tree) wi.info;
   tree t;
+  gimple stmt = gsi_stmt (*gsi);
 
   switch (gimple_code (stmt))
     {
Index: gimple.c
===================================================================
--- gimple.c	(revision 132745)
+++ gimple.c	(working copy)
@@ -1104,7 +1104,7 @@ walk_gimple_seq (gimple_seq seq, walk_st
       tree ret;
       if (wi)
 	wi->gsi = gsi;
-      ret = walk_gimple_stmt (gsi_stmt (gsi), callback_stmt, callback_op, wi);
+      ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi);
       if (ret)
 	return ret;
     }
@@ -1117,7 +1117,7 @@ walk_gimple_seq (gimple_seq seq, walk_st
 
 static tree
 walk_gimple_asm (gimple stmt, walk_tree_fn callback_op,
-		struct walk_stmt_info *wi)
+		 struct walk_stmt_info *wi)
 {
   tree ret;
   size_t noutputs;
@@ -1173,6 +1173,193 @@ walk_gimple_asm (gimple stmt, walk_tree_
 }
 
 
+/* Helper function of WALK_GIMPLE_STMT.  Walk every tree operand in
+   STMT.  CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
+
+   If the callback returns non-NULL for any operand, the remaining
+   operands are not scanned.  */
+inline tree
+walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
+		struct walk_stmt_info *wi)
+{
+  struct pointer_set_t *pset = (wi) ? wi->pset : NULL;
+  size_t i;
+  tree ret = NULL_TREE;
+
+  switch (gimple_code (stmt))
+    {
+    case GIMPLE_ASSIGN:
+      /* Walk the RHS operands.  A formal temporary LHS may use a
+	 COMPONENT_REF RHS.  */
+      if (wi)
+	wi->val_only = !is_gimple_formal_tmp_var (gimple_assign_lhs (stmt));
+
+      for (i = 1; i < gimple_num_ops (stmt); i++)
+	{
+	  ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
+			   pset);
+	  if (ret)
+	    return ret;
+	}
+
+      /* Walk the LHS.  If the RHS is appropriate for a memory, we
+	 may use a COMPONENT_REF on the LHS.  */
+      if (wi)
+	{
+	  wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt));
+	  wi->is_lhs = true;
+	}
+
+      ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
+      if (ret)
+	return ret;
+
+      if (wi)
+	{
+	  wi->val_only = true;
+	  wi->is_lhs = false;
+	}
+      break;
+
+    case GIMPLE_CALL:
+      if (wi)
+	wi->is_lhs = false;
+
+      for (i = 0; i < gimple_call_num_args (stmt); i++)
+	{
+	  ret = walk_tree (gimple_call_arg_ptr (stmt, i), callback_op, wi,
+			   pset);
+	  if (ret)
+	    return ret;
+	}
+
+      if (wi)
+	wi->is_lhs = true;
+
+      ret = walk_tree (gimple_call_lhs_ptr (stmt), callback_op, wi, pset);
+
+      if (ret)
+	return ret;
+
+      if (wi)
+	wi->is_lhs = false;
+      break;
+
+    case GIMPLE_CATCH:
+      ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_EH_FILTER:
+      ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_CHANGE_DYNAMIC_TYPE:
+      ret = walk_tree (gimple_cdt_location_ptr (stmt), callback_op, wi, pset);
+      if (ret)
+	return ret;
+
+      ret = walk_tree (gimple_cdt_new_type_ptr (stmt), callback_op, wi, pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_ASM:
+      ret = walk_gimple_asm (stmt, callback_op, wi);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_OMP_CRITICAL:
+      ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_OMP_FOR:
+      /* FIXME tuples */
+      /* This may need adjusting because of Jakub's code.  */
+      ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_for_index_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_for_initial_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_for_final_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_for_incr_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_OMP_PARALLEL:
+      ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op,
+		       wi, pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op,
+		       wi, pset);
+      if (ret)
+	return ret;
+      ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op,
+		       wi, pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_OMP_SECTIONS:
+      ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op,
+		       wi, pset);
+      if (ret)
+	return ret;
+      break;
+
+    case GIMPLE_OMP_SINGLE:
+      ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi,
+		       pset);
+      if (ret)
+	return ret;
+      break;
+
+      /* Tuples that do not have operands.  */
+    case GIMPLE_NOP:
+    case GIMPLE_RESX:
+    case GIMPLE_OMP_RETURN:
+      break;
+
+    default:
+      {
+	enum gimple_statement_structure_enum gss;
+	gss = gimple_statement_structure (stmt);
+	if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS)
+	  for (i = 0; i < gimple_num_ops (stmt); i++)
+	    {
+	      ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, pset);
+	      if (ret)
+		return ret;
+	    }
+      }
+      break;
+    }
+
+  return NULL_TREE;
+}
+
 
 /* Walk GIMPLE statement STMT (optionally using traversal state stored
    in WI).  If WI is NULL, no state is kept during traversal.
@@ -1194,13 +1381,11 @@ walk_gimple_asm (gimple stmt, walk_tree_
    NULL_TREE if no CALLBACK_OP is specified.  */
 
 tree
-walk_gimple_stmt (gimple stmt, walk_stmt_fn callback_stmt,
+walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
 		  walk_tree_fn callback_op, struct walk_stmt_info *wi)
 {
-  size_t i;
-  enum gimple_statement_structure_enum gss;
   tree ret;
-  struct pointer_set_t *pset = (wi) ? wi->pset : NULL;
+  gimple stmt = gsi_stmt (*gsi);
 
   if (wi && wi->want_locations && !gimple_locus_empty_p (stmt))
     input_location = gimple_locus (stmt);
@@ -1210,179 +1395,16 @@ walk_gimple_stmt (gimple stmt, walk_stmt
   /* Invoke the statement callback.  Return if the callback handled
      all of STMT operands by itself.  */
   if (callback_stmt)
-    if (callback_stmt (stmt, wi))
-      return ret;
+    {
+      if (callback_stmt (gsi, wi))
+        return ret;
+      /* Re-read stmt in case the callback changed it.  */
+      stmt = gsi_stmt (*gsi);
+    }
 
   /* If CALLBACK_OP is defined, invoke it on every operand of STMT.  */
   if (callback_op)
-    switch (gimple_code (stmt))
-      {
-      case GIMPLE_ASSIGN:
-	/* Walk the RHS operands.  A formal temporary LHS may use a
-	   COMPONENT_REF RHS.  */
-	if (wi)
-	  wi->val_only = !is_gimple_formal_tmp_var (gimple_assign_lhs (stmt));
-
-	for (i = 1; i < gimple_num_ops (stmt); i++)
-	  {
-	    ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
-			     pset);
-	    if (ret)
-	      return ret;
-	  }
-
-	/* Walk the LHS.  If the RHS is appropriate for a memory, we
-	   may use a COMPONENT_REF on the LHS.  */
-	if (wi)
-	  {
-	    wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt));
-	    wi->is_lhs = true;
-	  }
-
-	ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
-	if (ret)
-	  return ret;
-
-	if (wi)
-	  {
-	    wi->val_only = true;
-	    wi->is_lhs = false;
-	  }
-	break;
-
-      case GIMPLE_CALL:
-	if (wi)
-	  wi->is_lhs = false;
-
-	for (i = 0; i < gimple_call_num_args (stmt); i++)
-	  {
-	    ret = walk_tree (gimple_call_arg_ptr (stmt, i), callback_op, wi,
-			     pset);
-	    if (ret)
-	      return ret;
-	  }
-
-	if (wi)
-	  wi->is_lhs = true;
-
-	ret = walk_tree (gimple_call_lhs_ptr (stmt), callback_op, wi, pset);
-
-	if (ret)
-	  return ret;
-
-	if (wi)
-	  wi->is_lhs = false;
-	break;
-
-      case GIMPLE_CATCH:
-	ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_EH_FILTER:
-	ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi,
-	                 pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_CHANGE_DYNAMIC_TYPE:
-	ret = walk_tree (gimple_cdt_location_ptr (stmt), callback_op, wi, pset);
-	if (ret)
-	  return ret;
-
-	ret = walk_tree (gimple_cdt_new_type_ptr (stmt), callback_op, wi, pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_ASM:
-	ret = walk_gimple_asm (stmt, callback_op, wi);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_OMP_CRITICAL:
-	ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi,
-	                 pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_OMP_FOR:
-	/* FIXME tuples */
-	/* This may need adjusting because of Jakub's code.  */
-	ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_for_index_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_for_initial_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_for_final_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_for_incr_ptr (stmt), callback_op, wi,
-			 pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_OMP_PARALLEL:
-	ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op,
-	                 wi, pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op,
-	                 wi, pset);
-	if (ret)
-	  return ret;
-	ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op,
-	                 wi, pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_OMP_SECTIONS:
-	ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op,
-	                 wi, pset);
-	if (ret)
-	  return ret;
-	break;
-
-      case GIMPLE_OMP_SINGLE:
-	ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi,
-	                 pset);
-	if (ret)
-	  return ret;
-	break;
-
-	/* Tuples that do not have operands.  */
-      case GIMPLE_NOP:
-      case GIMPLE_RESX:
-      case GIMPLE_OMP_RETURN:
-	break;
-
-      default:
-	gss = gimple_statement_structure (stmt);
-	if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS)
-	  for (i = 0; i < gimple_num_ops (stmt); i++)
-	    {
-	      ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
-			       pset);
-	      if (ret)
-		return ret;
-	    }
-	break;
-      }
+    ret = walk_gimple_op (stmt, callback_op, wi);
 
   /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them.  */
   switch (gimple_code (stmt))
Index: gimple.h
===================================================================
--- gimple.h	(revision 132745)
+++ gimple.h	(working copy)
@@ -3020,7 +3020,7 @@ void gsi_commit_edge_inserts (void);
 
 /* Callback for walk_gimple_stmt.  Called for every statement found
    during traversal.  */
-typedef bool (*walk_stmt_fn) (gimple, void *);
+typedef bool (*walk_stmt_fn) (gimple_stmt_iterator *, void *);
 
 /* Convenience routines to walk all statements of a gimple function.
    Note that this is useful exclusively before the code is converted
@@ -3067,7 +3067,8 @@ struct walk_stmt_info
 
 tree walk_gimple_seq (gimple_seq, walk_stmt_fn, walk_tree_fn,
 		      struct walk_stmt_info *);
-tree walk_gimple_stmt (gimple, walk_stmt_fn, walk_tree_fn,
+tree walk_gimple_stmt (gimple_stmt_iterator *, walk_stmt_fn, walk_tree_fn,
 		       struct walk_stmt_info *);
+tree walk_gimple_op (gimple, walk_tree_fn, struct walk_stmt_info *);
 
 #endif  /* GCC_GIMPLE_H */
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 132745)
+++ tree-cfg.c	(working copy)
@@ -3808,10 +3808,12 @@ verify_types_in_gimple_seq (gimple_seq s
    TODO: Implement type checking.  */
 
 static bool
-verify_stmt (gimple stmt, bool last_in_block)
+verify_stmt (gimple_stmt_iterator *gsi)
 {
   tree addr;
   struct walk_stmt_info wi;
+  bool last_in_block = gsi_one_before_end_p (*gsi);
+  gimple stmt = gsi_stmt (*gsi);
 
   if (is_gimple_omp (stmt))
     {
@@ -3825,7 +3827,7 @@ verify_stmt (gimple stmt, bool last_in_b
     }
 
   memset (&wi, 0, sizeof (wi));
-  addr = walk_gimple_stmt (stmt, NULL, verify_expr, &wi);
+  addr = walk_gimple_stmt (gsi, NULL, verify_expr, &wi);
   if (addr)
     {
       debug_generic_expr (addr);
@@ -4022,9 +4024,8 @@ verify_stmts (void)
 	      err |= true;
 	    }
 
-	  gsi_next (&gsi);
-	  err |= verify_stmt (stmt, gsi_end_p (gsi));
-	  addr = walk_gimple_stmt (stmt, NULL, verify_node_sharing, &wi);
+	  err |= verify_stmt (&gsi);
+	  addr = walk_gimple_stmt (&gsi, NULL, verify_node_sharing, &wi);
 	  if (addr)
 	    {
 	      error ("incorrect sharing of tree nodes");
@@ -4032,6 +4033,7 @@ verify_stmts (void)
 	      debug_generic_expr (addr);
 	      err |= true;
 	    }
+	  gsi_next (&gsi);
 	}
     }
 


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