public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gimple-classes, committed 04/10] Make all gimple_omp_sections_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (4 preceding siblings ...)
  2014-10-29 18:52 ` [gimple-classes, committed 02/10] Make all gimple_omp_for_ " David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 19:04 ` [gimple-classes, committed 03/10] Make remaining gimple_omp_teams_ " David Malcolm
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_sections_clauses): Strengthen param from
	const_gimple to const gomp_sections *.
	(gimple_omp_sections_control): Likewise.
	(gimple_omp_sections_clauses_ptr): Strengthen param from gimple to
	gomp_sections *.
	(gimple_omp_sections_set_clauses): Likewise.
	(gimple_omp_sections_control_ptr): Likewise.
	(gimple_omp_sections_set_control): Likewise.

	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_SECTIONS,
	introduce local "omp_sections_stmt" via a checked cast and use it
	in place of "stmt" for typesafety.
	* gimple.c (gimple_copy): Likewise, introducing locals
	"omp_sections_stmt" and "omp_sections_copy", using them in place
	of "stmt" and "copy".
	* omp-low.c (check_omp_nesting_restrictions): Add checked casts.
	* tree-inline.c (remap_gimple_stmt): Within case
	GIMPLE_OMP_SECTIONS, introduce local "omp_sections_stmt" via a
	checked cast and use it in place of "stmt" for typesafety.
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
---
 gcc/ChangeLog.gimple-classes | 24 ++++++++++++++++++++++++
 gcc/gimple-walk.c            | 20 +++++++++++---------
 gcc/gimple.c                 | 12 ++++++++----
 gcc/gimple.h                 | 37 +++++++++++++------------------------
 gcc/omp-low.c                | 14 ++++++++------
 gcc/tree-inline.c            |  9 ++++++---
 gcc/tree-nested.c            | 31 +++++++++++++++++++++----------
 7 files changed, 91 insertions(+), 56 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 626ea2f..469c009 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,29 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_sections_clauses): Strengthen param from
+	const_gimple to const gomp_sections *.
+	(gimple_omp_sections_control): Likewise.
+	(gimple_omp_sections_clauses_ptr): Strengthen param from gimple to
+	gomp_sections *.
+	(gimple_omp_sections_set_clauses): Likewise.
+	(gimple_omp_sections_control_ptr): Likewise.
+	(gimple_omp_sections_set_control): Likewise.
+
+	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_SECTIONS,
+	introduce local "omp_sections_stmt" via a checked cast and use it
+	in place of "stmt" for typesafety.
+	* gimple.c (gimple_copy): Likewise, introducing locals
+	"omp_sections_stmt" and "omp_sections_copy", using them in place
+	of "stmt" and "copy".
+	* omp-low.c (check_omp_nesting_restrictions): Add checked casts.
+	* tree-inline.c (remap_gimple_stmt): Within case
+	GIMPLE_OMP_SECTIONS, introduce local "omp_sections_stmt" via a
+	checked cast and use it in place of "stmt" for typesafety.
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_local_reference_stmt): Likewise.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_teams_clauses): Strengthen param from
 	const_gimple to const gomp_teams *.
 	(gimple_omp_teams_clauses_ptr): Strengthen param from gimple to
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 13c16bb..b802c95 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -406,16 +406,18 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-
-      ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
+      {
+	gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt);
+	ret = walk_tree (gimple_omp_sections_clauses_ptr (omp_sections_stmt), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
 
+	ret = walk_tree (gimple_omp_sections_control_ptr (omp_sections_stmt), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_SINGLE:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index f02930d..b34ac10 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1797,10 +1797,14 @@ gimple_copy (gimple stmt)
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_SECTIONS:
-	  t = unshare_expr (gimple_omp_sections_clauses (stmt));
-	  gimple_omp_sections_set_clauses (copy, t);
-	  t = unshare_expr (gimple_omp_sections_control (stmt));
-	  gimple_omp_sections_set_control (copy, t);
+	  {
+	    gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt);
+	    gomp_sections *omp_sections_copy = as_a <gomp_sections *> (copy);
+	    t = unshare_expr (gimple_omp_sections_clauses (omp_sections_stmt));
+	    gimple_omp_sections_set_clauses (omp_sections_copy, t);
+	    t = unshare_expr (gimple_omp_sections_control (omp_sections_stmt));
+	    gimple_omp_sections_set_control (omp_sections_copy, t);
+	  }
 	  /* FALLTHRU  */
 
 	case GIMPLE_OMP_SINGLE:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 41f1691..723c2f5 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -5105,72 +5105,61 @@ gimple_omp_teams_set_clauses (gomp_teams *omp_teams_stmt, tree clauses)
 }
 
 
-/* Return the clauses associated with OMP_SECTIONS GS.  */
+/* Return the clauses associated with OMP_SECTIONS OMP_SECTIONS_STMT.  */
 
 static inline tree
-gimple_omp_sections_clauses (const_gimple gs)
+gimple_omp_sections_clauses (const gomp_sections *omp_sections_stmt)
 {
-  const gomp_sections *omp_sections_stmt =
-    as_a <const gomp_sections *> (gs);
   return omp_sections_stmt->clauses;
 }
 
 
-/* Return a pointer to the clauses associated with OMP_SECTIONS GS.  */
+/* Return a pointer to the clauses associated with OMP_SECTIONS
+   OMP_SECTIONS_STMT.  */
 
 static inline tree *
-gimple_omp_sections_clauses_ptr (gimple gs)
+gimple_omp_sections_clauses_ptr (gomp_sections *omp_sections_stmt)
 {
-  gomp_sections *omp_sections_stmt =
-    as_a <gomp_sections *> (gs);
   return &omp_sections_stmt->clauses;
 }
 
 
 /* Set CLAUSES to be the set of clauses associated with OMP_SECTIONS
-   GS.  */
+   OMP_SECTIONS_STMT.  */
 
 static inline void
-gimple_omp_sections_set_clauses (gimple gs, tree clauses)
+gimple_omp_sections_set_clauses (gomp_sections *omp_sections_stmt, tree clauses)
 {
-  gomp_sections *omp_sections_stmt =
-    as_a <gomp_sections *> (gs);
   omp_sections_stmt->clauses = clauses;
 }
 
 
 /* Return the control variable associated with the GIMPLE_OMP_SECTIONS
-   in GS.  */
+   in OMP_SECTIONS_STMT.  */
 
 static inline tree
-gimple_omp_sections_control (const_gimple gs)
+gimple_omp_sections_control (const gomp_sections *omp_sections_stmt)
 {
-  const gomp_sections *omp_sections_stmt =
-    as_a <const gomp_sections *> (gs);
   return omp_sections_stmt->control;
 }
 
 
 /* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
-   GS.  */
+   OMP_SECTIONS_STMT.  */
 
 static inline tree *
-gimple_omp_sections_control_ptr (gimple gs)
+gimple_omp_sections_control_ptr (gomp_sections *omp_sections_stmt)
 {
-  gomp_sections *omp_sections_stmt =
-    as_a <gomp_sections *> (gs);
   return &omp_sections_stmt->control;
 }
 
 
 /* Set CONTROL to be the set of clauses associated with the
-   GIMPLE_OMP_SECTIONS in GS.  */
+   GIMPLE_OMP_SECTIONS in OMP_SECTIONS_STMT.  */
 
 static inline void
-gimple_omp_sections_set_control (gimple gs, tree control)
+gimple_omp_sections_set_control (gomp_sections *omp_sections_stmt, tree control)
 {
-  gomp_sections *omp_sections_stmt =
-    as_a <gomp_sections *> (gs);
   omp_sections_stmt->control = control;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index c43f5ea..509f3f8 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2516,9 +2516,10 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 		  if (gimple_code (ctx->stmt) == GIMPLE_OMP_SECTIONS)
 		    {
 		      ctx->cancellable = true;
-		      if (find_omp_clause (gimple_omp_sections_clauses
-								(ctx->stmt),
-					   OMP_CLAUSE_NOWAIT))
+		      if (find_omp_clause (
+			    gimple_omp_sections_clauses (
+			      as_a <gomp_sections *> (ctx->stmt)),
+			    OMP_CLAUSE_NOWAIT))
 			warning_at (gimple_location (stmt), 0,
 				    "%<#pragma omp cancel sections%> inside "
 				    "%<nowait%> sections construct");
@@ -2529,9 +2530,10 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 				  && gimple_code (ctx->outer->stmt)
 				     == GIMPLE_OMP_SECTIONS);
 		      ctx->outer->cancellable = true;
-		      if (find_omp_clause (gimple_omp_sections_clauses
-							(ctx->outer->stmt),
-					   OMP_CLAUSE_NOWAIT))
+		      if (find_omp_clause (
+			    gimple_omp_sections_clauses (
+			      as_a <gomp_sections *> (ctx->outer->stmt)),
+			    OMP_CLAUSE_NOWAIT))
 			warning_at (gimple_location (stmt), 0,
 				    "%<#pragma omp cancel sections%> inside "
 				    "%<nowait%> sections construct");
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6498e23..bc19939 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1455,9 +1455,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_SECTIONS:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_sections
-	           (s1, gimple_omp_sections_clauses (stmt));
+	  {
+	    gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt);
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_sections_stmt), id);
+	    copy = gimple_build_omp_sections (
+		     s1, gimple_omp_sections_clauses (omp_sections_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_SINGLE:
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 3463151..f0756c1 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1365,11 +1365,17 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      save_suppress = info->suppress_expansion;
-      convert_nonlocal_omp_clauses (gimple_omp_sections_clauses_ptr (stmt), wi);
-      walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op,
-	         info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_nonlocal_omp_clauses (gimple_omp_sections_clauses_ptr (
+					omp_sections_stmt),
+				      wi);
+	walk_body (convert_nonlocal_reference_stmt,
+		   convert_nonlocal_reference_op,
+		   info, gimple_omp_body_ptr (omp_sections_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SINGLE:
@@ -1944,11 +1950,16 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      save_suppress = info->suppress_expansion;
-      convert_local_omp_clauses (gimple_omp_sections_clauses_ptr (stmt), wi);
-      walk_body (convert_local_reference_stmt, convert_local_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_sections *omp_sections_stmt = as_a <gomp_sections *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_local_omp_clauses (gimple_omp_sections_clauses_ptr (
+				     omp_sections_stmt),
+				   wi);
+	walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		   info, gimple_omp_body_ptr (omp_sections_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SINGLE:
-- 
1.7.11.7

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

* [gimple-classes, committed 01/10] Make all of gimple_omp_task_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 09/10] Make remaining gimple_eh_filter_ " David Malcolm
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_task_clauses): Strengthen param from
	const_gimple to const gomp_task *.
	(gimple_omp_task_child_fn): Likewise.
	(gimple_omp_task_data_arg): Likewise.
	(gimple_omp_task_copy_fn): Likewise.
	(gimple_omp_task_arg_size): Likewise.
	(gimple_omp_task_arg_align): Likewise.
	(gimple_omp_task_clauses_ptr): Strengthen param from gimple to
	gomp_task *.
	(gimple_omp_task_set_clauses): Likewise.
	(gimple_omp_task_child_fn_ptr): Likewise.
	(gimple_omp_task_set_child_fn): Likewise.
	(gimple_omp_task_data_arg_ptr): Likewise.
	(gimple_omp_task_set_data_arg): Likewise.
	(gimple_omp_task_copy_fn_ptr): Likewise.
	(gimple_omp_task_set_copy_fn): Likewise.
	(gimple_omp_task_arg_size_ptr): Likewise.
	(gimple_omp_task_set_arg_size): Likewise.
	(gimple_omp_task_arg_align_ptr): Likewise.
	(gimple_omp_task_set_arg_align): Likewise.

	* cgraphbuild.c (pass_build_cgraph_edges::execute): Replace check
	for GIMPLE_OMP_TASK with a dyn_cast, introducing local "omp_task"
	and using it in place of "stmt" for typesafety.
	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_TASK,
	introduce local "omp_task" via a checked cast, using it in place
	of "stmt" for typesafety.
	* gimple.c (gimple_copy): Likewise, introducing locals
	"omp_task_stmt" and "omp_task_copy".
	* omp-low.c (create_omp_child_function): Add a checked cast.
	(finish_taskreg_scan): Add checked casts.
	(optimize_omp_library_calls): Add a checked cast.
	(lower_depend_clauses): Strengthen param "stmt" from gimple to
	gomp_task *.
	(lower_omp_taskreg): Add a checked cast.
	* tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TASK,
	introduce local "omp_task_stmt" via a checked cast, using it in
	place of "stmt" for typesafety.
---
 gcc/ChangeLog.gimple-classes |  41 ++++++++++++++++
 gcc/cgraphbuild.c            |   6 +--
 gcc/gimple-walk.c            |  51 ++++++++++----------
 gcc/gimple.c                 |  28 ++++++-----
 gcc/gimple.h                 | 111 +++++++++++++++----------------------------
 gcc/omp-low.c                |  13 ++---
 gcc/tree-inline.c            |  21 ++++----
 7 files changed, 145 insertions(+), 126 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 10c3957..07ebee7 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,3 +1,44 @@
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
+	* gimple.h (gimple_omp_task_clauses): Strengthen param from
+	const_gimple to const gomp_task *.
+	(gimple_omp_task_child_fn): Likewise.
+	(gimple_omp_task_data_arg): Likewise.
+	(gimple_omp_task_copy_fn): Likewise.
+	(gimple_omp_task_arg_size): Likewise.
+	(gimple_omp_task_arg_align): Likewise.
+	(gimple_omp_task_clauses_ptr): Strengthen param from gimple to
+	gomp_task *.
+	(gimple_omp_task_set_clauses): Likewise.
+	(gimple_omp_task_child_fn_ptr): Likewise.
+	(gimple_omp_task_set_child_fn): Likewise.
+	(gimple_omp_task_data_arg_ptr): Likewise.
+	(gimple_omp_task_set_data_arg): Likewise.
+	(gimple_omp_task_copy_fn_ptr): Likewise.
+	(gimple_omp_task_set_copy_fn): Likewise.
+	(gimple_omp_task_arg_size_ptr): Likewise.
+	(gimple_omp_task_set_arg_size): Likewise.
+	(gimple_omp_task_arg_align_ptr): Likewise.
+	(gimple_omp_task_set_arg_align): Likewise.
+
+	* cgraphbuild.c (pass_build_cgraph_edges::execute): Replace check
+	for GIMPLE_OMP_TASK with a dyn_cast, introducing local "omp_task"
+	and using it in place of "stmt" for typesafety.
+	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_TASK,
+	introduce local "omp_task" via a checked cast, using it in place
+	of "stmt" for typesafety.
+	* gimple.c (gimple_copy): Likewise, introducing locals
+	"omp_task_stmt" and "omp_task_copy".
+	* omp-low.c (create_omp_child_function): Add a checked cast.
+	(finish_taskreg_scan): Add checked casts.
+	(optimize_omp_library_calls): Add a checked cast.
+	(lower_depend_clauses): Strengthen param "stmt" from gimple to
+	gomp_task *.
+	(lower_omp_taskreg): Add a checked cast.
+	* tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TASK,
+	introduce local "omp_task_stmt" via a checked cast, using it in
+	place of "stmt" for typesafety.
+
 2014-10-28  David Malcolm  <dmalcolm@redhat.com>
 
 	* gimple.h (gimple_try_kind): Strengthen param from const_gimple
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 32319a6..8d44002 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -369,13 +369,13 @@ pass_build_cgraph_edges::execute (function *fun)
 	      node->create_reference (cgraph_node::get_create (fn),
 				      IPA_REF_ADDR, stmt);
 	    }
-	  if (gimple_code (stmt) == GIMPLE_OMP_TASK)
+	  if (gomp_task *omp_task = dyn_cast <gomp_task *> (stmt))
 	    {
-	      tree fn = gimple_omp_task_child_fn (stmt);
+	      tree fn = gimple_omp_task_child_fn (omp_task);
 	      if (fn)
 		node->create_reference (cgraph_node::get_create (fn),
 					IPA_REF_ADDR, stmt);
-	      fn = gimple_omp_task_copy_fn (stmt);
+	      fn = gimple_omp_task_copy_fn (omp_task);
 	      if (fn)
 		node->create_reference (cgraph_node::get_create (fn),
 					IPA_REF_ADDR, stmt);
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 1248e75..020e55f 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -373,30 +373,33 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_TASK:
-      ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
+      {
+	gomp_task *omp_task = as_a <gomp_task *> (stmt);
+	ret = walk_tree (gimple_omp_task_clauses_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_task_child_fn_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_task_data_arg_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_task_copy_fn_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_task_arg_size_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_task_arg_align_ptr (omp_task), callback_op,
+			 wi, pset);
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_SECTIONS:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index c6d0f7a..7021300 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1771,18 +1771,22 @@ gimple_copy (gimple stmt)
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_TASK:
-	  t = unshare_expr (gimple_omp_task_clauses (stmt));
-	  gimple_omp_task_set_clauses (copy, t);
-	  t = unshare_expr (gimple_omp_task_child_fn (stmt));
-	  gimple_omp_task_set_child_fn (copy, t);
-	  t = unshare_expr (gimple_omp_task_data_arg (stmt));
-	  gimple_omp_task_set_data_arg (copy, t);
-	  t = unshare_expr (gimple_omp_task_copy_fn (stmt));
-	  gimple_omp_task_set_copy_fn (copy, t);
-	  t = unshare_expr (gimple_omp_task_arg_size (stmt));
-	  gimple_omp_task_set_arg_size (copy, t);
-	  t = unshare_expr (gimple_omp_task_arg_align (stmt));
-	  gimple_omp_task_set_arg_align (copy, t);
+	  {
+	    gomp_task *omp_task_stmt = as_a <gomp_task *> (stmt);
+	    gomp_task *omp_task_copy = as_a <gomp_task *> (copy);
+	    t = unshare_expr (gimple_omp_task_clauses (omp_task_stmt));
+	    gimple_omp_task_set_clauses (omp_task_copy, t);
+	    t = unshare_expr (gimple_omp_task_child_fn (omp_task_stmt));
+	    gimple_omp_task_set_child_fn (omp_task_copy, t);
+	    t = unshare_expr (gimple_omp_task_data_arg (omp_task_stmt));
+	    gimple_omp_task_set_data_arg (omp_task_copy, t);
+	    t = unshare_expr (gimple_omp_task_copy_fn (omp_task_stmt));
+	    gimple_omp_task_set_copy_fn (omp_task_copy, t);
+	    t = unshare_expr (gimple_omp_task_arg_size (omp_task_stmt));
+	    gimple_omp_task_set_arg_size (omp_task_copy, t);
+	    t = unshare_expr (gimple_omp_task_arg_align (omp_task_stmt));
+	    gimple_omp_task_set_arg_align (omp_task_copy, t);
+	  }
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_CRITICAL:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 8e82914..ef1f4f7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4707,103 +4707,87 @@ gimple_omp_parallel_set_data_arg (gomp_parallel *omp_parallel_stmt,
 }
 
 
-/* Return the clauses associated with OMP_TASK GS.  */
+/* Return the clauses associated with OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_clauses (const_gimple gs)
+gimple_omp_task_clauses (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->clauses;
 }
 
 
-/* Return a pointer to the clauses associated with OMP_TASK GS.  */
+/* Return a pointer to the clauses associated with OMP_TASK
+   OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_clauses_ptr (gimple gs)
+gimple_omp_task_clauses_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->clauses;
 }
 
 
 /* Set CLAUSES to be the list of clauses associated with OMP_TASK
-   GS.  */
+   OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_clauses (gimple gs, tree clauses)
+gimple_omp_task_set_clauses (gomp_task *omp_task_stmt, tree clauses)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->clauses = clauses;
 }
 
 
-/* Return the child function used to hold the body of OMP_TASK GS.  */
+/* Return the child function used to hold the body of OMP_TASK
+   OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_child_fn (const_gimple gs)
+gimple_omp_task_child_fn (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->child_fn;
 }
 
 /* Return a pointer to the child function used to hold the body of
-   OMP_TASK GS.  */
+   OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_child_fn_ptr (gimple gs)
+gimple_omp_task_child_fn_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->child_fn;
 }
 
 
-/* Set CHILD_FN to be the child function for OMP_TASK GS.  */
+/* Set CHILD_FN to be the child function for OMP_TASK OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
+gimple_omp_task_set_child_fn (gomp_task *omp_task_stmt, tree child_fn)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->child_fn = child_fn;
 }
 
 
 /* Return the artificial argument used to send variables and values
-   from the parent to the children threads in OMP_TASK GS.  */
+   from the parent to the children threads in OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_data_arg (const_gimple gs)
+gimple_omp_task_data_arg (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->data_arg;
 }
 
 
-/* Return a pointer to the data argument for OMP_TASK GS.  */
+/* Return a pointer to the data argument for OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_data_arg_ptr (gimple gs)
+gimple_omp_task_data_arg_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->data_arg;
 }
 
 
-/* Set DATA_ARG to be the data argument for OMP_TASK GS.  */
+/* Set DATA_ARG to be the data argument for OMP_TASK OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
+gimple_omp_task_set_data_arg (gomp_task *omp_task_stmt, tree data_arg)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->data_arg = data_arg;
 }
 
@@ -4909,101 +4893,84 @@ gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
 }
 
 
-/* Return the copy function used to hold the body of OMP_TASK GS.  */
+/* Return the copy function used to hold the body of OMP_TASK
+   OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_copy_fn (const_gimple gs)
+gimple_omp_task_copy_fn (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->copy_fn;
 }
 
 /* Return a pointer to the copy function used to hold the body of
-   OMP_TASK GS.  */
+   OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_copy_fn_ptr (gimple gs)
+gimple_omp_task_copy_fn_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->copy_fn;
 }
 
 
-/* Set CHILD_FN to be the copy function for OMP_TASK GS.  */
+/* Set CHILD_FN to be the copy function for OMP_TASK OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
+gimple_omp_task_set_copy_fn (gomp_task *omp_task_stmt, tree copy_fn)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->copy_fn = copy_fn;
 }
 
 
-/* Return size of the data block in bytes in OMP_TASK GS.  */
+/* Return size of the data block in bytes in OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_arg_size (const_gimple gs)
+gimple_omp_task_arg_size (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->arg_size;
 }
 
 
-/* Return a pointer to the data block size for OMP_TASK GS.  */
+/* Return a pointer to the data block size for OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_arg_size_ptr (gimple gs)
+gimple_omp_task_arg_size_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->arg_size;
 }
 
 
-/* Set ARG_SIZE to be the data block size for OMP_TASK GS.  */
+/* Set ARG_SIZE to be the data block size for OMP_TASK OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
+gimple_omp_task_set_arg_size (gomp_task *omp_task_stmt, tree arg_size)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->arg_size = arg_size;
 }
 
 
-/* Return align of the data block in bytes in OMP_TASK GS.  */
+/* Return align of the data block in bytes in OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree
-gimple_omp_task_arg_align (const_gimple gs)
+gimple_omp_task_arg_align (const gomp_task *omp_task_stmt)
 {
-  const gomp_task *omp_task_stmt =
-    as_a <const gomp_task *> (gs);
   return omp_task_stmt->arg_align;
 }
 
 
-/* Return a pointer to the data block align for OMP_TASK GS.  */
+/* Return a pointer to the data block align for OMP_TASK OMP_TASK_STMT.  */
 
 static inline tree *
-gimple_omp_task_arg_align_ptr (gimple gs)
+gimple_omp_task_arg_align_ptr (gomp_task *omp_task_stmt)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   return &omp_task_stmt->arg_align;
 }
 
 
-/* Set ARG_SIZE to be the data block align for OMP_TASK GS.  */
+/* Set ARG_SIZE to be the data block align for OMP_TASK OMP_TASK_STMT.  */
 
 static inline void
-gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
+gimple_omp_task_set_arg_align (gomp_task *omp_task_stmt, tree arg_align)
 {
-  gomp_task *omp_task_stmt =
-    as_a <gomp_task *> (gs);
   omp_task_stmt->arg_align = arg_align;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 0a5de1a..2f28761 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1922,7 +1922,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
   if (!task_copy)
     ctx->cb.dst_fn = decl;
   else
-    gimple_omp_task_set_copy_fn (ctx->stmt, decl);
+    gimple_omp_task_set_copy_fn (as_a <gomp_task *> (ctx->stmt), decl);
 
   TREE_STATIC (decl) = 1;
   TREE_USED (decl) = 1;
@@ -2271,10 +2271,10 @@ finish_taskreg_scan (omp_context *ctx)
 	layout_type (ctx->srecord_type);
       tree t = fold_convert_loc (loc, long_integer_type_node,
 				 TYPE_SIZE_UNIT (ctx->record_type));
-      gimple_omp_task_set_arg_size (ctx->stmt, t);
+      gimple_omp_task_set_arg_size (as_a <gomp_task *> (ctx->stmt), t);
       t = build_int_cst (long_integer_type_node,
 			 TYPE_ALIGN_UNIT (ctx->record_type));
-      gimple_omp_task_set_arg_align (ctx->stmt, t);
+      gimple_omp_task_set_arg_align (as_a <gomp_task *> (ctx->stmt), t);
     }
 }
 
