public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gimple-classes, committed 0/3] More accessor typesafety
@ 2014-10-29 14:06 David Malcolm
  2014-10-29 14:07 ` [gimple-classes, committed 1/3] Strengthen params of all gimple_wce_ accessors David Malcolm
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Malcolm @ 2014-10-29 14:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

I've pushed the following three patches to the git branch
"dmalcolm/gimple-classes".

Successfully bootstrapped&regrtested the combination of the three
patches on x86_64-unknown-linux-gnu (Fedora 20) - same results
relative to an unpatched control bootstrap of trunk's r216746.

David Malcolm (3):
  Strengthen params of all gimple_wce_ accessors
  Make gimple_goto_dest require a const ggoto *
  Strengthen remaining gimple_try_ accessors to require a gtry *

 gcc/ChangeLog.gimple-classes | 106 +++++++++++++++++++++++++++++++++++++++++++
 gcc/cfgexpand.c              |   2 +-
 gcc/doc/gimple.texi          |   2 +-
 gcc/gimple-low.c             |  78 ++++++++++++++++---------------
 gcc/gimple-walk.c            |  28 +++++++-----
 gcc/gimple.c                 |   8 ++--
 gcc/gimple.h                 |  47 ++++++++-----------
 gcc/gimplify.c               |   6 +--
 gcc/gsstruct.def             |   2 +-
 gcc/ipa-icf-gimple.c         |   7 +--
 gcc/ipa-icf-gimple.h         |   4 +-
 gcc/omp-low.c                |   9 ++--
 gcc/tree-cfg.c               |  30 ++++++++----
 gcc/tree-cfgcleanup.c        |   9 ++--
 gcc/tree-eh.c                |  82 +++++++++++++++++++--------------
 gcc/tree-inline.c            |  22 ++++++---
 gcc/tree-nested.c            |   4 +-
 gcc/tree-ssa-dom.c           |  12 ++---
 gcc/tree-ssa-sccvn.c         |   2 +-
 gcc/tree-ssa-threadedge.c    |   2 +-
 gcc/tree-ssa-threadupdate.c  |   2 +-
 21 files changed, 305 insertions(+), 159 deletions(-)

-- 
1.7.11.7

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

* [gimple-classes, committed 1/3] Strengthen params of all gimple_wce_ accessors
  2014-10-29 14:06 [gimple-classes, committed 0/3] More accessor typesafety David Malcolm
@ 2014-10-29 14:07 ` David Malcolm
  2014-10-29 14:15 ` [gimple-classes, committed 3/3] Strengthen remaining gimple_try_ accessors to require a gtry * David Malcolm
  2014-10-29 15:01 ` [gimple-classes, committed 2/3] Make gimple_goto_dest require a const ggoto * David Malcolm
  2 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2014-10-29 14:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Update
	for renaming of gimple_statement_wce to gwce.
	* gimple-walk.c (walk_gimple_stmt): Add checked cast to gwce *
	within case GIMPLE_WITH_CLEANUP_EXPR.
	* gimple.c (gimple_build_wce): Strengthen return type and local
	"p" from gimple to gwce *.
	(gimple_copy): Add checked casts to gwce * within case
	GIMPLE_WITH_CLEANUP_EXPR.
	* gimple.h (struct gimple_statement_wce): Rename to...
	(struct gwce): ...this.
	(is_a_helper <gimple_statement_wce *>::test): Rename to...
	(is_a_helper <gwce *>::test): ...this.
	(gimple_build_wce): Strengthen return type from gimple to gwce *.
	(gimple_wce_cleanup_ptr): Strengthen param from gimple to gwce *.
	(gimple_wce_cleanup): Likewise.
	(gimple_wce_set_cleanup): Likewise.
	(gimple_wce_cleanup_eh_only): Strengthen param from const_gimple
	to const gwce *.
	(gimple_wce_set_cleanup_eh_only): Strengthen param from gimple to
	gwce *.
	* gimplify.c (gimplify_cleanup_point_expr): Replace check against
	GIMPLE_WITH_CLEANUP_EXPR with a dyn_cast <gwce *>, strengthening
	local "wce" from gimple to gwce *.
	(gimple_push_cleanup): Strengthen local "wce" from gimple to
	gwce *.
	* gsstruct.def (GSS_WCE): Update for renaming of
	gimple_statement_wce to gwce.
	* tree-inline.c (remap_gimple_stmt): Add checked cast to gwce *
	within case GIMPLE_WITH_CLEANUP_EXPR.
---
 gcc/ChangeLog.gimple-classes | 32 ++++++++++++++++++++++++++++++++
 gcc/doc/gimple.texi          |  2 +-
 gcc/gimple-walk.c            |  5 +++--
 gcc/gimple.c                 |  8 ++++----
 gcc/gimple.h                 | 25 +++++++++++--------------
 gcc/gimplify.c               |  6 +++---
 gcc/gsstruct.def             |  2 +-
 gcc/tree-inline.c            |  3 ++-
 8 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 133965c..b7a62de 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,37 @@
 2014-10-28  David Malcolm  <dmalcolm@redhat.com>
 
+	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Update
+	for renaming of gimple_statement_wce to gwce.
+	* gimple-walk.c (walk_gimple_stmt): Add checked cast to gwce *
+	within case GIMPLE_WITH_CLEANUP_EXPR.
+	* gimple.c (gimple_build_wce): Strengthen return type and local
+	"p" from gimple to gwce *.
+	(gimple_copy): Add checked casts to gwce * within case
+	GIMPLE_WITH_CLEANUP_EXPR.
+	* gimple.h (struct gimple_statement_wce): Rename to...
+	(struct gwce): ...this.
+	(is_a_helper <gimple_statement_wce *>::test): Rename to...
+	(is_a_helper <gwce *>::test): ...this.
+	(gimple_build_wce): Strengthen return type from gimple to gwce *.
+	(gimple_wce_cleanup_ptr): Strengthen param from gimple to gwce *.
+	(gimple_wce_cleanup): Likewise.
+	(gimple_wce_set_cleanup): Likewise.
+	(gimple_wce_cleanup_eh_only): Strengthen param from const_gimple
+	to const gwce *.
+	(gimple_wce_set_cleanup_eh_only): Strengthen param from gimple to
+	gwce *.
+	* gimplify.c (gimplify_cleanup_point_expr): Replace check against
+	GIMPLE_WITH_CLEANUP_EXPR with a dyn_cast <gwce *>, strengthening
+	local "wce" from gimple to gwce *.
+	(gimple_push_cleanup): Strengthen local "wce" from gimple to
+	gwce *.
+	* gsstruct.def (GSS_WCE): Update for renaming of
+	gimple_statement_wce to gwce.
+	* tree-inline.c (remap_gimple_stmt): Add checked cast to gwce *
+	within case GIMPLE_WITH_CLEANUP_EXPR.
+
+2014-10-28  David Malcolm  <dmalcolm@redhat.com>
+
 	* auto-profile.c (autofdo::function_instance::find_icall_target_map):
 	Strengthen param "stmt" from gimple to gcall *.
 	(autofdo::autofdo_source_profile::update_inlined_ind_target):
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 621c860..de7345e 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -414,7 +414,7 @@ kinds, along with their relationships to @code{GSS_} values (layouts) and
      + gtry
      |        layout: GSS_TRY, code: GIMPLE_TRY
      |
