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]

[PATCH 68/89] Concretize three gimple_return_ accessors


gcc/
	* gimple.h (gimple_return_retval_ptr): Require a const_gimple_return
	rather than a const_gimple.
	(gimple_return_retval): Likewise.
	(gimple_return_set_retval): Require a gimple_return.

	* cfgexpand.c (expand_gimple_stmt_1): Add a checked cast to
	gimple_return.
	(expand_gimple_basic_block): Likewise.
	* tree-complex.c (expand_complex_move): Likewise.
	(expand_complex_comparison): Likewise.
	* tree-inline.c (remap_gimple_stmt): Likewise.
	* tree-sra.c (scan_function): Likewise.
	(sra_modify_function_body): Likewise.
	(ipa_sra_modify_function_body): Likewise.
	* tree-ssa-structalias.c (find_func_aliases): Likewise.

	* gimple-walk.c (walk_stmt_load_store_addr_ops): Replace a check
	for code GIMPLE_RETURN with a dyn_cast and a new local.
	* gimple.c (infer_nonnull_range): Likewise.
	* ipa-split.c (find_return_bb): Likewise.
	(find_retval): Likewise.
	(split_function): Likewise.
	* omp-low.c (ipa_simd_modify_function_body): Likewise.
	* tree-cfg.c (execute_warn_function_return): Likewise.
	* tree-nrv.c (tree_nrv): Likewise.
	* tree-ssa-alias.c (ref_maybe_used_by_stmt_p): Likewise.
	* tree-ssa-dce.c (propagate_necessity): Likewise.
	* tree-ssa-structalias.c (find_func_clobbers): Likewise.
	* tree-tailcall.c (find_tail_calls): Likewise.

	* predict.c (apply_return_prediction): Rework the search for
	return_stmt so that the latter can have type gimple_return.
---
 gcc/cfgexpand.c            |  4 ++--
 gcc/gimple-walk.c          |  4 ++--
 gcc/gimple.c               | 14 +++++++-------
 gcc/gimple.h               |  9 +++------
 gcc/ipa-split.c            | 13 +++++++------
 gcc/omp-low.c              |  4 ++--
 gcc/predict.c              | 13 ++++++++-----
 gcc/tree-cfg.c             |  5 +++--
 gcc/tree-complex.c         |  9 ++++++---
 gcc/tree-inline.c          |  2 +-
 gcc/tree-nrv.c             |  4 ++--
 gcc/tree-sra.c             |  6 +++---
 gcc/tree-ssa-alias.c       |  4 ++--
 gcc/tree-ssa-dce.c         |  4 ++--
 gcc/tree-ssa-structalias.c | 12 +++++++-----
 gcc/tree-tailcall.c        |  2 +-
 16 files changed, 58 insertions(+), 51 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index ed4f037..4768a69 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3158,7 +3158,7 @@ expand_gimple_stmt_1 (gimple stmt)
       break;
 
     case GIMPLE_RETURN:
-      op0 = gimple_return_retval (stmt);
+      op0 = gimple_return_retval (stmt->as_a_gimple_return ());
 
       if (op0 && op0 != error_mark_node)
 	{
@@ -4858,7 +4858,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
   if (!gsi_end_p (gsi)
       && gimple_code (gsi_stmt (gsi)) == GIMPLE_RETURN)
     {
-      gimple ret_stmt = gsi_stmt (gsi);
+      gimple_return ret_stmt = gsi_stmt (gsi)->as_a_gimple_return ();
 
       gcc_assert (single_succ_p (bb));
       gcc_assert (single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun));
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index cdb5516..94a8b96 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -852,9 +852,9 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	      }
 	  }
     }