@@ -4803,7 +4803,8 @@ optimize_omp_library_calls (gimple entry_stmt)
   tree num_thr_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS);
   tree num_thr_id = DECL_ASSEMBLER_NAME (num_thr_tree);
   bool untied_task = (gimple_code (entry_stmt) == GIMPLE_OMP_TASK
-		      && find_omp_clause (gimple_omp_task_clauses (entry_stmt),
+		      && find_omp_clause (gimple_omp_task_clauses (
+					    as_a <gomp_task *> (entry_stmt)),
 					  OMP_CLAUSE_UNTIED) != NULL);
 
   FOR_EACH_BB_FN (bb, cfun)
@@ -9870,7 +9871,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
 }
 
 static void
-lower_depend_clauses (gimple stmt, gimple_seq *iseq, gimple_seq *oseq)
+lower_depend_clauses (gomp_task *stmt, gimple_seq *iseq, gimple_seq *oseq)
 {
   tree c, clauses;
   gimple g;
@@ -9969,7 +9970,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
     {
       push_gimplify_context ();
       dep_bind = gimple_build_bind (NULL, NULL, make_node (BLOCK));
-      lower_depend_clauses (stmt, &dep_ilist, &dep_olist);
+      lower_depend_clauses (as_a <gomp_task *> (stmt), &dep_ilist, &dep_olist);
     }
 
   if (ctx->srecord_type)
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 0a076ce..8688a99 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1387,15 +1387,18 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_TASK:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_task
-	           (s1,
-		    gimple_omp_task_clauses (stmt),
-		    gimple_omp_task_child_fn (stmt),
-		    gimple_omp_task_data_arg (stmt),
-		    gimple_omp_task_copy_fn (stmt),
-		    gimple_omp_task_arg_size (stmt),
-		    gimple_omp_task_arg_align (stmt));
+	  {
+	    gomp_task *omp_task_stmt = as_a <gomp_task *> (stmt);
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_task_stmt), id);
+	    copy = gimple_build_omp_task
+	             (s1,
+		      gimple_omp_task_clauses (omp_task_stmt),
+		      gimple_omp_task_child_fn (omp_task_stmt),
+		      gimple_omp_task_data_arg (omp_task_stmt),
+		      gimple_omp_task_copy_fn (omp_task_stmt),
+		      gimple_omp_task_arg_size (omp_task_stmt),
+		      gimple_omp_task_arg_align (omp_task_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_FOR:
-- 
1.7.11.7

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

* [gimple-classes, committed 00/10] Even more accessor typesafety
@ 2014-10-29 18:52 David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 01/10] Make all of gimple_omp_task_ accessors typesafe David Malcolm
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

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

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

David Malcolm (10):
  Make all of gimple_omp_task_ accessors typesafe
  Make all gimple_omp_for_ accessors typesafe
  Make remaining gimple_omp_teams_ accessors typesafe
  Make all gimple_omp_sections_ accessors typesafe
  Make all gimple_omp_return_ accessors typesafe
  Convert remaining gimple_omp_single_ accessors to be typesafe
  Make remaining gimple_omp_target_ accessors typesafe
  Make remainging gimple_omp_parallel_ accessors typesafe
  Make remaining gimple_eh_filter_ accessors typesafe
  Introduce gpredict subclass and use it for all gimple_predict_
    accessors

 gcc/ChangeLog.gimple-classes | 303 +++++++++++++++++++++++++++++++
 gcc/cgraphbuild.c            |   6 +-
 gcc/coretypes.h              |   1 +
 gcc/doc/gimple.texi          |   3 +-
 gcc/gimple-low.c             |   7 +-
 gcc/gimple-pretty-print.c    |  23 ++-
 gcc/gimple-walk.c            | 153 ++++++++--------
 gcc/gimple.c                 |  87 +++++----
 gcc/gimple.h                 | 414 ++++++++++++++++---------------------------
 gcc/omp-low.c                | 325 +++++++++++++++++++--------------
 gcc/predict.c                |   7 +-
 gcc/tree-cfg.c               |   6 +-
 gcc/tree-eh.c                |  15 +-
 gcc/tree-inline.c            | 124 ++++++++-----
 gcc/tree-nested.c            | 359 ++++++++++++++++++++++---------------
 15 files changed, 1120 insertions(+), 713 deletions(-)

-- 
1.7.11.7

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

* [gimple-classes, committed 06/10] Convert remaining gimple_omp_single_ accessors to be typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 01/10] Make all of gimple_omp_task_ accessors typesafe David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 09/10] Make remaining gimple_eh_filter_ " David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 07/10] Make remaining gimple_omp_target_ accessors typesafe David Malcolm
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_single_clauses): Strengthen param from
	const_gimple to const gomp_single *.
	(gimple_omp_single_clauses_ptr): Strengthen param from gimple to
	gomp_single *.

	* gimple-walk.c (walk_gimple_op): Add checked cast.
	* tree-inline.c (remap_gimple_stmt): Within case
	GIMPLE_OMP_SINGLE, introduce local "omp_single_stmt" via a
	checked cast and use in place of "stmt".
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
---
 gcc/ChangeLog.gimple-classes | 14 ++++++++++++++
 gcc/gimple-walk.c            |  5 +++--
 gcc/gimple.h                 | 13 +++++--------
 gcc/tree-inline.c            |  9 ++++++---
 gcc/tree-nested.c            | 31 +++++++++++++++++++++----------
 5 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index d85abcd..f265a25 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,19 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_single_clauses): Strengthen param from
+	const_gimple to const gomp_single *.
+	(gimple_omp_single_clauses_ptr): Strengthen param from gimple to
+	gomp_single *.
+
+	* gimple-walk.c (walk_gimple_op): Add checked cast.
+	* tree-inline.c (remap_gimple_stmt): Within case
+	GIMPLE_OMP_SINGLE, introduce local "omp_single_stmt" via a
+	checked cast and use in place of "stmt".
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_local_reference_stmt): Likewise.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (struct gimple_statement_omp_return): Rename to...
 	(struct gomp_return): ...this.
 	(is_a_helper <gimple_statement_omp_return *>::test): Rename to...
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index ce78bea..5882fe6 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -421,8 +421,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_SINGLE:
-      ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_omp_single_clauses_ptr (
+			 as_a <gomp_single *> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6355d96..26a9c71 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4928,24 +4928,21 @@ gimple_omp_task_set_arg_align (gomp_task *omp_task_stmt, tree arg_align)
 }
 
 
-/* Return the clauses associated with OMP_SINGLE GS.  */
+/* Return the clauses associated with OMP_SINGLE OMP_SINGLE_STMT.  */
 
 static inline tree
-gimple_omp_single_clauses (const_gimple gs)
+gimple_omp_single_clauses (const gomp_single *omp_single_stmt)
 {
-  const gomp_single *omp_single_stmt =
-    as_a <const gomp_single *> (gs);
   return omp_single_stmt->clauses;
 }
 
 
-/* Return a pointer to the clauses associated with OMP_SINGLE GS.  */
+/* Return a pointer to the clauses associated with OMP_SINGLE
+   OMP_SINGLE_STMT.  */
 
 static inline tree *