-     + gimple_statement_wce
+     + gwce
      |        layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR
      |
      + gomp_continue
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index a6ea1ec..002308c 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -635,8 +635,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_WITH_CLEANUP_EXPR:
-      ret = walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt), callback_stmt,
-			     callback_op, wi);
+      ret = walk_gimple_seq_mod (gimple_wce_cleanup_ptr (as_a <gwce *> (stmt)),
+				 callback_stmt,
+				 callback_op, wi);
       if (ret)
 	return wi->callback_result;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 061a7a1..c6d0f7a 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -708,10 +708,10 @@ gimple_build_try (gimple_seq eval, gimple_seq cleanup,
 
    CLEANUP is the cleanup expression.  */
 
-gimple
+gwce *
 gimple_build_wce (gimple_seq cleanup)
 {
-  gimple p = gimple_alloc (GIMPLE_WITH_CLEANUP_EXPR, 0);
+  gwce *p = as_a <gwce *> (gimple_alloc (GIMPLE_WITH_CLEANUP_EXPR, 0));
   if (cleanup)
     gimple_wce_set_cleanup (p, cleanup);
 
@@ -1818,8 +1818,8 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_WITH_CLEANUP_EXPR:
-	  new_seq = gimple_seq_copy (gimple_wce_cleanup (stmt));
-	  gimple_wce_set_cleanup (copy, new_seq);
+	  new_seq = gimple_seq_copy (gimple_wce_cleanup (as_a <gwce *> (stmt)));
+	  gimple_wce_set_cleanup (as_a <gwce *> (copy), new_seq);
 	  break;
 
 	default:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index ccafde5..ba4d084 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -459,7 +459,7 @@ enum gimple_try_flags
 /* GIMPLE_WITH_CLEANUP_EXPR */
 
 struct GTY((tag("GSS_WCE")))
-  gimple_statement_wce : public gimple_statement_base
+  gwce : public gimple_statement_base
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -1094,7 +1094,7 @@ is_a_helper <gtry *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_wce *>::test (gimple gs)
+is_a_helper <gwce *>::test (gimple gs)
 {
   return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
 }
@@ -1319,7 +1319,7 @@ geh_mnt *gimple_build_eh_must_not_throw (tree);
 geh_else *gimple_build_eh_else (gimple_seq, gimple_seq);
 gtry *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
-gimple gimple_build_wce (gimple_seq);
+gwce *gimple_build_wce (gimple_seq);
 gresx *gimple_build_resx (int);
 gswitch *gimple_build_switch_nlabels (unsigned, tree, tree);
 gswitch *gimple_build_switch (tree, tree, vec<tree> );
@@ -3776,12 +3776,12 @@ gimple_try_set_cleanup (gtry *try_stmt, gimple_seq cleanup)
 }
 
 
-/* Return a pointer to the cleanup sequence for cleanup statement GS.  */
+/* Return a pointer to the cleanup sequence for cleanup statement
+   WCE_STMT.  */
 
 static inline gimple_seq *
-gimple_wce_cleanup_ptr (gimple gs)
+gimple_wce_cleanup_ptr (gwce *wce_stmt)
 {
-  gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
   return &wce_stmt->cleanup;
 }
 
@@ -3789,18 +3789,17 @@ gimple_wce_cleanup_ptr (gimple gs)
 /* Return the cleanup sequence for cleanup statement GS.  */
 
 static inline gimple_seq
-gimple_wce_cleanup (gimple gs)
+gimple_wce_cleanup (gwce *gs)
 {
   return *gimple_wce_cleanup_ptr (gs);
 }
 
 
-/* Set CLEANUP to be the cleanup sequence for GS.  */
+/* Set CLEANUP to be the cleanup sequence for WCE_STMT.  */
 
 static inline void
-gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
+gimple_wce_set_cleanup (gwce *wce_stmt, gimple_seq cleanup)
 {
-  gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
   wce_stmt->cleanup = cleanup;
 }
 
@@ -3808,9 +3807,8 @@ gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
 /* Return the CLEANUP_EH_ONLY flag for a WCE tuple.  */
 
 static inline bool
-gimple_wce_cleanup_eh_only (const_gimple gs)
+gimple_wce_cleanup_eh_only (const gwce *gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
   return gs->subcode != 0;
 }
 
@@ -3818,9 +3816,8 @@ gimple_wce_cleanup_eh_only (const_gimple gs)
 /* Set the CLEANUP_EH_ONLY flag for a WCE tuple.  */
 
 static inline void
-gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
+gimple_wce_set_cleanup_eh_only (gwce *gs, bool eh_only_p)
 {
-  GIMPLE_CHECK (gs, GIMPLE_WITH_CLEANUP_EXPR);
   gs->subcode = (unsigned int) eh_only_p;
 }
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index bef38c3..36367fe 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -5201,9 +5201,9 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p)
 
   for (iter = gsi_start (body_sequence); !gsi_end_p (iter); )
     {
-      gimple wce = gsi_stmt (iter);
+      gwce *wce = dyn_cast <gwce *> (gsi_stmt (iter));
 
-      if (gimple_code (wce) == GIMPLE_WITH_CLEANUP_EXPR)
+      if (wce)
 	{
 	  if (gsi_one_before_end_p (iter))
 	    {
@@ -5259,7 +5259,7 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p)
 static void
 gimple_push_cleanup (tree var, tree cleanup, bool eh_only, gimple_seq *pre_p)
 {
-  gimple wce;
+  gwce *wce;
   gimple_seq cleanup_stmts = NULL;
 
   /* Errors can result in improperly nested cleanups.  Which results in
diff --git a/gcc/gsstruct.def b/gcc/gsstruct.def
index ed4caa1..4d708d3 100644
--- a/gcc/gsstruct.def
+++ b/gcc/gsstruct.def
@@ -39,7 +39,7 @@ DEFGSSTRUCT(GSS_EH_FILTER, geh_filter, false)
 DEFGSSTRUCT(GSS_EH_MNT, geh_mnt, false)
 DEFGSSTRUCT(GSS_EH_CTRL, gimple_statement_eh_ctrl, false)
 DEFGSSTRUCT(GSS_EH_ELSE, geh_else, false)
-DEFGSSTRUCT(GSS_WCE, gimple_statement_wce, false)
+DEFGSSTRUCT(GSS_WCE, gwce, false)
 DEFGSSTRUCT(GSS_OMP, gimple_statement_omp, false)
 DEFGSSTRUCT(GSS_OMP_CRITICAL, gomp_critical, false)
 DEFGSSTRUCT(GSS_OMP_FOR, gomp_for, false)
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index e005da1..3ed11b5 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1365,7 +1365,8 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_WITH_CLEANUP_EXPR:
-	  s1 = remap_gimple_seq (gimple_wce_cleanup (stmt), id);
+	  s1 = remap_gimple_seq (gimple_wce_cleanup (as_a <gwce *> (stmt)),
+				 id);
 	  copy = gimple_build_wce (s1);
 	  break;
 
-- 
1.7.11.7

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

* [gimple-classes, committed 3/3] Strengthen remaining gimple_try_ accessors to require a gtry *
  2014-10-29 14:06 [gimple-classes, committed 0/3] More accessor typesafety David Malcolm
  2014-10-29 14:07 ` [gimple-classes, committed 1/3] Strengthen params of all gimple_wce_ accessors David Malcolm
@ 2014-10-29 14:15 ` David Malcolm
  2014-10-29 15:01 ` [gimple-classes, committed 2/3] Make gimple_goto_dest require a const ggoto * David Malcolm
  2 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2014-10-29 14:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_try_kind): Strengthen param from const_gimple
	to const gtry *.
	(gimple_try_catch_is_cleanup): Likewise.
	(gimple_try_eval_ptr): Strengthen param from gimple gtry *.
	(gimple_try_eval): Likewise.
	(gimple_try_cleanup_ptr): Likewise.
	(gimple_try_cleanup): Likewise.
	* gimple-low.c (lower_stmt): Introduce new local gtry *try_stmt
	via a checked cast, using it in place of stmt for typesafety.
	(lower_try_catch): Strengthen local "stmt" from gimple to gtry *.
	(gimple_stmt_may_fallthru): Within case GIMPLE_TRY, introduce new
	local gtry *try_stmt via a checked cast, using it in place of stmt
	for typesafety.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* omp-low.c (lower_omp_1): Likewise.
	* tree-cfg.c (verify_gimple_in_seq_2): Likewise.
	(do_warn_unused_result): Likewise.
	* tree-eh.c (collect_finally_tree): Likewise.
	(replace_goto_queue_1): Likewise.
	(honor_protect_cleanup_actions): Replace check against GIMPLE_TRY
	with a dyn_cast <gtry *>, introducing new local "try_stmt", using it
	in place of "stmt".
	(optimize_double_finally): Strengthen local "oneh" from gimple to
	gtry *, via a dyn_cast.
	(refactor_eh_r): Within case GIMPLE_TRY, introduce new local
	gtry *try_stmt via a checked cast, using it in place of stmt for
	typesafety.
	* tree-inline.c (remap_gimple_stmt): Likewise.
	(estimate_num_insns): Likewise.
---
 gcc/ChangeLog.gimple-classes | 32 ++++++++++++++++++
 gcc/gimple-low.c             | 78 ++++++++++++++++++++++++--------------------
 gcc/gimple-walk.c            | 21 +++++++-----
 gcc/gimple.h                 | 19 +++++------
 gcc/omp-low.c                |  7 ++--
 gcc/tree-cfg.c               | 14 +++++---
 gcc/tree-eh.c                | 67 +++++++++++++++++++++----------------
 gcc/tree-inline.c            | 17 +++++++---
 8 files changed, 161 insertions(+), 94 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 50b87b9..10c3957 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,37 @@
 2014-10-28  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_try_kind): Strengthen param from const_gimple
+	to const gtry *.
+	(gimple_try_catch_is_cleanup): Likewise.
+	(gimple_try_eval_ptr): Strengthen param from gimple gtry *.
+	(gimple_try_eval): Likewise.
+	(gimple_try_cleanup_ptr): Likewise.
+	(gimple_try_cleanup): Likewise.
+	* gimple-low.c (lower_stmt): Introduce new local gtry *try_stmt
+	via a checked cast, using it in place of stmt for typesafety.
+	(lower_try_catch): Strengthen local "stmt" from gimple to gtry *.
+	(gimple_stmt_may_fallthru): Within case GIMPLE_TRY, introduce new
+	local gtry *try_stmt via a checked cast, using it in place of stmt
+	for typesafety.
+	* gimple-walk.c (walk_gimple_stmt): Likewise.
+	* omp-low.c (lower_omp_1): Likewise.
+	* tree-cfg.c (verify_gimple_in_seq_2): Likewise.
+	(do_warn_unused_result): Likewise.
+	* tree-eh.c (collect_finally_tree): Likewise.
+	(replace_goto_queue_1): Likewise.
+	(honor_protect_cleanup_actions): Replace check against GIMPLE_TRY
+	with a dyn_cast <gtry *>, introducing new local "try_stmt", using it
+	in place of "stmt".
+	(optimize_double_finally): Strengthen local "oneh" from gimple to
+	gtry *, via a dyn_cast.
+	(refactor_eh_r): Within case GIMPLE_TRY, introduce new local
+	gtry *try_stmt via a checked cast, using it in place of stmt for
+	typesafety.
+	* tree-inline.c (remap_gimple_stmt): Likewise.
+	(estimate_num_insns): Likewise.
+
+2014-10-28  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_goto_dest): Strengthen param from const_gimple to
 	const ggoto *.
 	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to ggoto *
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index ab191a0..0aec000 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -271,27 +271,30 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
       return;
 
     case GIMPLE_TRY:
-      if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
-	lower_try_catch (gsi, data);
-      else
-	{
-	  /* It must be a GIMPLE_TRY_FINALLY.  */
-	  bool cannot_fallthru;
-	  lower_sequence (gimple_try_eval_ptr (stmt), data);
-	  cannot_fallthru = data->cannot_fallthru;
-
-	  /* The finally clause is always executed after the try clause,
-	     so if it does not fall through, then the try-finally will not
-	     fall through.  Otherwise, if the try clause does not fall
-	     through, then when the finally clause falls through it will
-	     resume execution wherever the try clause was going.  So the
-	     whole try-finally will only fall through if both the try
-	     clause and the finally clause fall through.  */
-	  data->cannot_fallthru = false;
-	  lower_sequence (gimple_try_cleanup_ptr (stmt), data);
-	  data->cannot_fallthru |= cannot_fallthru;
-	  gsi_next (gsi);
-	}
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	if (gimple_try_kind (try_stmt) == GIMPLE_TRY_CATCH)
+	  lower_try_catch (gsi, data);
+	else
+	  {
+	    /* It must be a GIMPLE_TRY_FINALLY.  */
+	    bool cannot_fallthru;
+	    lower_sequence (gimple_try_eval_ptr (try_stmt), data);
+	    cannot_fallthru = data->cannot_fallthru;
+
+	    /* The finally clause is always executed after the try clause,
+	       so if it does not fall through, then the try-finally will not
+	       fall through.  Otherwise, if the try clause does not fall
+	       through, then when the finally clause falls through it will
+	       resume execution wherever the try clause was going.  So the
+	       whole try-finally will only fall through if both the try
+	       clause and the finally clause fall through.  */
+	    data->cannot_fallthru = false;
+	    lower_sequence (gimple_try_cleanup_ptr (try_stmt), data);
+	    data->cannot_fallthru |= cannot_fallthru;
+	    gsi_next (gsi);
+	  }
+      }
       return;
 
     case GIMPLE_EH_ELSE:
@@ -444,7 +447,7 @@ static void
 lower_try_catch (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
   bool cannot_fallthru;
-  gimple stmt = gsi_stmt (*gsi);
+  gtry *stmt = as_a <gtry *> (gsi_stmt (*gsi));
   gimple_stmt_iterator i;
 
   /* We don't handle GIMPLE_TRY_FINALLY.  */
@@ -591,20 +594,23 @@ gimple_stmt_may_fallthru (gimple stmt)
 	       gimple_bind_body (as_a <gbind *> (stmt)));
 
     case GIMPLE_TRY:
-      if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
-        return gimple_try_catch_may_fallthru (as_a <gtry *> (stmt));
-
-      /* It must be a GIMPLE_TRY_FINALLY.  */
-
-      /* The finally clause is always executed after the try clause,
-	 so if it does not fall through, then the try-finally will not
-	 fall through.  Otherwise, if the try clause does not fall
-	 through, then when the finally clause falls through it will
-	 resume execution wherever the try clause was going.  So the
-	 whole try-finally will only fall through if both the try
-	 clause and the finally clause fall through.  */
-      return (gimple_seq_may_fallthru (gimple_try_eval (stmt))
-	      && gimple_seq_may_fallthru (gimple_try_cleanup (stmt)));
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	if (gimple_try_kind (try_stmt) == GIMPLE_TRY_CATCH)
+	  return gimple_try_catch_may_fallthru (try_stmt);
+
+	/* It must be a GIMPLE_TRY_FINALLY.  */
+
+	/* The finally clause is always executed after the try clause,
+	   so if it does not fall through, then the try-finally will not
+	   fall through.  Otherwise, if the try clause does not fall
+	   through, then when the finally clause falls through it will
+	   resume execution wherever the try clause was going.  So the
+	   whole try-finally will only fall through if both the try
+	   clause and the finally clause fall through.  */
+	return (gimple_seq_may_fallthru (gimple_try_eval (try_stmt))
+		&& gimple_seq_may_fallthru (gimple_try_cleanup (try_stmt)));
+      }
 
     case GIMPLE_EH_ELSE:
       {
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 4aa2201..1248e75 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -599,15 +599,20 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_TRY:
-      ret = walk_gimple_seq_mod (gimple_try_eval_ptr (stmt), callback_stmt, callback_op,
-	                     wi);
-      if (ret)
-	return wi->callback_result;
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	ret = walk_gimple_seq_mod (gimple_try_eval_ptr (try_stmt),
+				   callback_stmt, callback_op,
+				   wi);
+	if (ret)
+	  return wi->callback_result;
 
-      ret = walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt), callback_stmt,
-	                     callback_op, wi);
-      if (ret)
-	return wi->callback_result;
+	ret = walk_gimple_seq_mod (gimple_try_cleanup_ptr (try_stmt),
+				   callback_stmt,
+				   callback_op, wi);
+	if (ret)
+	  return wi->callback_result;
+      }
       break;
 
     case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a947126..8e82914 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3672,9 +3672,8 @@ gimple_eh_else_set_e_body (geh_else *eh_else_stmt, gimple_seq seq)
    either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY.  */
 
 static inline enum gimple_try_flags