-  else if (gimple_code (stmt) == GIMPLE_RETURN)
+  else if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
     {
-      tree op = gimple_return_retval (stmt);
+      tree op = gimple_return_retval (return_stmt);
       if (op)
 	{
 	  if (visit_addr
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 01cdc33..69c639a 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2633,13 +2633,13 @@ infer_nonnull_range (gimple stmt, tree op, bool dereference, bool attribute)
 
   /* If this function is marked as returning non-null, then we can
      infer OP is non-null if it is used in the return statement.  */
-  if (attribute
-      && gimple_code (stmt) == GIMPLE_RETURN
-      && gimple_return_retval (stmt)
-      && operand_equal_p (gimple_return_retval (stmt), op, 0)
-      && lookup_attribute ("returns_nonnull",
-			   TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl))))
-    return true;
+  if (attribute)
+    if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
+      if (gimple_return_retval (return_stmt)
+	  && operand_equal_p (gimple_return_retval (return_stmt), op, 0)
+	  && lookup_attribute ("returns_nonnull",
+			       TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl))))
+	return true;
 
   return false;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index db3f425..15e09db 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -5791,18 +5791,16 @@ gimple_transaction_set_subcode (gimple_transaction transaction_stmt,
 /* Return a pointer to the return value for GIMPLE_RETURN GS.  */
 
 static inline tree *
-gimple_return_retval_ptr (const_gimple gs)
+gimple_return_retval_ptr (const_gimple_return gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_RETURN);
   return gimple_op_ptr (gs, 0);
 }
 
 /* Return the return value for GIMPLE_RETURN GS.  */
 
 static inline tree
-gimple_return_retval (const_gimple gs)
+gimple_return_retval (const_gimple_return gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_RETURN);
   return gimple_op (gs, 0);
 }
 
@@ -5810,9 +5808,8 @@ gimple_return_retval (const_gimple gs)
 /* Set RETVAL to be the return value for GIMPLE_RETURN GS.  */
 
 static inline void
-gimple_return_set_retval (gimple gs, tree retval)
+gimple_return_set_retval (gimple_return gs, tree retval)
 {
-  GIMPLE_CHECK (gs, GIMPLE_RETURN);
   gimple_set_op (gs, 0, retval);
 }
 
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 4e00e82..1287757 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -682,10 +682,10 @@ find_return_bb (void)
 		   || is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))
 	       && retval == gimple_assign_lhs (stmt))
 	;
-      else if (gimple_code (stmt) == GIMPLE_RETURN)
+      else if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
 	{
 	  found_return = true;
-	  retval = gimple_return_retval (stmt);
+	  retval = gimple_return_retval (return_stmt);
 	}
       else
 	break;