-gimple_omp_single_clauses_ptr (gimple gs)
+gimple_omp_single_clauses_ptr (gomp_single *omp_single_stmt)
 {
-  gomp_single *omp_single_stmt =
-    as_a <gomp_single *> (gs);
   return &omp_single_stmt->clauses;
 }
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index bc19939..cc5c3bb 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1464,9 +1464,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_SINGLE:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_single
-	           (s1, gimple_omp_single_clauses (stmt));
+	  {
+	    gomp_single *omp_single_stmt = as_a <gomp_single *> (stmt);
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_single_stmt), id);
+	    copy = gimple_build_omp_single (
+		     s1, gimple_omp_single_clauses (omp_single_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_TARGET:
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index f0756c1..2ee8cfd 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1379,11 +1379,17 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SINGLE:
-      save_suppress = info->suppress_expansion;
-      convert_nonlocal_omp_clauses (gimple_omp_single_clauses_ptr (stmt), wi);
-      walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op,
-	         info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_single *omp_single_stmt = as_a <gomp_single *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_nonlocal_omp_clauses (gimple_omp_single_clauses_ptr (
+					omp_single_stmt),
+				      wi);
+	walk_body (convert_nonlocal_reference_stmt,
+		   convert_nonlocal_reference_op,
+		   info, gimple_omp_body_ptr (omp_single_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_TARGET:
@@ -1963,11 +1969,16 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SINGLE:
-      save_suppress = info->suppress_expansion;
-      convert_local_omp_clauses (gimple_omp_single_clauses_ptr (stmt), wi);
-      walk_body (convert_local_reference_stmt, convert_local_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_single *omp_single_stmt = as_a <gomp_single *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_local_omp_clauses (gimple_omp_single_clauses_ptr (
+				     omp_single_stmt),
+				   wi);
+	walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		   info, gimple_omp_body_ptr (omp_single_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_TARGET:
-- 
1.7.11.7

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

* [gimple-classes, committed 07/10] Make remaining gimple_omp_target_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (2 preceding siblings ...)
  2014-10-29 18:52 ` [gimple-classes, committed 06/10] Convert remaining gimple_omp_single_ accessors to be typesafe David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 02/10] Make all gimple_omp_for_ " David Malcolm
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_target_clauses): Strengthen param from
	const_gimple to const gomp_target *.
	(gimple_omp_target_kind): Likewise.
	(gimple_omp_target_clauses_ptr): Strengthen param from gimple to
	gomp_target *.

	* gimple-walk.c (walk_gimple_op): Add checked cast.
	* omp-low.c (scan_sharing_clauses): Add checked casts.
	(create_omp_child_function): Likewise.
	(check_omp_nesting_restrictions): Likewise.
	(expand_omp_target): Likewise.
	(build_omp_regions_1): Likewise.
	(make_gimple_omp_edges): Likewise.
	* tree-inline.c (remap_gimple_stmt): Within case
	GIMPLE_OMP_TARGET, introduce local "omp_target_stmt" via a checked
	cast and use it in place of "stmt" for typesafety.
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
	(convert_tramp_reference_stmt): Add checked cast.
	(convert_gimple_call): Within case GIMPLE_OMP_TARGET, introduce
	local "omp_target_stmt" via a checked cast and use it in place of
	"stmt" for typesafety.
---
 gcc/ChangeLog.gimple-classes |  25 +++++
 gcc/gimple-walk.c            |   4 +-
 gcc/gimple.h                 |  16 ++--
 gcc/omp-low.c                |  28 +++---
 gcc/tree-inline.c            |  12 ++-
 gcc/tree-nested.c            | 224 ++++++++++++++++++++++++-------------------
 6 files changed, 184 insertions(+), 125 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index f265a25..cc8b97b 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,30 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_target_clauses): Strengthen param from
+	const_gimple to const gomp_target *.
+	(gimple_omp_target_kind): Likewise.
+	(gimple_omp_target_clauses_ptr): Strengthen param from gimple to
+	gomp_target *.
+
+	* gimple-walk.c (walk_gimple_op): Add checked cast.
+	* omp-low.c (scan_sharing_clauses): Add checked casts.
+	(create_omp_child_function): Likewise.
+	(check_omp_nesting_restrictions): Likewise.
+	(expand_omp_target): Likewise.
+	(build_omp_regions_1): Likewise.
+	(make_gimple_omp_edges): Likewise.
+	* tree-inline.c (remap_gimple_stmt): Within case
+	GIMPLE_OMP_TARGET, introduce local "omp_target_stmt" via a checked
+	cast and use it in place of "stmt" for typesafety.
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_local_reference_stmt): Likewise.
+	(convert_tramp_reference_stmt): Add checked cast.
+	(convert_gimple_call): Within case GIMPLE_OMP_TARGET, introduce
+	local "omp_target_stmt" via a checked cast and use it in place of
+	"stmt" for typesafety.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_single_clauses): Strengthen param from
 	const_gimple to const gomp_single *.
 	(gimple_omp_single_clauses_ptr): Strengthen param from gimple to
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 5882fe6..1ba48c1 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -429,8 +429,8 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_TARGET:
-      ret = walk_tree (gimple_omp_target_clauses_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_omp_target_clauses_ptr (as_a <gomp_target *> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 26a9c71..3220f9a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4956,24 +4956,21 @@ gimple_omp_single_set_clauses (gomp_single *omp_single_stmt, tree clauses)
 }
 
 
-/* Return the clauses associated with OMP_TARGET GS.  */
+/* Return the clauses associated with OMP_TARGET OMP_TARGET_STMT.  */
 
 static inline tree
-gimple_omp_target_clauses (const_gimple gs)
+gimple_omp_target_clauses (const gomp_target *omp_target_stmt)
 {
-  const gomp_target *omp_target_stmt =
-    as_a <const gomp_target *> (gs);
   return omp_target_stmt->clauses;
 }
 
 
-/* Return a pointer to the clauses associated with OMP_TARGET GS.  */
+/* Return a pointer to the clauses associated with OMP_TARGET
+   OMP_TARGET_STMT.  */
 
 static inline tree *
-gimple_omp_target_clauses_ptr (gimple gs)
+gimple_omp_target_clauses_ptr (gomp_target *omp_target_stmt)
 {
-  gomp_target *omp_target_stmt =
-    as_a <gomp_target *> (gs);
   return &omp_target_stmt->clauses;
 }
 
@@ -4991,9 +4988,8 @@ gimple_omp_target_set_clauses (gomp_target *omp_target_stmt,
 /* Return the kind of OMP target statemement.  */
 
 static inline int
-gimple_omp_target_kind (const_gimple g)
+gimple_omp_target_kind (const gomp_target *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
   return (gimple_omp_subcode (g) & GF_OMP_TARGET_KIND_MASK);
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 07eed83..21eee0f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1647,7 +1647,8 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	      /* Ignore OMP_CLAUSE_MAP_POINTER kind for arrays in
 		 #pragma omp target data, there is nothing to map for
 		 those.  */
-	      if (gimple_omp_target_kind (ctx->stmt) == GF_OMP_TARGET_KIND_DATA
+	      if (gimple_omp_target_kind (as_a <gomp_target *> (ctx->stmt))
+		  == GF_OMP_TARGET_KIND_DATA
 		  && !POINTER_TYPE_P (TREE_TYPE (decl)))
 		break;
 	    }
@@ -1673,7 +1674,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 		    install_var_field (decl, true, 7, ctx);
 		  else
 		    install_var_field (decl, true, 3, ctx);
-		  if (gimple_omp_target_kind (ctx->stmt)
+		  if (gimple_omp_target_kind (as_a <gomp_target *> (ctx->stmt))
 		      == GF_OMP_TARGET_KIND_REGION)
 		    install_var_local (decl, ctx);
 		}
@@ -1774,7 +1775,8 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	  break;
 
 	case OMP_CLAUSE_MAP:
-	  if (gimple_omp_target_kind (ctx->stmt) == GF_OMP_TARGET_KIND_DATA)
+	  if (gimple_omp_target_kind (as_a <gomp_target *> (ctx->stmt))
+	      == GF_OMP_TARGET_KIND_DATA)
 	    break;
 	  decl = OMP_CLAUSE_DECL (c);
 	  if (DECL_P (decl)
@@ -1943,7 +1945,7 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
       omp_context *octx;
       for (octx = ctx; octx; octx = octx->outer)
 	if (gimple_code (octx->stmt) == GIMPLE_OMP_TARGET
-	    && gimple_omp_target_kind (octx->stmt)
+	    && gimple_omp_target_kind (as_a <gomp_target *> (octx->stmt))
 	       == GF_OMP_TARGET_KIND_REGION)
 	  {
 	    target_p = true;
@@ -2665,7 +2667,8 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
     case GIMPLE_OMP_TEAMS:
       if (ctx == NULL
 	  || gimple_code (ctx->stmt) != GIMPLE_OMP_TARGET
-	  || gimple_omp_target_kind (ctx->stmt) != GF_OMP_TARGET_KIND_REGION)
+	  || (gimple_omp_target_kind (as_a <gomp_target *> (ctx->stmt))
+	      != GF_OMP_TARGET_KIND_REGION))
 	{
 	  error_at (gimple_location (stmt),
 		    "teams construct not closely nested inside of target "
@@ -2676,10 +2679,11 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
     case GIMPLE_OMP_TARGET:
       for (; ctx != NULL; ctx = ctx->outer)
 	if (gimple_code (ctx->stmt) == GIMPLE_OMP_TARGET
-	    && gimple_omp_target_kind (ctx->stmt) == GF_OMP_TARGET_KIND_REGION)
+	    && (gimple_omp_target_kind (as_a <gomp_target *> (ctx->stmt))
+		== GF_OMP_TARGET_KIND_REGION))
 	  {
 	    const char *name;
-	    switch (gimple_omp_target_kind (stmt))
+	    switch (gimple_omp_target_kind (as_a <gomp_target *> (stmt)))
 	      {
 	      case GF_OMP_TARGET_KIND_REGION: name = "target"; break;
 	      case GF_OMP_TARGET_KIND_DATA: name = "target data"; break;
@@ -8406,8 +8410,8 @@ expand_omp_target (struct omp_region *region)
       gsi = gsi_last_bb (entry_bb);
       stmt = gsi_stmt (gsi);
       gcc_assert (stmt && gimple_code (stmt) == GIMPLE_OMP_TARGET
-		  && gimple_omp_target_kind (stmt)
-		     == GF_OMP_TARGET_KIND_REGION);
+		  && (gimple_omp_target_kind (as_a <gomp_target *> (stmt))
+		      == GF_OMP_TARGET_KIND_REGION));
       gsi_remove (&gsi, true);
       e = split_block (entry_bb, stmt);
       entry_bb = e->dest;
@@ -8749,7 +8753,8 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent,
 	  ;
 	}
       else if (code == GIMPLE_OMP_TARGET
-	       && gimple_omp_target_kind (stmt) == GF_OMP_TARGET_KIND_UPDATE)
+	       && (gimple_omp_target_kind (as_a <gomp_target *> (stmt))
+		   == GF_OMP_TARGET_KIND_UPDATE))
 	new_omp_region (bb, code, parent);
       else
 	{
@@ -11068,7 +11073,8 @@ make_gimple_omp_edges (basic_block bb, struct omp_region **region,
     case GIMPLE_OMP_TARGET:
       cur_region = new_omp_region (bb, code, cur_region);
       fallthru = true;
-      if (gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_UPDATE)
+      if (gimple_omp_target_kind (as_a <gomp_target *> (last))
+	  == GF_OMP_TARGET_KIND_UPDATE)
 	cur_region = cur_region->outer;
       break;
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index cc5c3bb..eceed15 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1473,10 +1473,14 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_TARGET:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_target
-		   (s1, gimple_omp_target_kind (stmt),
-		    gimple_omp_target_clauses (stmt));
+	  {
+	    gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_target_stmt), id);
+	    copy = gimple_build_omp_target (
+		     s1,
+		     gimple_omp_target_kind (omp_target_stmt),
+		     gimple_omp_target_clauses (omp_target_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_TEAMS:
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 2ee8cfd..57acc50 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1393,43 +1393,51 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TARGET:
-      if (gimple_omp_target_kind (stmt) != GF_OMP_TARGET_KIND_REGION)
-	{
-	  save_suppress = info->suppress_expansion;
-	  convert_nonlocal_omp_clauses (gimple_omp_target_clauses_ptr (stmt),
-					wi);
-	  info->suppress_expansion = save_suppress;
-	  walk_body (convert_nonlocal_reference_stmt,
-		     convert_nonlocal_reference_op, info,
-		     gimple_omp_body_ptr (stmt));
-	  break;
-	}
-      save_suppress = info->suppress_expansion;
-      if (convert_nonlocal_omp_clauses (gimple_omp_target_clauses_ptr (stmt),
-					wi))
-	{
-	  tree c, decl;
-	  decl = get_chain_decl (info);
-	  c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
-	  OMP_CLAUSE_DECL (c) = decl;
-	  OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TO;
-	  OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
-	  OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt);
-	  gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt), c);
-	}
+      {
+	gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
+	if (gimple_omp_target_kind (omp_target_stmt)
+	    != GF_OMP_TARGET_KIND_REGION)
+	  {
+	    save_suppress = info->suppress_expansion;
+	    convert_nonlocal_omp_clauses (gimple_omp_target_clauses_ptr (
+					    omp_target_stmt),
+					  wi);
+	    info->suppress_expansion = save_suppress;
+	    walk_body (convert_nonlocal_reference_stmt,
+		       convert_nonlocal_reference_op, info,
+		       gimple_omp_body_ptr (omp_target_stmt));
+	    break;
+	  }
+	save_suppress = info->suppress_expansion;
+	if (convert_nonlocal_omp_clauses (gimple_omp_target_clauses_ptr (
+					    omp_target_stmt),
+					  wi))
+	  {
+	    tree c, decl;
+	    decl = get_chain_decl (info);
+	    c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+	    OMP_CLAUSE_DECL (c) = decl;
+	    OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TO;
+	    OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
+	    OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (omp_target_stmt);
+	    gimple_omp_target_set_clauses (omp_target_stmt, c);
+	  }
 
-      save_local_var_chain = info->new_local_var_chain;
-      info->new_local_var_chain = NULL;
+	save_local_var_chain = info->new_local_var_chain;
+	info->new_local_var_chain = NULL;
 
-      walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
+	walk_body (convert_nonlocal_reference_stmt,
+		   convert_nonlocal_reference_op,
+		   info, gimple_omp_body_ptr (omp_target_stmt));
 
-      if (info->new_local_var_chain)
-	declare_vars (info->new_local_var_chain,
-		      gimple_seq_first_stmt (gimple_omp_body (stmt)),
-		      false);
-      info->new_local_var_chain = save_local_var_chain;
-      info->suppress_expansion = save_suppress;
+	if (info->new_local_var_chain)
+	  declare_vars (info->new_local_var_chain,
+			gimple_seq_first_stmt (gimple_omp_body (
+						 omp_target_stmt)),
+			false);
+	info->new_local_var_chain = save_local_var_chain;
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_TEAMS:
@@ -1982,39 +1990,50 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TARGET:
-      if (gimple_omp_target_kind (stmt) != GF_OMP_TARGET_KIND_REGION)
-	{
-	  save_suppress = info->suppress_expansion;
-	  convert_local_omp_clauses (gimple_omp_target_clauses_ptr (stmt), wi);
-	  info->suppress_expansion = save_suppress;
-	  walk_body (convert_local_reference_stmt, convert_local_reference_op,
-		     info, gimple_omp_body_ptr (stmt));
-	  break;
-	}
-      save_suppress = info->suppress_expansion;
-      if (convert_local_omp_clauses (gimple_omp_target_clauses_ptr (stmt), wi))
-	{
-	  tree c;
-	  (void) get_frame_type (info);
-	  c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
-	  OMP_CLAUSE_DECL (c) = info->frame_decl;
-	  OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TOFROM;
-	  OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (info->frame_decl);
-	  OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt);
-	  gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt), c);
+      {
+	gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
+	if (gimple_omp_target_kind (omp_target_stmt)
+	    != GF_OMP_TARGET_KIND_REGION)
+	  {
+	    save_suppress = info->suppress_expansion;
+	    convert_local_omp_clauses (gimple_omp_target_clauses_ptr (
+					 omp_target_stmt),
+				       wi);
+	    info->suppress_expansion = save_suppress;
+	    walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		       info, gimple_omp_body_ptr (omp_target_stmt));
+	    break;
 	}
+	save_suppress = info->suppress_expansion;
+	if (convert_local_omp_clauses (gimple_omp_target_clauses_ptr (
+					 omp_target_stmt),
+				       wi))
+	  {
+	    tree c;
+	    (void) get_frame_type (info);
+	    c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
+	    OMP_CLAUSE_DECL (c) = info->frame_decl;
+	    OMP_CLAUSE_MAP_KIND (c) = OMP_CLAUSE_MAP_TOFROM;
+	    OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (info->frame_decl);
+	    OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (omp_target_stmt);
+	    gimple_omp_target_set_clauses (omp_target_stmt, c);
+	  }
 
-      save_local_var_chain = info->new_local_var_chain;
-      info->new_local_var_chain = NULL;
+	save_local_var_chain = info->new_local_var_chain;
+	info->new_local_var_chain = NULL;
 
-      walk_body (convert_local_reference_stmt, convert_local_reference_op, info,
-		 gimple_omp_body_ptr (stmt));
+	walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		   info,
+		   gimple_omp_body_ptr (omp_target_stmt));
 
-      if (info->new_local_var_chain)
-	declare_vars (info->new_local_var_chain,
-		      gimple_seq_first_stmt (gimple_omp_body (stmt)), false);
-      info->new_local_var_chain = save_local_var_chain;
-      info->suppress_expansion = save_suppress;
+	if (info->new_local_var_chain)
+	  declare_vars (info->new_local_var_chain,
+			gimple_seq_first_stmt (gimple_omp_body (
+						 omp_target_stmt)),
+			false);
+	info->new_local_var_chain = save_local_var_chain;
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_TEAMS:
@@ -2320,7 +2339,8 @@ convert_tramp_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       }
 
     case GIMPLE_OMP_TARGET:
-      if (gimple_omp_target_kind (stmt) != GF_OMP_TARGET_KIND_REGION)
+      if (gimple_omp_target_kind (as_a <gomp_target *> (stmt))
+	  != GF_OMP_TARGET_KIND_REGION)
 	{
 	  *handled_ops_p = false;
 	  return NULL_TREE;
@@ -2419,40 +2439,48 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TARGET:
-      if (gimple_omp_target_kind (stmt) != GF_OMP_TARGET_KIND_REGION)
-	{
-	  walk_body (convert_gimple_call, NULL, info, gimple_omp_body_ptr (stmt));
-	  break;
-	}
-      save_static_chain_added = info->static_chain_added;
-      info->static_chain_added = 0;
-      walk_body (convert_gimple_call, NULL, info, gimple_omp_body_ptr (stmt));
-      for (i = 0; i < 2; i++)
-	{
-	  tree c, decl;
-	  if ((info->static_chain_added & (1 << i)) == 0)
-	    continue;
-	  decl = i ? get_chain_decl (info) : info->frame_decl;
-	  /* Don't add CHAIN.* or FRAME.* twice.  */
-	  for (c = gimple_omp_target_clauses (stmt);
-	       c;
-	       c = OMP_CLAUSE_CHAIN (c))
-	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
-		&& OMP_CLAUSE_DECL (c) == decl)
-	      break;
-	  if (c == NULL)
-	    {
-	      c = build_omp_clause (gimple_location (stmt), OMP_CLAUSE_MAP);
-	      OMP_CLAUSE_DECL (c) = decl;
-	      OMP_CLAUSE_MAP_KIND (c)
-		= i ? OMP_CLAUSE_MAP_TO : OMP_CLAUSE_MAP_TOFROM;
-	      OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
-	      OMP_CLAUSE_CHAIN (c) = gimple_omp_target_clauses (stmt);
-	      gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt),
-					     c);
-	    }
-	}
-      info->static_chain_added |= save_static_chain_added;
+      {
+	gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
+	if (gimple_omp_target_kind (omp_target_stmt)
+	    != GF_OMP_TARGET_KIND_REGION)
+	  {
+	    walk_body (convert_gimple_call, NULL, info,
+		       gimple_omp_body_ptr (omp_target_stmt));
+	    break;
+	  }
+	save_static_chain_added = info->static_chain_added;
+	info->static_chain_added = 0;
+	walk_body (convert_gimple_call, NULL, info,
+		   gimple_omp_body_ptr (omp_target_stmt));
+	for (i = 0; i < 2; i++)
+	  {
+	    tree c, decl;
+	    if ((info->static_chain_added & (1 << i)) == 0)
+	      continue;
+	    decl = i ? get_chain_decl (info) : info->frame_decl;
+	    /* Don't add CHAIN.* or FRAME.* twice.  */
+	    for (c = gimple_omp_target_clauses (omp_target_stmt);
+		 c;
+		 c = OMP_CLAUSE_CHAIN (c))
+	      if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+		  && OMP_CLAUSE_DECL (c) == decl)
+		break;
+	    if (c == NULL)
+	      {
+		c = build_omp_clause (gimple_location (omp_target_stmt),
+				      OMP_CLAUSE_MAP);
+		OMP_CLAUSE_DECL (c) = decl;
+		OMP_CLAUSE_MAP_KIND (c)
+		  = i ? OMP_CLAUSE_MAP_TO : OMP_CLAUSE_MAP_TOFROM;
+		OMP_CLAUSE_SIZE (c) = DECL_SIZE_UNIT (decl);
+		OMP_CLAUSE_CHAIN (c) =
+		  gimple_omp_target_clauses (omp_target_stmt);
+		gimple_omp_target_set_clauses (omp_target_stmt,
+					       c);
+	      }
+	  }
+	info->static_chain_added |= save_static_chain_added;
+      }
       break;
 
     case GIMPLE_OMP_FOR:
-- 
1.7.11.7

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

* [gimple-classes, committed 09/10] Make remaining gimple_eh_filter_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 01/10] Make all of gimple_omp_task_ accessors typesafe David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 06/10] Convert remaining gimple_omp_single_ accessors to be typesafe David Malcolm
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_eh_filter_types): Strengthen param from
	const_gimple to const geh_filter *.
	(gimple_eh_filter_types_ptr): Strengthen param from gimple to
	geh_filter *.
	(gimple_eh_filter_failure_ptr): Likewise.
	(gimple_eh_filter_failure): Likewise.

	* gimple-low.c (lower_try_catch): Add a checked cast.
	(gimple_try_catch_may_fallthru): Likewise.
	* gimple-walk.c (walk_gimple_op): Likewise.
	(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.
	(lower_eh_filter): Strengthen local "inner" from gimple to
	geh_filter * via a checked cast.
	(refactor_eh_r): Add a checked cast.
	* tree-inline.c (remap_gimple_stmt): Within case
	GIMPLE_EH_FILTER, introduce local "filter_stmt" via a checked cast
	and use in place of "stmt".
	(estimate_num_insns): Add checked cast.
---
 gcc/ChangeLog.gimple-classes | 26 ++++++++++++++++++++++++++
 gcc/gimple-low.c             |  7 +++++--
 gcc/gimple-walk.c            |  9 +++++----
 gcc/gimple.h                 | 18 ++++++------------
 gcc/omp-low.c                |  3 ++-
 gcc/tree-cfg.c               |  6 ++++--
 gcc/tree-eh.c                | 15 ++++++++++-----
 gcc/tree-inline.c            | 12 +++++++++---
 8 files changed, 67 insertions(+), 29 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index e8001f4..07c12cd 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,31 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_eh_filter_types): Strengthen param from
+	const_gimple to const geh_filter *.
+	(gimple_eh_filter_types_ptr): Strengthen param from gimple to
+	geh_filter *.
+	(gimple_eh_filter_failure_ptr): Likewise.
+	(gimple_eh_filter_failure): Likewise.
+
+	* gimple-low.c (lower_try_catch): Add a checked cast.
+	(gimple_try_catch_may_fallthru): Likewise.
+	* gimple-walk.c (walk_gimple_op): Likewise.
+	(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.
+	(lower_eh_filter): Strengthen local "inner" from gimple to
+	geh_filter * via a checked cast.
+	(refactor_eh_r): Add a checked cast.
+	* tree-inline.c (remap_gimple_stmt): Within case
+	GIMPLE_EH_FILTER, introduce local "filter_stmt" via a checked cast
+	and use in place of "stmt".
+	(estimate_num_insns): Add checked cast.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_parallel_combined_p): Strengthen param from
 	const_gimple to const gomp_parallel *.
 	(gimple_omp_parallel_clauses): Likewise.
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 0aec000..a30fae5 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -485,7 +485,9 @@ lower_try_catch (gimple_stmt_iterator *gsi, struct lower_data *data)
 	 so we just ignore EH_FILTER_TYPES and assume that we might
 	 throw an exception which doesn't match.  */
       data->cannot_fallthru = false;
-      lower_sequence (gimple_eh_filter_failure_ptr (gsi_stmt (i)), data);
+      lower_sequence (gimple_eh_filter_failure_ptr (
+			as_a <geh_filter *> (gsi_stmt (i))),
+		      data);
       if (!data->cannot_fallthru)
 	cannot_fallthru = false;
       break;
@@ -546,7 +548,8 @@ gimple_try_catch_may_fallthru (gtry *stmt)
 	 will throw an exception which matches EH_FILTER_TYPES or not,
 	 so we just ignore EH_FILTER_TYPES and assume that we might
 	 throw an exception which doesn't match.  */
-      return gimple_seq_may_fallthru (gimple_eh_filter_failure (gsi_stmt (i)));
+      return gimple_seq_may_fallthru (gimple_eh_filter_failure (
+					as_a <geh_filter *> (gsi_stmt (i))));
 
     default:
       /* This case represents statements to be executed when an
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 1ba48c1..767e584 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -293,8 +293,8 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_EH_FILTER:
-      ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_eh_filter_types_ptr (as_a <geh_filter *> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
@@ -589,8 +589,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_EH_FILTER:
-      ret = walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt), callback_stmt,
-		             callback_op, wi);
+      ret = walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (
+				   as_a <geh_filter *> (stmt)),
+				 callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
       break;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 4e86476..0b09165 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3535,25 +3535,21 @@ gimple_catch_set_handler (gcatch *catch_stmt, gimple_seq handler)
 }
 
 
-/* Return the types handled by GIMPLE_EH_FILTER statement GS.  */
+/* Return the types handled by GIMPLE_EH_FILTER statement EH_FILTER_STMT.  */
 
 static inline tree
-gimple_eh_filter_types (const_gimple gs)
+gimple_eh_filter_types (const geh_filter *eh_filter_stmt)
 {
-  const geh_filter *eh_filter_stmt =
-    as_a <const geh_filter *> (gs);
   return eh_filter_stmt->types;
 }
 
 
 /* Return a pointer to the types handled by GIMPLE_EH_FILTER statement
-   GS.  */
+   EH_FILTER_STMT.  */
 
 static inline tree *
-gimple_eh_filter_types_ptr (gimple gs)
+gimple_eh_filter_types_ptr (geh_filter *eh_filter_stmt)
 {
-  geh_filter *eh_filter_stmt =
-    as_a <geh_filter *> (gs);
   return &eh_filter_stmt->types;
 }
 
@@ -3562,10 +3558,8 @@ gimple_eh_filter_types_ptr (gimple gs)
    GIMPLE_EH_FILTER statement fails.  */
 
 static inline gimple_seq *
-gimple_eh_filter_failure_ptr (gimple gs)
+gimple_eh_filter_failure_ptr (geh_filter *eh_filter_stmt)
 {
-  geh_filter *eh_filter_stmt =
-    as_a <geh_filter *> (gs);
   return &eh_filter_stmt->failure;
 }
 
@@ -3574,7 +3568,7 @@ gimple_eh_filter_failure_ptr (gimple gs)
    statement fails.  */
 
 static inline gimple_seq
-gimple_eh_filter_failure (gimple gs)
+gimple_eh_filter_failure (geh_filter *gs)
 {
   return *gimple_eh_filter_failure_ptr (gs);
 }
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 6e0db88..b411e64 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10548,7 +10548,8 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       lower_omp (gimple_catch_handler_ptr (as_a <gcatch *> (stmt)), ctx);
       break;
     case GIMPLE_EH_FILTER:
-      lower_omp (gimple_eh_filter_failure_ptr (stmt), ctx);
+      lower_omp (gimple_eh_filter_failure_ptr (as_a <geh_filter *> (stmt)),
+		 ctx);
       break;
     case GIMPLE_TRY:
       {
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index ee3432d..b0df8b6 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4688,7 +4688,8 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
 	  break;
 
 	case GIMPLE_EH_FILTER:
-	  err |= verify_gimple_in_seq_2 (gimple_eh_filter_failure (stmt));
+	  err |= verify_gimple_in_seq_2 (gimple_eh_filter_failure (
+					   as_a <geh_filter *> (stmt)));
 	  break;
 
 	case GIMPLE_EH_ELSE:
@@ -8438,7 +8439,8 @@ do_warn_unused_result (gimple_seq seq)
 				   as_a <gcatch *> (g)));
 	  break;
 	case GIMPLE_EH_FILTER:
-	  do_warn_unused_result (gimple_eh_filter_failure (g));
+	  do_warn_unused_result (gimple_eh_filter_failure (
+				   as_a <geh_filter *> (g)));
 	  break;
 
 	case GIMPLE_CALL:
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 77fb9a2..4974051 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -283,7 +283,9 @@ collect_finally_tree (gimple stmt, gtry *region)
       break;
 
     case GIMPLE_EH_FILTER:
-      collect_finally_tree_1 (gimple_eh_filter_failure (stmt), region);
+      collect_finally_tree_1 (gimple_eh_filter_failure  (
+				as_a <geh_filter *> (stmt)),
+			      region);
       break;
 
     case GIMPLE_EH_ELSE:
@@ -546,7 +548,9 @@ replace_goto_queue_1 (gimple stmt, struct leh_tf_state *tf,
 				    tf);
       break;
     case GIMPLE_EH_FILTER:
-      replace_goto_queue_stmt_list (gimple_eh_filter_failure_ptr (stmt), tf);
+      replace_goto_queue_stmt_list (gimple_eh_filter_failure_ptr (
+				      as_a <geh_filter *> (stmt)),
+				    tf);
       break;
     case GIMPLE_EH_ELSE:
       {
@@ -1849,10 +1853,11 @@ lower_eh_filter (struct leh_state *state, gtry *tp)
 {
   struct leh_state this_state = *state;
   eh_region this_region = NULL;
-  gimple inner, x;
+  geh_filter *inner;
+  gimple x;
   gimple_seq new_seq;
 
-  inner = gimple_seq_first_stmt (gimple_try_cleanup (tp));
+  inner = as_a <geh_filter *> (gimple_seq_first_stmt (gimple_try_cleanup (tp)));
 
   if (flag_exceptions)
     {
@@ -3109,7 +3114,7 @@ refactor_eh_r (gimple_seq seq)
 	    refactor_eh_r (gimple_catch_handler (as_a <gcatch *> (one)));
 	    break;
 	  case GIMPLE_EH_FILTER:
-	    refactor_eh_r (gimple_eh_filter_failure (one));
+	    refactor_eh_r (gimple_eh_filter_failure (as_a <geh_filter *> (one)));
 	    break;
 	  case GIMPLE_EH_ELSE:
 	    {
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index eceed15..9cd25c6 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1354,8 +1354,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_EH_FILTER:
-	  s1 = remap_gimple_seq (gimple_eh_filter_failure (stmt), id);
-	  copy = gimple_build_eh_filter (gimple_eh_filter_types (stmt), s1);
+	  {
+	    geh_filter *filter_stmt = as_a <geh_filter *> (stmt);
+	    s1 = remap_gimple_seq (gimple_eh_filter_failure (filter_stmt), id);
+	    copy = gimple_build_eh_filter (gimple_eh_filter_types (filter_stmt),
+					   s1);
+	  }
 	  break;
 
 	case GIMPLE_TRY:
@@ -4030,7 +4034,9 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
 	       weights);
 
     case GIMPLE_EH_FILTER:
-      return estimate_num_insns_seq (gimple_eh_filter_failure (stmt), weights);
+      return estimate_num_insns_seq (gimple_eh_filter_failure (
+				       as_a <geh_filter *> (stmt)),
+				     weights);
 
     case GIMPLE_CATCH:
       return estimate_num_insns_seq (gimple_catch_handler (
-- 
1.7.11.7

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

* [gimple-classes, committed 02/10] Make all gimple_omp_for_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (3 preceding siblings ...)
  2014-10-29 18:52 ` [gimple-classes, committed 07/10] Make remaining gimple_omp_target_ accessors typesafe David Malcolm
@ 2014-10-29 18:52 ` David Malcolm
  2014-10-29 18:52 ` [gimple-classes, committed 04/10] Make all gimple_omp_sections_ " David Malcolm
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 18:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_for_kind): Strengthen param from
	const_gimple to const gomp_for *.
	(gimple_omp_for_combined_p): Likewise.
	(gimple_omp_for_combined_into_p): Likewise.
	(gimple_omp_for_clauses): Likewise.
	(gimple_omp_for_index): Likewise.
	(gimple_omp_for_initial): Likewise.
	(gimple_omp_for_final): Likewise.
	(gimple_omp_for_incr): Likewise.
	(gimple_omp_for_pre_body): Likewise.
	(gimple_omp_for_cond): Likewise.
	(gimple_omp_for_clauses_ptr): Strengthen param from gimple to
	gomp_for *.
	(gimple_omp_for_set_clauses): Likewise.
	(gimple_omp_for_index_ptr): Likewise.
	(gimple_omp_for_set_index): Likewise.
	(gimple_omp_for_initial_ptr): Likewise.
	(gimple_omp_for_set_initial): Likewise.
	(gimple_omp_for_final_ptr): Likewise.
	(gimple_omp_for_set_final): Likewise.
	(gimple_omp_for_incr_ptr): Likewise.
	(gimple_omp_for_set_incr): Likewise.
	(gimple_omp_for_pre_body_ptr): Likewise.
	(gimple_omp_for_set_pre_body): Likewise.
	(gimple_omp_for_set_cond): Likewise.
	(gimple_omp_for_collapse): Strengthen param from gimple to
	const gomp_for *.

	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_FOR,
	introduce local "omp_for_stmt" via a checked cast and use it in
	place of "stmt" for typesafety.
	(walk_gimple_stmt): Add checked cast.
	* gimple.c (gimple_copy): Within case GIMPLE_OMP_FOR, introduce
	locals "omp_for_stmt" and "omp_for_copy" via checked casts and use
	them in place of "stmt" and "copy" for typesafety.
	* omp-low.c (determine_parallel_type): Add a checked cast.
	(build_outer_var_ref): Likewise.
	(find_combined_for): Within case GIMPLE_OMP_FOR,
	introduce local "omp_for_stmt" via a checked cast and use it in
	place of "stmt" for typesafety.
	(check_omp_nesting_restrictions): Add checked casts.
	(check_omp_nesting_restrictions): Likewise.  Within
	case GIMPLE_OMP_FOR, introduce local "omp_for_stmt" via a checked
	cast and use it in place of "stmt" for typesafety.
	(scan_omp_1_stmt): Add checked cast.
	(lower_rec_simd_input_clauses): Likewise.
	(lower_rec_input_clauses): Likewise.  Introduce two locals named
	"omp_for_ctx_stmt" via checked casts and use them in place of
	"ctx->stmt" for typesafety.
	(lower_lastprivate_clauses): Add checked cast.
	(lower_reduction_clauses): Likewise.
	(expand_omp_for_init_vars): Likewise.
	(expand_omp_for_generic): Introduce local "omp_for_inner_stmt" via
	a checked cast and use in place of "inner_stmt" for typesafety.
	(expand_omp_for_static_nochunk): Add checked cast.
	(expand_omp_for_static_chunk): Likewise.
	(expand_omp_for): Introduce local "omp_for_stmt" via a checked
	cast and use in place of "last_stmt (region->entry)" for
	typesafety.
	(expand_omp): Add a checked cast.
	(diagnose_sb_0): Add checked casts.
	(diagnose_sb_1): Within	case GIMPLE_OMP_FOR, introduce local
	"omp_for_stmt" via a checked cast and use it in place of "stmt" for
	typesafety.
	(diagnose_sb_2): Likewise.
	* tree-inline.c (remap_gimple_stmt): Likewise, introducing locals
	"omp_for_stmt" and "omp_for_copy", using in place of "stmt" and
	"copy".
	(estimate_num_insns): Likewise, introducing local "omp_for_stmt"
	for use in place of "stmt".
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
	(convert_gimple_call): Add a checked cast.
---
 gcc/ChangeLog.gimple-classes |  76 ++++++++++++++++++++
 gcc/gimple-walk.c            |  54 +++++++-------
 gcc/gimple.c                 |  39 +++++-----
 gcc/gimple.h                 | 136 ++++++++++++-----------------------
 gcc/omp-low.c                | 167 ++++++++++++++++++++++++++-----------------
 gcc/tree-inline.c            |  52 +++++++++-----
 gcc/tree-nested.c            |  42 ++++++-----
 7 files changed, 330 insertions(+), 236 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 07ebee7..68add33 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,81 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_for_kind): Strengthen param from
+	const_gimple to const gomp_for *.
+	(gimple_omp_for_combined_p): Likewise.
+	(gimple_omp_for_combined_into_p): Likewise.
+	(gimple_omp_for_clauses): Likewise.
+	(gimple_omp_for_index): Likewise.
+	(gimple_omp_for_initial): Likewise.
+	(gimple_omp_for_final): Likewise.
+	(gimple_omp_for_incr): Likewise.
+	(gimple_omp_for_pre_body): Likewise.
+	(gimple_omp_for_cond): Likewise.
+	(gimple_omp_for_clauses_ptr): Strengthen param from gimple to
+	gomp_for *.
+	(gimple_omp_for_set_clauses): Likewise.
+	(gimple_omp_for_index_ptr): Likewise.
+	(gimple_omp_for_set_index): Likewise.
+	(gimple_omp_for_initial_ptr): Likewise.
+	(gimple_omp_for_set_initial): Likewise.
+	(gimple_omp_for_final_ptr): Likewise.
+	(gimple_omp_for_set_final): Likewise.
+	(gimple_omp_for_incr_ptr): Likewise.
+	(gimple_omp_for_set_incr): Likewise.
+	(gimple_omp_for_pre_body_ptr): Likewise.
+	(gimple_omp_for_set_pre_body): Likewise.
+	(gimple_omp_for_set_cond): Likewise.
+	(gimple_omp_for_collapse): Strengthen param from gimple to
+	const gomp_for *.
+
+	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_OMP_FOR,
+	introduce local "omp_for_stmt" via a checked cast and use it in
+	place of "stmt" for typesafety.
+	(walk_gimple_stmt): Add checked cast.
+	* gimple.c (gimple_copy): Within case GIMPLE_OMP_FOR, introduce
+	locals "omp_for_stmt" and "omp_for_copy" via checked casts and use
+	them in place of "stmt" and "copy" for typesafety.
+	* omp-low.c (determine_parallel_type): Add a checked cast.
+	(build_outer_var_ref): Likewise.
+	(find_combined_for): Within case GIMPLE_OMP_FOR,
+	introduce local "omp_for_stmt" via a checked cast and use it in
+	place of "stmt" for typesafety.
+	(check_omp_nesting_restrictions): Add checked casts.
+	(check_omp_nesting_restrictions): Likewise.  Within
+	case GIMPLE_OMP_FOR, introduce local "omp_for_stmt" via a checked
+	cast and use it in place of "stmt" for typesafety.
+	(scan_omp_1_stmt): Add checked cast.
+	(lower_rec_simd_input_clauses): Likewise.
+	(lower_rec_input_clauses): Likewise.  Introduce two locals named
+	"omp_for_ctx_stmt" via checked casts and use them in place of
+	"ctx->stmt" for typesafety.
+	(lower_lastprivate_clauses): Add checked cast.
+	(lower_reduction_clauses): Likewise.
+	(expand_omp_for_init_vars): Likewise.
+	(expand_omp_for_generic): Introduce local "omp_for_inner_stmt" via
+	a checked cast and use in place of "inner_stmt" for typesafety.
+	(expand_omp_for_static_nochunk): Add checked cast.
+	(expand_omp_for_static_chunk): Likewise.
+	(expand_omp_for): Introduce local "omp_for_stmt" via a checked
+	cast and use in place of "last_stmt (region->entry)" for
+	typesafety.
+	(expand_omp): Add a checked cast.
+	(diagnose_sb_0): Add checked casts.
+	(diagnose_sb_1): Within	case GIMPLE_OMP_FOR, introduce local
+	"omp_for_stmt" via a checked cast and use it in place of "stmt" for
+	typesafety.
+	(diagnose_sb_2): Likewise.
+	* tree-inline.c (remap_gimple_stmt): Likewise, introducing locals
+	"omp_for_stmt" and "omp_for_copy", using in place of "stmt" and
+	"copy".
+	(estimate_num_insns): Likewise, introducing local "omp_for_stmt"
+	for use in place of "stmt".
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_local_reference_stmt): Likewise.
+	(convert_gimple_call): Add a checked cast.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_task_clauses): Strengthen param from
 	const_gimple to const gomp_task *.
 	(gimple_omp_task_child_fn): Likewise.
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 020e55f..28648c4 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -329,29 +329,32 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_FOR:
-      ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi,
-		       pset);
-      if (ret)
-	return ret;
-      for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
-	{
-	  ret = walk_tree (gimple_omp_for_index_ptr (stmt, i), callback_op,
-			   wi, pset);
-	  if (ret)
-	    return ret;
-	  ret = walk_tree (gimple_omp_for_initial_ptr (stmt, i), callback_op,
-			   wi, pset);
-	  if (ret)
-	    return ret;
-	  ret = walk_tree (gimple_omp_for_final_ptr (stmt, i), callback_op,
-			   wi, pset);
-	  if (ret)
-	    return ret;
-	  ret = walk_tree (gimple_omp_for_incr_ptr (stmt, i), callback_op,
-			   wi, pset);
-	}
-      if (ret)
-	return ret;
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	ret = walk_tree (gimple_omp_for_clauses_ptr (omp_for_stmt), callback_op, wi,
+			 pset);
+	if (ret)
+	  return ret;
+	for (i = 0; i < gimple_omp_for_collapse (omp_for_stmt); i++)
+	  {
+	    ret = walk_tree (gimple_omp_for_index_ptr (omp_for_stmt, i),
+			     callback_op, wi, pset);
+	    if (ret)
+	      return ret;
+	    ret = walk_tree (gimple_omp_for_initial_ptr (omp_for_stmt, i),
+			     callback_op, wi, pset);
+	    if (ret)
+	      return ret;
+	    ret = walk_tree (gimple_omp_for_final_ptr (omp_for_stmt, i),
+			     callback_op, wi, pset);
+	    if (ret)
+	      return ret;
+	    ret = walk_tree (gimple_omp_for_incr_ptr (omp_for_stmt, i),
+			     callback_op, wi, pset);
+	  }
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_PARALLEL:
@@ -619,8 +622,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_OMP_FOR:
-      ret = walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt), callback_stmt,
-		             callback_op, wi);
+      ret = walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (
+				   as_a <gomp_for *> (stmt)),
+				 callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
 
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 7021300..f02930d 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1731,28 +1731,29 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_OMP_FOR:
-	  new_seq = gimple_seq_copy (gimple_omp_for_pre_body (stmt));
-	  gimple_omp_for_set_pre_body (copy, new_seq);
-	  t = unshare_expr (gimple_omp_for_clauses (stmt));
-	  gimple_omp_for_set_clauses (copy, t);
 	  {
+	    gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
 	    gomp_for *omp_for_copy = as_a <gomp_for *> (copy);
+	    new_seq = gimple_seq_copy (gimple_omp_for_pre_body (omp_for_stmt));
+	    gimple_omp_for_set_pre_body (omp_for_copy, new_seq);
+	    t = unshare_expr (gimple_omp_for_clauses (omp_for_stmt));
+	    gimple_omp_for_set_clauses (omp_for_copy, t);
 	    omp_for_copy->iter = ggc_vec_alloc<gimple_omp_for_iter>
-	      ( gimple_omp_for_collapse (stmt));
-          }
-	  for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
-	    {
-	      gimple_omp_for_set_cond (copy, i,
-				       gimple_omp_for_cond (stmt, i));
-	      gimple_omp_for_set_index (copy, i,
-					gimple_omp_for_index (stmt, i));
-	      t = unshare_expr (gimple_omp_for_initial (stmt, i));
-	      gimple_omp_for_set_initial (copy, i, t);
-	      t = unshare_expr (gimple_omp_for_final (stmt, i));
-	      gimple_omp_for_set_final (copy, i, t);
-	      t = unshare_expr (gimple_omp_for_incr (stmt, i));
-	      gimple_omp_for_set_incr (copy, i, t);
-	    }
+	      ( gimple_omp_for_collapse (omp_for_stmt));
+	    for (i = 0; i < gimple_omp_for_collapse (omp_for_stmt); i++)
+	      {
+		gimple_omp_for_set_cond (omp_for_copy, i,
+					 gimple_omp_for_cond (omp_for_stmt, i));
+		gimple_omp_for_set_index (omp_for_copy, i,
+					  gimple_omp_for_index (omp_for_stmt, i));
+		t = unshare_expr (gimple_omp_for_initial (omp_for_stmt, i));
+		gimple_omp_for_set_initial (omp_for_copy, i, t);
+		t = unshare_expr (gimple_omp_for_final (omp_for_stmt, i));
+		gimple_omp_for_set_final (omp_for_copy, i, t);
+		t = unshare_expr (gimple_omp_for_incr (omp_for_stmt, i));
+		gimple_omp_for_set_incr (omp_for_copy, i, t);
+	      }
+	  }
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_PARALLEL:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index ef1f4f7..6df9dbf 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4333,9 +4333,8 @@ gimple_omp_critical_set_name (gomp_critical *crit_stmt, tree name)
 /* Return the kind of OMP for statemement.  */
 
 static inline int