-gimple_try_kind (const_gimple gs)
+gimple_try_kind (const gtry *gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_TRY);
   return (enum gimple_try_flags) (gs->subcode & GIMPLE_TRY_KIND);
 }
 
@@ -3694,7 +3693,7 @@ gimple_try_set_kind (gtry *gs, enum gimple_try_flags kind)
 /* Return the GIMPLE_TRY_CATCH_IS_CLEANUP flag.  */
 
 static inline bool
-gimple_try_catch_is_cleanup (const_gimple gs)
+gimple_try_catch_is_cleanup (const gtry *gs)
 {
   gcc_gimple_checking_assert (gimple_try_kind (gs) == GIMPLE_TRY_CATCH);
   return (gs->subcode & GIMPLE_TRY_CATCH_IS_CLEANUP) != 0;
@@ -3702,12 +3701,11 @@ gimple_try_catch_is_cleanup (const_gimple gs)
 
 
 /* Return a pointer to the sequence of statements used as the
-   body for GIMPLE_TRY GS.  */
+   body for GIMPLE_TRY TRY_STMT.  */
 
 static inline gimple_seq *
-gimple_try_eval_ptr (gimple gs)
+gimple_try_eval_ptr (gtry *try_stmt)
 {
-  gtry *try_stmt = as_a <gtry *> (gs);
   return &try_stmt->eval;
 }
 
@@ -3715,19 +3713,18 @@ gimple_try_eval_ptr (gimple gs)
 /* Return the sequence of statements used as the body for GIMPLE_TRY GS.  */
 
 static inline gimple_seq
-gimple_try_eval (gimple gs)
+gimple_try_eval (gtry *gs)
 {
   return *gimple_try_eval_ptr (gs);
 }
 
 
 /* Return a pointer to the sequence of statements used as the cleanup body for
-   GIMPLE_TRY GS.  */
+   GIMPLE_TRY TRY_STMT.  */
 
 static inline gimple_seq *
-gimple_try_cleanup_ptr (gimple gs)
+gimple_try_cleanup_ptr (gtry *try_stmt)
 {
-  gtry *try_stmt = as_a <gtry *> (gs);
   return &try_stmt->cleanup;
 }
 
@@ -3736,7 +3733,7 @@ gimple_try_cleanup_ptr (gimple gs)
    GIMPLE_TRY GS.  */
 
 static inline gimple_seq
-gimple_try_cleanup (gimple gs)
+gimple_try_cleanup (gtry *gs)
 {
   return *gimple_try_cleanup_ptr (gs);
 }
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d9ac691..0a5de1a 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10504,8 +10504,11 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       lower_omp (gimple_eh_filter_failure_ptr (stmt), ctx);
       break;
     case GIMPLE_TRY:
-      lower_omp (gimple_try_eval_ptr (stmt), ctx);
-      lower_omp (gimple_try_cleanup_ptr (stmt), ctx);
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	lower_omp (gimple_try_eval_ptr (try_stmt), ctx);
+	lower_omp (gimple_try_cleanup_ptr (try_stmt), ctx);
+      }
       break;
     case GIMPLE_TRANSACTION:
       lower_omp (gimple_transaction_body_ptr (
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 669f23e..ee3432d 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4680,8 +4680,11 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
 	  break;
 
 	case GIMPLE_TRY:
-	  err |= verify_gimple_in_seq_2 (gimple_try_eval (stmt));
-	  err |= verify_gimple_in_seq_2 (gimple_try_cleanup (stmt));
+	  {
+	    gtry *try_stmt = as_a <gtry *> (stmt);
+	    err |= verify_gimple_in_seq_2 (gimple_try_eval (try_stmt));
+	    err |= verify_gimple_in_seq_2 (gimple_try_cleanup (try_stmt));
+	  }
 	  break;
 
 	case GIMPLE_EH_FILTER:
@@ -8424,8 +8427,11 @@ do_warn_unused_result (gimple_seq seq)
 	  do_warn_unused_result (gimple_bind_body (as_a <gbind *>(g)));
 	  break;
 	case GIMPLE_TRY:
-	  do_warn_unused_result (gimple_try_eval (g));
-	  do_warn_unused_result (gimple_try_cleanup (g));
+	  {
+	    gtry *try_stmt = as_a <gtry *> (g);
+	    do_warn_unused_result (gimple_try_eval (try_stmt));
+	    do_warn_unused_result (gimple_try_cleanup (try_stmt));
+	  }
 	  break;
 	case GIMPLE_CATCH:
 	  do_warn_unused_result (gimple_catch_handler (
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 3d601c0..77fb9a2 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -258,19 +258,22 @@ collect_finally_tree (gimple stmt, gtry *region)
       break;
 
     case GIMPLE_TRY:
-      if (gimple_try_kind (stmt) == GIMPLE_TRY_FINALLY)
-        {
-          temp.g = stmt;
-          record_in_finally_tree (temp, region);
-          collect_finally_tree_1 (gimple_try_eval (stmt),
-				  as_a <gtry *> (stmt));
-	  collect_finally_tree_1 (gimple_try_cleanup (stmt), region);
-        }
-      else if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
-        {
-          collect_finally_tree_1 (gimple_try_eval (stmt), region);
-          collect_finally_tree_1 (gimple_try_cleanup (stmt), region);
-        }
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	if (gimple_try_kind (try_stmt) == GIMPLE_TRY_FINALLY)
+	  {
+	    temp.g = try_stmt;
+	    record_in_finally_tree (temp, region);
+	    collect_finally_tree_1 (gimple_try_eval (try_stmt),
+				    try_stmt);
+	    collect_finally_tree_1 (gimple_try_cleanup (try_stmt), region);
+	  }
+	else if (gimple_try_kind (try_stmt) == GIMPLE_TRY_CATCH)
+	  {
+	    collect_finally_tree_1 (gimple_try_eval (try_stmt), region);
+	    collect_finally_tree_1 (gimple_try_cleanup (try_stmt), region);
+	  }
+      }
       break;
 
     case GIMPLE_CATCH:
@@ -531,8 +534,11 @@ replace_goto_queue_1 (gimple stmt, struct leh_tf_state *tf,
       break;
 
     case GIMPLE_TRY:
-      replace_goto_queue_stmt_list (gimple_try_eval_ptr (stmt), tf);
-      replace_goto_queue_stmt_list (gimple_try_cleanup_ptr (stmt), tf);
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	replace_goto_queue_stmt_list (gimple_try_eval_ptr (try_stmt), tf);
+	replace_goto_queue_stmt_list (gimple_try_cleanup_ptr (try_stmt), tf);
+      }
       break;
     case GIMPLE_CATCH:
       replace_goto_queue_stmt_list (gimple_catch_handler_ptr (
@@ -1042,13 +1048,14 @@ honor_protect_cleanup_actions (struct leh_state *outer_state,
      MUST_NOT_THROW filter.  */
   gsi = gsi_start (finally);
   x = gsi_stmt (gsi);
-  if (gimple_code (x) == GIMPLE_TRY
-      && gimple_try_kind (x) == GIMPLE_TRY_CATCH
-      && gimple_try_catch_is_cleanup (x))
-    {
-      gsi_insert_seq_before (&gsi, gimple_try_eval (x), GSI_SAME_STMT);
-      gsi_remove (&gsi, false);
-    }
+  if (gtry *try_stmt = dyn_cast <gtry *> (x))
+    if (gimple_try_kind (try_stmt) == GIMPLE_TRY_CATCH
+	&& gimple_try_catch_is_cleanup (try_stmt))
+      {
+	gsi_insert_seq_before (&gsi, gimple_try_eval (try_stmt),
+			       GSI_SAME_STMT);
+	gsi_remove (&gsi, false);
+      }
 
   /* Wrap the block with protect_cleanup_actions as the action.  */
   eh_mnt = gimple_build_eh_must_not_throw (protect_cleanup_actions);
@@ -3036,7 +3043,7 @@ same_handler_p (gimple_seq oneh, gimple_seq twoh)
 static void
 optimize_double_finally (gtry *one, gtry *two)
 {
-  gimple oneh;
+  gtry *oneh;
   gimple_stmt_iterator gsi;
   gimple_seq cleanup;
 
@@ -3045,9 +3052,10 @@ optimize_double_finally (gtry *one, gtry *two)
   if (!gsi_one_before_end_p (gsi))
     return;
 
-  oneh = gsi_stmt (gsi);
-  if (gimple_code (oneh) != GIMPLE_TRY
-      || gimple_try_kind (oneh) != GIMPLE_TRY_CATCH)
+  oneh = dyn_cast <gtry *> (gsi_stmt (gsi));
+  if (!oneh)
+    return;
+  if (gimple_try_kind (oneh) != GIMPLE_TRY_CATCH)
     return;
 
   if (same_handler_p (gimple_try_cleanup (oneh), gimple_try_cleanup (two)))
@@ -3091,8 +3099,11 @@ refactor_eh_r (gimple_seq seq)
 	switch (gimple_code (one))
 	  {
 	  case GIMPLE_TRY:
-	    refactor_eh_r (gimple_try_eval (one));
-	    refactor_eh_r (gimple_try_cleanup (one));
+	    {
+	      gtry *try_one = as_a <gtry *> (one);
+	      refactor_eh_r (gimple_try_eval (try_one));
+	      refactor_eh_r (gimple_try_cleanup (try_one));
+	    }
 	    break;
 	  case GIMPLE_CATCH:
 	    refactor_eh_r (gimple_catch_handler (as_a <gcatch *> (one)));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index fa08c98..0a076ce 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1359,9 +1359,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_TRY:
-	  s1 = remap_gimple_seq (gimple_try_eval (stmt), id);
-	  s2 = remap_gimple_seq (gimple_try_cleanup (stmt), id);
-	  copy = gimple_build_try (s1, s2, gimple_try_kind (stmt));
+	  {
+	    gtry *try_stmt = as_a <gtry *> (stmt);
+	    s1 = remap_gimple_seq (gimple_try_eval (try_stmt), id);
+	    s2 = remap_gimple_seq (gimple_try_cleanup (try_stmt), id);
+	    copy = gimple_build_try (s1, s2, gimple_try_kind (try_stmt));
+	  }
 	  break;
 
 	case GIMPLE_WITH_CLEANUP_EXPR:
@@ -4010,8 +4013,12 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
 				     weights);
 
     case GIMPLE_TRY:
-      return (estimate_num_insns_seq (gimple_try_eval (stmt), weights)
-              + estimate_num_insns_seq (gimple_try_cleanup (stmt), weights));
+      {
+	gtry *try_stmt = as_a <gtry *> (stmt);
+	return (estimate_num_insns_seq (gimple_try_eval (try_stmt), weights)
+		+ estimate_num_insns_seq (gimple_try_cleanup (try_stmt),
+					  weights));
+      }
 
     /* OpenMP directives are generally very expensive.  */
 
-- 
1.7.11.7

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

* [gimple-classes, committed 2/3] Make gimple_goto_dest require a const ggoto *
  2014-10-29 14:06 [gimple-classes, committed 0/3] More accessor typesafety David Malcolm
  2014-10-29 14:07 ` [gimple-classes, committed 1/3] Strengthen params of all gimple_wce_ accessors David Malcolm
  2014-10-29 14:15 ` [gimple-classes, committed 3/3] Strengthen remaining gimple_try_ accessors to require a gtry * David Malcolm
@ 2014-10-29 15:01 ` David Malcolm
  2 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2014-10-29 15:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_goto_dest): Strengthen param from const_gimple to
	const ggoto *.
	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to ggoto *
	within case GIMPLE_GOTO.
	* gimple-walk.c (walk_stmt_load_store_addr_ops): Add checked cast
	to ggoto *.
	* ipa-icf-gimple.c (ipa_icf_gimple::func_checker::compare_bb): Add
	checked casts to ggoto * within case GIMPLE_GOTO.
	(ipa_icf_gimple::func_checker::compare_gimple_goto): Strengthen
	both params from gimple to const ggoto *.
	* ipa-icf-gimple.h (ipa_icf_gimple::func_checker::compare_gimple_goto):
	Likewise.
	* omp-low.c (diagnose_sb_2): Add checked cast to ggoto * within
	case GIMPLE_GOTO.
	* tree-cfg.c (computed_goto_p): Replace check for GIMPLE_GOTO with
	a dyn_cast <ggoto *>, introducing new local "goto_stmt".
	(handle_abnormal_edges): Strengthen local "last" from gimple to
	ggoto *.
	(make_goto_expr_edges): Add checked cast to ggoto * within region
	where we know it's a simple goto.
	(simple_goto_p): Replace check for GIMPLE_GOTO with a
	dyn_cast <ggoto *>, introducing new local "goto_stmt".
	* tree-cfgcleanup.c (cleanup_control_flow_bb): Likewise, using
	new "goto_stmt" in place of "stmt".
	* tree-eh.c (replace_goto_queue_cond_clause): Likewise, using
	new "goto_stmt" in place of gimple_seq_first_stmt (new_seq).
	(maybe_record_in_goto_queue): Add checked cast to ggoto * within
	case GIMPLE_GOTO.
	* tree-inline.c (inline_forbidden_p_stmt): Likewise.
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_nl_goto_reference): Add checked cast to ggoto *.
	* tree-ssa-dom.c (initialize_hash_element): Replace check for
	GIMPLE_GOTO with a dyn_cast <ggoto *>, introducing new local
	"goto_stmt".
	(optimize_stmt): Likewise.
	(propagate_rhs_into_lhs): Add checked cast to ggoto *.
	* tree-ssa-sccvn.c (cond_dom_walker::before_dom_children): Likewise.
	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
	* tree-ssa-threadupdate.c (bb_ends_with_multiway_branch): Likewise.
---
 gcc/ChangeLog.gimple-classes | 42 ++++++++++++++++++++++++++++++++++++++++++
 gcc/cfgexpand.c              |  2 +-
 gcc/gimple-walk.c            |  2 +-
 gcc/gimple.h                 |  3 +--
 gcc/ipa-icf-gimple.c         |  7 ++++---
 gcc/ipa-icf-gimple.h         |  4 ++--
 gcc/omp-low.c                |  2 +-
 gcc/tree-cfg.c               | 16 ++++++++++------
 gcc/tree-cfgcleanup.c        |  9 +++++----
 gcc/tree-eh.c                | 15 ++++++++-------
 gcc/tree-inline.c            |  2 +-
 gcc/tree-nested.c            |  4 ++--
 gcc/tree-ssa-dom.c           | 12 ++++++------
 gcc/tree-ssa-sccvn.c         |  2 +-
 gcc/tree-ssa-threadedge.c    |  2 +-
 gcc/tree-ssa-threadupdate.c  |  2 +-
 16 files changed, 87 insertions(+), 39 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b7a62de..50b87b9 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,47 @@
 2014-10-28  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_goto_dest): Strengthen param from const_gimple to
+	const ggoto *.
+	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to ggoto *
+	within case GIMPLE_GOTO.
+	* gimple-walk.c (walk_stmt_load_store_addr_ops): Add checked cast
+	to ggoto *.
+	* ipa-icf-gimple.c (ipa_icf_gimple::func_checker::compare_bb): Add
+	checked casts to ggoto * within case GIMPLE_GOTO.
+	(ipa_icf_gimple::func_checker::compare_gimple_goto): Strengthen
+	both params from gimple to const ggoto *.
+	* ipa-icf-gimple.h (ipa_icf_gimple::func_checker::compare_gimple_goto):
+	Likewise.
+	* omp-low.c (diagnose_sb_2): Add checked cast to ggoto * within
+	case GIMPLE_GOTO.
+	* tree-cfg.c (computed_goto_p): Replace check for GIMPLE_GOTO with
+	a dyn_cast <ggoto *>, introducing new local "goto_stmt".
+	(handle_abnormal_edges): Strengthen local "last" from gimple to
+	ggoto *.
+	(make_goto_expr_edges): Add checked cast to ggoto * within region
+	where we know it's a simple goto.
+	(simple_goto_p): Replace check for GIMPLE_GOTO with a
+	dyn_cast <ggoto *>, introducing new local "goto_stmt".
+	* tree-cfgcleanup.c (cleanup_control_flow_bb): Likewise, using
+	new "goto_stmt" in place of "stmt".
+	* tree-eh.c (replace_goto_queue_cond_clause): Likewise, using
+	new "goto_stmt" in place of gimple_seq_first_stmt (new_seq).
+	(maybe_record_in_goto_queue): Add checked cast to ggoto * within
+	case GIMPLE_GOTO.
+	* tree-inline.c (inline_forbidden_p_stmt): Likewise.
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_nl_goto_reference): Add checked cast to ggoto *.
+	* tree-ssa-dom.c (initialize_hash_element): Replace check for
+	GIMPLE_GOTO with a dyn_cast <ggoto *>, introducing new local
+	"goto_stmt".
+	(optimize_stmt): Likewise.
+	(propagate_rhs_into_lhs): Add checked cast to ggoto *.
+	* tree-ssa-sccvn.c (cond_dom_walker::before_dom_children): Likewise.
+	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
+	* tree-ssa-threadupdate.c (bb_ends_with_multiway_branch): Likewise.
+
+2014-10-28  David Malcolm  <dmalcolm@redhat.com>
+
 	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Update
 	for renaming of gimple_statement_wce to gwce.
 	* gimple-walk.c (walk_gimple_stmt): Add checked cast to gwce *
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index a2cb483..73862eb 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3208,7 +3208,7 @@ expand_gimple_stmt_1 (gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_GOTO:
-      op0 = gimple_goto_dest (stmt);
+      op0 = gimple_goto_dest (as_a <ggoto *> (stmt));
       if (TREE_CODE (op0) == LABEL_DECL)
 	expand_goto (op0);
       else
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 002308c..4aa2201 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -890,7 +890,7 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
   else if (visit_addr
 	   && gimple_code (stmt) == GIMPLE_GOTO)
     {
-      tree op = gimple_goto_dest (stmt);
+      tree op = gimple_goto_dest (as_a <ggoto *> (stmt));
       if (TREE_CODE (op) == ADDR_EXPR)
 	ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data);
     }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index ba4d084..a947126 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3196,9 +3196,8 @@ gimple_label_set_label (glabel *gs, tree label)
 /* Return the destination of the unconditional jump GS.  */
 
 static inline tree
-gimple_goto_dest (const_gimple gs)
+gimple_goto_dest (const ggoto *gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_GOTO);
   return gimple_op (gs, 0);
 }
 
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 9ebef25..c86e8c3 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -622,7 +622,8 @@ func_checker::compare_bb (sem_bb *bb1, sem_bb *bb2)
 	    return return_different_stmts (s1, s2, "GIMPLE_RETURN");
 	  break;
 	case GIMPLE_GOTO:
-	  if (!compare_gimple_goto (s1, s2))
+	  if (!compare_gimple_goto (as_a <ggoto *> (s1),
+				    as_a <ggoto *> (s2)))
 	    return return_different_stmts (s1, s2, "GIMPLE_GOTO");
 	  break;
 	case GIMPLE_ASM:
@@ -828,11 +829,11 @@ func_checker::compare_gimple_return (const greturn *g1, const greturn *g2)
     return compare_operand (t1, t2);
 }
 
-/* Verifies for given GIMPLEs S1 and S2 that
+/* Verifies for given GIMPLE_GOTO stmts S1 and S2 that
    goto statements are semantically equivalent.  */
 
 bool
-func_checker::compare_gimple_goto (gimple g1, gimple g2)
+func_checker::compare_gimple_goto (const ggoto *g1, const ggoto *g2)
 {
   tree dest1, dest2;
 
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 07d84f9..559df66 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -181,9 +181,9 @@ public:
      return statements are semantically equivalent.  */
   bool compare_gimple_return (const greturn *s1, const greturn *s2);
 
-  /* Verifies for given GIMPLEs S1 and S2 that
+  /* Verifies for given GIMPLE_GOTO stmts S1 and S2 that
      goto statements are semantically equivalent.  */
-  bool compare_gimple_goto (gimple s1, gimple s2);
+  bool compare_gimple_goto (const ggoto *s1, const ggoto *s2);
 
   /* Verifies for given GIMPLE_RESX stmts S1 and S2 that
      resx statements are semantically equivalent.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index e53f4ff..d9ac691 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10959,7 +10959,7 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_GOTO:
       {
-	tree lab = gimple_goto_dest (stmt);
+	tree lab = gimple_goto_dest (as_a <ggoto *> (stmt));
 	if (TREE_CODE (lab) != LABEL_DECL)
 	  break;
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 36650e0..669f23e 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -399,8 +399,10 @@ make_pass_build_cfg (gcc::context *ctxt)
 bool
 computed_goto_p (gimple t)
 {
-  return (gimple_code (t) == GIMPLE_GOTO
-	  && TREE_CODE (gimple_goto_dest (t)) != LABEL_DECL);
+  ggoto *goto_stmt = dyn_cast <ggoto *> (t);
+  if (!goto_stmt)
+    return false;
+  return TREE_CODE (gimple_goto_dest (goto_stmt)) != LABEL_DECL;
 }
 
 /* Returns true for edge E where e->src ends with a GIMPLE_COND and
@@ -732,7 +734,7 @@ handle_abnormal_edges (basic_block *dispatcher_bbs,
 		continue;
 
 	      gsi = gsi_last_bb (bb);
-	      gimple last = gsi_stmt (gsi);
+	      ggoto *last = as_a <ggoto *>  (gsi_stmt (gsi));
 
 	      gcc_assert (computed_goto_p (last));
 
@@ -1246,7 +1248,7 @@ make_goto_expr_edges (basic_block bb)
   /* A simple GOTO creates normal edges.  */
   if (simple_goto_p (goto_t))
     {
-      tree dest = gimple_goto_dest (goto_t);
+      tree dest = gimple_goto_dest (as_a <ggoto *> (goto_t));
       basic_block label_bb = label_to_block (dest);
       edge e = make_edge (bb, label_bb, EDGE_FALLTHRU);
       e->goto_locus = gimple_location (goto_t);
@@ -2470,8 +2472,10 @@ is_ctrl_altering_stmt (gimple t)
 bool
 simple_goto_p (gimple t)
 {
-  return (gimple_code (t) == GIMPLE_GOTO
-	  && TREE_CODE (gimple_goto_dest (t)) == LABEL_DECL);
+  ggoto *goto_stmt = dyn_cast <ggoto *> (t);
+  if (!goto_stmt)
+    return false;
+  return TREE_CODE (gimple_goto_dest (goto_stmt)) == LABEL_DECL;
 }
 
 
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 8c86225..d0da8c0 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -198,6 +198,7 @@ cleanup_control_flow_bb (basic_block bb)
   gimple_stmt_iterator gsi;
   bool retval = false;
   gimple stmt;
+  ggoto *goto_stmt;
 
   /* If the last statement of the block could throw and now cannot,
      we need to prune cfg.  */
@@ -215,9 +216,9 @@ cleanup_control_flow_bb (basic_block bb)
   if (gimple_code (stmt) == GIMPLE_COND
       || gimple_code (stmt) == GIMPLE_SWITCH)
     retval |= cleanup_control_expr_graph (bb, gsi);
-  else if (gimple_code (stmt) == GIMPLE_GOTO
-	   && TREE_CODE (gimple_goto_dest (stmt)) == ADDR_EXPR
-	   && (TREE_CODE (TREE_OPERAND (gimple_goto_dest (stmt), 0))
+  else if ((goto_stmt = dyn_cast <ggoto *> (stmt))
+	   && TREE_CODE (gimple_goto_dest (goto_stmt)) == ADDR_EXPR
+	   && (TREE_CODE (TREE_OPERAND (gimple_goto_dest (goto_stmt), 0))
 	       == LABEL_DECL))
     {
       /* If we had a computed goto which has a compile-time determinable
@@ -230,7 +231,7 @@ cleanup_control_flow_bb (basic_block bb)
       /* First look at all the outgoing edges.  Delete any outgoing
 	 edges which do not go to the right block.  For the one
 	 edge which goes to the right block, fix up its flags.  */
-      label = TREE_OPERAND (gimple_goto_dest (stmt), 0);
+      label = TREE_OPERAND (gimple_goto_dest (goto_stmt), 0);
       target_block = label_to_block (label);
       for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
 	{
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index a27ed35..3d601c0 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -483,12 +483,12 @@ replace_goto_queue_cond_clause (tree *tp, struct leh_tf_state *tf,
   if (!new_seq)
     return;
 
-  if (gimple_seq_singleton_p (new_seq)
-      && gimple_code (gimple_seq_first_stmt (new_seq)) == GIMPLE_GOTO)
-    {
-      *tp = gimple_goto_dest (gimple_seq_first_stmt (new_seq));
-      return;
-    }
+  if (gimple_seq_singleton_p (new_seq))
+    if (ggoto *goto_stmt = dyn_cast <ggoto *> (gimple_seq_first_stmt (new_seq)))
+      {
+	*tp = gimple_goto_dest (goto_stmt);
+	return;
+      }
 
   label = create_artificial_label (loc);
   /* Set the new label for the GIMPLE_COND */
@@ -695,7 +695,8 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple stmt)
       break;
     case GIMPLE_GOTO:
       new_stmt.g = stmt;
-      record_in_goto_queue_label (tf, new_stmt, gimple_goto_dest (stmt),
+      record_in_goto_queue_label (tf, new_stmt,
+				  gimple_goto_dest (as_a <ggoto *> (stmt)),
 				  gimple_location (stmt));
       break;
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 3ed11b5..fa08c98 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3502,7 +3502,7 @@ inline_forbidden_p_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_GOTO:
-      t = gimple_goto_dest (stmt);
+      t = gimple_goto_dest (as_a <ggoto *> (stmt));
 
       /* We will not inline a function which uses computed goto.  The
 	 addresses of its local labels, which may be tucked into
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index a254a1c..c95fe81 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1311,7 +1311,7 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
     {
     case GIMPLE_GOTO:
       /* Don't walk non-local gotos for now.  */
-      if (TREE_CODE (gimple_goto_dest (stmt)) != LABEL_DECL)
+      if (TREE_CODE (gimple_goto_dest (as_a <ggoto *> (stmt))) != LABEL_DECL)
 	{
 	  wi->val_only = true;
 	  wi->is_lhs = false;
@@ -2081,7 +2081,7 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       return NULL_TREE;
     }
 
-  label = gimple_goto_dest (stmt);
+  label = gimple_goto_dest (as_a <ggoto *> (stmt));
   if (TREE_CODE (label) != LABEL_DECL)
     {
       *handled_ops_p = false;
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 747354b..c1ed637 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -362,11 +362,11 @@ initialize_hash_element (gimple stmt, tree lhs,
       expr->kind = EXPR_SINGLE;
       expr->ops.single.rhs = gimple_switch_index (swtch_stmt);
     }
-  else if (code == GIMPLE_GOTO)
+  else if (ggoto *goto_stmt = dyn_cast <ggoto *> (stmt))
     {
-      expr->type = TREE_TYPE (gimple_goto_dest (stmt));
+      expr->type = TREE_TYPE (gimple_goto_dest (goto_stmt));
       expr->kind = EXPR_SINGLE;
-      expr->ops.single.rhs = gimple_goto_dest (stmt);
+      expr->ops.single.rhs = gimple_goto_dest (goto_stmt);
     }
   else if (code == GIMPLE_PHI)
     {
@@ -2367,8 +2367,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
       /* We only need to consider cases that can yield a gimple operand.  */
       if (gimple_assign_single_p (stmt))
         rhs = gimple_assign_rhs1 (stmt);
-      else if (gimple_code (stmt) == GIMPLE_GOTO)
-        rhs = gimple_goto_dest (stmt);
+      else if (ggoto *goto_stmt = dyn_cast <ggoto *> (stmt))
+        rhs = gimple_goto_dest (goto_stmt);
       else if (gswitch *swtch_stmt = dyn_cast <gswitch *> (stmt))
         /* This should never be an ADDR_EXPR.  */
         rhs = gimple_switch_index (swtch_stmt);
@@ -2848,7 +2848,7 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
               else if (gimple_code (use_stmt) == GIMPLE_SWITCH)
 		val = gimple_switch_index (as_a <gswitch *> (use_stmt));
 	      else
-		val = gimple_goto_dest  (use_stmt);
+		val = gimple_goto_dest  (as_a <ggoto *> (use_stmt));
 
 	      if (val && is_gimple_min_invariant (val))
 		{
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 683e50e..039d0b1 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4271,7 +4271,7 @@ cond_dom_walker::before_dom_children (basic_block bb)
       val = gimple_switch_index (as_a <gswitch *> (stmt));
       break;
     case GIMPLE_GOTO:
-      val = gimple_goto_dest (stmt);
+      val = gimple_goto_dest (as_a <ggoto *> (stmt));
       break;
     default:
       gcc_unreachable ();
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 1f3825d..d5b2941 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -628,7 +628,7 @@ simplify_control_stmt_condition (edge e,
   if (code == GIMPLE_SWITCH)
     cond = gimple_switch_index (as_a <gswitch *> (stmt));
   else if (code == GIMPLE_GOTO)
-    cond = gimple_goto_dest (stmt);
+    cond = gimple_goto_dest (as_a <ggoto *> (stmt));
   else
     gcc_unreachable ();
 
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 8868c0a..76a9a9f 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2307,7 +2307,7 @@ bb_ends_with_multiway_branch (basic_block bb ATTRIBUTE_UNUSED)
   if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
     return true;
   if (stmt && gimple_code (stmt) == GIMPLE_GOTO
-      && TREE_CODE (gimple_goto_dest (stmt)) == SSA_NAME)
+      && TREE_CODE (gimple_goto_dest (as_a <ggoto *> (stmt))) == SSA_NAME)
     return true;
   return false;
 }
-- 
1.7.11.7

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

end of thread, other threads:[~2014-10-29 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29 14:06 [gimple-classes, committed 0/3] More accessor typesafety David Malcolm
2014-10-29 14:07 ` [gimple-classes, committed 1/3] Strengthen params of all gimple_wce_ accessors David Malcolm
2014-10-29 14:15 ` [gimple-classes, committed 3/3] Strengthen remaining gimple_try_ accessors to require a gtry * David Malcolm
2014-10-29 15:01 ` [gimple-classes, committed 2/3] Make gimple_goto_dest require a const ggoto * David Malcolm

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).