@@ -703,8 +703,8 @@ find_retval (basic_block return_bb)
 {
   gimple_stmt_iterator bsi;
   for (bsi = gsi_start_bb (return_bb); !gsi_end_p (bsi); gsi_next (&bsi))
-    if (gimple_code (gsi_stmt (bsi)) == GIMPLE_RETURN)
-      return gimple_return_retval (gsi_stmt (bsi));
+    if (gimple_return return_stmt = gsi_stmt (bsi)->dyn_cast_gimple_return ())
+      return gimple_return_retval (return_stmt);
     else if (gimple_code (gsi_stmt (bsi)) == GIMPLE_ASSIGN
 	     && !gimple_clobber_p (gsi_stmt (bsi)))
       return gimple_assign_rhs1 (gsi_stmt (bsi));
@@ -1421,9 +1421,10 @@ split_function (struct split_point *split_point)
 		      gimple_stmt_iterator bsi;
 		      for (bsi = gsi_start_bb (return_bb); !gsi_end_p (bsi);
 			   gsi_next (&bsi))
-			if (gimple_code (gsi_stmt (bsi)) == GIMPLE_RETURN)
+			if (gimple_return return_stmt =
+			    gsi_stmt (bsi)->dyn_cast_gimple_return ())
 			  {
-			    gimple_return_set_retval (gsi_stmt (bsi), retval);
+			    gimple_return_set_retval (return_stmt, retval);
 			    break;
 			  }
 			else if (gimple_code (gsi_stmt (bsi)) == GIMPLE_ASSIGN
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 79f725c..fd3a545 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11437,9 +11437,9 @@ ipa_simd_modify_function_body (struct cgraph_node *node,
 	  wi.info = &info;
 	  walk_gimple_op (stmt, ipa_simd_modify_stmt_ops, &wi);
 
-	  if (gimple_code (stmt) == GIMPLE_RETURN)
+	  if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
 	    {
-	      tree retval = gimple_return_retval (stmt);
+	      tree retval = gimple_return_retval (return_stmt);
 	      if (!retval)
 		{
 		  gsi_remove (&gsi, true);
diff --git a/gcc/predict.c b/gcc/predict.c
index b15de97..7fa31d8 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2217,7 +2217,7 @@ return_prediction (tree val, enum prediction *prediction)
 static void
 apply_return_prediction (void)
 {
-  gimple return_stmt = NULL;
+  gimple_return return_stmt = NULL;
   tree return_val;
   edge e;
   gimple_phi phi;
@@ -2228,10 +2228,13 @@ apply_return_prediction (void)
 
   FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
     {
-      return_stmt = last_stmt (e->src);
-      if (return_stmt
-	  && gimple_code (return_stmt) == GIMPLE_RETURN)
-	break;
+      gimple last = last_stmt (e->src);
+      if (last
+	  && gimple_code (last) == GIMPLE_RETURN)
+	{
+	  return_stmt = last->as_a_gimple_return ();
+	  break;
+	}
     }
   if (!e)
     return;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 2a54b71..caa11c1 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -8221,8 +8221,9 @@ execute_warn_function_return (void)
       FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
 	{
 	  gimple last = last_stmt (e->src);
-	  if (gimple_code (last) == GIMPLE_RETURN
-	      && gimple_return_retval (last) == NULL
+	  gimple_return return_stmt = last->dyn_cast_gimple_return ();
+	  if (return_stmt
+	      && gimple_return_retval (return_stmt) == NULL
 	      && !gimple_no_warning_p (last))
 	    {
 	      location = gimple_location (last);
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 166eb1b..fb2db1a 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -853,7 +853,7 @@ expand_complex_move (gimple_stmt_iterator *gsi, tree type)
 
 	  stmt = gsi_stmt (*gsi);
 	  gcc_assert (gimple_code (stmt) == GIMPLE_RETURN);
-	  gimple_return_set_retval (stmt, lhs);
+	  gimple_return_set_retval (stmt->as_a_gimple_return (), lhs);
 	}
 
       update_stmt (stmt);
@@ -1392,8 +1392,11 @@ expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
   switch (gimple_code (stmt))
     {
     case GIMPLE_RETURN:
-      type = TREE_TYPE (gimple_return_retval (stmt));
-      gimple_return_set_retval (stmt, fold_convert (type, cc));
+      {
+	gimple_return return_stmt = stmt->as_a_gimple_return ();
+	type = TREE_TYPE (gimple_return_retval (return_stmt));
+	gimple_return_set_retval (return_stmt, fold_convert (type, cc));
+      }
       break;
 
     case GIMPLE_ASSIGN:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 2f675d2..274b073 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1260,7 +1260,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
      statement.  */
   if (gimple_code (stmt) == GIMPLE_RETURN && id->transform_return_to_modify)
     {
-      tree retval = gimple_return_retval (stmt);
+      tree retval = gimple_return_retval (stmt->as_a_gimple_return ());
 
       /* If we're returning something, just turn that into an
 	 assignment into the equivalent of the original RESULT_DECL.
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 5a5a5d8..085e5d3 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -151,12 +151,12 @@ tree_nrv (void)
 	  gimple stmt = gsi_stmt (gsi);
 	  tree ret_val;
 
-	  if (gimple_code (stmt) == GIMPLE_RETURN)
+	  if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
 	    {
 	      /* In a function with an aggregate return value, the
 		 gimplifier has changed all non-empty RETURN_EXPRs to
 		 return the RESULT_DECL.  */
-	      ret_val = gimple_return_retval (stmt);
+	      ret_val = gimple_return_retval (return_stmt);
 	      if (ret_val)
 		gcc_assert (ret_val == result);
 	    }
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index e6e0629..223909e 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1279,7 +1279,7 @@ scan_function (void)
 	  switch (gimple_code (stmt))
 	    {
 	    case GIMPLE_RETURN:
-	      t = gimple_return_retval (stmt);
+	      t = gimple_return_retval (stmt->as_a_gimple_return ());
 	      if (t != NULL_TREE)
 		ret |= build_access_from_expr (t, stmt, false);
 	      if (final_bbs)
@@ -3347,7 +3347,7 @@ sra_modify_function_body (void)
 	  switch (gimple_code (stmt))
 	    {
 	    case GIMPLE_RETURN:
-	      t = gimple_return_retval_ptr (stmt);
+	      t = gimple_return_retval_ptr (stmt->as_a_gimple_return ());
 	      if (*t != NULL_TREE)
 		modified |= sra_modify_expr (t, &gsi, false);
 	      break;
@@ -4615,7 +4615,7 @@ ipa_sra_modify_function_body (ipa_parm_adjustment_vec adjustments)
 	  switch (gimple_code (stmt))
 	    {
 	    case GIMPLE_RETURN:
-	      t = gimple_return_retval_ptr (stmt);
+	      t = gimple_return_retval_ptr (stmt->as_a_gimple_return ());
 	      if (*t != NULL_TREE)
 		modified |= ipa_modify_expr (t, true, adjustments);
 	      break;
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3fd2789..1555bfe 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1678,9 +1678,9 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
     }
   else if (is_gimple_call (stmt))
     return ref_maybe_used_by_call_p (stmt->as_a_gimple_call (), ref);
-  else if (gimple_code (stmt) == GIMPLE_RETURN)
+  else if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
     {
-      tree retval = gimple_return_retval (stmt);
+      tree retval = gimple_return_retval (return_stmt);
       tree base;
       if (retval
 	  && TREE_CODE (retval) != SSA_NAME
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 2953a1b..907db1a 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -864,9 +864,9 @@ propagate_necessity (bool aggressive)
 		    mark_all_reaching_defs_necessary (stmt);
 		}
 	    }
-	  else if (gimple_code (stmt) == GIMPLE_RETURN)
+	  else if (gimple_return return_stmt = stmt->dyn_cast_gimple_return ())
 	    {
-	      tree rhs = gimple_return_retval (stmt);
+	      tree rhs = gimple_return_retval (return_stmt);
 	      /* A return statement may perform a load.  */
 	      if (rhs
 		  && TREE_CODE (rhs) != SSA_NAME
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 72b20f2..fa77c30 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -4752,12 +4752,13 @@ find_func_aliases (gimple origt)
     }
   /* Handle escapes through return.  */
   else if (gimple_code (t) == GIMPLE_RETURN
-	   && gimple_return_retval (t) != NULL_TREE)
+	   && gimple_return_retval (t->as_a_gimple_return ()) != NULL_TREE)
     {
+      gimple_return return_stmt = t->as_a_gimple_return ();
       fi = NULL;
       if (!in_ipa_mode
 	  || !(fi = get_vi_for_tree (cfun->decl)))
-	make_escape_constraint (gimple_return_retval (t));
+	make_escape_constraint (gimple_return_retval (return_stmt));
       else if (in_ipa_mode
 	       && fi != NULL)
 	{
@@ -4766,7 +4767,7 @@ find_func_aliases (gimple origt)
 	  unsigned i;
 
 	  lhs = get_function_part_constraint (fi, fi_result);
-	  get_constraint_for_rhs (gimple_return_retval (t), &rhsc);
+	  get_constraint_for_rhs (gimple_return_retval (return_stmt), &rhsc);
 	  FOR_EACH_VEC_ELT (rhsc, i, rhsp)
 	    process_constraint (new_constraint (lhs, *rhsp));
 	}
@@ -4910,10 +4911,11 @@ find_func_clobbers (gimple origt)
   /* Account for uses in assigments and returns.  */
   if (gimple_assign_single_p (t)
       || (gimple_code (t) == GIMPLE_RETURN
-	  && gimple_return_retval (t) != NULL_TREE))
+	  && gimple_return_retval (t->as_a_gimple_return ()) != NULL_TREE))
     {
       tree rhs = (gimple_assign_single_p (t)
-		  ? gimple_assign_rhs1 (t) : gimple_return_retval (t));
+		  ? gimple_assign_rhs1 (t)
+		  : gimple_return_retval (t->as_a_gimple_return ()));
       tree tem = rhs;
       while (handled_component_p (tem))
 	tem = TREE_OPERAND (tem, 0);
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index a508511..d3f2504 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -576,7 +576,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
     }
 
   /* See if this is a tail call we can handle.  */
-  ret_var = gimple_return_retval (stmt);
+  ret_var = gimple_return_retval (stmt->as_a_gimple_return ());
 
   /* We may proceed if there either is no return value, or the return value
      is identical to the call's return.  */
-- 
1.8.5.3


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