-gimple_omp_for_kind (const_gimple g)
+gimple_omp_for_kind (const gomp_for *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   return (gimple_omp_subcode (g) & GF_OMP_FOR_KIND_MASK);
 }
 
@@ -4354,9 +4353,8 @@ gimple_omp_for_set_kind (gomp_for *g, int kind)
    GF_OMP_FOR_COMBINED flag set.  */
 
 static inline bool
-gimple_omp_for_combined_p (const_gimple g)
+gimple_omp_for_combined_p (const gomp_for *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED) != 0;
 }
 
@@ -4378,9 +4376,8 @@ gimple_omp_for_set_combined_p (gomp_for *g, bool combined_p)
    GF_OMP_FOR_COMBINED_INTO flag set.  */
 
 static inline bool
-gimple_omp_for_combined_into_p (const_gimple g)
+gimple_omp_for_combined_into_p (const gomp_for *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   return (gimple_omp_subcode (g) & GF_OMP_FOR_COMBINED_INTO) != 0;
 }
 
@@ -4398,224 +4395,189 @@ gimple_omp_for_set_combined_into_p (gomp_for *g, bool combined_p)
 }
 
 
-/* Return the clauses associated with OMP_FOR GS.  */
+/* Return the clauses associated with OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree
-gimple_omp_for_clauses (const_gimple gs)
+gimple_omp_for_clauses (const gomp_for *omp_for_stmt)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   return omp_for_stmt->clauses;
 }
 
 
-/* Return a pointer to the OMP_FOR GS.  */
+/* Return a pointer to the OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree *
-gimple_omp_for_clauses_ptr (gimple gs)
+gimple_omp_for_clauses_ptr (gomp_for *omp_for_stmt)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   return &omp_for_stmt->clauses;
 }
 
 
-/* Set CLAUSES to be the list of clauses associated with OMP_FOR GS.  */
+/* Set CLAUSES to be the list of clauses associated with OMP_FOR
+   OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_clauses (gimple gs, tree clauses)
+gimple_omp_for_set_clauses (gomp_for *omp_for_stmt, tree clauses)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   omp_for_stmt->clauses = clauses;
 }
 
 
-/* Get the collapse count of OMP_FOR GS.  */
+/* Get the collapse count of OMP_FOR OMP_FOR_STMT.  */
 
 static inline size_t
-gimple_omp_for_collapse (gimple gs)
+gimple_omp_for_collapse (const gomp_for *omp_for_stmt)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   return omp_for_stmt->collapse;
 }
 
 
-/* Return the index variable for OMP_FOR GS.  */
+/* Return the index variable for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree
-gimple_omp_for_index (const_gimple gs, size_t i)
+gimple_omp_for_index (const gomp_for *omp_for_stmt, size_t i)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].index;
 }
 
 
-/* Return a pointer to the index variable for OMP_FOR GS.  */
+/* Return a pointer to the index variable for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree *
-gimple_omp_for_index_ptr (gimple gs, size_t i)
+gimple_omp_for_index_ptr (gomp_for *omp_for_stmt, size_t i)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].index;
 }
 
 
-/* Set INDEX to be the index variable for OMP_FOR GS.  */
+/* Set INDEX to be the index variable for OMP_FOR OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_index (gimple gs, size_t i, tree index)
+gimple_omp_for_set_index (gomp_for *omp_for_stmt, size_t i, tree index)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].index = index;
 }
 
 
-/* Return the initial value for OMP_FOR GS.  */
+/* Return the initial value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree
-gimple_omp_for_initial (const_gimple gs, size_t i)
+gimple_omp_for_initial (const gomp_for *omp_for_stmt, size_t i)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].initial;
 }
 
 
-/* Return a pointer to the initial value for OMP_FOR GS.  */
+/* Return a pointer to the initial value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree *
-gimple_omp_for_initial_ptr (gimple gs, size_t i)
+gimple_omp_for_initial_ptr (gomp_for *omp_for_stmt, size_t i)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].initial;
 }
 
 
-/* Set INITIAL to be the initial value for OMP_FOR GS.  */
+/* Set INITIAL to be the initial value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
+gimple_omp_for_set_initial (gomp_for *omp_for_stmt, size_t i, tree initial)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].initial = initial;
 }
 
 
-/* Return the final value for OMP_FOR GS.  */
+/* Return the final value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree
-gimple_omp_for_final (const_gimple gs, size_t i)
+gimple_omp_for_final (const gomp_for *omp_for_stmt, size_t i)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].final;
 }
 
 
-/* Return a pointer to the final value for OMP_FOR GS.  */
+/* Return a pointer to the final value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree *
-gimple_omp_for_final_ptr (gimple gs, size_t i)
+gimple_omp_for_final_ptr (gomp_for *omp_for_stmt, size_t i)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].final;
 }
 
 
-/* Set FINAL to be the final value for OMP_FOR GS.  */
+/* Set FINAL to be the final value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_final (gimple gs, size_t i, tree final)
+gimple_omp_for_set_final (gomp_for *omp_for_stmt, size_t i, tree final)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].final = final;
 }
 
 
-/* Return the increment value for OMP_FOR GS.  */
+/* Return the increment value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree
-gimple_omp_for_incr (const_gimple gs, size_t i)
+gimple_omp_for_incr (const gomp_for *omp_for_stmt, size_t i)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].incr;
 }
 
 
-/* Return a pointer to the increment value for OMP_FOR GS.  */
+/* Return a pointer to the increment value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline tree *
-gimple_omp_for_incr_ptr (gimple gs, size_t i)
+gimple_omp_for_incr_ptr (gomp_for *omp_for_stmt, size_t i)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].incr;
 }
 
 
-/* Set INCR to be the increment value for OMP_FOR GS.  */
+/* Set INCR to be the increment value for OMP_FOR OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
+gimple_omp_for_set_incr (gomp_for *omp_for_stmt, size_t i, tree incr)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].incr = incr;
 }
 
 
 /* Return a pointer to the sequence of statements to execute before the OMP_FOR
-   statement GS starts.  */
+   statement OMP_FOR_STMT starts.  */
 
 static inline gimple_seq *
-gimple_omp_for_pre_body_ptr (gimple gs)
+gimple_omp_for_pre_body_ptr (gomp_for *omp_for_stmt)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   return &omp_for_stmt->pre_body;
 }
 
 
 /* Return the sequence of statements to execute before the OMP_FOR
-   statement GS starts.  */
+   statement OMP_FOR_STMT starts.  */
 
 static inline gimple_seq
-gimple_omp_for_pre_body (gimple gs)
+gimple_omp_for_pre_body (gomp_for *omp_for_stmt)
 {
-  return *gimple_omp_for_pre_body_ptr (gs);
+  return *gimple_omp_for_pre_body_ptr (omp_for_stmt);
 }
 
 
 /* Set PRE_BODY to be the sequence of statements to execute before the
-   OMP_FOR statement GS starts.  */
+   OMP_FOR statement OMP_FOR_STMT starts.  */
 
 static inline void
-gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
+gimple_omp_for_set_pre_body (gomp_for *omp_for_stmt, gimple_seq pre_body)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   omp_for_stmt->pre_body = pre_body;
 }
 
@@ -5216,26 +5178,22 @@ gimple_omp_sections_set_control (gimple gs, tree control)
 }
 
 
-/* Set COND to be the condition code for OMP_FOR GS.  */
+/* Set COND to be the condition code for OMP_FOR OMP_FOR_STMT.  */
 
 static inline void
-gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
+gimple_omp_for_set_cond (gomp_for *omp_for_stmt, size_t i, enum tree_code cond)
 {
-  gomp_for *omp_for_stmt =
-    as_a <gomp_for *> (gs);
   gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
 			      && i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].cond = cond;
 }
 
 
-/* Return the condition code associated with OMP_FOR GS.  */
+/* Return the condition code associated with OMP_FOR OMP_FOR_STMT.  */
 
 static inline enum tree_code
-gimple_omp_for_cond (const_gimple gs, size_t i)
+gimple_omp_for_cond (const gomp_for *omp_for_stmt, size_t i)
 {
-  const gomp_for *omp_for_stmt =
-    as_a <const gomp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].cond;
 }
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 2f28761..c43f5ea 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -785,7 +785,7 @@ determine_parallel_type (struct omp_region *region)
 	     parallel loop call would still need extra synchronization
 	     to implement ordered semantics, so there would not be any
 	     gain in using the combined call.  */
-	  tree clauses = gimple_omp_for_clauses (ws_stmt);
+	  tree clauses = gimple_omp_for_clauses (as_a <gomp_for *> (ws_stmt));
 	  tree c = find_omp_clause (clauses, OMP_CLAUSE_SCHEDULE);
 	  if (c == NULL
 	      || OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_STATIC
@@ -1034,7 +1034,8 @@ build_outer_var_ref (tree var, omp_context *ctx)
       x = build_receiver_ref (var, by_ref, ctx);
     }
   else if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-	   && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD)
+	   && (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+	       & GF_OMP_FOR_SIMD))
     {
       /* #pragma omp simd isn't a worksharing construct, and can reference even
 	 private vars in its linear etc. clauses.  */
@@ -2039,12 +2040,15 @@ find_combined_for (gimple_stmt_iterator *gsi_p,
     WALK_SUBSTMTS;
 
     case GIMPLE_OMP_FOR:
-      if (gimple_omp_for_combined_into_p (stmt)
-	  && gimple_omp_for_kind (stmt) == GF_OMP_FOR_KIND_FOR)
-	{
-	  wi->info = stmt;
-	  return integer_zero_node;
-	}
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	if (gimple_omp_for_combined_into_p (omp_for_stmt)
+	    && gimple_omp_for_kind (omp_for_stmt) == GF_OMP_FOR_KIND_FOR)
+	  {
+	    wi->info = stmt;
+	    return integer_zero_node;
+	  }
+      }
       break;
     default:
       break;
@@ -2404,7 +2408,8 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
   if (ctx != NULL)
     {
       if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-	  && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD)
+	  && (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+	      & GF_OMP_FOR_SIMD))
 	{
 	  error_at (gimple_location (stmt),
 		    "OpenMP constructs may not be nested inside simd region");
@@ -2413,7 +2418,7 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
       else if (gimple_code (ctx->stmt) == GIMPLE_OMP_TEAMS)
 	{
 	  if ((gimple_code (stmt) != GIMPLE_OMP_FOR
-	       || (gimple_omp_for_kind (stmt)
+	       || (gimple_omp_for_kind (as_a <gomp_for *> (stmt))
 		   != GF_OMP_FOR_KIND_DISTRIBUTE))
 	      && gimple_code (stmt) != GIMPLE_OMP_PARALLEL)
 	    {
@@ -2427,19 +2432,22 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
   switch (gimple_code (stmt))
     {
     case GIMPLE_OMP_FOR:
-      if (gimple_omp_for_kind (stmt) & GF_OMP_FOR_SIMD)
-	return true;
-      if (gimple_omp_for_kind (stmt) == GF_OMP_FOR_KIND_DISTRIBUTE)
-	{
-	  if (ctx != NULL && gimple_code (ctx->stmt) != GIMPLE_OMP_TEAMS)
-	    {
-	      error_at (gimple_location (stmt),
-			"distribute construct must be closely nested inside "
-			"teams construct");
-	      return false;
-	    }
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	if (gimple_omp_for_kind (omp_for_stmt) & GF_OMP_FOR_SIMD)
 	  return true;
-	}
+	if (gimple_omp_for_kind (omp_for_stmt) == GF_OMP_FOR_KIND_DISTRIBUTE)
+	  {
+	    if (ctx != NULL && gimple_code (ctx->stmt) != GIMPLE_OMP_TEAMS)
+	      {
+		error_at (gimple_location (stmt),
+			  "distribute construct must be closely nested inside "
+			  "teams construct");
+		return false;
+	      }
+	    return true;
+	  }
+      }
       /* FALLTHRU */
     case GIMPLE_CALL:
       if (is_gimple_call (stmt)
@@ -2474,19 +2482,22 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 	      break;
 	    case 2:
 	      if (gimple_code (ctx->stmt) != GIMPLE_OMP_FOR
-		  || gimple_omp_for_kind (ctx->stmt) != GF_OMP_FOR_KIND_FOR)
+		  || (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+		      != GF_OMP_FOR_KIND_FOR))
 		bad = "#pragma omp for";
 	      else if (DECL_FUNCTION_CODE (gimple_call_fndecl (stmt))
 		       == BUILT_IN_GOMP_CANCEL
 		       && !integer_zerop (gimple_call_arg (stmt, 1)))
 		{
 		  ctx->cancellable = true;
-		  if (find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
+		  if (find_omp_clause (gimple_omp_for_clauses (
+					 as_a <gomp_for *> (ctx->stmt)),
 				       OMP_CLAUSE_NOWAIT))
 		    warning_at (gimple_location (stmt), 0,
 				"%<#pragma omp cancel for%> inside "
 				"%<nowait%> for construct");
-		  if (find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
+		  if (find_omp_clause (gimple_omp_for_clauses (
+					 as_a <gomp_for *> (ctx->stmt)),
 				       OMP_CLAUSE_ORDERED))
 		    warning_at (gimple_location (stmt), 0,
 				"%<#pragma omp cancel for%> inside "
@@ -2614,7 +2625,8 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 		      "of critical or explicit task region");
 	    return false;
 	  case GIMPLE_OMP_FOR:
-	    if (find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
+	    if (find_omp_clause (gimple_omp_for_clauses (
+				   as_a <gomp_for *> (ctx->stmt)),
 				 OMP_CLAUSE_ORDERED) == NULL)
 	      {
 		error_at (gimple_location (stmt),
@@ -2774,7 +2786,8 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 	  if (setjmp_or_longjmp_p (fndecl)
 	      && ctx
 	      && gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-	      && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD)
+	      && (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+		  & GF_OMP_FOR_SIMD))
 	    {
 	      remove = true;
 	      error_at (gimple_location (stmt),
@@ -3141,7 +3154,8 @@ lower_rec_simd_input_clauses (tree new_var, omp_context *ctx, int &max_vf,
       max_vf = omp_max_vf ();
       if (max_vf > 1)
 	{
-	  tree c = find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
+	  tree c = find_omp_clause (gimple_omp_for_clauses (
+				      as_a <gomp_for *> (ctx->stmt)),
 				    OMP_CLAUSE_SAFELEN);
 	  if (c && TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) != INTEGER_CST)
 	    max_vf = 1;
@@ -3214,7 +3228,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
   bool reduction_omp_orig_ref = false;
   int pass;
   bool is_simd = (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-		  && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD);
+		  && (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+		      & GF_OMP_FOR_SIMD));
   int max_vf = 0;
   tree lane = NULL_TREE, idx = NULL_TREE;
   tree ivar = NULL_TREE, lvar = NULL_TREE;
@@ -3561,7 +3576,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 	      if (is_simd)
 		{
 		  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
-		      && gimple_omp_for_combined_into_p (ctx->stmt))
+		      && gimple_omp_for_combined_into_p  (
+			   as_a <gomp_for *> (ctx->stmt)))
 		    {
 		      tree t = OMP_CLAUSE_LINEAR_STEP (c);
 		      tree stept = TREE_TYPE (t);
@@ -3612,7 +3628,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 			  x = lang_hooks.decls.omp_clause_copy_ctor (c, iv, x);
 			  gimplify_and_add (x, ilist);
 			  gimple_stmt_iterator gsi
-			    = gsi_start_1 (gimple_omp_body_ptr (ctx->stmt));
+			    = gsi_start_1 (gimple_omp_body_ptr (
+					     as_a <gomp_for *> (ctx->stmt)));
 			  gassign *g
 			    = gimple_build_assign (unshare_expr (lvar), iv);
 			  gsi_insert_before_without_update (&gsi, g,
@@ -3829,8 +3846,9 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
       gsi_insert_before_without_update (&gsi, g, GSI_SAME_STMT);
       c = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__SIMDUID_);
       OMP_CLAUSE__SIMDUID__DECL (c) = uid;
-      OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (ctx->stmt);
-      gimple_omp_for_set_clauses (ctx->stmt, c);
+      gomp_for *omp_for_ctx_stmt = as_a <gomp_for *> (ctx->stmt);
+      OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (omp_for_ctx_stmt);
+      gimple_omp_for_set_clauses (omp_for_ctx_stmt, c);
       g = gimple_build_assign_with_ops (INTEGER_CST, lane,
 					build_int_cst (unsigned_type_node, 0),
 					NULL_TREE);
@@ -3886,7 +3904,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
       /* Don't add any barrier for #pragma omp simd or
 	 #pragma omp distribute.  */
       if (gimple_code (ctx->stmt) != GIMPLE_OMP_FOR
-	  || gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_FOR)
+	  || (gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt))
+	      == GF_OMP_FOR_KIND_FOR))
 	gimple_seq_add_stmt (ilist, build_omp_barrier (NULL_TREE));
     }
 
@@ -3894,7 +3913,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
      up to the max_vf we chose.  So stick it into the safelen clause.  */
   if (max_vf)
     {
-      tree c = find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
+      gomp_for *omp_for_ctx_stmt = as_a <gomp_for *> (ctx->stmt);
+      tree c = find_omp_clause (gimple_omp_for_clauses (omp_for_ctx_stmt),
 				OMP_CLAUSE_SAFELEN);
       if (c == NULL_TREE
 	  || (TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) == INTEGER_CST
@@ -3904,8 +3924,8 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 	  c = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_SAFELEN);
 	  OMP_CLAUSE_SAFELEN_EXPR (c) = build_int_cst (integer_type_node,
 						       max_vf);
-	  OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (ctx->stmt);
-	  gimple_omp_for_set_clauses (ctx->stmt, c);
+	  OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (omp_for_ctx_stmt);
+	  gimple_omp_for_set_clauses (omp_for_ctx_stmt, c);
 	}
     }
 }
@@ -3966,7 +3986,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
     }
 
   if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-      && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD)
+      && gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt)) & GF_OMP_FOR_SIMD)
     {
       simduid = find_omp_clause (orig_clauses, OMP_CLAUSE__SIMDUID_);
       if (simduid)
@@ -4069,7 +4089,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx)
 
   /* SIMD reductions are handled in lower_rec_input_clauses.  */
   if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
-      && gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_SIMD)
+      && gimple_omp_for_kind (as_a <gomp_for *> (ctx->stmt)) & GF_OMP_FOR_SIMD)
     return;
 
   /* First see if there is exactly one reduction clause.  Use OMP_ATOMIC
@@ -5355,7 +5375,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
 		     ? gimple_omp_parallel_clauses (inner_stmt)
-		     : gimple_omp_for_clauses (inner_stmt);
+		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       /* First two _looptemp_ clauses are for istart/iend, counts[0]
 	 isn't supposed to be handled, as the inner loop doesn't
 	 use it.  */
@@ -5802,10 +5822,12 @@ expand_omp_for_generic (struct omp_region *region,
 
   if (gimple_omp_for_combined_p (fd->for_stmt))
     {
-      gcc_assert (gimple_code (inner_stmt) == GIMPLE_OMP_FOR
-		  && gimple_omp_for_kind (inner_stmt)
-		     == GF_OMP_FOR_KIND_SIMD);
-      tree innerc = find_omp_clause (gimple_omp_for_clauses (inner_stmt),
+      gcc_assert (gimple_code (inner_stmt) == GIMPLE_OMP_FOR);
+      gomp_for *omp_for_inner_stmt = as_a <gomp_for *> (inner_stmt);
+      gcc_assert (gimple_omp_for_kind (omp_for_inner_stmt)
+		  == GF_OMP_FOR_KIND_SIMD);
+      tree innerc = find_omp_clause (gimple_omp_for_clauses (
+				       omp_for_inner_stmt),
 				     OMP_CLAUSE__LOOPTEMP_);
       gcc_assert (innerc);
       startvar = OMP_CLAUSE_DECL (innerc);
@@ -6227,7 +6249,7 @@ expand_omp_for_static_nochunk (struct omp_region *region,
     {
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
 		     ? gimple_omp_parallel_clauses (inner_stmt)
-		     : gimple_omp_for_clauses (inner_stmt);
+		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_);
       gcc_assert (innerc);
       startvar = OMP_CLAUSE_DECL (innerc);
@@ -6618,7 +6640,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
     {
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
 		     ? gimple_omp_parallel_clauses (inner_stmt)
-		     : gimple_omp_for_clauses (inner_stmt);
+		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_);
       gcc_assert (innerc);
       startvar = OMP_CLAUSE_DECL (innerc);
@@ -7335,13 +7357,13 @@ expand_omp_for (struct omp_region *region, gimple inner_stmt)
 {
   struct omp_for_data fd;
   struct omp_for_data_loop *loops;
+  gomp_for *omp_for_stmt = as_a <gomp_for *> (last_stmt (region->entry));
 
   loops
     = (struct omp_for_data_loop *)
-      alloca (gimple_omp_for_collapse (last_stmt (region->entry))
+      alloca (gimple_omp_for_collapse (omp_for_stmt)
 	      * sizeof (struct omp_for_data_loop));
-  extract_omp_for_data (as_a <gomp_for *> (last_stmt (region->entry)),
-			&fd, loops);
+  extract_omp_for_data (omp_for_stmt, &fd, loops);
   region->sched_kind = fd.sched_kind;
 
   gcc_assert (EDGE_COUNT (region->entry->succs) == 2);
@@ -8603,7 +8625,8 @@ expand_omp (struct omp_region *region)
 	determine_parallel_type (region);
 
       if (region->type == GIMPLE_OMP_FOR
-	  && gimple_omp_for_combined_p (last_stmt (region->entry)))
+	  && gimple_omp_for_combined_p (
+	       as_a <gomp_for *> (last_stmt (region->entry))))
 	inner_stmt = last_stmt (region->inner->entry);
 
       if (region->inner)
@@ -10808,10 +10831,12 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p,
     {
       if ((branch_ctx
 	   && gimple_code (branch_ctx) == GIMPLE_OMP_FOR
-	   && gimple_omp_for_kind (branch_ctx) == GF_OMP_FOR_KIND_CILKSIMD)
+	   && (gimple_omp_for_kind (as_a <gomp_for *> (branch_ctx))
+	       == GF_OMP_FOR_KIND_CILKSIMD))
 	  || (label_ctx
 	      && gimple_code (label_ctx) == GIMPLE_OMP_FOR
-	      && gimple_omp_for_kind (label_ctx) == GF_OMP_FOR_KIND_CILKSIMD))
+	      && (gimple_omp_for_kind (as_a <gomp_for *> (label_ctx))
+		  == GF_OMP_FOR_KIND_CILKSIMD)))
 	cilkplus_block = true;
     }
 
@@ -10872,14 +10897,18 @@ diagnose_sb_1 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_FOR:
-      inner_context = stmt;
-      wi->info = inner_context;
-      /* gimple_omp_for_{index,initial,final} are all DECLs; no need to
-	 walk them.  */
-      walk_gimple_seq (gimple_omp_for_pre_body (stmt),
-	  	       diagnose_sb_1, NULL, wi);
-      walk_gimple_seq (gimple_omp_body (stmt), diagnose_sb_1, NULL, wi);
-      wi->info = context;
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	inner_context = stmt;
+	wi->info = inner_context;
+	/* gimple_omp_for_{index,initial,final} are all DECLs; no need to
+	   walk them.  */
+	walk_gimple_seq (gimple_omp_for_pre_body (omp_for_stmt),
+			 diagnose_sb_1, NULL, wi);
+	walk_gimple_seq (gimple_omp_body (omp_for_stmt), diagnose_sb_1, NULL,
+			 wi);
+	wi->info = context;
+      }
       break;
 
     case GIMPLE_LABEL:
@@ -10930,13 +10959,17 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_FOR:
-      wi->info = stmt;
-      /* gimple_omp_for_{index,initial,final} are all DECLs; no need to
-	 walk them.  */
-      walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt),
-			   diagnose_sb_2, NULL, wi);
-      walk_gimple_seq_mod (gimple_omp_body_ptr (stmt), diagnose_sb_2, NULL, wi);
-      wi->info = context;
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	wi->info = stmt;
+	/* gimple_omp_for_{index,initial,final} are all DECLs; no need to
+	   walk them.  */
+	walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (omp_for_stmt),
+			     diagnose_sb_2, NULL, wi);
+	walk_gimple_seq_mod (gimple_omp_body_ptr (omp_for_stmt), diagnose_sb_2,
+			     NULL, wi);
+	wi->info = context;
+      }
       break;
 
     case GIMPLE_COND:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 8688a99..fd20bcb 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1402,25 +1402,34 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_FOR:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  s2 = remap_gimple_seq (gimple_omp_for_pre_body (stmt), id);
-	  copy = gimple_build_omp_for (s1, gimple_omp_for_kind (stmt),
-				       gimple_omp_for_clauses (stmt),
-				       gimple_omp_for_collapse (stmt), s2);
 	  {
+	    gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	    gomp_for *omp_for_copy;
 	    size_t i;
-	    for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_for_stmt), id);
+	    s2 = remap_gimple_seq (gimple_omp_for_pre_body (omp_for_stmt), id);
+	    copy = omp_for_copy =
+	      gimple_build_omp_for (s1, gimple_omp_for_kind (omp_for_stmt),
+				    gimple_omp_for_clauses (omp_for_stmt),
+				    gimple_omp_for_collapse (omp_for_stmt),
+				    s2);
+	    for (i = 0; i < gimple_omp_for_collapse (omp_for_stmt); i++)
 	      {
-		gimple_omp_for_set_index (copy, i,
-					  gimple_omp_for_index (stmt, i));
-		gimple_omp_for_set_initial (copy, i,
-					    gimple_omp_for_initial (stmt, i));
-		gimple_omp_for_set_final (copy, i,
-					  gimple_omp_for_final (stmt, i));
-		gimple_omp_for_set_incr (copy, i,
-					 gimple_omp_for_incr (stmt, i));
-		gimple_omp_for_set_cond (copy, i,
-					 gimple_omp_for_cond (stmt, i));
+		gimple_omp_for_set_index (omp_for_copy, i,
+					  gimple_omp_for_index (omp_for_stmt,
+								i));
+		gimple_omp_for_set_initial (omp_for_copy, i,
+					    gimple_omp_for_initial (
+					      omp_for_stmt, i));
+		gimple_omp_for_set_final (omp_for_copy, i,
+					  gimple_omp_for_final (omp_for_stmt,
+								i));
+		gimple_omp_for_set_incr (omp_for_copy, i,
+					 gimple_omp_for_incr (omp_for_stmt,
+							      i));
+		gimple_omp_for_set_cond (omp_for_copy, i,
+					 gimple_omp_for_cond (omp_for_stmt,
+							      i));
 	      }
 	  }
 	  break;
@@ -4036,9 +4045,14 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       return weights->omp_cost;
 
     case GIMPLE_OMP_FOR:
-      return (weights->omp_cost
-              + estimate_num_insns_seq (gimple_omp_body (stmt), weights)
-              + estimate_num_insns_seq (gimple_omp_for_pre_body (stmt), weights));
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	return (weights->omp_cost
+		+ estimate_num_insns_seq (gimple_omp_body (omp_for_stmt),
+					  weights)
+		+ estimate_num_insns_seq (gimple_omp_for_pre_body (omp_for_stmt),
+					  weights));
+      }
 
     case GIMPLE_OMP_PARALLEL:
     case GIMPLE_OMP_TASK:
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index c95fe81..95ecbc0 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1350,14 +1350,18 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_FOR:
-      save_suppress = info->suppress_expansion;
-      convert_nonlocal_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
-      walk_gimple_omp_for (as_a <gomp_for *> (stmt),
-			   convert_nonlocal_reference_stmt,
-	  		   convert_nonlocal_reference_op, info);
-      walk_body (convert_nonlocal_reference_stmt,
-	  	 convert_nonlocal_reference_op, info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_nonlocal_omp_clauses (gimple_omp_for_clauses_ptr (omp_for_stmt), wi);
+	walk_gimple_omp_for (omp_for_stmt,
+			     convert_nonlocal_reference_stmt,
+			     convert_nonlocal_reference_op, info);
+	walk_body (convert_nonlocal_reference_stmt,
+		   convert_nonlocal_reference_op, info,
+		   gimple_omp_body_ptr (omp_for_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SECTIONS:
@@ -1919,14 +1923,18 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_FOR:
-      save_suppress = info->suppress_expansion;
-      convert_local_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
-      walk_gimple_omp_for (as_a <gomp_for *> (stmt),
-			   convert_local_reference_stmt,
-			   convert_local_reference_op, info);
-      walk_body (convert_local_reference_stmt, convert_local_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_for *omp_for_stmt = as_a <gomp_for *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_local_omp_clauses (gimple_omp_for_clauses_ptr (omp_for_stmt),
+				   wi);
+	walk_gimple_omp_for (omp_for_stmt,
+			     convert_local_reference_stmt,
+			     convert_local_reference_op, info);
+	walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		   info, gimple_omp_body_ptr (omp_for_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SECTIONS:
@@ -2416,7 +2424,7 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 
     case GIMPLE_OMP_FOR:
       walk_body (convert_gimple_call, NULL, info,
-	  	 gimple_omp_for_pre_body_ptr (stmt));
+		 gimple_omp_for_pre_body_ptr (as_a <gomp_for *> (stmt)));
       /* FALLTHRU */
     case GIMPLE_OMP_SECTIONS:
     case GIMPLE_OMP_SECTION:
-- 
1.7.11.7

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

* [gimple-classes, committed 03/10] Make remaining gimple_omp_teams_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (5 preceding siblings ...)
  2014-10-29 18:52 ` [gimple-classes, committed 04/10] Make all gimple_omp_sections_ " David Malcolm
@ 2014-10-29 19:04 ` David Malcolm
  2014-10-29 19:08 ` [gimple-classes, committed 05/10] Make all gimple_omp_return_ " David Malcolm
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 19:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_teams_clauses): Strengthen param from
	const_gimple to const gomp_teams *.
	(gimple_omp_teams_clauses_ptr): Strengthen param from gimple to
	gomp_teams *.

	* gimple-walk.c (walk_gimple_op): Add checked cast.
	* tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TEAMS,
	introduce local "omp_teams_stmt" via a checked cast, and use in
	place of "stmt".
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
---
 gcc/ChangeLog.gimple-classes | 14 ++++++++++++++
 gcc/gimple-walk.c            |  5 +++--
 gcc/gimple.h                 | 13 +++++--------
 gcc/tree-inline.c            |  9 ++++++---
 gcc/tree-nested.c            | 31 +++++++++++++++++++++----------
 5 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 68add33..626ea2f 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,19 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_teams_clauses): Strengthen param from
+	const_gimple to const gomp_teams *.
+	(gimple_omp_teams_clauses_ptr): Strengthen param from gimple to
+	gomp_teams *.
+
+	* gimple-walk.c (walk_gimple_op): Add checked cast.
+	* tree-inline.c (remap_gimple_stmt): Within case GIMPLE_OMP_TEAMS,
+	introduce local "omp_teams_stmt" via a checked cast, and use in
+	place of "stmt".
+	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
+	(convert_local_reference_stmt): Likewise.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_for_kind): Strengthen param from
 	const_gimple to const gomp_for *.
 	(gimple_omp_for_combined_p): Likewise.
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 28648c4..13c16bb 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -433,8 +433,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_TEAMS:
-      ret = walk_tree (gimple_omp_teams_clauses_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_omp_teams_clauses_ptr (
+			 as_a <gomp_teams *> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6df9dbf..41f1691 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -5077,24 +5077,21 @@ gimple_omp_target_set_data_arg (gomp_target *omp_target_stmt,
 }
 
 
-/* Return the clauses associated with OMP_TEAMS GS.  */
+/* Return the clauses associated with OMP_TEAMS OMP_TEAMS_STMT.  */
 
 static inline tree
-gimple_omp_teams_clauses (const_gimple gs)
+gimple_omp_teams_clauses (const gomp_teams *omp_teams_stmt)
 {
-  const gomp_teams *omp_teams_stmt =
-    as_a <const gomp_teams *> (gs);
   return omp_teams_stmt->clauses;
 }
 
 
-/* Return a pointer to the clauses associated with OMP_TEAMS GS.  */
+/* Return a pointer to the clauses associated with OMP_TEAMS
+   OMP_TEAMS_STMT.  */
 
 static inline tree *
-gimple_omp_teams_clauses_ptr (gimple gs)
+gimple_omp_teams_clauses_ptr (gomp_teams *omp_teams_stmt)
 {
-  gomp_teams *omp_teams_stmt =
-    as_a <gomp_teams *> (gs);
   return &omp_teams_stmt->clauses;
 }
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index fd20bcb..6498e23 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1474,9 +1474,12 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_TEAMS:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_teams
-		   (s1, gimple_omp_teams_clauses (stmt));
+	  {
+	    gomp_teams *omp_teams_stmt = as_a <gomp_teams *> (stmt);
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_teams_stmt), id);
+	    copy = gimple_build_omp_teams
+		     (s1, gimple_omp_teams_clauses (omp_teams_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_CRITICAL:
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 95ecbc0..3463151 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1421,11 +1421,17 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TEAMS:
-      save_suppress = info->suppress_expansion;
-      convert_nonlocal_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), wi);
-      walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_teams *omp_teams_stmt = as_a <gomp_teams *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_nonlocal_omp_clauses (gimple_omp_teams_clauses_ptr (
+					omp_teams_stmt),
+				      wi);
+	walk_body (convert_nonlocal_reference_stmt,
+		   convert_nonlocal_reference_op,
+		   info, gimple_omp_body_ptr (omp_teams_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SECTION:
@@ -1990,11 +1996,16 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TEAMS:
-      save_suppress = info->suppress_expansion;
-      convert_local_omp_clauses (gimple_omp_teams_clauses_ptr (stmt), wi);
-      walk_body (convert_local_reference_stmt, convert_local_reference_op,
-		 info, gimple_omp_body_ptr (stmt));
-      info->suppress_expansion = save_suppress;
+      {
+	gomp_teams *omp_teams_stmt = as_a <gomp_teams *> (stmt);
+	save_suppress = info->suppress_expansion;
+	convert_local_omp_clauses (gimple_omp_teams_clauses_ptr (
+				     omp_teams_stmt),
+				   wi);
+	walk_body (convert_local_reference_stmt, convert_local_reference_op,
+		   info, gimple_omp_body_ptr (omp_teams_stmt));
+	info->suppress_expansion = save_suppress;
+      }
       break;
 
     case GIMPLE_OMP_SECTION:
-- 
1.7.11.7

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

* [gimple-classes, committed 05/10] Make all gimple_omp_return_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (6 preceding siblings ...)
  2014-10-29 19:04 ` [gimple-classes, committed 03/10] Make remaining gimple_omp_teams_ " David Malcolm
@ 2014-10-29 19:08 ` David Malcolm
  2014-10-29 19:23 ` [gimple-classes, committed 10/10] Introduce gpredict subclass and use it for all gimple_predict_ accessors David Malcolm
  2014-10-29 19:31 ` [gimple-classes, committed 08/10] Make remainging gimple_omp_parallel_ accessors typesafe David Malcolm
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 19:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (struct gimple_statement_omp_return): Rename to...
	(struct gomp_return): ...this.
	(is_a_helper <gimple_statement_omp_return *>::test): Rename to...
	(is_a_helper <gomp_return *>::test): ...this.
	(is_a_helper <const gimple_statement_omp_return *>::test): Rename to...
	(is_a_helper <const gomp_return *>::test): ...this.
	(gimple_build_omp_return): Strengthen return type from gimple to
	gomp_return *.
	(gimple_omp_return_set_nowait): Likewise for param.
	(gimple_omp_return_set_lhs): Likewise.
	(gimple_omp_return_lhs_ptr): Likewise.
	(gimple_omp_return_nowait_p): Strengthen param from const_gimple
	to const gomp_return *.
	(gimple_omp_return_lhs): Likewise.

	* gimple-pretty-print.c (dump_gimple_omp_return): Strengthen param
	from gimple to gomp_return *.
	(pp_gimple_stmt_1): Add checked cast.
	* gimple-walk.c (walk_gimple_op): Likewise.
	* gimple.c (gimple_build_omp_return): Strengthen return type and
	local "p" from gimple to gomp_return *.
	* omp-low.c (remove_exit_barrier): Replace check against
	GIMPLE_OMP_RETURN with a dyn_cast, introducing local
	"omp_return_stmt" and using it in place of "stmt".
	(expand_omp_for_generic): Introduce local "omp_return_stmt" via a
	checked cast, using it in place of "gsi_stmt (gsi)".
	(expand_omp_for_static_nochunk): Likewise.
	(expand_omp_for_static_chunk): Likewise.
	(expand_omp_sections): Introduce local "omp_return_stmt" via a
	checked cast, using it in place of "gsi_stmt (si)".
	(expand_omp_single): Likewise.
	(maybe_add_implicit_barrier_cancel): Strengthen local "omp_return"
	from gimple to gomp_return * via a checked cast.
---
 gcc/ChangeLog.gimple-classes | 36 ++++++++++++++++++++++++++++++++++++
 gcc/gimple-pretty-print.c    |  5 +++--
 gcc/gimple-walk.c            |  5 +++--
 gcc/gimple.c                 |  4 ++--
 gcc/gimple.h                 | 27 +++++++++------------------
 gcc/omp-low.c                | 44 +++++++++++++++++++++++++-------------------
 6 files changed, 78 insertions(+), 43 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 469c009..d85abcd 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,41 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (struct gimple_statement_omp_return): Rename to...
+	(struct gomp_return): ...this.
+	(is_a_helper <gimple_statement_omp_return *>::test): Rename to...
+	(is_a_helper <gomp_return *>::test): ...this.
+	(is_a_helper <const gimple_statement_omp_return *>::test): Rename to...
+	(is_a_helper <const gomp_return *>::test): ...this.
+	(gimple_build_omp_return): Strengthen return type from gimple to
+	gomp_return *.
+	(gimple_omp_return_set_nowait): Likewise for param.
+	(gimple_omp_return_set_lhs): Likewise.
+	(gimple_omp_return_lhs_ptr): Likewise.
+	(gimple_omp_return_nowait_p): Strengthen param from const_gimple
+	to const gomp_return *.
+	(gimple_omp_return_lhs): Likewise.
+
+	* gimple-pretty-print.c (dump_gimple_omp_return): Strengthen param
+	from gimple to gomp_return *.
+	(pp_gimple_stmt_1): Add checked cast.
+	* gimple-walk.c (walk_gimple_op): Likewise.
+	* gimple.c (gimple_build_omp_return): Strengthen return type and
+	local "p" from gimple to gomp_return *.
+	* omp-low.c (remove_exit_barrier): Replace check against
+	GIMPLE_OMP_RETURN with a dyn_cast, introducing local
+	"omp_return_stmt" and using it in place of "stmt".
+	(expand_omp_for_generic): Introduce local "omp_return_stmt" via a
+	checked cast, using it in place of "gsi_stmt (gsi)".
+	(expand_omp_for_static_nochunk): Likewise.
+	(expand_omp_for_static_chunk): Likewise.
+	(expand_omp_sections): Introduce local "omp_return_stmt" via a
+	checked cast, using it in place of "gsi_stmt (si)".
+	(expand_omp_single): Likewise.
+	(maybe_add_implicit_barrier_cancel): Strengthen local "omp_return"
+	from gimple to gomp_return * via a checked cast.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_sections_clauses): Strengthen param from
 	const_gimple to const gomp_sections *.
 	(gimple_omp_sections_control): Likewise.
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index e0bbb5c..864f636 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1502,7 +1502,8 @@ dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_return (pretty_printer *buffer, gomp_return *gs, int spc,
+			int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2191,7 +2192,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_RETURN:
-      dump_gimple_omp_return (buffer, gs, spc, flags);
+      dump_gimple_omp_return (buffer, as_a <gomp_return *> (gs), spc, flags);
       break;
 
     case GIMPLE_OMP_SECTIONS:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index b802c95..ce78bea 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -474,8 +474,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_RETURN:
-      ret = walk_tree (gimple_omp_return_lhs_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_omp_return_lhs_ptr (
+			 as_a <gomp_return *> (stmt)),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b34ac10..1421afe 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1001,10 +1001,10 @@ gimple_build_omp_ordered (gimple_seq body)
 /* Build a GIMPLE_OMP_RETURN statement.
    WAIT_P is true if this is a non-waiting return.  */
 
-gimple
+gomp_return *
 gimple_build_omp_return (bool wait_p)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_RETURN, 0);
+  gomp_return *p = as_a <gomp_return *> (gimple_alloc (GIMPLE_OMP_RETURN, 0));
   if (wait_p)
     gimple_omp_return_set_nowait (p);
 
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 723c2f5..6355d96 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -711,8 +711,7 @@ struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
 };
 
 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
-  gimple_statement_omp_return :
-    public gimple_statement_omp_atomic_store_layout
+  gomp_return : public gimple_statement_omp_atomic_store_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_RETURN.  */
@@ -966,7 +965,7 @@ is_a_helper <gomp_atomic_store *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_return *>::test (gimple gs)
+is_a_helper <gomp_return *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_RETURN;
 }
@@ -1174,7 +1173,7 @@ is_a_helper <const gomp_atomic_store *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_return *>::test (const_gimple gs)
+is_a_helper <const gomp_return *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_RETURN;
 }
@@ -1340,7 +1339,7 @@ gimple gimple_build_omp_master (gimple_seq);
 gimple gimple_build_omp_taskgroup (gimple_seq);
 gomp_continue *gimple_build_omp_continue (tree, tree);
 gimple gimple_build_omp_ordered (gimple_seq);
-gimple gimple_build_omp_return (bool);
+gomp_return *gimple_build_omp_return (bool);
 gomp_sections *gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
 gomp_single *gimple_build_omp_single (gimple_seq, tree);
@@ -2030,9 +2029,8 @@ gimple_omp_set_subcode (gimple s, unsigned int subcode)
 /* Set the nowait flag on OMP_RETURN statement S.  */
 
 static inline void
-gimple_omp_return_set_nowait (gimple s)
+gimple_omp_return_set_nowait (gomp_return *s)
 {
-  GIMPLE_CHECK (s, GIMPLE_OMP_RETURN);
   s->subcode |= GF_OMP_RETURN_NOWAIT;
 }
 
@@ -2041,9 +2039,8 @@ gimple_omp_return_set_nowait (gimple s)
    flag set.  */
 
 static inline bool
-gimple_omp_return_nowait_p (const_gimple g)
+gimple_omp_return_nowait_p (const gomp_return *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_RETURN);
   return (gimple_omp_subcode (g) & GF_OMP_RETURN_NOWAIT) != 0;
 }
 
@@ -2051,10 +2048,8 @@ gimple_omp_return_nowait_p (const_gimple g)
 /* Set the LHS of OMP return.  */
 
 static inline void
-gimple_omp_return_set_lhs (gimple g, tree lhs)
+gimple_omp_return_set_lhs (gomp_return *omp_return_stmt, tree lhs)
 {
-  gimple_statement_omp_return *omp_return_stmt =
-    as_a <gimple_statement_omp_return *> (g);
   omp_return_stmt->val = lhs;
 }
 
@@ -2062,10 +2057,8 @@ gimple_omp_return_set_lhs (gimple g, tree lhs)
 /* Get the LHS of OMP return.  */
 
 static inline tree
-gimple_omp_return_lhs (const_gimple g)
+gimple_omp_return_lhs (const gomp_return *omp_return_stmt)
 {
-  const gimple_statement_omp_return *omp_return_stmt =
-    as_a <const gimple_statement_omp_return *> (g);
   return omp_return_stmt->val;
 }
 
@@ -2073,10 +2066,8 @@ gimple_omp_return_lhs (const_gimple g)
 /* Return a pointer to the LHS of OMP return.  */
 
 static inline tree *
-gimple_omp_return_lhs_ptr (gimple g)
+gimple_omp_return_lhs_ptr (gomp_return *omp_return_stmt)
 {
-  gimple_statement_omp_return *omp_return_stmt =
-    as_a <gimple_statement_omp_return *> (g);
   return &omp_return_stmt->val;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 509f3f8..07eed83 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4739,8 +4739,9 @@ remove_exit_barrier (struct omp_region *region)
       if (gsi_end_p (gsi))
 	continue;
       stmt = gsi_stmt (gsi);
-      if (gimple_code (stmt) == GIMPLE_OMP_RETURN
-	  && !gimple_omp_return_nowait_p (stmt))
+      gomp_return *omp_return_stmt = dyn_cast <gomp_return *> (stmt);
+      if (omp_return_stmt
+	  && !gimple_omp_return_nowait_p (omp_return_stmt))
 	{
 	  /* OpenMP 3.0 tasks unfortunately prevent this optimization
 	     in many cases.  If there could be tasks queued, the barrier
@@ -4784,7 +4785,7 @@ remove_exit_barrier (struct omp_region *region)
 		}
 	    }
 	  if (!any_addressable_vars)
-	    gimple_omp_return_set_nowait (stmt);
+	    gimple_omp_return_set_nowait (omp_return_stmt);
 	}
     }
 }
@@ -5929,15 +5930,16 @@ expand_omp_for_generic (struct omp_region *region,
 
   /* Add the loop cleanup function.  */
   gsi = gsi_last_bb (exit_bb);
-  if (gimple_omp_return_nowait_p (gsi_stmt (gsi)))
+  gomp_return *omp_return_stmt = as_a <gomp_return *> (gsi_stmt (gsi));
+  if (gimple_omp_return_nowait_p (omp_return_stmt))
     t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT);
-  else if (gimple_omp_return_lhs (gsi_stmt (gsi)))
+  else if (gimple_omp_return_lhs (omp_return_stmt))
     t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_CANCEL);
   else
     t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END);
   gcall *call_stmt = gimple_build_call (t, 0);
-  if (gimple_omp_return_lhs (gsi_stmt (gsi)))
-    gimple_call_set_lhs (call_stmt, gimple_omp_return_lhs (gsi_stmt (gsi)));
+  if (gimple_omp_return_lhs (omp_return_stmt))
+    gimple_call_set_lhs (call_stmt, gimple_omp_return_lhs (omp_return_stmt));
   gsi_insert_after (&gsi, call_stmt, GSI_SAME_STMT);
   gsi_remove (&gsi, true);
 
@@ -6336,9 +6338,10 @@ expand_omp_for_static_nochunk (struct omp_region *region,
 
   /* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing.  */
   gsi = gsi_last_bb (exit_bb);
-  if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
+  gomp_return *omp_return_stmt = as_a <gomp_return *> (gsi_stmt (gsi));
+  if (!gimple_omp_return_nowait_p (omp_return_stmt))
     {
-      t = gimple_omp_return_lhs (gsi_stmt (gsi));
+      t = gimple_omp_return_lhs (omp_return_stmt);
       gsi_insert_after (&gsi, build_omp_barrier (t), GSI_SAME_STMT);
     }
   gsi_remove (&gsi, true);
@@ -6734,9 +6737,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
 
   /* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing.  */
   gsi = gsi_last_bb (exit_bb);
-  if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
+  gomp_return *omp_return_stmt = as_a <gomp_return *> (gsi_stmt (gsi));
+  if (!gimple_omp_return_nowait_p (omp_return_stmt))
     {
-      t = gimple_omp_return_lhs (gsi_stmt (gsi));
+      t = gimple_omp_return_lhs (omp_return_stmt);
       gsi_insert_after (&gsi, build_omp_barrier (t), GSI_SAME_STMT);
     }
   gsi_remove (&gsi, true);
@@ -7630,15 +7634,16 @@ expand_omp_sections (struct omp_region *region)
 
   /* Cleanup function replaces GIMPLE_OMP_RETURN in EXIT_BB.  */
   si = gsi_last_bb (l2_bb);
-  if (gimple_omp_return_nowait_p (gsi_stmt (si)))
+  gomp_return *omp_return_stmt = as_a <gomp_return *> (gsi_stmt (si));
+  if (gimple_omp_return_nowait_p (omp_return_stmt))
     t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END_NOWAIT);
-  else if (gimple_omp_return_lhs (gsi_stmt (si)))
+  else if (gimple_omp_return_lhs (omp_return_stmt))
     t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END_CANCEL);
   else
     t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END);
   stmt = gimple_build_call (t, 0);
-  if (gimple_omp_return_lhs (gsi_stmt (si)))
-    gimple_call_set_lhs (stmt, gimple_omp_return_lhs (gsi_stmt (si)));
+  if (gimple_omp_return_lhs (omp_return_stmt))
+    gimple_call_set_lhs (stmt, gimple_omp_return_lhs (omp_return_stmt));
   gsi_insert_after (&si, stmt, GSI_SAME_STMT);
   gsi_remove (&si, true);
 
@@ -7664,9 +7669,10 @@ expand_omp_single (struct omp_region *region)
   single_succ_edge (entry_bb)->flags = EDGE_FALLTHRU;
 
   si = gsi_last_bb (exit_bb);
-  if (!gimple_omp_return_nowait_p (gsi_stmt (si)))
+  gomp_return *omp_return_stmt = as_a <gomp_return *> (gsi_stmt (si));
+  if (!gimple_omp_return_nowait_p (omp_return_stmt))
     {
-      tree t = gimple_omp_return_lhs (gsi_stmt (si));
+      tree t = gimple_omp_return_lhs (omp_return_stmt);
       gsi_insert_after (&si, build_omp_barrier (t), GSI_SAME_STMT);
     }
   gsi_remove (&si, true);
@@ -8885,8 +8891,8 @@ make_pass_expand_omp (gcc::context *ctxt)
 static void
 maybe_add_implicit_barrier_cancel (omp_context *ctx, gimple_seq *body)
 {
-  gimple omp_return = gimple_seq_last_stmt (*body);
-  gcc_assert (gimple_code (omp_return) == GIMPLE_OMP_RETURN);
+  gomp_return *omp_return =
+    as_a <gomp_return *> (gimple_seq_last_stmt (*body));
   if (gimple_omp_return_nowait_p (omp_return))
     return;
   if (ctx->outer
-- 
1.7.11.7

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

* [gimple-classes, committed 10/10] Introduce gpredict subclass and use it for all gimple_predict_ accessors
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (7 preceding siblings ...)
  2014-10-29 19:08 ` [gimple-classes, committed 05/10] Make all gimple_omp_return_ " David Malcolm
@ 2014-10-29 19:23 ` David Malcolm
  2014-10-29 19:31 ` [gimple-classes, committed 08/10] Make remainging gimple_omp_parallel_ accessors typesafe David Malcolm
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 19:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* coretypes.h (struct gpredict): Add forward declaration.
	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Add
	gpredict.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Within case
	GIMPLE_PREDICT, add local "predict_stmt" via a checked cast and
	use it in place of "stmt".
	* gimple.c (gimple_build_predict): Strengthen return type and
	local "p" from gimple to gpredict *.
	* gimple.h (struct gpredict): New subclass of
	gimple_statement_base, adding invariant that code is
	GIMPLE_PREDICT.
	(is_a_helper <gpredict *>::test): New.
	(gimple_build_predict): Strengthen return type from gimple to
	gpredict *.
	(gimple_predict_predictor): Strengthen param from const_gimple to
	const gpredict *.
	(gimple_predict_outcome): Likewise.
	(gimple_predict_set_predictor): Strengthen param from gimple to
	gpredict *.
	(gimple_predict_set_outcome): Likewise.
	* predict.c (tree_bb_level_predictions): Convert check for
	GIMPLE_PREDICT to a dyn_cast, introducing local "predict_stmt" and
	using it in place of "stmt" for typesafety.
---
 gcc/ChangeLog.gimple-classes | 26 ++++++++++++++++++++++++++
 gcc/coretypes.h              |  1 +
 gcc/doc/gimple.texi          |  3 ++-
 gcc/gimple-pretty-print.c    | 18 +++++++++++-------
 gcc/gimple.c                 |  4 ++--
 gcc/gimple.h                 | 31 +++++++++++++++++++++++--------
 gcc/predict.c                |  7 ++++---
 7 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 07c12cd..7d9dfb3 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,31 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* coretypes.h (struct gpredict): Add forward declaration.
+	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Add
+	gpredict.
+	* gimple-pretty-print.c (pp_gimple_stmt_1): Within case
+	GIMPLE_PREDICT, add local "predict_stmt" via a checked cast and
+	use it in place of "stmt".
+	* gimple.c (gimple_build_predict): Strengthen return type and
+	local "p" from gimple to gpredict *.
+	* gimple.h (struct gpredict): New subclass of
+	gimple_statement_base, adding invariant that code is
+	GIMPLE_PREDICT.
+	(is_a_helper <gpredict *>::test): New.
+	(gimple_build_predict): Strengthen return type from gimple to
+	gpredict *.
+	(gimple_predict_predictor): Strengthen param from const_gimple to
+	const gpredict *.
+	(gimple_predict_outcome): Likewise.
+	(gimple_predict_set_predictor): Strengthen param from gimple to
+	gpredict *.
+	(gimple_predict_set_outcome): Likewise.
+	* predict.c (tree_bb_level_predictions): Convert check for
+	GIMPLE_PREDICT to a dyn_cast, introducing local "predict_stmt" and
+	using it in place of "stmt" for typesafety.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_eh_filter_types): Strengthen param from
 	const_gimple to const geh_filter *.
 	(gimple_eh_filter_types_ptr): Strengthen param from gimple to
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6e9f7b2..190d9a1 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -120,6 +120,7 @@ struct gomp_sections;
 struct gomp_single;
 struct gomp_target;
 struct gomp_teams;
+struct gpredict;
 
 union section;
 typedef union section section;
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index de7345e..887710a 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -305,7 +305,8 @@ kinds, along with their relationships to @code{GSS_} values (layouts) and
      |    used for 4 codes: GIMPLE_ERROR_MARK
      |                      GIMPLE_NOP
      |                      GIMPLE_OMP_SECTIONS_SWITCH
-     |                      GIMPLE_PREDICT
+     + gpredict
+     |   code: GIMPLE_PREDICT
      |
      + gimple_statement_with_ops_base
      |   |    (no GSS layout)
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 864f636..91a20d5 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2248,13 +2248,17 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_PREDICT:
-      pp_string (buffer, "// predicted ");
-      if (gimple_predict_outcome (gs))
-	pp_string (buffer, "likely by ");
-      else
-	pp_string (buffer, "unlikely by ");
-      pp_string (buffer, predictor_name (gimple_predict_predictor (gs)));
-      pp_string (buffer, " predictor.");
+      {
+	gpredict *predict_stmt = as_a <gpredict *> (gs);
+	pp_string (buffer, "// predicted ");
+	if (gimple_predict_outcome (predict_stmt))
+	  pp_string (buffer, "likely by ");
+	else
+	  pp_string (buffer, "unlikely by ");
+	pp_string (buffer,
+		   predictor_name (gimple_predict_predictor (predict_stmt)));
+	pp_string (buffer, " predictor.");
+      }
       break;
 
     case GIMPLE_TRANSACTION:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 1421afe..b58c9db 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1136,10 +1136,10 @@ gimple_build_transaction (gimple_seq body, tree label)
 /* Build a GIMPLE_PREDICT statement.  PREDICT is one of the predictors from
    predict.def, OUTCOME is NOT_TAKEN or TAKEN.  */
 
-gimple
+gpredict *
 gimple_build_predict (enum br_predictor predictor, enum prediction outcome)
 {
-  gimple p = gimple_alloc (GIMPLE_PREDICT, 0);
+  gpredict *p = as_a <gpredict *> (gimple_alloc (GIMPLE_PREDICT, 0));
   /* Ensure all the predictors fit into the lower bits of the subcode.  */
   gcc_assert ((int) END_PREDICTORS <= GF_PREDICT_TAKEN);
   gimple_predict_set_predictor (p, predictor);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 0b09165..582bbbb 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -834,6 +834,16 @@ struct GTY((tag("GSS_WITH_MEM_OPS")))
   /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
 };
 
+/* A statement with the invariant that
+      stmt->code == GIMPLE_PREDICT
+   i.e. a hint for branch prediction.  */
+
+struct GTY(())
+  gpredict : public gimple_statement_base
+{
+  /* no additional fields; this uses the layout for GSS_BASE. */
+};
+
 template <>
 template <>
 inline bool
@@ -1061,6 +1071,14 @@ is_a_helper <gphi *>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gpredict *>::test (gimple gs)
+{
+  return gs->code == GIMPLE_PREDICT;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <greturn *>::test (gimple gs)
 {
   return gs->code == GIMPLE_RETURN;
@@ -1348,7 +1366,7 @@ gomp_teams *gimple_build_omp_teams (gimple_seq, tree);
 gomp_atomic_load *gimple_build_omp_atomic_load (tree, tree);
 gomp_atomic_store *gimple_build_omp_atomic_store (tree);
 gtransaction *gimple_build_transaction (gimple_seq, tree);
-gimple gimple_build_predict (enum br_predictor, enum prediction);
+gpredict *gimple_build_predict (enum br_predictor, enum prediction);
 extern void gimple_seq_add_stmt (gimple_seq *, gimple);
 extern void gimple_seq_add_stmt_without_update (gimple_seq *, gimple);
 void gimple_seq_add_seq (gimple_seq *, gimple_seq);
@@ -5438,9 +5456,8 @@ is_gimple_resx (const_gimple gs)
 /* Return the predictor of GIMPLE_PREDICT statement GS.  */
 
 static inline enum br_predictor
-gimple_predict_predictor (gimple gs)
+gimple_predict_predictor (const gpredict *gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_PREDICT);
   return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
 }
 
@@ -5448,9 +5465,8 @@ gimple_predict_predictor (gimple gs)
 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT.  */
 
 static inline void
-gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
+gimple_predict_set_predictor (gpredict *gs, enum br_predictor predictor)
 {
-  GIMPLE_CHECK (gs, GIMPLE_PREDICT);
   gs->subcode = (gs->subcode & GF_PREDICT_TAKEN)
 		       | (unsigned) predictor;
 }
@@ -5459,9 +5475,8 @@ gimple_predict_set_predictor (gimple gs, enum br_predictor predictor)
 /* Return the outcome of GIMPLE_PREDICT statement GS.  */
 
 static inline enum prediction
-gimple_predict_outcome (gimple gs)
+gimple_predict_outcome (const gpredict *gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_PREDICT);
   return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
 }
 
@@ -5469,7 +5484,7 @@ gimple_predict_outcome (gimple gs)
 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME.  */
 
 static inline void
-gimple_predict_set_outcome (gimple gs, enum prediction outcome)
+gimple_predict_set_outcome (gpredict *gs, enum prediction outcome)
 {
   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
   if (outcome == TAKEN)
diff --git a/gcc/predict.c b/gcc/predict.c
index 352417a..fad0f10 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2204,10 +2204,11 @@ tree_bb_level_predictions (void)
 		predict_paths_leading_to (bb, PRED_COLD_FUNCTION,
 					  NOT_TAKEN);
 	    }
-	  else if (gimple_code (stmt) == GIMPLE_PREDICT)
+	  else if (gpredict *predict_stmt = dyn_cast <gpredict *> (stmt))
 	    {
-	      predict_paths_leading_to (bb, gimple_predict_predictor (stmt),
-					gimple_predict_outcome (stmt));
+	      predict_paths_leading_to (bb,
+					gimple_predict_predictor (predict_stmt),
+					gimple_predict_outcome (predict_stmt));
 	      /* Keep GIMPLE_PREDICT around so early inlining will propagate
 	         hints to callers.  */
 	    }
-- 
1.7.11.7

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

* [gimple-classes, committed 08/10] Make remainging gimple_omp_parallel_ accessors typesafe
  2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
                   ` (8 preceding siblings ...)
  2014-10-29 19:23 ` [gimple-classes, committed 10/10] Introduce gpredict subclass and use it for all gimple_predict_ accessors David Malcolm
@ 2014-10-29 19:31 ` David Malcolm
  9 siblings, 0 replies; 11+ messages in thread
From: David Malcolm @ 2014-10-29 19:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/ChangeLog.gimple-classes:
	* gimple.h (gimple_omp_parallel_combined_p): Strengthen param from
	const_gimple to const gomp_parallel *.
	(gimple_omp_parallel_clauses): Likewise.
	(gimple_omp_parallel_set_combined_p): Strengthen param from gimple
	to gomp_parallel *.

	* omp-low.c (get_ws_args_for): Add checked cast.
	(determine_parallel_type): Likewise.
	(create_omp_child_function): Likewise.
	(lower_lastprivate_clauses): Likewise.
	(expand_omp_taskreg): Likewise.
	(expand_omp_for_init_vars): Likewise.
	(expand_omp_for_static_nochunk): Likewise.
	(expand_omp_for_static_chunk): Likewise.
	(lower_omp_for): Likewise.
	(lower_omp_taskreg): Replace check against GIMPLE_OMP_PARALLEL
	with a dyn_cast, introducing local "par_stmt" and using it in
	place of "stmt" for typesafety.
---
 gcc/ChangeLog.gimple-classes | 21 +++++++++++++++++
 gcc/gimple.h                 | 12 ++++------
 gcc/omp-low.c                | 56 ++++++++++++++++++++++++++------------------
 3 files changed, 58 insertions(+), 31 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index cc8b97b..e8001f4 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,26 @@
 2014-10-29  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple.h (gimple_omp_parallel_combined_p): Strengthen param from
+	const_gimple to const gomp_parallel *.
+	(gimple_omp_parallel_clauses): Likewise.
+	(gimple_omp_parallel_set_combined_p): Strengthen param from gimple
+	to gomp_parallel *.
+
+	* omp-low.c (get_ws_args_for): Add checked cast.
+	(determine_parallel_type): Likewise.
+	(create_omp_child_function): Likewise.
+	(lower_lastprivate_clauses): Likewise.
+	(expand_omp_taskreg): Likewise.
+	(expand_omp_for_init_vars): Likewise.
+	(expand_omp_for_static_nochunk): Likewise.
+	(expand_omp_for_static_chunk): Likewise.
+	(lower_omp_for): Likewise.
+	(lower_omp_taskreg): Replace check against GIMPLE_OMP_PARALLEL
+	with a dyn_cast, introducing local "par_stmt" and using it in
+	place of "stmt" for typesafety.
+
+2014-10-29  David Malcolm  <dmalcolm@redhat.com>
+
 	* gimple.h (gimple_omp_target_clauses): Strengthen param from
 	const_gimple to const gomp_target *.
 	(gimple_omp_target_kind): Likewise.
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3220f9a..4e86476 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2097,9 +2097,8 @@ gimple_omp_section_set_last (gimple g)
    GF_OMP_PARALLEL_COMBINED flag set.  */
 
 static inline bool
-gimple_omp_parallel_combined_p (const_gimple g)
+gimple_omp_parallel_combined_p (const gomp_parallel *g)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
   return (gimple_omp_subcode (g) & GF_OMP_PARALLEL_COMBINED) != 0;
 }
 
@@ -2108,9 +2107,8 @@ gimple_omp_parallel_combined_p (const_gimple g)
    value of COMBINED_P.  */
 
 static inline void
-gimple_omp_parallel_set_combined_p (gimple g, bool combined_p)
+gimple_omp_parallel_set_combined_p (gomp_parallel *g, bool combined_p)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_PARALLEL);
   if (combined_p)
     g->subcode |= GF_OMP_PARALLEL_COMBINED;
   else
@@ -4573,13 +4571,11 @@ gimple_omp_for_set_pre_body (gomp_for *omp_for_stmt, gimple_seq pre_body)
 }
 
 
-/* Return the clauses associated with OMP_PARALLEL GS.  */
+/* Return the clauses associated with OMP_PARALLEL OMP_PARALLEL_STMT.  */
 
 static inline tree
-gimple_omp_parallel_clauses (const_gimple gs)
+gimple_omp_parallel_clauses (const gomp_parallel *omp_parallel_stmt)
 {
-  const gomp_parallel *omp_parallel_stmt =
-    as_a <const gomp_parallel *> (gs);
   return omp_parallel_stmt->clauses;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 21eee0f..6e0db88 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -693,7 +693,8 @@ get_ws_args_for (gimple par_stmt, gimple ws_stmt)
       if (gimple_omp_for_combined_into_p (for_stmt))
 	{
 	  tree innerc
-	    = find_omp_clause (gimple_omp_parallel_clauses (par_stmt),
+	    = find_omp_clause (gimple_omp_parallel_clauses (
+				 as_a <gomp_parallel *> (par_stmt)),
 			       OMP_CLAUSE__LOOPTEMP_);
 	  gcc_assert (innerc);
 	  n1 = OMP_CLAUSE_DECL (innerc);
@@ -767,7 +768,8 @@ determine_parallel_type (struct omp_region *region)
   if (single_succ (par_entry_bb) == ws_entry_bb
       && single_succ (ws_exit_bb) == par_exit_bb
       && workshare_safe_to_combine_p (ws_entry_bb)
-      && (gimple_omp_parallel_combined_p (last_stmt (par_entry_bb))
+      && (gimple_omp_parallel_combined_p (as_a <gomp_parallel *> (
+					    last_stmt (par_entry_bb)))
 	  || (last_and_only_stmt (ws_entry_bb)
 	      && last_and_only_stmt (par_exit_bb))))
     {
@@ -1901,7 +1903,8 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
 
   tree cilk_for_count
     = (flag_cilkplus && gimple_code (ctx->stmt) == GIMPLE_OMP_PARALLEL)
-      ? find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt),
+      ? find_omp_clause (gimple_omp_parallel_clauses (
+			   as_a <gomp_parallel *> (ctx->stmt)),
 			 OMP_CLAUSE__CILK_FOR_COUNT_) : NULL_TREE;
   tree cilk_var_type = NULL_TREE;
 
@@ -3967,7 +3970,8 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
       if (ctx == NULL || !is_parallel_ctx (ctx))
 	return;
 
-      clauses = find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt),
+      clauses = find_omp_clause (gimple_omp_parallel_clauses (
+				   as_a <gomp_parallel *> (ctx->stmt)),
 				 OMP_CLAUSE_LASTPRIVATE);
       if (clauses == NULL)
 	return;
@@ -4072,7 +4076,8 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
 	  if (ctx == NULL || !is_parallel_ctx (ctx))
 	    break;
 
-	  c = find_omp_clause (gimple_omp_parallel_clauses (ctx->stmt),
+	  c = find_omp_clause (gimple_omp_parallel_clauses (
+				 as_a <gomp_parallel *> (ctx->stmt)),
 			       OMP_CLAUSE_LASTPRIVATE);
 	  par_clauses = true;
 	}
@@ -4938,7 +4943,8 @@ expand_omp_taskreg (struct omp_region *region)
   bool is_cilk_for
     = (flag_cilkplus
        && gimple_code (entry_stmt) == GIMPLE_OMP_PARALLEL
-       && find_omp_clause (gimple_omp_parallel_clauses (entry_stmt),
+       && find_omp_clause (gimple_omp_parallel_clauses (
+			     as_a <gomp_parallel *> (entry_stmt)),
 			   OMP_CLAUSE__CILK_FOR_COUNT_) != NULL_TREE);
 
   if (is_cilk_for)
@@ -5381,7 +5387,8 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 	return;
 
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
-		     ? gimple_omp_parallel_clauses (inner_stmt)
+		     ? gimple_omp_parallel_clauses (
+			 as_a <gomp_parallel *> (inner_stmt))
 		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       /* First two _looptemp_ clauses are for istart/iend, counts[0]
 	 isn't supposed to be handled, as the inner loop doesn't
@@ -6256,7 +6263,8 @@ expand_omp_for_static_nochunk (struct omp_region *region,
   if (gimple_omp_for_combined_p (fd->for_stmt))
     {
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
-		     ? gimple_omp_parallel_clauses (inner_stmt)
+		     ? gimple_omp_parallel_clauses (
+			 as_a <gomp_parallel *> (inner_stmt))
 		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_);
       gcc_assert (innerc);
@@ -6648,7 +6656,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
   if (gimple_omp_for_combined_p (fd->for_stmt))
     {
       tree clauses = gimple_code (inner_stmt) == GIMPLE_OMP_PARALLEL
-		     ? gimple_omp_parallel_clauses (inner_stmt)
+		     ? gimple_omp_parallel_clauses (
+			 as_a <gomp_parallel *> (inner_stmt))
 		     : gimple_omp_for_clauses (as_a <gomp_for *> (inner_stmt));
       tree innerc = find_omp_clause (clauses, OMP_CLAUSE__LOOPTEMP_);
       gcc_assert (innerc);
@@ -9508,7 +9517,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       tree clauses = *pc;
       if (parallel_for)
 	outerc
-	  = find_omp_clause (gimple_omp_parallel_clauses (ctx->outer->stmt),
+	  = find_omp_clause (gimple_omp_parallel_clauses (
+			       as_a <gomp_parallel *> (ctx->outer->stmt)),
 			     OMP_CLAUSE__LOOPTEMP_);
       for (i = 0; i < count; i++)
 	{
@@ -9986,19 +9996,19 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
     as_a <gbind *> (gimple_seq_first_stmt (gimple_omp_body (stmt)));
   par_body = gimple_bind_body (par_bind);
   child_fn = ctx->cb.dst_fn;
-  if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
-      && !gimple_omp_parallel_combined_p (stmt))
-    {
-      struct walk_stmt_info wi;
-      int ws_num = 0;
-
-      memset (&wi, 0, sizeof (wi));
-      wi.info = &ws_num;
-      wi.val_only = true;
-      walk_gimple_seq (par_body, check_combined_parallel, NULL, &wi);
-      if (ws_num == 1)
-	gimple_omp_parallel_set_combined_p (stmt, true);
-    }
+  if (gomp_parallel *par_stmt = dyn_cast <gomp_parallel *> (stmt))
+    if (!gimple_omp_parallel_combined_p (par_stmt))
+      {
+	struct walk_stmt_info wi;
+	int ws_num = 0;
+
+	memset (&wi, 0, sizeof (wi));
+	wi.info = &ws_num;
+	wi.val_only = true;
+	walk_gimple_seq (par_body, check_combined_parallel, NULL, &wi);
+	if (ws_num == 1)
+	  gimple_omp_parallel_set_combined_p (par_stmt, true);
+      }
   gimple_seq dep_ilist = NULL;
   gimple_seq dep_olist = NULL;
   if (gimple_code (stmt) == GIMPLE_OMP_TASK
-- 
1.7.11.7

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29 18:52 [gimple-classes, committed 00/10] Even more accessor typesafety David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 01/10] Make all of gimple_omp_task_ accessors typesafe David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 09/10] Make remaining gimple_eh_filter_ " David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 06/10] Convert remaining gimple_omp_single_ accessors to be typesafe David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 07/10] Make remaining gimple_omp_target_ accessors typesafe David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 02/10] Make all gimple_omp_for_ " David Malcolm
2014-10-29 18:52 ` [gimple-classes, committed 04/10] Make all gimple_omp_sections_ " David Malcolm
2014-10-29 19:04 ` [gimple-classes, committed 03/10] Make remaining gimple_omp_teams_ " David Malcolm
2014-10-29 19:08 ` [gimple-classes, committed 05/10] Make all gimple_omp_return_ " David Malcolm
2014-10-29 19:23 ` [gimple-classes, committed 10/10] Introduce gpredict subclass and use it for all gimple_predict_ accessors David Malcolm
2014-10-29 19:31 ` [gimple-classes, committed 08/10] Make remainging gimple_omp_parallel_ accessors typesafe 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).