public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (13 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 17/89] Update various expressions within tree-scalar-evolution.c to be gimple_phi David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 18:34   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 06/89] Introduce gimple_label and use it in a few places David Malcolm
                   ` (76 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-loop-ivopts.c (determine_biv_step): Require a gimple_phi.
	(find_bivs): Convert local "phi" into a gimple_phi.
	(mark_bivs): Likewise.
---
 gcc/tree-ssa-loop-ivopts.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index ea18311..24f296a 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1009,7 +1009,7 @@ get_iv (struct ivopts_data *data, tree var)
    not define a simple affine biv with nonzero step.  */
 
 static tree
-determine_biv_step (gimple phi)
+determine_biv_step (gimple_phi phi)
 {
   struct loop *loop = gimple_bb (phi)->loop_father;
   tree name = PHI_RESULT (phi);
@@ -1029,7 +1029,7 @@ determine_biv_step (gimple phi)
 static bool
 find_bivs (struct ivopts_data *data)
 {
-  gimple phi;
+  gimple_phi phi;
   tree step, type, base;
   bool found = false;
   struct loop *loop = data->current_loop;
@@ -1074,7 +1074,8 @@ find_bivs (struct ivopts_data *data)
 static void
 mark_bivs (struct ivopts_data *data)
 {
-  gimple phi, def;
+  gimple_phi phi;
+  gimple def;
   tree var;
   struct iv *iv, *incr_iv;
   struct loop *loop = data->current_loop;
-- 
1.8.5.3

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

* [PATCH 20/89] Introduce gimple_call
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (7 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 58/89] Make gimple_label_set_label require a gimple_label David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 19:00   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi David Malcolm
                   ` (82 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_call): New typedef.
	(const_gimple_call): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_call): New.
	(gimple_statement_base::dyn_cast_gimple_call): New.
	(gimple_call_reset_alias_info): Require a gimple_call rather than
	a plain gimple.
	(gimple_call_set_internal_fn): Likewise.
	(gimple_call_set_chain): Likewise.

	(gimple_call_set_return_slot_opt): Likewise; remove redundant
	GIMPLE_CHECK.
	(gimple_call_set_from_thunk): Likewise.
	(gimple_call_from_thunk_p): Likewise.
	(gimple_call_set_va_arg_pack): Likewise.
	(gimple_call_va_arg_pack_p): Likewise.
	(gimple_call_set_alloca_for_var): Likewise.
	(gimple_call_alloca_for_var_p): Likewise.

	(gimple_build_call_vec): Return a gimple_call rather than a gimple.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_call_copy_skip_args): Likewise.

	(gimple_call_return_flags): Require a const_gimple_call rather than
	a plain const_gimple.
	(gimple_call_chain_ptr): Likewise.

	(gimple_expr_type): Introduce local "call_stmt", once we know we have
	a GIMPLE_CALL.

	* asan.c (get_mem_refs_of_builtin_call): Require a const_gimple_call
	rather than a plain const_gimple.
	(has_stmt_been_instrumented_p): Add checked cast to gimple_call in
	region where stmt is known to be a GIMPLE_CALL (owing to it being
	a builtin call).
	(instrument_strlen_call): Add checked cast to gimple_call.
	(instrument_builtin_call): Likewise.

	* builtins.c (validate_gimple_arglist): Require a const_gimple_call
	rather than a plain const_gimple.
	(gimple_fold_builtin_sprintf_chk): Require a gimple_call rather than
	a plain gimple.
	(gimple_fold_builtin_snprintf_chk): Likewise.
	(gimple_fold_builtin_varargs): Likewise.
	(fold_call_stmt): Likewise.

	* builtins.h (validate_gimple_arglist): Require a const_gimple_call
	rather than a plain const_gimple.

	* cfgexpand.c (expand_call_stmt): Require a gimple_call rather
	than a plain gimple.
	(expand_gimple_stmt_1): Add a checked cast to gimple_call within
	GIMPLE_CALL case of switch statement.

	* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Strengthen
	"new_stmt" from gimple to gimple_call; add checked cast.

	* cgraphunit.c (expand_thunk): Strengthen local "call" from gimple
	to a gimple_call.

	* gimple-fold.c (gimple_fold_builtin): Require a gimple_call rather
	than a plain gimple.
	(gimple_fold_call): Strengthen local "call" from gimple to a
	gimple_call.
	(gimple_fold_stmt_to_constant_1): Add a checked cast to gimple_call
	within GIMPLE_CALL case of switch statement.

	* gimple-fold.h (gimple_fold_builtin): Require a gimple_call rather
	than a plain gimple.

	* gimple-pretty-print.c (dump_gimple_call_args): Likewise.
	(dump_gimple_call): Likewise.
	(pp_gimple_stmt_1): Add a checked cast to gimple_call within
	GIMPLE_CALL case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Replace is_gimple_call
	within dyn_cast_gimple_call and a new local.  Add a checked cast to
	gimple_call when resetting alias information.

	* gimple-walk.c (walk_gimple_op): Add a checked cast to gimple_call
	within GIMPLE_CALL case of switch statement.

	* gimple.c (gimple_call_reset_alias_info): Require a gimple_call
	rather than a plain gimple.
	(gimple_build_call_1): Return a gimple_call rather than a gimple.
	(gimple_build_call_vec): Likewise.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal_1): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_call_copy_skip_args): Likewise.
	(gimple_call_return_flags): Require a const_gimple_call
	rather than a plain const_gimple.

	* gimplify.c (gimplify_call_expr): Convert local from gimple to
	gimple_call.
	(gimplify_modify_expr_to_memcpy): Likewise.
	(gimplify_modify_expr_to_memset): Likewise.
	(gimplify_expr): Likewise.
	(gimplify_function_tree): Likewise.
	(gimplify_modify_expr): Add checked cast to gimple_call.

	* internal-fn.def: Update comment to indicate that each
	expand_NAME now takes a gimple_call, rather than just a gimple.

	* internal-fn.c (expand_LOAD_LANES): Require a gimple_call
	rather than a plain gimple.
	(expand_STORE_LANES): Likewise.
	(expand_ANNOTATE): Likewise.
	(expand_GOMP_SIMD_LANE): Likewise.
	(expand_GOMP_SIMD_VF): Likewise.
	(expand_GOMP_SIMD_LAST_LANE): Likewise.
	(expand_UBSAN_NULL): Likewise.
	(ubsan_expand_si_overflow_addsub_check): Likewise.
	(ubsan_expand_si_overflow_neg_check): Likewise.
	(ubsan_expand_si_overflow_mul_check): Likewise.
	(expand_UBSAN_CHECK_ADD): Likewise.
	(expand_UBSAN_CHECK_SUB): Likewise.
	(expand_UBSAN_CHECK_MUL): Likewise.
	(expand_LOOP_VECTORIZED): Likewise.
	(expand_MASK_LOAD): Likewise.
	(expand_MASK_STORE): Likewise.
	(expand_ABNORMAL_DISPATCHER): Likewise.
	(expand_BUILTIN_EXPECT): Likewise.
	(internal_fn_expanders): Likewise.
	(expand_internal_call): Likewise.

	* internal-fn.h (expand_internal_call): Likewise.

	* ipa-prop.c (ipa_modify_call_arguments): Convert local from
	gimple to gimple_call.

	* ipa-pure-const.c (check_call): Require a gimple_call rather than
	just a gimple.
	(check_stmt): Add checked cast to gimple_call within GIMPLE_CALL
	case of switch statement.

	* ipa-split.c (split_function): Convert local from gimple to
	gimple_call.

	* omp-low.c (build_omp_barrier): Likewise.
	(lower_rec_input_clauses): Likewise.

	* trans-mem.c (build_tm_load): Return a gimple_call rather than a
	plain gimple.
	(build_tm_store): Likewise.
	(expand_transaction): Convert local from gimple to gimple_call.

	* tree-call-cdce.c (check_pow): Require a gimple_call rather than
	just a gimple.
	(check_builtin_call): Likewise.
	(is_call_dce_candidate): Likewise.
	(gen_conditions_for_pow): Likewise.
	(gen_shrink_wrap_conditions): Likewise.
	(shrink_wrap_one_built_in_call): Likewise.
	(shrink_wrap_conditional_dead_built_in_calls): Require a
	vec<gimple_call> rather than a vec<gimple>.
	(tree_call_cdce): Convert local "cond_dead_built_in_calls" from
	an auto_vec<gimple> to an auto_vec<gimple_call>; convert invocation
	of is_gimple_call to dyn_cast_gimple_call and new local.

	* tree-cfg.c (notice_special_calls): Require a gimple_call rather
	than just a gimple.
	* tree-cfg.h (notice_special_calls): Require a gimple_call rather
	than just a gimple.

	* tree-complex.c (expand_complex_libcall): Convert local from
	gimple to gimple_call.

	* tree-inline.c (remap_gimple_stmt): Add checked cast to
	gimple_call.
	(copy_bb): Likewise; convert local from gimple to gimple_call.
	(inline_forbidden_p_stmt): Add checked cast to gimple_call.

	* tree-nested.c (init_tmp_var_with_call): Require a gimple_call
	rather than a gimple.
	(convert_nl_goto_reference): Convert local from gimple to
	gimple_call.
	(convert_tramp_reference_op): Likewise.
	(convert_gimple_call): Add checked cast to gimple_call.

	* tree-nrv.c (dest_safe_for_nrv_p): Require a gimple_call
	rather than a gimple.
	(execute_return_slot_opt): Convert local from gimple to
	gimple_call.  Convert is_gimple_call to dyn_cast_gimple_call
	and new local.

	* tree-object-size.c (alloc_object_size): Require a
	const_gimple_call rather than a plain const_gimple.
	(pass_through_call): Likewise.
	(call_object_size): Require a gimple_call rather than a plain
	gimple.
	(collect_object_sizes_for): Add checked cast to gimple_call within
	GIMPLE_CALL case of switch statement.
	(check_for_plus_in_loops_1): Likewise.
	(compute_object_sizes): Add checked cast to gimple_call.

	* tree-profile.c (gimple_gen_interval_profiler): Convert local
	from gimple_call to gimple.
	(gimple_gen_pow2_profiler): Likewise.
	(gimple_gen_one_value_profiler): Likewise.
	(gimple_gen_time_profiler): Likewise.
	(gimple_gen_average_profiler): Likewise.
	(gimple_gen_ior_profiler): Likewise.

	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Require a
	gimple_call rather than a plain gimple.
	(ref_maybe_used_by_call_p): Likewise.
	(ref_maybe_used_by_stmt_p): Add checked cast to gimple_call.
	(call_may_clobber_ref_p_1): Require a gimple_call rather than a
	plain gimple.
	(call_may_clobber_ref_p): Likewise.
	(stmt_may_clobber_ref_p_1): Add checked cast to gimple_call.

	* tree-ssa-alias.h (call_may_clobber_ref_p): Require a gimple_call
	rather than a plain gimple.

	* tree-ssa-ccp.c (execute_fold_all_builtins): Add checked cast to
	gimple_call.

	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Likewise.

	* tree-ssa-loop-prefetch.c (emit_mfence_after_loop): Convert local
	from gimple to gimple_call.

	* tree-ssa-math-opts.c (build_and_insert_call): Likewise.
	(execute_optimize_bswap): Likewise.

	* tree-ssa-operands.c (maybe_add_call_vops): Require a gimple_call
	rather than a plain gimple.
	(parse_ssa_operands): Add checked cast to gimple_call within
	GIMPLE_CALL case of switch statement.

	* tree-ssa-pre.c (compute_avail): Add checked cast to gimple_call.

	* tree-ssa-sccvn.c (copy_reference_ops_from_call): Require a
	gimple_call rather than a plain gimple.
	(create_reference_ops_from_call): Likewise.
	(valueize_shared_reference_ops_from_call): Likewise.
	(visit_reference_op_call): Likewise.
	(visit_use): Replace is_gimple_call with dyn_cast_gimple_call and
	a new local.

	* tree-ssa-sccvn.h  (copy_reference_ops_from_call): Require a
	gimple_call rather than a plain gimple.

	* tree-ssa-structalias.c (get_call_vi): Likewise.
	(lookup_call_use_vi): Likewise.
	(lookup_call_clobber_vi): Likewise.
	(get_call_use_vi): Likewise.
	(get_call_clobber_vi): Likewise.
	(handle_rhs_call): Likewise.
	(handle_lhs_call): Likewise.
	(handle_const_call): Likewise.
	(handle_pure_call): Likewise.
	(get_fi_for_callee): Likewise.
	(find_func_aliases_for_builtin_call): Likewise.
	(find_func_aliases_for_call): Likewise.
	(find_func_aliases): Add checked cast to gimple_call.
	(find_func_clobbers): Replace is_gimple_call with
	dyn_cast_gimple_call and a new local.
	(compute_points_to_sets): Likewise.
	(ipa_pta_execute): Likewise.

	* tree-ssa-threadedge.c
	(record_temporary_equivalences_from_stmts_at_dest): Add checked cast
	to gimple_call.

	* tree-tailcall.c (find_tail_calls): Convert local from gimple to
	gimple_call.  Add checked cast to gimple_call.

	* tree-vect-data-refs.c (vect_setup_realignment): Split local new_stmt
	into two with more tight scopes, one as a gimple_assign, the other as
	a gimple_call.

	* tree-vect-patterns.c (vect_recog_pow_pattern): Convert local to a
	gimple_bind.

	* tree-vect-stmts.c (vectorizable_function): Require a gimple_call
	rather than a plain gimple.
	(vectorizable_call): Convert "stmt" to a gimple_call, by renaming
	parameter, and making stmt be the result of a dyn_cast.

	* tree-vectorizer.h (vectorizable_function): Require a gimple_call
	rather than a plain gimple.

	* tree.h (fold_call_stmt): Likewise.
	(gimple_fold_builtin_snprintf_chk): Likewise.

	* value-prof.c (check_ic_target): Likewise.
	(gimple_ic_transform): Replace check for GIMPLE_CALL with
	dyn_cast_gimple_call.
	(interesting_stringop_to_profile_p): Require a gimple_call rather
	than a plain gimple.
	(gimple_stringop_fixed_value): Likewise.
	(gimple_stringops_transform): Replace check for GIMPLE_CALL with
	dyn_cast_gimple_call.
	(gimple_stringops_values_to_profile): Likewise.

	* vtable-verify.c (verify_bb_vtables): Convert local from a gimple
	to a gimple_call.
---
 gcc/asan.c                   |  8 ++--
 gcc/builtins.c               | 11 +++---
 gcc/builtins.h               |  2 +-
 gcc/cfgexpand.c              |  4 +-
 gcc/cgraph.c                 |  4 +-
 gcc/cgraphunit.c             |  2 +-
 gcc/coretypes.h              |  4 ++
 gcc/gimple-fold.c            | 10 +++--
 gcc/gimple-fold.h            |  2 +-
 gcc/gimple-pretty-print.c    |  6 +--
 gcc/gimple-streamer-in.c     | 10 ++---
 gcc/gimple-walk.c            |  3 +-
 gcc/gimple.c                 | 42 +++++++++++----------
 gcc/gimple.h                 | 90 ++++++++++++++++++++++++--------------------
 gcc/gimplify.c               | 14 +++----
 gcc/internal-fn.c            | 42 ++++++++++-----------
 gcc/internal-fn.def          |  2 +-
 gcc/internal-fn.h            |  2 +-
 gcc/ipa-prop.c               |  2 +-
 gcc/ipa-pure-const.c         |  4 +-
 gcc/ipa-split.c              |  2 +-
 gcc/omp-low.c                |  4 +-
 gcc/trans-mem.c              | 10 ++---
 gcc/tree-call-cdce.c         | 25 ++++++------
 gcc/tree-cfg.c               |  2 +-
 gcc/tree-cfg.h               |  2 +-
 gcc/tree-complex.c           |  3 +-
 gcc/tree-inline.c            | 10 ++---
 gcc/tree-nested.c            | 11 +++---
 gcc/tree-nrv.c               |  7 ++--
 gcc/tree-object-size.c       | 20 +++++-----
 gcc/tree-profile.c           | 12 +++---
 gcc/tree-ssa-alias.c         | 12 +++---
 gcc/tree-ssa-alias.h         |  2 +-
 gcc/tree-ssa-ccp.c           |  2 +-
 gcc/tree-ssa-dce.c           |  2 +-
 gcc/tree-ssa-loop-prefetch.c |  2 +-
 gcc/tree-ssa-math-opts.c     |  4 +-
 gcc/tree-ssa-operands.c      |  4 +-
 gcc/tree-ssa-pre.c           |  3 +-
 gcc/tree-ssa-sccvn.c         | 15 ++++----
 gcc/tree-ssa-sccvn.h         |  2 +-
 gcc/tree-ssa-structalias.c   | 45 +++++++++++-----------
 gcc/tree-ssa-threadedge.c    |  2 +-
 gcc/tree-tailcall.c          |  7 ++--
 gcc/tree-vect-data-refs.c    |  3 +-
 gcc/tree-vect-patterns.c     |  2 +-
 gcc/tree-vect-stmts.c        | 14 ++++---
 gcc/tree-vectorizer.h        |  2 +-
 gcc/tree.h                   |  5 ++-
 gcc/value-prof.c             | 22 ++++++-----
 gcc/vtable-verify.c          |  2 +-
 52 files changed, 280 insertions(+), 244 deletions(-)

diff --git a/gcc/asan.c b/gcc/asan.c
index 8bfe25d..cab4d44 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -462,7 +462,7 @@ get_mem_ref_of_assignment (const_gimple_assign assignment,
    representing a builtin call that has to do with memory access.  */
 
 static bool
-get_mem_refs_of_builtin_call (const gimple call,
+get_mem_refs_of_builtin_call (const_gimple_call call,
 			      asan_mem_ref *src0,
 			      tree *src0_len,
 			      bool *src0_is_store,
@@ -816,7 +816,7 @@ has_stmt_been_instrumented_p (gimple stmt)
       tree src0_len = NULL_TREE, src1_len = NULL_TREE, dest_len = NULL_TREE;
       bool src0_is_store = false, src1_is_store = false,
 	dest_is_store = false, dest_is_deref = false;
-      if (get_mem_refs_of_builtin_call (stmt,
+      if (get_mem_refs_of_builtin_call (stmt->as_a_gimple_call (),
 					&src0, &src0_len, &src0_is_store,
 					&src1, &src1_len, &src1_is_store,
 					&dest, &dest_len, &dest_is_store,
@@ -1836,7 +1836,7 @@ instrument_mem_region_access (tree base, tree len,
 static bool
 instrument_strlen_call (gimple_stmt_iterator *iter)
 {
-  gimple call = gsi_stmt (*iter);
+  gimple_call call = gsi_stmt (*iter)->as_a_gimple_call ();
   gcc_assert (is_gimple_call (call));
 
   tree callee = gimple_call_fndecl (call);
@@ -1912,7 +1912,7 @@ instrument_builtin_call (gimple_stmt_iterator *iter)
     return false;
 
   bool iter_advanced_p = false;
-  gimple call = gsi_stmt (*iter);
+  gimple_call call = gsi_stmt (*iter)->as_a_gimple_call ();
 
   gcc_checking_assert (gimple_call_builtin_p (call, BUILT_IN_NORMAL));
 
diff --git a/gcc/builtins.c b/gcc/builtins.c
index dd57b1a..17206f9 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -11415,7 +11415,7 @@ validate_arg (const_tree arg, enum tree_code code)
    validate_arglist will then be removed.  */
 
 bool
-validate_gimple_arglist (const_gimple call, ...)
+validate_gimple_arglist (const_gimple_call call, ...)
 {
   enum tree_code code;
   bool res = 0;
@@ -14154,7 +14154,8 @@ do_mpc_arg2 (tree arg0, tree arg1, tree type, int do_nonfinite,
    inline.  FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK.  */
 
 static tree
-gimple_fold_builtin_sprintf_chk (gimple stmt, enum built_in_function fcode)
+gimple_fold_builtin_sprintf_chk (gimple_call stmt,
+				 enum built_in_function fcode)
 {
   int nargs = gimple_call_num_args (stmt);
 
@@ -14171,7 +14172,7 @@ gimple_fold_builtin_sprintf_chk (gimple stmt, enum built_in_function fcode)
    passed as second argument.  */
 
 tree
-gimple_fold_builtin_snprintf_chk (gimple stmt, tree maxlen,
+gimple_fold_builtin_snprintf_chk (gimple_call stmt, tree maxlen,
                                   enum built_in_function fcode)
 {
   int nargs = gimple_call_num_args (stmt);
@@ -14190,7 +14191,7 @@ gimple_fold_builtin_snprintf_chk (gimple stmt, tree maxlen,
    result of the function call is ignored.  */
 
 static tree
-gimple_fold_builtin_varargs (tree fndecl, gimple stmt,
+gimple_fold_builtin_varargs (tree fndecl, gimple_call stmt,
 			     bool ignore ATTRIBUTE_UNUSED)
 {
   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -14224,7 +14225,7 @@ gimple_fold_builtin_varargs (tree fndecl, gimple stmt,
    call node earlier than the warning is generated.  */
 
 tree
-fold_call_stmt (gimple stmt, bool ignore)
+fold_call_stmt (gimple_call stmt, bool ignore)
 {
   tree ret = NULL_TREE;
   tree fndecl = gimple_call_fndecl (stmt);
diff --git a/gcc/builtins.h b/gcc/builtins.h
index 5eb9303..a288693 100644
--- a/gcc/builtins.h
+++ b/gcc/builtins.h
@@ -44,6 +44,6 @@ extern struct target_builtins *this_target_builtins;
 #define this_target_builtins (&default_target_builtins)
 #endif
 
-extern bool validate_gimple_arglist (const_gimple, ...);
+extern bool validate_gimple_arglist (const_gimple_call, ...);
 
 #endif
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 679933d..175a9f4 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2179,7 +2179,7 @@ mark_transaction_restart_calls (gimple stmt)
    statement STMT.  */
 
 static void
-expand_call_stmt (gimple stmt)
+expand_call_stmt (gimple_call stmt)
 {
   tree exp, decl, lhs;
   bool builtin_p;
@@ -3153,7 +3153,7 @@ expand_gimple_stmt_1 (gimple stmt)
       expand_asm_stmt (stmt);
       break;
     case GIMPLE_CALL:
-      expand_call_stmt (stmt);
+      expand_call_stmt (stmt->as_a_gimple_call ());
       break;
 
     case GIMPLE_RETURN:
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index dcab984..3652796 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1332,7 +1332,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
 {
   tree decl = gimple_call_fndecl (e->call_stmt);
   tree lhs = gimple_call_lhs (e->call_stmt);
-  gimple new_stmt;
+  gimple_call new_stmt;
   gimple_stmt_iterator gsi;
 #ifdef ENABLE_CHECKING
   struct cgraph_node *node;
@@ -1469,7 +1469,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
     }
   else
     {
-      new_stmt = e->call_stmt;
+      new_stmt = e->call_stmt->as_a_gimple_call ();
       gimple_call_set_fndecl (new_stmt, e->callee->decl);
       update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
     }
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 06283fc..588fe13 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1531,7 +1531,7 @@ expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
       tree resdecl;
       tree restmp = NULL;
 
-      gimple call;
+      gimple_call call;
       gimple ret;
 
       if (in_lto_p)
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index e199b0c..0f884fd 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -89,6 +89,10 @@ struct gimple_statement_assign;
 typedef struct gimple_statement_assign *gimple_assign;
 typedef const struct gimple_statement_assign *const_gimple_assign;
 
+struct gimple_statement_call;
+typedef struct gimple_statement_call *gimple_call;
+typedef const struct gimple_statement_call *const_gimple_call;
+
 struct gimple_statement_bind;
 typedef struct gimple_statement_bind *gimple_bind;
 typedef const struct gimple_statement_bind *const_gimple_bind;
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 59f7ada..aa62bef 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -871,7 +871,7 @@ get_maxval_strlen (tree arg, tree *length, bitmap visited, int type)
    be valid in GIMPLE.  Callers must take care.  */
 
 tree
-gimple_fold_builtin (gimple stmt)
+gimple_fold_builtin (gimple_call stmt)
 {
   tree result, val[3];
   tree callee, a;
@@ -1080,7 +1080,7 @@ gimple_fold_builtin (gimple stmt)
 static bool
 gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_call stmt = gsi_stmt (*gsi)->as_a_gimple_call ();
   tree callee;
   bool changed = false;
   unsigned i;
@@ -2713,6 +2713,7 @@ gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree))
     case GIMPLE_CALL:
       {
 	tree fn;
+	gimple_call call_stmt = stmt->as_a_gimple_call ();
 
 	if (gimple_call_internal_p (stmt))
 	  {
@@ -2777,14 +2778,15 @@ gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree))
 	    for (i = 0; i < gimple_call_num_args (stmt); ++i)
 	      args[i] = (*valueize) (gimple_call_arg (stmt, i));
 	    call = build_call_array_loc (loc,
-					 gimple_call_return_type (stmt),
+					 gimple_call_return_type (call_stmt),
 					 fn, gimple_call_num_args (stmt), args);
 	    retval = fold_call_expr (EXPR_LOCATION (call), call, false);
 	    if (retval)
 	      {
 		/* fold_call_expr wraps the result inside a NOP_EXPR.  */
 		STRIP_NOPS (retval);
-		retval = fold_convert (gimple_call_return_type (stmt), retval);
+		retval = fold_convert (gimple_call_return_type (call_stmt),
+				       retval);
 	      }
 	    return retval;
 	  }
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 6b43066..d5a3e94 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -25,7 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 extern tree canonicalize_constructor_val (tree, tree);
 extern tree get_symbol_constant_value (tree);
 extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
-extern tree gimple_fold_builtin (gimple);
+extern tree gimple_fold_builtin (gimple_call);
 extern bool fold_stmt (gimple_stmt_iterator *);
 extern bool fold_stmt_inplace (gimple_stmt_iterator *);
 extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree, 
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index bf5f286..6b903aa 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -569,7 +569,7 @@ dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
    dump_gimple_call.  */
 
 static void
-dump_gimple_call_args (pretty_printer *buffer, gimple gs, int flags)
+dump_gimple_call_args (pretty_printer *buffer, gimple_call gs, int flags)
 {
   size_t i;
 
@@ -642,7 +642,7 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_call (pretty_printer *buffer, gimple_call gs, int spc, int flags)
 {
   tree lhs = gimple_call_lhs (gs);
   tree fn = gimple_call_fn (gs);
@@ -2103,7 +2103,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_CALL:
-      dump_gimple_call (buffer, gs, spc, flags);
+      dump_gimple_call (buffer, gs->as_a_gimple_call (), spc, flags);
       break;
 
     case GIMPLE_COND:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index fad04cd..2d5885f 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -185,13 +185,13 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
 		  == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0))))
 	    *opp = TREE_OPERAND (TREE_OPERAND (*opp, 0), 0);
 	}
-      if (is_gimple_call (stmt))
+      if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	{
-	  if (gimple_call_internal_p (stmt))
+	  if (gimple_call_internal_p (call_stmt))
 	    gimple_call_set_internal_fn
-	      (stmt, streamer_read_enum (ib, internal_fn, IFN_LAST));
+	      (call_stmt, streamer_read_enum (ib, internal_fn, IFN_LAST));
 	  else
-	    gimple_call_set_fntype (stmt, stream_read_tree (ib, data_in));
+	    gimple_call_set_fntype (call_stmt, stream_read_tree (ib, data_in));
 	}
       break;
 
@@ -230,7 +230,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
 
   /* Reset alias information.  */
   if (code == GIMPLE_CALL)
-    gimple_call_reset_alias_info (stmt);
+    gimple_call_reset_alias_info (stmt->as_a_gimple_call ());
 
   /* Mark the statement modified so its operand vectors can be filled in.  */
   gimple_set_modified (stmt, true);
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 85b6dcd..0bb86db 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -236,7 +236,8 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
 	  wi->val_only = true;
 	}
 
-      ret = walk_tree (gimple_call_chain_ptr (stmt), callback_op, wi, pset);
+      ret = walk_tree (gimple_call_chain_ptr (stmt->as_a_gimple_call ()),
+		       callback_op, wi, pset);
       if (ret)
         return ret;
 
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 943fa7c..6acf60b 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -189,7 +189,7 @@ gimple_build_return (tree retval)
 /* Reset alias information on call S.  */
 
 void
-gimple_call_reset_alias_info (gimple s)
+gimple_call_reset_alias_info (gimple_call s)
 {
   if (gimple_call_flags (s) & ECF_CONST)
     memset (gimple_call_use_set (s), 0, sizeof (struct pt_solution));
@@ -206,10 +206,11 @@ gimple_call_reset_alias_info (gimple s)
    components of a GIMPLE_CALL statement to function FN with NARGS
    arguments.  */
 
-static inline gimple
+static inline gimple_call
 gimple_build_call_1 (tree fn, unsigned nargs)
 {
-  gimple s = gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK, nargs + 3);
+  gimple_call s = gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
+					 nargs + 3)->as_a_gimple_call ();
   if (TREE_CODE (fn) == FUNCTION_DECL)
     fn = build_fold_addr_expr (fn);
   gimple_set_op (s, 1, fn);
@@ -222,12 +223,12 @@ gimple_build_call_1 (tree fn, unsigned nargs)
 /* Build a GIMPLE_CALL statement to function FN with the arguments
    specified in vector ARGS.  */
 
-gimple
+gimple_call
 gimple_build_call_vec (tree fn, vec<tree> args)
 {
   unsigned i;
   unsigned nargs = args.length ();
-  gimple call = gimple_build_call_1 (fn, nargs);
+  gimple_call call = gimple_build_call_1 (fn, nargs);
 
   for (i = 0; i < nargs; i++)
     gimple_call_set_arg (call, i, args[i]);
@@ -239,11 +240,11 @@ gimple_build_call_vec (tree fn, vec<tree> args)
 /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
    arguments.  The ... are the arguments.  */
 
-gimple
+gimple_call
 gimple_build_call (tree fn, unsigned nargs, ...)
 {
   va_list ap;
-  gimple call;
+  gimple_call call;
   unsigned i;
 
   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
@@ -262,10 +263,10 @@ gimple_build_call (tree fn, unsigned nargs, ...)
 /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
    arguments.  AP contains the arguments.  */
 
-gimple
+gimple_call
 gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
 {
-  gimple call;
+  gimple_call call;
   unsigned i;
 
   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
@@ -283,10 +284,11 @@ gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
    Build the basic components of a GIMPLE_CALL statement to internal
    function FN with NARGS arguments.  */
 
-static inline gimple
+static inline gimple_call
 gimple_build_call_internal_1 (enum internal_fn fn, unsigned nargs)
 {
-  gimple s = gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK, nargs + 3);
+  gimple_call s = gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
+					 nargs + 3)->as_a_gimple_call ();
   s->subcode |= GF_CALL_INTERNAL;
   gimple_call_set_internal_fn (s, fn);
   gimple_call_reset_alias_info (s);
@@ -297,11 +299,11 @@ gimple_build_call_internal_1 (enum internal_fn fn, unsigned nargs)
 /* Build a GIMPLE_CALL statement to internal function FN.  NARGS is
    the number of arguments.  The ... are the arguments.  */
 
-gimple
+gimple_call
 gimple_build_call_internal (enum internal_fn fn, unsigned nargs, ...)
 {
   va_list ap;
-  gimple call;
+  gimple_call call;
   unsigned i;
 
   call = gimple_build_call_internal_1 (fn, nargs);
@@ -317,11 +319,11 @@ gimple_build_call_internal (enum internal_fn fn, unsigned nargs, ...)
 /* Build a GIMPLE_CALL statement to internal function FN with the arguments
    specified in vector ARGS.  */
 
-gimple
+gimple_call
 gimple_build_call_internal_vec (enum internal_fn fn, vec<tree> args)
 {
   unsigned i, nargs;
-  gimple call;
+  gimple_call call;
 
   nargs = args.length ();
   call = gimple_build_call_internal_1 (fn, nargs);
@@ -336,11 +338,11 @@ gimple_build_call_internal_vec (enum internal_fn fn, vec<tree> args)
    assumed to be in GIMPLE form already.  Minimal checking is done of
    this fact.  */
 
-gimple
+gimple_call
 gimple_build_call_from_tree (tree t)
 {
   unsigned i, nargs;
-  gimple call;
+  gimple_call call;
   tree fndecl = get_callee_fndecl (t);
 
   gcc_assert (TREE_CODE (t) == CALL_EXPR);
@@ -1387,7 +1389,7 @@ gimple_call_arg_flags (const_gimple stmt, unsigned arg)
 /* Detects return flags for the call STMT.  */
 
 int
-gimple_call_return_flags (const_gimple stmt)
+gimple_call_return_flags (const_gimple_call stmt)
 {
   tree attr;
 
@@ -2011,13 +2013,13 @@ canonicalize_cond_expr_cond (tree t)
 /* Build a GIMPLE_CALL identical to STMT but skipping the arguments in
    the positions marked by the set ARGS_TO_SKIP.  */
 
-gimple
+gimple_call
 gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip)
 {
   int i;
   int nargs = gimple_call_num_args (stmt);
   auto_vec<tree> vargs (nargs);
-  gimple new_stmt;
+  gimple_call new_stmt;
 
   for (i = 0; i < nargs; i++)
     if (!bitmap_bit_p (args_to_skip, i))
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 62f9756..4e0be1f 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -240,6 +240,18 @@ public:
     return as_a <gimple_statement_assign> (this);
   }
 
+  inline gimple_call
+  as_a_gimple_call ()
+  {
+    return as_a <gimple_statement_call> (this);
+  }
+
+  inline const_gimple_call
+  as_a_gimple_call () const
+  {
+    return as_a <const gimple_statement_call> (this);
+  }
+
   inline gimple_bind
   as_a_gimple_bind ()
   {
@@ -290,6 +302,12 @@ public:
     return dyn_cast <gimple_statement_assign> (this);
   }
 
+  inline gimple_call
+  dyn_cast_gimple_call ()
+  {
+    return dyn_cast <gimple_statement_call> (this);
+  }
+
   inline gimple_bind
   dyn_cast_gimple_bind ()
   {
@@ -1363,13 +1381,13 @@ extern gimple currently_expanding_gimple_stmt;
 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
 gimple gimple_build_return (tree);
-void gimple_call_reset_alias_info (gimple);
-gimple gimple_build_call_vec (tree, vec<tree> );
-gimple gimple_build_call (tree, unsigned, ...);
-gimple gimple_build_call_valist (tree, unsigned, va_list);
-gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
-gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
-gimple gimple_build_call_from_tree (tree);
+void gimple_call_reset_alias_info (gimple_call);
+gimple_call gimple_build_call_vec (tree, vec<tree> );
+gimple_call gimple_build_call (tree, unsigned, ...);
+gimple_call gimple_build_call_valist (tree, unsigned, va_list);
+gimple_call gimple_build_call_internal (enum internal_fn, unsigned, ...);
+gimple_call gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
+gimple_call gimple_build_call_from_tree (tree);
 gimple_assign gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
 gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
@@ -1434,7 +1452,7 @@ gimple_seq gimple_seq_copy (gimple_seq);
 bool gimple_call_same_target_p (const_gimple, const_gimple);
 int gimple_call_flags (const_gimple);
 int gimple_call_arg_flags (const_gimple, unsigned);
-int gimple_call_return_flags (const_gimple);
+int gimple_call_return_flags (const_gimple_call);
 bool gimple_assign_copy_p (gimple);
 bool gimple_assign_ssa_name_copy_p (gimple);
 bool gimple_assign_unary_nop_p (gimple);
@@ -1452,7 +1470,7 @@ bool gimple_assign_rhs_could_trap_p (gimple);
 extern void dump_gimple_statistics (void);
 unsigned get_gimple_rhs_num_ops (enum tree_code);
 extern tree canonicalize_cond_expr_cond (tree);
-gimple gimple_call_copy_skip_args (gimple, bitmap);
+gimple_call gimple_call_copy_skip_args (gimple, bitmap);
 extern bool gimple_compare_field_offset (tree, tree);
 extern tree gimple_unsigned_type (tree);
 extern tree gimple_signed_type (tree);
@@ -2726,13 +2744,12 @@ gimple_call_set_fndecl (gimple gs, tree decl)
 }
 
 
-/* Set internal function FN to be the function called by call statement GS.  */
+/* Set internal function FN to be the function called by call statement CALL_STMT.  */
 
 static inline void
-gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
+gimple_call_set_internal_fn (gimple_call call_stmt, enum internal_fn fn)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call> (gs);
-  gcc_gimple_checking_assert (gimple_call_internal_p (gs));
+  gcc_gimple_checking_assert (gimple_call_internal_p (call_stmt));
   call_stmt->u.internal_fn = fn;
 }
 
@@ -2751,7 +2768,7 @@ gimple_call_fndecl (const_gimple gs)
 /* Return the type returned by call statement GS.  */
 
 static inline tree
-gimple_call_return_type (const_gimple gs)
+gimple_call_return_type (const_gimple_call gs)
 {
   tree type = gimple_call_fntype (gs);
 
@@ -2774,23 +2791,20 @@ gimple_call_chain (const_gimple gs)
 }
 
 
-/* Return a pointer to the static chain for call statement GS.  */
+/* Return a pointer to the static chain for call statement CALL_STMT.  */
 
 static inline tree *
-gimple_call_chain_ptr (const_gimple gs)
+gimple_call_chain_ptr (const_gimple_call call_stmt)
 {
-  GIMPLE_CHECK (gs, GIMPLE_CALL);
-  return gimple_op_ptr (gs, 2);
+  return gimple_op_ptr (call_stmt, 2);
 }
 
-/* Set CHAIN to be the static chain for call statement GS.  */
+/* Set CHAIN to be the static chain for call statement CALL_STMT.  */
 
 static inline void
-gimple_call_set_chain (gimple gs, tree chain)
+gimple_call_set_chain (gimple_call call_stmt, tree chain)
 {
-  GIMPLE_CHECK (gs, GIMPLE_CALL);
-
-  gimple_set_op (gs, 2, chain);
+  gimple_set_op (call_stmt, 2, chain);
 }
 
 
@@ -2867,9 +2881,8 @@ gimple_call_tail_p (gimple s)
    expansion as the return slot for calls that return in memory.  */
 
 static inline void
-gimple_call_set_return_slot_opt (gimple s, bool return_slot_opt_p)
+gimple_call_set_return_slot_opt (gimple_call s, bool return_slot_opt_p)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (return_slot_opt_p)
     s->subcode |= GF_CALL_RETURN_SLOT_OPT;
   else
@@ -2891,9 +2904,8 @@ gimple_call_return_slot_opt_p (gimple s)
    thunk to the thunked-to function.  */
 
 static inline void
-gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
+gimple_call_set_from_thunk (gimple_call s, bool from_thunk_p)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (from_thunk_p)
     s->subcode |= GF_CALL_FROM_THUNK;
   else
@@ -2904,9 +2916,8 @@ gimple_call_set_from_thunk (gimple s, bool from_thunk_p)
 /* Return true if GIMPLE_CALL S is a jump from a thunk.  */
 
 static inline bool
-gimple_call_from_thunk_p (gimple s)
+gimple_call_from_thunk_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (s->subcode & GF_CALL_FROM_THUNK) != 0;
 }
 
@@ -2915,9 +2926,8 @@ gimple_call_from_thunk_p (gimple s)
    argument pack in its argument list.  */
 
 static inline void
-gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
+gimple_call_set_va_arg_pack (gimple_call s, bool pass_arg_pack_p)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (pass_arg_pack_p)
     s->subcode |= GF_CALL_VA_ARG_PACK;
   else
@@ -2929,9 +2939,8 @@ gimple_call_set_va_arg_pack (gimple s, bool pass_arg_pack_p)
    argument pack in its argument list.  */
 
 static inline bool
-gimple_call_va_arg_pack_p (gimple s)
+gimple_call_va_arg_pack_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (s->subcode & GF_CALL_VA_ARG_PACK) != 0;
 }
 
@@ -2974,9 +2983,8 @@ gimple_call_nothrow_p (gimple s)
    stack growth even when they occur in loops.  */
 
 static inline void
-gimple_call_set_alloca_for_var (gimple s, bool for_var)
+gimple_call_set_alloca_for_var (gimple_call s, bool for_var)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (for_var)
     s->subcode |= GF_CALL_ALLOCA_FOR_VAR;
   else
@@ -2986,9 +2994,8 @@ gimple_call_set_alloca_for_var (gimple s, bool for_var)
 /* Return true of S is a call to builtin_alloca emitted for VLA objects.  */
 
 static inline bool
-gimple_call_alloca_for_var_p (gimple s)
+gimple_call_alloca_for_var_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (s->subcode & GF_CALL_ALLOCA_FOR_VAR) != 0;
 }
 
@@ -5831,11 +5838,12 @@ gimple_expr_type (const_gimple stmt)
 	 original RHS type as far as we can reconstruct it.  */
       if (code == GIMPLE_CALL)
 	{
-	  if (gimple_call_internal_p (stmt)
-	      && gimple_call_internal_fn (stmt) == IFN_MASK_STORE)
-	    type = TREE_TYPE (gimple_call_arg (stmt, 3));
+	  const_gimple_call call_stmt = stmt->as_a_gimple_call ();
+	  if (gimple_call_internal_p (call_stmt)
+	      && gimple_call_internal_fn (call_stmt) == IFN_MASK_STORE)
+	    type = TREE_TYPE (gimple_call_arg (call_stmt, 3));
 	  else
-	    type = gimple_call_return_type (stmt);
+	    type = gimple_call_return_type (call_stmt);
 	}
       else
 	switch (gimple_assign_rhs_code (stmt))
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 46dc786..bfb8f98 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2214,7 +2214,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
   tree fndecl, parms, p, fnptrtype;
   enum gimplify_status ret;
   int i, nargs;
-  gimple call;
+  gimple_call call;
   bool builtin_va_start_p = false;
   location_t loc = EXPR_LOCATION (*expr_p);
 
@@ -3142,7 +3142,7 @@ gimplify_modify_expr_to_memcpy (tree *expr_p, tree size, bool want_value,
     				gimple_seq *seq_p)
 {
   tree t, to, to_ptr, from, from_ptr;
-  gimple gs;
+  gimple_call gs;
   location_t loc = EXPR_LOCATION (*expr_p);
 
   to = TREE_OPERAND (*expr_p, 0);
@@ -3189,7 +3189,7 @@ gimplify_modify_expr_to_memset (tree *expr_p, tree size, bool want_value,
     				gimple_seq *seq_p)
 {
   tree t, from, to, to_ptr;
-  gimple gs;
+  gimple_call gs;
   location_t loc = EXPR_LOCATION (*expr_p);
 
   /* Assert our assumptions, to abort instead of producing wrong code
@@ -4580,7 +4580,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	  assign = gimple_build_call_from_tree (*from_p);
 	  gimple_call_set_fntype (assign, TREE_TYPE (fnptrtype));
 	}
-      notice_special_calls (assign);
+      notice_special_calls (assign->as_a_gimple_call ());
       if (!gimple_call_noreturn_p (assign))
 	gimple_call_set_lhs (assign, *to_p);
     }
@@ -7519,8 +7519,8 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	      }
 	    tree tmp = create_tmp_var (type, NULL);
 	    gimplify_arg (&cond, pre_p, EXPR_LOCATION (*expr_p));
-	    gimple call = gimple_build_call_internal (IFN_ANNOTATE, 2,
-						      cond, id);
+	    gimple_call call = gimple_build_call_internal (IFN_ANNOTATE, 2,
+							   cond, id);
 	    gimple_call_set_lhs (call, tmp);
 	    gimplify_seq_add_stmt (pre_p, call);
 	    *expr_p = tmp;
@@ -8739,7 +8739,7 @@ gimplify_function_tree (tree fndecl)
       gimple tf;
       gimple_seq cleanup = NULL, body = NULL;
       tree tmp_var;
-      gimple call;
+      gimple_call call;
 
       x = builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS);
       call = gimple_build_call (x, 1, integer_zero_node);
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index 1062ea8..38a06f3 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -76,7 +76,7 @@ get_multi_vector_move (tree array_type, convert_optab optab)
 /* Expand LOAD_LANES call STMT.  */
 
 static void
-expand_LOAD_LANES (gimple stmt)
+expand_LOAD_LANES (gimple_call stmt)
 {
   struct expand_operand ops[2];
   tree type, lhs, rhs;
@@ -100,7 +100,7 @@ expand_LOAD_LANES (gimple stmt)
 /* Expand STORE_LANES call STMT.  */
 
 static void
-expand_STORE_LANES (gimple stmt)
+expand_STORE_LANES (gimple_call stmt)
 {
   struct expand_operand ops[2];
   tree type, lhs, rhs;
@@ -122,7 +122,7 @@ expand_STORE_LANES (gimple stmt)
 }
 
 static void
-expand_ANNOTATE (gimple stmt ATTRIBUTE_UNUSED)
+expand_ANNOTATE (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
@@ -130,7 +130,7 @@ expand_ANNOTATE (gimple stmt ATTRIBUTE_UNUSED)
 /* This should get expanded in adjust_simduid_builtins.  */
 
 static void
-expand_GOMP_SIMD_LANE (gimple stmt ATTRIBUTE_UNUSED)
+expand_GOMP_SIMD_LANE (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
@@ -138,7 +138,7 @@ expand_GOMP_SIMD_LANE (gimple stmt ATTRIBUTE_UNUSED)
 /* This should get expanded in adjust_simduid_builtins.  */
 
 static void
-expand_GOMP_SIMD_VF (gimple stmt ATTRIBUTE_UNUSED)
+expand_GOMP_SIMD_VF (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
@@ -146,7 +146,7 @@ expand_GOMP_SIMD_VF (gimple stmt ATTRIBUTE_UNUSED)
 /* This should get expanded in adjust_simduid_builtins.  */
 
 static void
-expand_GOMP_SIMD_LAST_LANE (gimple stmt ATTRIBUTE_UNUSED)
+expand_GOMP_SIMD_LAST_LANE (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
@@ -154,7 +154,7 @@ expand_GOMP_SIMD_LAST_LANE (gimple stmt ATTRIBUTE_UNUSED)
 /* This should get expanded in the sanopt pass.  */
 
 static void
-expand_UBSAN_NULL (gimple stmt ATTRIBUTE_UNUSED)
+expand_UBSAN_NULL (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
@@ -163,7 +163,7 @@ expand_UBSAN_NULL (gimple stmt ATTRIBUTE_UNUSED)
    CODE says whether the operation is +, or -.  */
 
 void
-ubsan_expand_si_overflow_addsub_check (tree_code code, gimple stmt)
+ubsan_expand_si_overflow_addsub_check (tree_code code, gimple_call stmt)
 {
   rtx res, op0, op1;
   tree lhs, fn, arg0, arg1;
@@ -311,7 +311,7 @@ ubsan_expand_si_overflow_addsub_check (tree_code code, gimple stmt)
 /* Add negate overflow checking to the statement STMT.  */
 
 void
-ubsan_expand_si_overflow_neg_check (gimple stmt)
+ubsan_expand_si_overflow_neg_check (gimple_call stmt)
 {
   rtx res, op1;
   tree lhs, fn, arg1;
@@ -387,7 +387,7 @@ ubsan_expand_si_overflow_neg_check (gimple stmt)
 /* Add mul overflow checking to the statement STMT.  */
 
 void
-ubsan_expand_si_overflow_mul_check (gimple stmt)
+ubsan_expand_si_overflow_mul_check (gimple_call stmt)
 {
   rtx res, op0, op1;
   tree lhs, fn, arg0, arg1;
@@ -782,7 +782,7 @@ ubsan_expand_si_overflow_mul_check (gimple stmt)
 /* Expand UBSAN_CHECK_ADD call STMT.  */
 
 static void
-expand_UBSAN_CHECK_ADD (gimple stmt)
+expand_UBSAN_CHECK_ADD (gimple_call stmt)
 {
   ubsan_expand_si_overflow_addsub_check (PLUS_EXPR, stmt);
 }
@@ -790,7 +790,7 @@ expand_UBSAN_CHECK_ADD (gimple stmt)
 /* Expand UBSAN_CHECK_SUB call STMT.  */
 
 static void
-expand_UBSAN_CHECK_SUB (gimple stmt)
+expand_UBSAN_CHECK_SUB (gimple_call stmt)
 {
   if (integer_zerop (gimple_call_arg (stmt, 0)))
     ubsan_expand_si_overflow_neg_check (stmt);
@@ -801,7 +801,7 @@ expand_UBSAN_CHECK_SUB (gimple stmt)
 /* Expand UBSAN_CHECK_MUL call STMT.  */
 
 static void
-expand_UBSAN_CHECK_MUL (gimple stmt)
+expand_UBSAN_CHECK_MUL (gimple_call stmt)
 {
   ubsan_expand_si_overflow_mul_check (stmt);
 }
@@ -809,13 +809,13 @@ expand_UBSAN_CHECK_MUL (gimple stmt)
 /* This should get folded in tree-vectorizer.c.  */
 
 static void
-expand_LOOP_VECTORIZED (gimple stmt ATTRIBUTE_UNUSED)
+expand_LOOP_VECTORIZED (gimple_call stmt ATTRIBUTE_UNUSED)
 {
   gcc_unreachable ();
 }
 
 static void
-expand_MASK_LOAD (gimple stmt)
+expand_MASK_LOAD (gimple_call stmt)
 {
   struct expand_operand ops[3];
   tree type, lhs, rhs, maskt;
@@ -840,7 +840,7 @@ expand_MASK_LOAD (gimple stmt)
 }
 
 static void
-expand_MASK_STORE (gimple stmt)
+expand_MASK_STORE (gimple_call stmt)
 {
   struct expand_operand ops[3];
   tree type, lhs, rhs, maskt;
@@ -863,12 +863,12 @@ expand_MASK_STORE (gimple stmt)
 }
 
 static void
-expand_ABNORMAL_DISPATCHER (gimple)
+expand_ABNORMAL_DISPATCHER (gimple_call)
 {
 }
 
 static void
-expand_BUILTIN_EXPECT (gimple stmt)
+expand_BUILTIN_EXPECT (gimple_call stmt)
 {
   /* When guessing was done, the hints should be already stripped away.  */
   gcc_assert (!flag_guess_branch_prob || optimize == 0 || seen_error ());
@@ -887,10 +887,10 @@ expand_BUILTIN_EXPECT (gimple stmt)
 /* Routines to expand each internal function, indexed by function number.
    Each routine has the prototype:
 
-       expand_<NAME> (gimple stmt)
+       expand_<NAME> (gimple_call stmt)
 
    where STMT is the statement that performs the call. */
-static void (*const internal_fn_expanders[]) (gimple) = {
+static void (*const internal_fn_expanders[]) (gimple_call) = {
 #define DEF_INTERNAL_FN(CODE, FLAGS) expand_##CODE,
 #include "internal-fn.def"
 #undef DEF_INTERNAL_FN
@@ -900,7 +900,7 @@ static void (*const internal_fn_expanders[]) (gimple) = {
 /* Expand STMT, which is a call to internal function FN.  */
 
 void
-expand_internal_call (gimple stmt)
+expand_internal_call (gimple_call stmt)
 {
   internal_fn_expanders[(int) gimple_call_internal_fn (stmt)] (stmt);
 }
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 31dc4c9..99013f4 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  If not see
    ECF_* flags.  Each entry must have a corresponding expander
    of the form:
 
-     void expand_NAME (gimple stmt)
+     void expand_NAME (gimple_call stmt)
 
    where STMT is the statement that performs the call.  */
 
diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h
index 9c3215f..014f39f 100644
--- a/gcc/internal-fn.h
+++ b/gcc/internal-fn.h
@@ -48,6 +48,6 @@ internal_fn_flags (enum internal_fn fn)
   return internal_fn_flags_array[(int) fn];
 }
 
-extern void expand_internal_call (gimple);
+extern void expand_internal_call (gimple_call);
 
 #endif
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 9f144fa..45d540e 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -3665,7 +3665,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
   struct cgraph_node *current_node = cgraph_get_node (current_function_decl);
   vec<tree> vargs;
   vec<tree, va_gc> **debug_args = NULL;
-  gimple new_stmt;
+  gimple_call new_stmt;
   gimple_stmt_iterator gsi, prev_gsi;
   tree callee_decl;
   int i, len;
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 7d35880..e5ec305 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -464,7 +464,7 @@ special_builtin_state (enum pure_const_state_e *state, bool *looping,
    the entire call expression.  */
 
 static void
-check_call (funct_state local, gimple call, bool ipa)
+check_call (funct_state local, gimple_call call, bool ipa)
 {
   int flags = gimple_call_flags (call);
   tree callee_t = gimple_call_fndecl (call);
@@ -685,7 +685,7 @@ check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
   switch (gimple_code (stmt))
     {
     case GIMPLE_CALL:
-      check_call (local, stmt, ipa);
+      check_call (local, stmt->as_a_gimple_call (), ipa);
       break;
     case GIMPLE_LABEL:
       if (DECL_NONLOCAL (gimple_label_label (stmt)))
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 38bd883..dbcc787 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1091,7 +1091,7 @@ split_function (struct split_point *split_point)
   basic_block return_bb = find_return_bb ();
   basic_block call_bb;
   gimple_stmt_iterator gsi;
-  gimple call;
+  gimple_call call;
   edge e;
   edge_iterator ei;
   tree retval = NULL, real_retval = NULL;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cbf13d2..af50d89 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2717,7 +2717,7 @@ build_omp_barrier (tree lhs)
 {
   tree fndecl = builtin_decl_explicit (lhs ? BUILT_IN_GOMP_BARRIER_CANCEL
 					   : BUILT_IN_GOMP_BARRIER);
-  gimple g = gimple_build_call (fndecl, 0);
+  gimple_call g = gimple_build_call (fndecl, 0);
   if (lhs)
     gimple_call_set_lhs (g, lhs);
   return g;
@@ -3147,7 +3147,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 
 	      if (c_kind != OMP_CLAUSE_FIRSTPRIVATE || !is_task_ctx (ctx))
 		{
-		  gimple stmt;
+		  gimple_call stmt;
 		  tree tmp, atmp;
 
 		  ptr = DECL_VALUE_EXPR (new_var);
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index f3300c3..1d992f6 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -2096,12 +2096,12 @@ transaction_subcode_ior (struct tm_region *region, unsigned flags)
 
    LOC is the location to use for the new statement(s).  */
 
-static gimple
+static gimple_call
 build_tm_load (location_t loc, tree lhs, tree rhs, gimple_stmt_iterator *gsi)
 {
   enum built_in_function code = END_BUILTINS;
   tree t, type = TREE_TYPE (rhs), decl;
-  gimple gcall;
+  gimple_call gcall;
 
   if (type == float_type_node)
     code = BUILT_IN_TM_LOAD_FLOAT;
@@ -2168,12 +2168,12 @@ build_tm_load (location_t loc, tree lhs, tree rhs, gimple_stmt_iterator *gsi)
 
 /* Similarly for storing TYPE in a transactional context.  */
 
-static gimple
+static gimple_call
 build_tm_store (location_t loc, tree lhs, tree rhs, gimple_stmt_iterator *gsi)
 {
   enum built_in_function code = END_BUILTINS;
   tree t, fn, type = TREE_TYPE (rhs), simple_type;
-  gimple gcall;
+  gimple_call gcall;
 
   if (type == float_type_node)
     code = BUILT_IN_TM_STORE_FLOAT;
@@ -2729,7 +2729,7 @@ expand_transaction (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
     if (subcode & GTMA_IS_OUTER)
       region->original_transaction_was_outer = true;
     tree t = build_int_cst (tm_state_type, flags);
-    gimple call = gimple_build_call (tm_start, 1, t);
+    gimple_call call = gimple_build_call (tm_start, 1, t);
     gimple_call_set_lhs (call, tm_state);
     gimple_set_location (call, gimple_location (region->transaction_stmt));
 
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index 4b2ad87..d7941e3 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -174,7 +174,7 @@ check_target_format (tree arg)
 #define MAX_BASE_INT_BIT_SIZE 32
 
 static bool
-check_pow (gimple pow_call)
+check_pow (gimple_call pow_call)
 {
   tree base, expn;
   enum tree_code bc, ec;
@@ -248,7 +248,7 @@ check_pow (gimple pow_call)
    Returns true if the function call is a candidate.  */
 
 static bool
-check_builtin_call (gimple bcall)
+check_builtin_call (gimple_call bcall)
 {
   tree arg;
 
@@ -261,7 +261,7 @@ check_builtin_call (gimple bcall)
    is a candidate.  */
 
 static bool
-is_call_dce_candidate (gimple call)
+is_call_dce_candidate (gimple_call call)
 {
   tree fn;
   enum built_in_function fnc;
@@ -537,7 +537,7 @@ gen_conditions_for_pow_int_base (tree base, tree expn,
    and *NCONDS is the number of logical conditions.  */
 
 static void
-gen_conditions_for_pow (gimple pow_call, vec<gimple> conds,
+gen_conditions_for_pow (gimple_call pow_call, vec<gimple> conds,
                         unsigned *nconds)
 {
   tree base, expn;
@@ -673,10 +673,10 @@ get_no_error_domain (enum built_in_function fnc)
    condition are separated by NULL tree in the vector.  */
 
 static void
-gen_shrink_wrap_conditions (gimple bi_call, vec<gimple> conds,
+gen_shrink_wrap_conditions (gimple_call bi_call, vec<gimple> conds,
                             unsigned int *nconds)
 {
-  gimple call;
+  gimple_call call;
   tree fn;
   enum built_in_function fnc;
 
@@ -714,7 +714,7 @@ gen_shrink_wrap_conditions (gimple bi_call, vec<gimple> conds,
    transformation actually happens.  */
 
 static bool
-shrink_wrap_one_built_in_call (gimple bi_call)
+shrink_wrap_one_built_in_call (gimple_call bi_call)
 {
   gimple_stmt_iterator bi_call_bsi;
   basic_block bi_call_bb, join_tgt_bb, guard_bb, guard_bb0;
@@ -849,7 +849,7 @@ shrink_wrap_one_built_in_call (gimple bi_call)
    wrapping transformation.  */
 
 static bool
-shrink_wrap_conditional_dead_built_in_calls (vec<gimple> calls)
+shrink_wrap_conditional_dead_built_in_calls (vec<gimple_call> calls)
 {
   bool changed = false;
   unsigned i = 0;
@@ -860,7 +860,7 @@ shrink_wrap_conditional_dead_built_in_calls (vec<gimple> calls)
 
   for (; i < n ; i++)
     {
-      gimple bi_call = calls[i];
+      gimple_call bi_call = calls[i];
       changed |= shrink_wrap_one_built_in_call (bi_call);
     }
 
@@ -875,15 +875,14 @@ tree_call_cdce (void)
   basic_block bb;
   gimple_stmt_iterator i;
   bool something_changed = false;
-  auto_vec<gimple> cond_dead_built_in_calls;
+  auto_vec<gimple_call> cond_dead_built_in_calls;
   FOR_EACH_BB_FN (bb, cfun)
     {
       /* Collect dead call candidates.  */
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
         {
-	  gimple stmt = gsi_stmt (i);
-          if (is_gimple_call (stmt)
-              && is_call_dce_candidate (stmt))
+	  gimple_call stmt = gsi_stmt (i)->dyn_cast_gimple_call ();
+          if (stmt && is_call_dce_candidate (stmt))
             {
               if (dump_file && (dump_flags & TDF_DETAILS))
                 {
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 53c4808..8168d97 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1899,7 +1899,7 @@ single_noncomplex_succ (basic_block bb)
 /* T is CALL_EXPR.  Set current_function_calls_* flags.  */
 
 void
-notice_special_calls (gimple call)
+notice_special_calls (gimple_call call)
 {
   int flags = gimple_call_flags (call);
 
diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index c15d6ab..e291a0c 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -36,7 +36,7 @@ extern void group_case_labels_stmt (gimple_switch);
 extern void group_case_labels (void);
 extern void replace_uses_by (tree, tree);
 extern basic_block single_noncomplex_succ (basic_block bb);
-extern void notice_special_calls (gimple);
+extern void notice_special_calls (gimple_call);
 extern void clear_special_calls (void);
 extern edge find_taken_edge (basic_block, tree);
 extern void gimple_debug_bb (basic_block);
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 8b335cc..55b120e 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -948,7 +948,8 @@ expand_complex_libcall (gimple_stmt_iterator *gsi, tree ar, tree ai,
   enum machine_mode mode;
   enum built_in_function bcode;
   tree fn, type, lhs;
-  gimple old_stmt, stmt;
+  gimple old_stmt;
+  gimple_call stmt;
 
   old_stmt = gsi_stmt (*gsi);
   lhs = gimple_assign_lhs (old_stmt);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 9cea36c..9f06006 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1518,7 +1518,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 		 keep it valid over inlining by setting DECL_PT_UID.  */
 	      if (!id->src_cfun->gimple_df
 		  || !id->src_cfun->gimple_df->ipa_pta)
-		gimple_call_reset_alias_info (copy);
+		gimple_call_reset_alias_info (copy->as_a_gimple_call ());
 	    }
 	    break;
 
@@ -1660,13 +1660,13 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 
 	  stmt = gsi_stmt (copy_gsi);
 	  if (is_gimple_call (stmt)
-	      && gimple_call_va_arg_pack_p (stmt)
+	      && gimple_call_va_arg_pack_p (stmt->as_a_gimple_call ())
 	      && id->gimple_call)
 	    {
 	      /* __builtin_va_arg_pack () should be replaced by
 		 all arguments corresponding to ... in the caller.  */
 	      tree p;
-	      gimple new_call;
+	      gimple_call new_call;
 	      vec<tree> argarray;
 	      size_t nargs = gimple_call_num_args (id->gimple_call);
 	      size_t n;
@@ -1868,7 +1868,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 		    }
 		}
 
-	      notice_special_calls (stmt);
+	      notice_special_calls (stmt->as_a_gimple_call ());
 	    }
 
 	  maybe_duplicate_eh_stmt_fn (cfun, stmt, id->src_cfun, orig_stmt,
@@ -3349,7 +3349,7 @@ inline_forbidden_p_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 	 VLA objects as those can't cause unbounded growth (they're always
 	 wrapped inside stack_save/stack_restore regions.  */
       if (gimple_alloca_call_p (stmt)
-	  && !gimple_call_alloca_for_var_p (stmt)
+	  && !gimple_call_alloca_for_var_p (stmt->as_a_gimple_call ())
 	  && !lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)))
 	{
 	  inline_forbidden_reason
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 78de464..4009311 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -411,7 +411,7 @@ get_chain_field (struct nesting_info *info)
 
 static tree
 init_tmp_var_with_call (struct nesting_info *info, gimple_stmt_iterator *gsi,
-		        gimple call)
+		        gimple_call call)
 {
   tree t;
 
@@ -1864,7 +1864,7 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p,
   struct nesting_info *const info = (struct nesting_info *) wi->info, *i;
   tree label, new_label, target_context, x, field;
   void **slot;
-  gimple call;
+  gimple_call call;
   gimple stmt = gsi_stmt (*gsi);
 
   if (gimple_code (stmt) != GIMPLE_GOTO)
@@ -1982,7 +1982,7 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data)
   struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
   struct nesting_info *const info = (struct nesting_info *) wi->info, *i;
   tree t = *tp, decl, target_context, x, builtin;
-  gimple call;
+  gimple_call call;
 
   *walk_subtrees = 0;
   switch (TREE_CODE (t))
@@ -2125,8 +2125,9 @@ convert_gimple_call (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       target_context = decl_function_context (decl);
       if (target_context && DECL_STATIC_CHAIN (decl))
 	{
-	  gimple_call_set_chain (stmt, get_static_chain (info, target_context,
-							 &wi->gsi));
+	  gimple_call_set_chain (stmt->as_a_gimple_call (),
+				 get_static_chain (info, target_context,
+						   &wi->gsi));
 	  info->static_chain_added |= (1 << (info->context != target_context));
 	}
       break;
diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index b443388..5a5a5d8 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -323,7 +323,7 @@ make_pass_nrv (gcc::context *ctxt)
    DEST is available if it is not clobbered or used by the call.  */
 
 static bool
-dest_safe_for_nrv_p (gimple call)
+dest_safe_for_nrv_p (gimple_call call)
 {
   tree dest = gimple_call_lhs (call);
 
@@ -363,10 +363,11 @@ execute_return_slot_opt (void)
       gimple_stmt_iterator gsi;
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple stmt = gsi_stmt (gsi);
+	  gimple_call stmt;
 	  bool slot_opt_p;
 
-	  if (is_gimple_call (stmt)
+	  stmt = gsi_stmt (gsi)->dyn_cast_gimple_call ();
+	  if (stmt
 	      && gimple_call_lhs (stmt)
 	      && !gimple_call_return_slot_opt_p (stmt)
 	      && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 994845b..6a7e17b 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -58,8 +58,8 @@ static const unsigned HOST_WIDE_INT unknown[4] = { -1, -1, 0, 0 };
 static tree compute_object_offset (const_tree, const_tree);
 static unsigned HOST_WIDE_INT addr_object_size (struct object_size_info *,
 						const_tree, int);
-static unsigned HOST_WIDE_INT alloc_object_size (const_gimple, int);
-static tree pass_through_call (const_gimple);
+static unsigned HOST_WIDE_INT alloc_object_size (const_gimple_call, int);
+static tree pass_through_call (const_gimple_call);
 static void collect_object_sizes_for (struct object_size_info *, tree);
 static void expr_object_size (struct object_size_info *, tree, tree);
 static bool merge_object_sizes (struct object_size_info *, tree, tree,
@@ -392,7 +392,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
    unknown[object_size_type].  */
 
 static unsigned HOST_WIDE_INT
-alloc_object_size (const_gimple call, int object_size_type)
+alloc_object_size (const_gimple_call call, int object_size_type)
 {
   tree callee, bytes = NULL_TREE;
   tree alloc_size;
@@ -455,7 +455,7 @@ alloc_object_size (const_gimple call, int object_size_type)
    Otherwise return NULL.  */
 
 static tree
-pass_through_call (const_gimple call)
+pass_through_call (const_gimple_call call)
 {
   tree callee = gimple_call_fndecl (call);
 
@@ -669,7 +669,7 @@ expr_object_size (struct object_size_info *osi, tree ptr, tree value)
 /* Compute object_sizes for PTR, defined to the result of a call.  */
 
 static void
-call_object_size (struct object_size_info *osi, tree ptr, gimple call)
+call_object_size (struct object_size_info *osi, tree ptr, gimple_call call)
 {
   int object_size_type = osi->object_size_type;
   unsigned int varno = SSA_NAME_VERSION (ptr);
@@ -966,7 +966,8 @@ collect_object_sizes_for (struct object_size_info *osi, tree var)
 
     case GIMPLE_CALL:
       {
-        tree arg = pass_through_call (stmt);
+	gimple_call call_stmt = stmt->as_a_gimple_call ();
+        tree arg = pass_through_call (call_stmt);
         if (arg)
           {
             if (TREE_CODE (arg) == SSA_NAME
@@ -976,7 +977,7 @@ collect_object_sizes_for (struct object_size_info *osi, tree var)
               expr_object_size (osi, var, arg);
           }
         else
-          call_object_size (osi, var, stmt);
+          call_object_size (osi, var, call_stmt);
 	break;
       }
 
@@ -1102,7 +1103,8 @@ check_for_plus_in_loops_1 (struct object_size_info *osi, tree var,
 
     case GIMPLE_CALL:
       {
-        tree arg = pass_through_call (stmt);
+	gimple_call call_stmt = stmt->as_a_gimple_call ();
+        tree arg = pass_through_call (call_stmt);
         if (arg)
           {
             if (TREE_CODE (arg) == SSA_NAME)
@@ -1222,7 +1224,7 @@ compute_object_sizes (void)
 	    continue;
 
 	  init_object_sizes ();
-	  result = fold_call_stmt (call, false);
+	  result = fold_call_stmt (call->as_a_gimple_call (), false);
 	  if (!result)
 	    {
 	      if (gimple_call_num_args (call) == 2
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 02e9ff2..e79fedc 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -328,7 +328,7 @@ gimple_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref = tree_coverage_counter_ref (tag, base), ref_ptr;
-  gimple call;
+  gimple_call call;
   tree val;
   tree start = build_int_cst_type (integer_type_node,
 				   value->hdata.intvl.int_start);
@@ -354,7 +354,7 @@ gimple_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
-  gimple call;
+  gimple_call call;
   tree val;
 
   ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
@@ -374,7 +374,7 @@ gimple_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned bas
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
-  gimple call;
+  gimple_call call;
   tree val;
 
   ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
@@ -492,7 +492,7 @@ gimple_gen_time_profiler (unsigned tag, unsigned base,
                           gimple_stmt_iterator &gsi)
 {
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
-  gimple call;
+  gimple_call call;
 
   ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
 				      true, NULL_TREE, true, GSI_SAME_STMT);
@@ -527,7 +527,7 @@ gimple_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
-  gimple call;
+  gimple_call call;
   tree val;
 
   ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
@@ -548,7 +548,7 @@ gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
-  gimple call;
+  gimple_call call;
   tree val;
 
   ref_ptr = force_gimple_operand_gsi (&gsi, ref_ptr,
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index e706275..3fd2789 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1329,7 +1329,7 @@ refs_output_dependent_p (tree store1, tree store2)
    otherwise return false.  */
 
 static bool
-ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref)
+ref_maybe_used_by_call_p_1 (gimple_call call, ao_ref *ref)
 {
   tree base, callee;
   unsigned i;
@@ -1640,7 +1640,7 @@ process_args:
 }
 
 static bool
-ref_maybe_used_by_call_p (gimple call, tree ref)
+ref_maybe_used_by_call_p (gimple_call call, tree ref)
 {
   ao_ref r;
   bool res;
@@ -1677,7 +1677,7 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
       return refs_may_alias_p (rhs, ref);
     }
   else if (is_gimple_call (stmt))
-    return ref_maybe_used_by_call_p (stmt, ref);
+    return ref_maybe_used_by_call_p (stmt->as_a_gimple_call (), ref);
   else if (gimple_code (stmt) == GIMPLE_RETURN)
     {
       tree retval = gimple_return_retval (stmt);
@@ -1706,7 +1706,7 @@ ref_maybe_used_by_stmt_p (gimple stmt, tree ref)
    return true, otherwise return false.  */
 
 static bool
-call_may_clobber_ref_p_1 (gimple call, ao_ref *ref)
+call_may_clobber_ref_p_1 (gimple_call call, ao_ref *ref)
 {
   tree base;
   tree callee;
@@ -1969,7 +1969,7 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref)
    return true, otherwise return false.  */
 
 bool
-call_may_clobber_ref_p (gimple call, tree ref)
+call_may_clobber_ref_p (gimple_call call, tree ref)
 {
   bool res;
   ao_ref r;
@@ -2001,7 +2001,7 @@ stmt_may_clobber_ref_p_1 (gimple stmt, ao_ref *ref)
 	    return true;
 	}
 
-      return call_may_clobber_ref_p_1 (stmt, ref);
+      return call_may_clobber_ref_p_1 (stmt->as_a_gimple_call (), ref);
     }
   else if (gimple_assign_single_p (stmt))
     {
diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
index 3544aaf..be91bc6 100644
--- a/gcc/tree-ssa-alias.h
+++ b/gcc/tree-ssa-alias.h
@@ -109,7 +109,7 @@ extern bool ref_maybe_used_by_stmt_p (gimple, tree);
 extern bool stmt_may_clobber_global_p (gimple);
 extern bool stmt_may_clobber_ref_p (gimple, tree);
 extern bool stmt_may_clobber_ref_p_1 (gimple, ao_ref *);
-extern bool call_may_clobber_ref_p (gimple, tree);
+extern bool call_may_clobber_ref_p (gimple_call, tree);
 extern bool stmt_kills_ref_p (gimple, tree);
 extern tree get_continuation_for_phi (gimple, ao_ref *,
 				      unsigned int *, bitmap *, bool);
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 41debfb..d10f9ba 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2613,7 +2613,7 @@ execute_fold_all_builtins (void)
 	    }
 	  fcode = DECL_FUNCTION_CODE (callee);
 
-	  result = gimple_fold_builtin (stmt);
+	  result = gimple_fold_builtin (stmt->as_a_gimple_call ());
 
 	  if (result)
 	    gimple_remove_stmt_histograms (cfun, stmt);
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index c5a530b..8d3fc5b 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1217,7 +1217,7 @@ eliminate_unnecessary_stmts (void)
 	    {
 	      tree name = gimple_call_lhs (stmt);
 
-	      notice_special_calls (stmt);
+	      notice_special_calls (stmt->as_a_gimple_call ());
 
 	      /* When LHS of var = call (); is dead, simplify it into
 		 call (); saving one operand.  */
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index c0968c8..be34d05 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -1244,7 +1244,7 @@ emit_mfence_after_loop (struct loop *loop)
 {
   vec<edge> exits = get_loop_exit_edges (loop);
   edge exit;
-  gimple call;
+  gimple_call call;
   gimple_stmt_iterator bsi;
   unsigned i;
 
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 9ff857c..c9e5674 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -1072,7 +1072,7 @@ static tree
 build_and_insert_call (gimple_stmt_iterator *gsi, location_t loc,
 		       tree fn, tree arg)
 {
-  gimple call_stmt;
+  gimple_call call_stmt;
   tree ssa_target;
 
   call_stmt = gimple_build_call (fn, 1, arg);
@@ -1965,7 +1965,7 @@ execute_optimize_bswap (void)
 	  tree bswap_tmp;
 	  tree fndecl = NULL_TREE;
 	  int type_size;
-	  gimple call;
+	  gimple_call call;
 
 	  if (!is_gimple_assign (stmt)
 	      || gimple_assign_rhs_code (stmt) != BIT_IOR_EXPR)
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 352ccca..b95a273 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -639,7 +639,7 @@ get_tmr_operands (struct function *fn, gimple stmt, tree expr, int flags)
    escape, add them to the VDEF/VUSE lists for it.  */
 
 static void
-maybe_add_call_vops (struct function *fn, gimple stmt)
+maybe_add_call_vops (struct function *fn, gimple_call stmt)
 {
   int call_flags = gimple_call_flags (stmt);
 
@@ -936,7 +936,7 @@ parse_ssa_operands (struct function *fn, gimple stmt)
 
     case GIMPLE_CALL:
       /* Add call-clobbered operands, if needed.  */
-      maybe_add_call_vops (fn, stmt);
+      maybe_add_call_vops (fn, stmt->as_a_gimple_call ());
       /* FALLTHRU */
 
     case GIMPLE_ASSIGN:
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 1e55356..044d59d 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3831,7 +3831,8 @@ compute_avail (void)
 		if (gimple_call_internal_p (stmt))
 		  continue;
 
-		copy_reference_ops_from_call (stmt, &ops);
+		copy_reference_ops_from_call (stmt->as_a_gimple_call (),
+					      &ops);
 		vn_reference_lookup_pieces (gimple_vuse (stmt), 0,
 					    gimple_expr_type (stmt),
 					    ops, &ref, VN_NOWALK);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 6516a4f..27ff70d 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1098,7 +1098,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref,
    vn_reference_op_s's.  */
 
 void
-copy_reference_ops_from_call (gimple call,
+copy_reference_ops_from_call (gimple_call call,
 			      vec<vn_reference_op_s> *result)
 {
   vn_reference_op_s temp;
@@ -1140,7 +1140,7 @@ copy_reference_ops_from_call (gimple call,
    call statement.  The vector is not shared.  */
 
 static vec<vn_reference_op_s> 
-create_reference_ops_from_call (gimple call)
+create_reference_ops_from_call (gimple_call call)
 {
   vec<vn_reference_op_s> result = vNULL;
 
@@ -1433,7 +1433,7 @@ valueize_shared_reference_ops_from_ref (tree ref, bool *valueized_anything)
    this function.  */
 
 static vec<vn_reference_op_s> 
-valueize_shared_reference_ops_from_call (gimple call)
+valueize_shared_reference_ops_from_call (gimple_call call)
 {
   if (!call)
     return vNULL;
@@ -2771,7 +2771,7 @@ visit_nary_op (tree lhs, gimple stmt)
    of the LHS has changed as a result.  */
 
 static bool
-visit_reference_op_call (tree lhs, gimple stmt)
+visit_reference_op_call (tree lhs, gimple_call stmt)
 {
   bool changed = false;
   struct vn_reference_s vr1;
@@ -3552,7 +3552,7 @@ visit_use (tree use)
 	  else
 	    changed = defs_to_varying (stmt);
 	}
-      else if (is_gimple_call (stmt))
+      else if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	{
 	  tree lhs = gimple_call_lhs (stmt);
 
@@ -3596,8 +3596,9 @@ visit_use (tree use)
 		         not alias with anything else.  In which case the
 			 information that the values are distinct are encoded
 			 in the IL.  */
-		      && !(gimple_call_return_flags (stmt) & ERF_NOALIAS))))
-	    changed = visit_reference_op_call (lhs, stmt);
+		      && !(gimple_call_return_flags (call_stmt)
+			   & ERF_NOALIAS))))
+	    changed = visit_reference_op_call (lhs, call_stmt);
 	  else
 	    changed = defs_to_varying (stmt);
 	}
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index f52783a..5d1095c 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -203,7 +203,7 @@ vn_nary_op_t vn_nary_op_insert_pieces (unsigned int, enum tree_code,
 void vn_reference_fold_indirect (vec<vn_reference_op_s> *,
 				 unsigned int *);
 void copy_reference_ops_from_ref (tree, vec<vn_reference_op_s> *);
-void copy_reference_ops_from_call (gimple, vec<vn_reference_op_s> *);
+void copy_reference_ops_from_call (gimple_call, vec<vn_reference_op_s> *);
 bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, tree,
 				    vec<vn_reference_op_s> );
 tree vn_reference_lookup_pieces (tree, alias_set_type, tree,
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 8201cb4..01905cf 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -398,7 +398,7 @@ static struct pointer_map_t *call_stmt_vars;
 /* Lookup or create the variable for the call statement CALL.  */
 
 static varinfo_t
-get_call_vi (gimple call)
+get_call_vi (gimple_call call)
 {
   void **slot_p;
   varinfo_t vi, vi2;
@@ -429,7 +429,7 @@ get_call_vi (gimple call)
    the uses.  Returns NULL if there is nothing special about this call.  */
 
 static varinfo_t
-lookup_call_use_vi (gimple call)
+lookup_call_use_vi (gimple_call call)
 {
   void **slot_p;
 
@@ -444,7 +444,7 @@ lookup_call_use_vi (gimple call)
    the clobbers.  Returns NULL if there is nothing special about this call.  */
 
 static varinfo_t
-lookup_call_clobber_vi (gimple call)
+lookup_call_clobber_vi (gimple_call call)
 {
   varinfo_t uses = lookup_call_use_vi (call);
   if (!uses)
@@ -457,7 +457,7 @@ lookup_call_clobber_vi (gimple call)
    the uses.  */
 
 static varinfo_t
-get_call_use_vi (gimple call)
+get_call_use_vi (gimple_call call)
 {
   return get_call_vi (call);
 }
@@ -466,7 +466,7 @@ get_call_use_vi (gimple call)
    the clobbers.  */
 
 static varinfo_t ATTRIBUTE_UNUSED
-get_call_clobber_vi (gimple call)
+get_call_clobber_vi (gimple_call call)
 {
   return vi_next (get_call_vi (call));
 }
@@ -3851,7 +3851,7 @@ get_function_part_constraint (varinfo_t fi, unsigned part)
    RHS.  */
 
 static void
-handle_rhs_call (gimple stmt, vec<ce_s> *results)
+handle_rhs_call (gimple_call stmt, vec<ce_s> *results)
 {
   struct constraint_expr rhsc;
   unsigned i;
@@ -3953,7 +3953,7 @@ handle_rhs_call (gimple stmt, vec<ce_s> *results)
    the LHS point to global and escaped variables.  */
 
 static void
-handle_lhs_call (gimple stmt, tree lhs, int flags, vec<ce_s> rhsc,
+handle_lhs_call (gimple_call stmt, tree lhs, int flags, vec<ce_s> rhsc,
 		 tree fndecl)
 {
   auto_vec<ce_s> lhsc;
@@ -4017,7 +4017,7 @@ handle_lhs_call (gimple stmt, tree lhs, int flags, vec<ce_s> rhsc,
    const function that returns a pointer in the statement STMT.  */
 
 static void
-handle_const_call (gimple stmt, vec<ce_s> *results)
+handle_const_call (gimple_call stmt, vec<ce_s> *results)
 {
   struct constraint_expr rhsc;
   unsigned int k;
@@ -4058,7 +4058,7 @@ handle_const_call (gimple stmt, vec<ce_s> *results)
    pure function in statement STMT.  */
 
 static void
-handle_pure_call (gimple stmt, vec<ce_s> *results)
+handle_pure_call (gimple_call stmt, vec<ce_s> *results)
 {
   struct constraint_expr rhsc;
   unsigned i;
@@ -4105,7 +4105,7 @@ handle_pure_call (gimple stmt, vec<ce_s> *results)
 /* Return the varinfo for the callee of CALL.  */
 
 static varinfo_t
-get_fi_for_callee (gimple call)
+get_fi_for_callee (gimple_call call)
 {
   tree decl, fn = gimple_call_fn (call);
 
@@ -4136,7 +4136,7 @@ get_fi_for_callee (gimple call)
    was handled, otherwise false.  */
 
 static bool
-find_func_aliases_for_builtin_call (gimple t)
+find_func_aliases_for_builtin_call (gimple_call t)
 {
   tree fndecl = gimple_call_fndecl (t);
   vec<ce_s> lhsc = vNULL;
@@ -4502,7 +4502,7 @@ find_func_aliases_for_builtin_call (gimple t)
 /* Create constraints for the call T.  */
 
 static void
-find_func_aliases_for_call (gimple t)
+find_func_aliases_for_call (gimple_call t)
 {
   tree fndecl = gimple_call_fndecl (t);
   vec<ce_s> lhsc = vNULL;
@@ -4665,7 +4665,7 @@ find_func_aliases (gimple origt)
      In non-ipa mode, we need to generate constraints for each
      pointer passed by address.  */
   else if (is_gimple_call (t))
-    find_func_aliases_for_call (t);
+    find_func_aliases_for_call (t->as_a_gimple_call ());
     
   /* Otherwise, just a regular assignment statement.  Only care about
      operations with pointer result, others are dealt with as escape
@@ -4934,7 +4934,7 @@ find_func_clobbers (gimple origt)
 	}
     }
 
-  if (is_gimple_call (t))
+  if (gimple_call call_stmt = t->dyn_cast_gimple_call ())
     {
       varinfo_t cfi = NULL;
       tree decl = gimple_call_fndecl (t);
@@ -5074,7 +5074,7 @@ find_func_clobbers (gimple origt)
 
       /* Build constraints for propagating clobbers/uses along the
 	 callgraph edges.  */
-      cfi = get_fi_for_callee (t);
+      cfi = get_fi_for_callee (call_stmt);
       if (cfi->id == anything_id)
 	{
 	  if (gimple_vdef (t))
@@ -5098,10 +5098,10 @@ find_func_clobbers (gimple origt)
 	  make_copy_constraint (first_vi_for_offset (fi, fi_uses), escaped_id);
 
 	  /* Also honor the call statement use/clobber info.  */
-	  if ((vi = lookup_call_clobber_vi (t)) != NULL)
+	  if ((vi = lookup_call_clobber_vi (call_stmt)) != NULL)
 	    make_copy_constraint (first_vi_for_offset (fi, fi_clobbers),
 				  vi->id);
-	  if ((vi = lookup_call_use_vi (t)) != NULL)
+	  if ((vi = lookup_call_use_vi (call_stmt)) != NULL)
 	    make_copy_constraint (first_vi_for_offset (fi, fi_uses),
 				  vi->id);
 	  return;
@@ -6858,9 +6858,11 @@ compute_points_to_sets (void)
 
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple stmt = gsi_stmt (gsi);
+	  gimple_call stmt;
 	  struct pt_solution *pt;
-	  if (!is_gimple_call (stmt))
+
+	  stmt = gsi_stmt (gsi)->dyn_cast_gimple_call ();
+	  if (!stmt)
 	    continue;
 
 	  pt = gimple_call_use_set (stmt);
@@ -7306,12 +7308,13 @@ ipa_pta_execute (void)
 
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      gimple stmt = gsi_stmt (gsi);
+	      gimple_call stmt;
 	      struct pt_solution *pt;
 	      varinfo_t vi;
 	      tree decl;
 
-	      if (!is_gimple_call (stmt))
+	      stmt = gsi_stmt (gsi)->dyn_cast_gimple_call ();
+	      if (!stmt)
 		continue;
 
 	      /* Handle direct calls to external functions.  */
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index a332456..0a4af13 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -474,7 +474,7 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
 	  /* Try to fold/lookup the new expression.  Inserting the
 	     expression into the hash table is unlikely to help.  */
           if (is_gimple_call (stmt))
-            cached_lhs = fold_call_stmt (stmt, false);
+            cached_lhs = fold_call_stmt (stmt->as_a_gimple_call (), false);
 	  else
             cached_lhs = fold_assignment_stmt (stmt);
 
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 4c85f3d..71e3c3b 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -396,7 +396,8 @@ static void
 find_tail_calls (basic_block bb, struct tailcall **ret)
 {
   tree ass_var = NULL_TREE, ret_var, func, param;
-  gimple stmt, call = NULL;
+  gimple stmt;
+  gimple_call call = NULL;
   gimple_stmt_iterator gsi, agsi;
   bool tail_recursion;
   struct tailcall *nw;
@@ -423,8 +424,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
       /* Check for a call.  */
       if (is_gimple_call (stmt))
 	{
-	  call = stmt;
-	  ass_var = gimple_call_lhs (stmt);
+	  call = stmt->as_a_gimple_call ();
+	  ass_var = gimple_call_lhs (call);
 	  break;
 	}
 
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index fbc35a3..fe8cd9d 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4600,7 +4600,6 @@ vect_setup_realignment (gimple stmt, gimple_stmt_iterator *gsi,
   gimple inc;
   tree ptr;
   tree data_ref;
-  gimple new_stmt;
   basic_block new_bb;
   tree msq_init = NULL_TREE;
   tree new_temp;
@@ -4695,6 +4694,7 @@ vect_setup_realignment (gimple stmt, gimple_stmt_iterator *gsi,
   if (alignment_support_scheme == dr_explicit_realign_optimized)
     {
       /* Create msq_init = *(floor(p1)) in the loop preheader  */
+      gimple_assign new_stmt;
 
       gcc_assert (!compute_in_loop);
       vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -4731,6 +4731,7 @@ vect_setup_realignment (gimple stmt, gimple_stmt_iterator *gsi,
 
   if (targetm.vectorize.builtin_mask_for_load)
     {
+      gimple_call new_stmt;
       tree builtin_decl;
 
       /* Compute INIT_ADDR - the initial addressed accessed by this memref.  */
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 5db023f..ef79cd4 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -809,7 +809,7 @@ vect_recog_pow_pattern (vec<gimple> *stmts, tree *type_in,
       *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
       if (*type_in)
 	{
-	  gimple stmt = gimple_build_call (newfn, 1, base);
+	  gimple_call stmt = gimple_build_call (newfn, 1, base);
 	  if (vectorizable_function (stmt, *type_in, *type_in)
 	      != NULL_TREE)
 	    {
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 884e769..a166d1e 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1705,7 +1705,7 @@ vect_finish_stmt_generation (gimple stmt, gimple vec_stmt,
    of the function, or NULL_TREE if the function cannot be vectorized.  */
 
 tree
-vectorizable_function (gimple call, tree vectype_out, tree vectype_in)
+vectorizable_function (gimple_call call, tree vectype_out, tree vectype_in)
 {
   tree fndecl = gimple_call_fndecl (call);
 
@@ -2176,20 +2176,21 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi,
 
 /* Function vectorizable_call.
 
-   Check if STMT performs a function call that can be vectorized.
+   Check if GS performs a function call that can be vectorized.
    If VEC_STMT is also passed, vectorize the STMT: create a vectorized
    stmt to replace it, put it in VEC_STMT, and insert it at BSI.
    Return FALSE if not a vectorizable STMT, TRUE otherwise.  */
 
 static bool
-vectorizable_call (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
+vectorizable_call (gimple gs, gimple_stmt_iterator *gsi, gimple *vec_stmt,
 		   slp_tree slp_node)
 {
+  gimple_call stmt;
   tree vec_dest;
   tree scalar_dest;
   tree op, type;
   tree vec_oprnd0 = NULL_TREE, vec_oprnd1 = NULL_TREE;
-  stmt_vec_info stmt_info = vinfo_for_stmt (stmt), prev_stmt_info;
+  stmt_vec_info stmt_info = vinfo_for_stmt (gs), prev_stmt_info;
   tree vectype_out, vectype_in;
   int nunits_in;
   int nunits_out;
@@ -2212,8 +2213,9 @@ vectorizable_call (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def)
     return false;
 
-  /* Is STMT a vectorizable call?   */
-  if (!is_gimple_call (stmt))
+  /* Is GS a vectorizable call?   */
+  stmt = gs->dyn_cast_gimple_call ();
+  if (!stmt)
     return false;
 
   if (gimple_call_internal_p (stmt)
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index f8efe47..f71a70c 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -998,7 +998,7 @@ extern bool supportable_narrowing_operation (enum tree_code, tree, tree,
 extern stmt_vec_info new_stmt_vec_info (gimple stmt, loop_vec_info,
                                         bb_vec_info);
 extern void free_stmt_vec_info (gimple stmt);
-extern tree vectorizable_function (gimple, tree, tree);
+extern tree vectorizable_function (gimple_call, tree, tree);
 extern void vect_model_simple_cost (stmt_vec_info, int, enum vect_def_type *,
                                     stmt_vector_for_cost *,
 				    stmt_vector_for_cost *);
diff --git a/gcc/tree.h b/gcc/tree.h
index 9fbc5c4..d8ff456 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4573,8 +4573,9 @@ extern unsigned int get_object_alignment (tree);
 extern bool get_pointer_alignment_1 (tree, unsigned int *,
 				     unsigned HOST_WIDE_INT *);
 extern unsigned int get_pointer_alignment (tree);
-extern tree fold_call_stmt (gimple, bool);
-extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum built_in_function);
+extern tree fold_call_stmt (gimple_call, bool);
+extern tree gimple_fold_builtin_snprintf_chk (gimple_call, tree,
+					      enum built_in_function);
 extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
 extern bool is_simple_builtin (tree);
 extern bool is_inexpensive_builtin (tree);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 555f3a4..a635bf7 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1293,7 +1293,7 @@ find_func_by_profile_id (int profile_id)
    Returns true if TARGET is considered ok for call CALL_STMT.  */
 
 static bool
-check_ic_target (gimple call_stmt, struct cgraph_node *target)
+check_ic_target (gimple_call call_stmt, struct cgraph_node *target)
 {
    location_t locus;
    if (gimple_check_call_matching_types (call_stmt, target->decl, true))
@@ -1458,12 +1458,13 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
 static bool
 gimple_ic_transform (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_call stmt;
   histogram_value histogram;
   gcov_type val, count, all, bb_all;
   struct cgraph_node *direct_call;
 
-  if (gimple_code (stmt) != GIMPLE_CALL)
+  stmt = gsi_stmt (*gsi)->dyn_cast_gimple_call ();
+  if (!stmt)
     return false;
 
   if (gimple_call_fndecl (stmt) != NULL_TREE)
@@ -1545,7 +1546,7 @@ gimple_ic_transform (gimple_stmt_iterator *gsi)
    operation.
 */
 static bool
-interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg)
+interesting_stringop_to_profile_p (tree fndecl, gimple_call call, int *size_arg)
 {
   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
 
@@ -1582,7 +1583,7 @@ interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg)
    assuming we'll propagate a true constant into ICALL_SIZE later.  */
 
 static void
-gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob,
+gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
 			     gcov_type count, gcov_type all)
 {
   gimple tmp_stmt, cond_stmt, icall_stmt;
@@ -1676,7 +1677,7 @@ gimple_stringop_fixed_value (gimple vcall_stmt, tree icall_size, int prob,
 static bool
 gimple_stringops_transform (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_call stmt;
   tree fndecl;
   tree blck_size;
   enum built_in_function fcode;
@@ -1688,7 +1689,8 @@ gimple_stringops_transform (gimple_stmt_iterator *gsi)
   tree tree_val;
   int size_arg;
 
-  if (gimple_code (stmt) != GIMPLE_CALL)
+  stmt = gsi_stmt (*gsi)->dyn_cast_gimple_call ();
+  if (!stmt)
     return false;
   fndecl = gimple_call_fndecl (stmt);
   if (!fndecl)
@@ -1892,14 +1894,16 @@ gimple_indirect_call_to_profile (gimple stmt, histogram_values *values)
 /* Find values inside STMT for that we want to measure histograms for
    string operations.  */
 static void
-gimple_stringops_values_to_profile (gimple stmt, histogram_values *values)
+gimple_stringops_values_to_profile (gimple gs, histogram_values *values)
 {
+  gimple_call stmt;
   tree fndecl;
   tree blck_size;
   tree dest;
   int size_arg;
 
-  if (gimple_code (stmt) != GIMPLE_CALL)
+  stmt = gs->dyn_cast_gimple_call ();
+  if (!stmt)
     return;
   fndecl = gimple_call_fndecl (stmt);
   if (!fndecl)
diff --git a/gcc/vtable-verify.c b/gcc/vtable-verify.c
index 4e4c21a..8af7829 100644
--- a/gcc/vtable-verify.c
+++ b/gcc/vtable-verify.c
@@ -598,7 +598,7 @@ verify_bb_vtables (basic_block bb)
           tree vtbl_var_decl = NULL_TREE;
           struct vtbl_map_node *vtable_map_node;
           tree vtbl_decl = NULL_TREE;
-          gimple call_stmt;
+          gimple_call call_stmt;
           const char *vtable_name = "<unknown>";
           tree tmp0;
           bool found;
-- 
1.8.5.3

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

* [PATCH 04/89] Introduce gimple_cond and use it in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 14:13   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 49/89] Make add_phi_arg require a gimple_phi David Malcolm
                   ` (90 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_cond): New typedef.
	(const_gimple_cond): Likewise.

	* gimple.h (struct gimple_statement_cond): New subclass of
	gimple_statement_with_ops, adding the invariant that
	stmt->code == GIMPLE_COND.
	(gimple_statement_base::as_a_gimple_cond): New.
	(gimple_statement_base::dyn_cast_gimple_cond): New.
	(is_a_helper <gimple_statement_cond>::test): New.
	(gimple_build_cond): Return a gimple_cond, rather than just
	a gimple.
	(gimple_build_cond_from_tree): Likewise.

	* gdbhooks.py (build_pretty_printer): Add gimple_cond and its
	variants, using the gimple printer.

	* cfgexpand.c (expand_gimple_cond): Require a gimple_cond rather
	than just a gimple.
	* gimple.h (gimple_cond_set_condition_from_tree): Likewise.
	(gimple_cond_true_p): Likewise.
	(gimple_cond_false_p): Likewise.
	(gimple_cond_set_condition): Likewise.
	* gimple.c (gimple_cond_set_condition_from_tree): Likewise.
	* gimple-fold.c (fold_gimple_cond): Likewise.
	* gimple-pretty-print.c (dump_gimple_cond): Likewise.
	* tree-ssa-dom.c (canonicalize_comparison): Likewise.
	* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise.
	* tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise.
	(recognize_bits_test): Likewise.
	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
	(thread_around_empty_blocks): Likewise.
	(thread_through_normal_block): Likewise.
	(thread_across_edge): Likewise.
	* tree-ssa-threadedge.h (thread_across_edge): Likewise.
	* tree-vrp.c (range_fits_type_p): Likewise.

	* cfgexpand.c (expand_gimple_basic_block): Add checked cast to
	gimple_cond in regions where a stmt is known to have code GIMPLE_COND.
	* gimple-fold.c (fold_stmt_1): Likewise.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* tree-ssa-dom.c (optimize_stmt): Likewise.
	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
	* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise.
	* tree-vrp.c (simplify_stmt_using_ranges): Likewise.

	* cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a
	gimple_cond.
	* tree-vrp.c (identify_jump_threads): Likewise.

	* gimple.c (gimple_build_cond): Return a gimple_cond, rather than
	just a gimple.
	(gimple_build_cond_from_tree): Likewise.

	* tree-ssa-dom.c (class dom_opt_dom_walker): Strengthen type of
	field "m_dummy_cond" from a plain gimple to a gimple_cond.

	* tree-ssa-ifcombine.c (ifcombine_ifandif): Introduce locals
	inner_stmt and outer_stmt so that inner_cond and outer_cond can be
	of type gimple_cond once we know that we have code == GIMPLE_COND.
	* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Introduce local
	"last" so that stmt can be of type gimple_cond.
---
 gcc/cfgexpand.c              |  4 ++--
 gcc/cfgloopmanip.c           |  2 +-
 gcc/coretypes.h              |  4 ++++
 gcc/gdbhooks.py              |  2 ++
 gcc/gimple-fold.c            |  4 ++--
 gcc/gimple-pretty-print.c    |  4 ++--
 gcc/gimple.c                 | 10 +++++-----
 gcc/gimple.h                 | 43 +++++++++++++++++++++++++++++++++++++------
 gcc/tree-ssa-dom.c           |  6 +++---
 gcc/tree-ssa-forwprop.c      |  5 +++--
 gcc/tree-ssa-ifcombine.c     | 21 ++++++++++++---------
 gcc/tree-ssa-loop-unswitch.c | 19 ++++++++++++-------
 gcc/tree-ssa-threadedge.c    |  8 ++++----
 gcc/tree-ssa-threadedge.h    |  2 +-
 gcc/tree-vrp.c               |  6 +++---
 15 files changed, 93 insertions(+), 47 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 05ab95e..679933d 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2007,7 +2007,7 @@ maybe_cleanup_end_of_block (edge e, rtx last)
    block and created a new one.  */
 
 static basic_block
-expand_gimple_cond (basic_block bb, gimple stmt)
+expand_gimple_cond (basic_block bb, gimple_cond stmt)
 {
   basic_block new_bb, dest;
   edge new_edge;
@@ -5014,7 +5014,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
 	 fixup the CFG accordingly.  */
       if (gimple_code (stmt) == GIMPLE_COND)
 	{
-	  new_bb = expand_gimple_cond (bb, stmt);
+	  new_bb = expand_gimple_cond (bb, stmt->as_a_gimple_cond ());
 	  if (new_bb)
 	    return new_bb;
 	}
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 83a0d51..3fa2535 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -776,7 +776,7 @@ create_empty_loop_on_edge (edge entry_edge,
   struct loop *loop;
   gimple_stmt_iterator gsi;
   gimple_seq stmts;
-  gimple cond_expr;
+  gimple_cond cond_expr;
   tree exit_test;
   edge exit_e;
   int prob;
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index a39900f..68172f7 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -69,6 +69,10 @@ struct gimple_stmt_iterator;
 /* Typedefs for leaf gimple subclasses (for individual gimple codes).
    Keep this in the same order as the corresponding codes in gimple.def.  */
 
+struct gimple_statement_cond;
+typedef struct gimple_statement_cond *gimple_cond;
+typedef const struct gimple_statement_cond *const_gimple_cond;
+
 struct gimple_statement_switch;
 typedef struct gimple_statement_switch *gimple_switch;
 typedef const struct gimple_statement_switch *const_gimple_switch;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 5dcc76f..e45bdd2 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -457,6 +457,8 @@ def build_pretty_printer():
     pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
 
                               # Keep this in the same order as gimple.def:
+                              'gimple_cond', 'const_gimple_cond',
+                              'gimple_statement_cond *',
                               'gimple_switch', 'const_gimple_switch',
                               'gimple_statement_switch *',
                               'gimple_bind', 'const_gimple_bind',
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6402cce..59f7ada 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -602,7 +602,7 @@ fold_gimple_assign (gimple_stmt_iterator *si)
    assumed that the operands have been previously folded.  */
 
 static bool
-fold_gimple_cond (gimple stmt)
+fold_gimple_cond (gimple_cond stmt)
 {
   tree result = fold_binary_loc (gimple_location (stmt),
 			     gimple_cond_code (stmt),
@@ -1294,7 +1294,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace)
       }
 
     case GIMPLE_COND:
-      changed |= fold_gimple_cond (stmt);
+      changed |= fold_gimple_cond (stmt->as_a_gimple_cond ());
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 22d927f..61824a6 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -809,7 +809,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
@@ -2107,7 +2107,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_COND:
-      dump_gimple_cond (buffer, gs, spc, flags);
+      dump_gimple_cond (buffer, gs->as_a_gimple_cond (), spc, flags);
       break;
 
     case GIMPLE_LABEL:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b3fbb0f..2cb5e2e 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -438,14 +438,14 @@ gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
    T_LABEL is the label to jump to if the condition is true.
    F_LABEL is the label to jump to otherwise.  */
 
-gimple
+gimple_cond
 gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs,
 		   tree t_label, tree f_label)
 {
-  gimple p;
+  gimple_cond p;
 
   gcc_assert (TREE_CODE_CLASS (pred_code) == tcc_comparison);
-  p = gimple_build_with_ops (GIMPLE_COND, pred_code, 4);
+  p = gimple_build_with_ops (GIMPLE_COND, pred_code, 4)->as_a_gimple_cond ();
   gimple_cond_set_lhs (p, lhs);
   gimple_cond_set_rhs (p, rhs);
   gimple_cond_set_true_label (p, t_label);
@@ -456,7 +456,7 @@ gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs,
 /* Build a GIMPLE_COND statement from the conditional expression tree
    COND.  T_LABEL and F_LABEL are as in gimple_build_cond.  */
 
-gimple
+gimple_cond
 gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label)
 {
   enum tree_code code;
@@ -470,7 +470,7 @@ gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label)
    boolean expression tree COND.  */
 
 void
-gimple_cond_set_condition_from_tree (gimple stmt, tree cond)
+gimple_cond_set_condition_from_tree (gimple_cond stmt, tree cond)
 {
   enum tree_code code;
   tree lhs, rhs;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 620495d..989f85a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -214,6 +214,12 @@ public:
      Keep these in the same order as the corresponding entries in
      gimple.def.  */
 
+  inline gimple_cond
+  as_a_gimple_cond ()
+  {
+    return as_a <gimple_statement_cond> (this);
+  }
+
   inline gimple_switch
   as_a_gimple_switch ()
   {
@@ -234,6 +240,12 @@ public:
      is less verbose than
        dyn_cast <gimple_statement_foo> (stmt).  */
 
+  inline gimple_cond
+  dyn_cast_gimple_cond ()
+  {
+    return dyn_cast <gimple_statement_cond> (this);
+  }
+
   inline gimple_switch
   dyn_cast_gimple_switch ()
   {
@@ -812,6 +824,16 @@ enum gimple_statement_structure_enum {
 #undef DEFGSSTRUCT
 
 /* A statement with the invariant that
+      stmt->code == GIMPLE_COND
+   i.e. a conditional jump statement.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_cond : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
+/* A statement with the invariant that
       stmt->code == GIMPLE_SWITCH
    i.e. a switch statement.  */
 
@@ -856,6 +878,14 @@ is_a_helper <gimple_statement_catch>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_cond>::test (gimple gs)
+{
+  return gs->code == GIMPLE_COND;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_resx>::test (gimple gs)
 {
   return gs->code == GIMPLE_RESX;
@@ -1240,9 +1270,9 @@ gimple gimple_build_assign_with_ops (enum tree_code, tree,
 				     tree, tree, tree CXX_MEM_STAT_INFO);
 gimple gimple_build_assign_with_ops (enum tree_code, tree,
 				     tree, tree CXX_MEM_STAT_INFO);
-gimple gimple_build_cond (enum tree_code, tree, tree, tree, tree);
-gimple gimple_build_cond_from_tree (tree, tree, tree);
-void gimple_cond_set_condition_from_tree (gimple, tree);
+gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
+gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
+void gimple_cond_set_condition_from_tree (gimple_cond, tree);
 gimple gimple_build_label (tree label);
 gimple gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
@@ -3050,7 +3080,7 @@ gimple_cond_make_true (gimple gs)
   'if (0 == 0)', 'if (1 != 0)' or 'if (0 != 1)' */
 
 static inline bool
-gimple_cond_true_p (const_gimple gs)
+gimple_cond_true_p (const_gimple_cond gs)
 {
   tree lhs = gimple_cond_lhs (gs);
   tree rhs = gimple_cond_rhs (gs);
@@ -3075,7 +3105,7 @@ gimple_cond_true_p (const_gimple gs)
    'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
 
 static inline bool
-gimple_cond_false_p (const_gimple gs)
+gimple_cond_false_p (const_gimple_cond gs)
 {
   tree lhs = gimple_cond_lhs (gs);
   tree rhs = gimple_cond_rhs (gs);
@@ -3099,7 +3129,8 @@ gimple_cond_false_p (const_gimple gs)
 /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS.  */
 
 static inline void
-gimple_cond_set_condition (gimple stmt, enum tree_code code, tree lhs, tree rhs)
+gimple_cond_set_condition (gimple_cond stmt, enum tree_code code, tree lhs,
+			   tree rhs)
 {
   gimple_cond_set_code (stmt, code);
   gimple_cond_set_lhs (stmt, lhs);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 2daddda..24099cc 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -823,7 +823,7 @@ public:
 private:
   void thread_across_edge (edge);
 
-  gimple m_dummy_cond;
+  gimple_cond m_dummy_cond;
 };
 
 /* Jump threading, redundancy elimination and const/copy propagation.
@@ -1004,7 +1004,7 @@ make_pass_dominator (gcc::context *ctxt)
    condition to a canonical form.  */
 
 static void
-canonicalize_comparison (gimple condstmt)
+canonicalize_comparison (gimple_cond condstmt)
 {
   tree op0;
   tree op1;
@@ -2340,7 +2340,7 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
     }
 
   if (gimple_code (stmt) == GIMPLE_COND)
-    canonicalize_comparison (stmt);
+    canonicalize_comparison (stmt->as_a_gimple_cond ());
 
   update_stmt_if_modified (stmt);
   opt_stats.num_stmts++;
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index d34ee1f..87e44b7 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -501,7 +501,7 @@ forward_propagate_into_comparison (gimple_stmt_iterator *gsi)
    This must be kept in sync with forward_propagate_into_cond.  */
 
 static int
-forward_propagate_into_gimple_cond (gimple stmt)
+forward_propagate_into_gimple_cond (gimple_cond stmt)
 {
   tree tmp;
   enum tree_code code = gimple_cond_code (stmt);
@@ -3790,7 +3790,8 @@ ssa_forward_propagate_and_combine (void)
 	    case GIMPLE_COND:
 	      {
 		int did_something;
-		did_something = forward_propagate_into_gimple_cond (stmt);
+		did_something =
+		  forward_propagate_into_gimple_cond (stmt->as_a_gimple_cond ());
 		if (did_something == 2)
 		  cfg_changed = true;
 		changed = did_something != 0;
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index be28fb0..1a060b5 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -198,7 +198,7 @@ get_name_for_bit_test (tree candidate)
    Returns true if the pattern matched, false otherwise.  */
 
 static bool
-recognize_single_bit_test (gimple cond, tree *name, tree *bit, bool inv)
+recognize_single_bit_test (gimple_cond cond, tree *name, tree *bit, bool inv)
 {
   gimple stmt;
 
@@ -306,7 +306,7 @@ recognize_single_bit_test (gimple cond, tree *name, tree *bit, bool inv)
    Returns true if the pattern matched, false otherwise.  */
 
 static bool
-recognize_bits_test (gimple cond, tree *name, tree *bits, bool inv)
+recognize_bits_test (gimple_cond cond, tree *name, tree *bits, bool inv)
 {
   gimple stmt;
 
@@ -337,18 +337,21 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
 		   basic_block outer_cond_bb, bool outer_inv, bool result_inv)
 {
   gimple_stmt_iterator gsi;
-  gimple inner_cond, outer_cond;
+  gimple inner_stmt, outer_stmt;
+  gimple_cond inner_cond, outer_cond;
   tree name1, name2, bit1, bit2, bits1, bits2;
 
-  inner_cond = last_stmt (inner_cond_bb);
-  if (!inner_cond
-      || gimple_code (inner_cond) != GIMPLE_COND)
+  inner_stmt = last_stmt (inner_cond_bb);
+  if (!inner_stmt
+      || gimple_code (inner_stmt) != GIMPLE_COND)
     return false;
+  inner_cond = inner_stmt->as_a_gimple_cond ();
 
-  outer_cond = last_stmt (outer_cond_bb);
-  if (!outer_cond
-      || gimple_code (outer_cond) != GIMPLE_COND)
+  outer_stmt = last_stmt (outer_cond_bb);
+  if (!outer_stmt
+      || gimple_code (outer_stmt) != GIMPLE_COND)
     return false;
+  outer_cond = outer_stmt->as_a_gimple_cond ();
 
   /* See if we test a single bit of the same name in both tests.  In
      that case remove the outer test, merging both else edges,
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 5031378..03e6648 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -138,15 +138,17 @@ tree_ssa_unswitch_loops (void)
 static tree
 tree_may_unswitch_on (basic_block bb, struct loop *loop)
 {
-  gimple stmt, def;
+  gimple last, def;
+  gimple_cond stmt;
   tree cond, use;
   basic_block def_bb;
   ssa_op_iter iter;
 
   /* BB must end in a simple conditional jump.  */
-  stmt = last_stmt (bb);
-  if (!stmt || gimple_code (stmt) != GIMPLE_COND)
+  last = last_stmt (bb);
+  if (!last || gimple_code (last) != GIMPLE_COND)
     return NULL_TREE;
+  stmt = last->as_a_gimple_cond ();
 
   /* To keep the things simple, we do not directly remove the conditions,
      but just replace tests with 0 != 0 resp. 1 != 0.  Prevent the infinite
@@ -248,13 +250,15 @@ tree_unswitch_single_loop (struct loop *loop, int num)
       if (integer_nonzerop (cond))
 	{
 	  /* Remove false path.  */
-	  gimple_cond_set_condition_from_tree (stmt, boolean_true_node);
+	  gimple_cond_set_condition_from_tree (stmt->as_a_gimple_cond (),
+					       boolean_true_node);
 	  changed = true;
 	}
       else if (integer_zerop (cond))
 	{
 	  /* Remove true path.  */
-	  gimple_cond_set_condition_from_tree (stmt, boolean_false_node);
+	  gimple_cond_set_condition_from_tree (stmt->as_a_gimple_cond (),
+					       boolean_false_node);
 	  changed = true;
 	}
       /* Do not unswitch too much.  */
@@ -316,9 +320,10 @@ tree_unswitch_single_loop (struct loop *loop, int num)
 	      if (stmt
 		  && gimple_code (stmt) == GIMPLE_COND)
 		{
-		  if (gimple_cond_true_p (stmt))
+		  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+		  if (gimple_cond_true_p (cond_stmt))
 		    flags = EDGE_FALSE_VALUE;
-		  else if (gimple_cond_false_p (stmt))
+		  else if (gimple_cond_false_p (cond_stmt))
 		    flags = EDGE_TRUE_VALUE;
 		}
 	    }
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index c447b72..ce1dee5 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -536,7 +536,7 @@ dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED)
 static tree
 simplify_control_stmt_condition (edge e,
 				 gimple stmt,
-				 gimple dummy_cond,
+				 gimple_cond dummy_cond,
 				 tree (*simplify) (gimple, gimple),
 				 bool handle_dominating_asserts)
 {
@@ -800,7 +800,7 @@ propagate_threaded_block_debug_into (basic_block dest, basic_block src)
    try and simplify the condition at the end of TAKEN_EDGE->dest.  */
 static bool
 thread_around_empty_blocks (edge taken_edge,
-			    gimple dummy_cond,
+			    gimple_cond dummy_cond,
 			    bool handle_dominating_asserts,
 			    tree (*simplify) (gimple, gimple),
 			    bitmap visited,
@@ -943,7 +943,7 @@ thread_around_empty_blocks (edge taken_edge,
 
 static bool
 thread_through_normal_block (edge e,
-			     gimple dummy_cond,
+			     gimple_cond dummy_cond,
 			     bool handle_dominating_asserts,
 			     vec<tree> *stack,
 			     tree (*simplify) (gimple, gimple),
@@ -1064,7 +1064,7 @@ thread_through_normal_block (edge e,
    SIMPLIFY is a pass-specific function used to simplify statements.  */
 
 void
-thread_across_edge (gimple dummy_cond,
+thread_across_edge (gimple_cond dummy_cond,
 		    edge e,
 		    bool handle_dominating_asserts,
 		    vec<tree> *stack,
diff --git a/gcc/tree-ssa-threadedge.h b/gcc/tree-ssa-threadedge.h
index f005607..7ad5691 100644
--- a/gcc/tree-ssa-threadedge.h
+++ b/gcc/tree-ssa-threadedge.h
@@ -30,7 +30,7 @@ extern void threadedge_initialize_values (void);
 extern void threadedge_finalize_values (void);
 extern bool potentially_threadable_block (basic_block);
 extern void propagate_threaded_block_debug_into (basic_block, basic_block);
-extern void thread_across_edge (gimple, edge, bool,
+extern void thread_across_edge (gimple_cond, edge, bool,
 				vec<tree> *, tree (*) (gimple, gimple));
 
 #endif /* GCC_TREE_SSA_THREADEDGE_H */
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3a31d78..f9366b9 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -8920,7 +8920,7 @@ range_fits_type_p (value_range_t *vr, unsigned precision, bool unsigned_p)
    the original conditional.  */
 
 static bool
-simplify_cond_using_ranges (gimple stmt)
+simplify_cond_using_ranges (gimple_cond stmt)
 {
   tree op0 = gimple_cond_lhs (stmt);
   tree op1 = gimple_cond_rhs (stmt);
@@ -9459,7 +9459,7 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
 	}
     }
   else if (gimple_code (stmt) == GIMPLE_COND)
-    return simplify_cond_using_ranges (stmt);
+    return simplify_cond_using_ranges (stmt->as_a_gimple_cond ());
   else if (gimple_code (stmt) == GIMPLE_SWITCH)
     return simplify_switch_using_ranges (stmt->as_a_gimple_switch ());
   else if (is_gimple_call (stmt)
@@ -9603,7 +9603,7 @@ static void
 identify_jump_threads (void)
 {
   basic_block bb;
-  gimple dummy;
+  gimple_cond dummy;
   int i;
   edge e;
 
-- 
1.8.5.3

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

* [PATCH 00/89] Compile-time gimple-checking
@ 2014-04-21 16:56 David Malcolm
  2014-04-21 16:56 ` [PATCH 04/89] Introduce gimple_cond and use it in various places David Malcolm
                   ` (91 more replies)
  0 siblings, 92 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

This is a greatly-expanded version of:
  http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01262.html

As of r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and
r205428 (a90353203da18288cdac1b0b78fe7b22c69fe63f) the various gimple
statements form a C++ inheritance hierarchy, but we're not yet making much
use of that in the code: everything refers to just "gimple" (or
"const_gimple"), and type-checking is performed at run-time within the
various gimple_foo_* accessors in gimple.h, and almost nowhere else.

The following patch series introduces compile-time checking of much of
the handling of gimple statements.

Various new typedefs are introduced for pointers to statements where the
specific code is known, matching the corresponding names from gimple.def.

For example, it introduces a "gimple_bind" typedef, which is a
  (gimple_statement_bind *)
which has the invariant that stmt->code == GIMPLE_BIND.

The idea is that all of the gimple_foo_* accessors in gimple.h are
converted from taking just a "gimple" to a "gimple_foo".  I've managed
this so far for 15 of the gimple statement subclasses; for example, all
of the "gimple_bind_*" accessors now require a "gimple_bind" rather than
a plain "gimple".

Similarly, variabless throughout the middle-end have their types
strengthened from plain "gimple" to a typedef expressing a pointer to
some concrete statement subclass, and similarly for vectors.  For example
various variables have their types strengthened from "gimple" to
"gimple_bind", and from plain vec<gimple> to vec<gimple_bind> (e.g. within
gimplify.c for handling the bind stack).

Numerous other such typedefs are introduced: essentially two for each of
the gimple code values: a gimple_foo and a const_gimple_foo variant e.g.
gimple_switch and const_gimple_switch (some of the rarer codes don't have
such typedefs yet).

Some of these typedefs are aliases for existing subclasses within the
"gimple" class hierarchy, but others are new with this patch series.  As
with the existing subclasses, they don't add any extra fields, they merely
express invariants on the gimple's code.

In each case there are some checked downcasts from "gimple" down to the
more concrete statement-type, so that the runtime-checking in the checked
build happens there, at the boundary between types, rather than the
current checking, which is every time an accessor is called and almost
nowhere else. 

Once we're in a more concrete type than "gimple", the compiler can enforce
the type-checking for us at compile-time.

An additional benefit is that human readers of the code should (I hope)
have an easier time following what's going on: assumptions about the
underlying gimple_code of a stmt that previously were hidden are now
obvious, expressed directly in the type system.

For example, various variables in tree-into-ssa.c change from just
vec<gimple> to being vec<gimple_phi>, capturing the "phi-ness" of the
contents as a compile-time check (and then not needing to check them any
more); indeed great swathes of phi-manipulation code are changed from
acting on vanilla "gimple" to acting on "gimple_phi".

Similarly, within tree-inline.h's struct copy_body_data, the field
"debug_stmts" can be "concretized" from a vec<gimple> to a
vec<gimple_debug>.

Another notable such concretization is that the "call_stmt" field of a
cgraph_edge becomes a gimple_call, rather than a plain gimple.

In doing the checked downcasts I ran into the verbosity of the as_a <>
API (in our "is-a.h").  I first tried simplifying them with custom
functions e.g.:

   static inline gimple_bind as_a_gimple_bind (gimple gs)
   {
     return as_a <gimple_statement_bind> (gs);
   }

but the approach I've gone with makes these checked casts be *methods* of
the gimple_statement_base class, so that e.g. in a switch statement you
can write:

    case GIMPLE_SWITCH:
      dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
      break;

where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
concrete "gimple_switch" in a release build, with runtime checking for
code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
internally).

This is much less verbose than trying to do it with as_a <> directly, and
I think doing it as a method reads better aloud (to my English-speaking
mind, at-least):
  "gs as a gimple switch",
as opposed to:
  "as a gimple switch... gs",
which I find clunky.

It makes the base class a little cluttered, but IMHO it hits a sweet-spot
of readability and type-safety with relatively little verbosity (only 8
more characters than doing it with a raw C-style cast).   Another
advantage of having the checked cast as a *method* is that it implicitly
documents the requirement that the input must be non-NULL.

There are an analogous family of "dyn_cast_gimple_foo" methods in the
base class, again as an abbreviation of the rather verbose is-a.h API.

For phis, I made gsi_start_phis return a gimple_phi_iterator, rather than
a gimple_stmt_iterator, where the phi iterator type is new, a subclass of
gimple_stmt_iterator.  It has identical layout, but adds a "phi ()" method,
which is like gsi_stmt(), but does a checked cast to a gimple_phi.  This
allows lots of phi-manipulation code to be concretized into working on
type "gimple_phi" (rather than just "gimple"), with minimal patching.

Having these typedefs around may also be useful for debugging, so that you
can now type e.g.

  (gdb) p *(gimple_cond)stmt

to quickly get all fields of a stmt (without having to think
"is this code a gimple_statement_with_ops?")

***********
Correctness
***********
Successfully bootstrapped&regtested the cumulative effect of the patches
on x86_64-unknown-linux-gnu with cloog and thus graphite, with all
frontends (via --enable-languages=all,ada,go), on top of r209027: the
regrtest shows identical results to that of a control build, in both cases
with:

 gcc/testsuite/ada/acats/acats.sum : total: 2320 PASS: 2320
 gcc/testsuite/g++/g++.sum : total: 90205 FAIL: 3 PASS: 86738 XFAIL: 445 UNSUPPORTED: 3019
 gcc/testsuite/gcc/gcc.sum : total: 110165 FAIL: 31 PASS: 108028 XFAIL: 263 XPASS: 40 UNSUPPORTED: 1803
 gcc/testsuite/gfortran/gfortran.sum : total: 45650 PASS: 45533 XFAIL: 52 UNSUPPORTED: 65
 gcc/testsuite/gnat/gnat.sum : total: 1245 PASS: 1224 XFAIL: 18 UNSUPPORTED: 3
 gcc/testsuite/go/go.sum : total: 7266 PASS: 7258 XFAIL: 1 UNTESTED: 6 UNSUPPORTED: 1
 gcc/testsuite/objc/objc.sum : total: 2973 PASS: 2893 XFAIL: 6 UNSUPPORTED: 74
 x86_64-unknown-linux-gnu/boehm-gc/testsuite/boehm-gc.sum : total: 13 PASS: 12 UNSUPPORTED: 1
 x86_64-unknown-linux-gnu/libatomic/testsuite/libatomic.sum : total: 54 PASS: 54
 x86_64-unknown-linux-gnu/libffi/testsuite/libffi.sum : total: 1856 PASS: 1801 UNSUPPORTED: 55
 x86_64-unknown-linux-gnu/libgo/libgo.sum : total: 122 PASS: 122
 x86_64-unknown-linux-gnu/libgomp/testsuite/libgomp.sum : total: 2412 PASS: 2412
 x86_64-unknown-linux-gnu/libitm/testsuite/libitm.sum : total: 30 PASS: 26 XFAIL: 3 UNSUPPORTED: 1
 x86_64-unknown-linux-gnu/libjava/testsuite/libjava.sum : total: 2586 PASS: 2582 XFAIL: 4
 x86_64-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum : total: 10260 PASS: 9995 XFAIL: 41 UNSUPPORTED: 224

apart from a test removed/test added false positive in:
  go.test/test/dwarf/dwarf.dir/main.go
due to the test summary containing embedded absolute paths, which vary
between my control vs experiment builds.

[FWIW, for the above I used a new DejaVu result-handling tool I've
written, "jamais-vu":
  https://github.com/davidmalcolm/jamais-vu
which others on this list may find helpful]

***********
Performance
***********
I benchmarked the compiler with and without this patch series (experiment
and control, respectively), by repeatedly building the two complicated C++
files supplied by Michael Matz in:
  http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00062.html
with stripped cc1plus, using taskset(1) to pin the cc1plus invocations to
cpu 0 for consistency on this NUMA box.

There were no significant differences in timings or memory usage between
the runs; full details (including links to timeline graphs) follow: 

Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: usr
      control: [47.99, 47.91, 48.0, 47.99, 48.09, 48.36, 48.2, 48.11, 48.22, 47.88, 48.14, 48.25, 48.17, 48.17, 48.16, 48.24, 48.03, 47.88, 47.98, 47.98, 48.08, 48.02, 48.0, 47.99, 48.05, 48.21, 48.0, 48.16, 48.08, 48.05, 48.0, 48.13, 47.92, 47.9, 48.16, 48.03, 48.07, 48.12, 48.16, 48.14]
   experiment: [48.48, 48.05, 48.01, 48.19, 47.99, 47.95, 48.0, 48.0, 47.89, 47.81, 47.75, 47.94, 48.1, 48.02, 47.88, 47.83, 48.16, 48.04, 48.03, 47.98, 48.12, 48.05, 47.89, 48.03, 47.81, 47.88, 48.06, 47.85, 48.27, 47.99, 47.81, 48.07, 48.01, 48.06, 48.07, 47.95, 48.03, 47.9, 47.94, 47.99]
Min: 47.880000 -> 47.750000: 1.00x faster
Avg: 48.075500 -> 47.997000: 1.00x faster
Not significant
Stddev: 0.11145 -> 0.13531: 1.2141x larger
Timeline: http://goo.gl/k3ct18

Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: sys
      control: [6.19, 6.29, 6.16, 6.25, 6.18, 6.06, 6.06, 6.19, 6.2, 6.27, 6.11, 6.09, 6.11, 6.0, 6.12, 6.25, 6.1, 6.32, 6.22, 6.23, 6.12, 6.13, 6.22, 6.13, 6.08, 6.02, 6.15, 6.11, 6.16, 6.16, 6.15, 6.05, 6.22, 6.24, 6.09, 6.12, 6.11, 6.14, 6.0, 5.99]
   experiment: [6.12, 6.1, 6.13, 6.17, 6.16, 6.18, 6.13, 6.15, 6.18, 6.3, 6.32, 6.17, 6.0, 6.17, 6.25, 6.25, 6.23, 6.15, 6.05, 6.13, 6.04, 6.12, 6.18, 6.14, 6.27, 6.18, 6.12, 6.23, 6.13, 6.09, 6.24, 6.12, 6.08, 6.07, 6.02, 6.33, 6.1, 6.19, 6.08, 6.14]
Min: 5.990000 -> 6.000000: 1.00x slower
Avg: 6.144750 -> 6.155250: 1.00x slower
Not significant
Stddev: 0.08105 -> 0.07782: 1.0415x smaller
Timeline: http://goo.gl/wiiVbY

Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: wall
      control: [54.9, 54.38, 54.34, 54.42, 54.45, 54.6, 54.44, 54.47, 54.6, 54.33, 54.43, 54.52, 54.46, 54.35, 54.46, 54.67, 54.31, 54.38, 54.37, 54.4, 54.37, 54.34, 54.41, 54.3, 54.31, 54.41, 54.34, 54.45, 54.43, 54.39, 54.33, 54.36, 54.31, 54.31, 54.43, 54.33, 54.36, 54.44, 54.34, 54.31]
   experiment: [54.96, 54.51, 54.53, 54.68, 54.56, 54.54, 54.54, 54.53, 54.44, 54.5, 54.47, 54.5, 54.5, 54.56, 54.46, 54.47, 54.78, 54.59, 54.48, 54.49, 54.5, 54.54, 54.46, 54.52, 54.47, 54.38, 54.47, 54.38, 54.74, 54.42, 54.4, 54.53, 54.41, 54.48, 54.44, 54.64, 54.49, 54.4, 54.31, 54.4]
Min: 54.300000 -> 54.310000: 1.00x slower
Avg: 54.413750 -> 54.511750: 1.00x slower
Not significant
Stddev: 0.11562 -> 0.11786: 1.0194x larger
Timeline: http://goo.gl/1Xlhp6

Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: ggc
      control: [1298648.0, 1298649.0, 1298651.0, 1298656.0, 1298655.0, 1298651.0, 1298650.0, 1298652.0, 1298651.0, 1298650.0, 1298648.0, 1298644.0, 1298654.0, 1298655.0, 1298659.0, 1298659.0, 1298650.0, 1298652.0, 1298665.0, 1298655.0, 1298651.0, 1298655.0, 1298652.0, 1298656.0, 1298659.0, 1298653.0, 1298645.0, 1298649.0, 1298645.0, 1298643.0, 1298657.0, 1298653.0, 1298652.0, 1298659.0, 1298648.0, 1298651.0, 1298653.0, 1298651.0, 1298654.0, 1298651.0]
   experiment: [1298653.0, 1298658.0, 1298649.0, 1298658.0, 1298654.0, 1298654.0, 1298647.0, 1298652.0, 1298651.0, 1298652.0, 1298656.0, 1298649.0, 1298644.0, 1298655.0, 1298648.0, 1298650.0, 1298648.0, 1298652.0, 1298651.0, 1298649.0, 1298647.0, 1298661.0, 1298641.0, 1298652.0, 1298645.0, 1298650.0, 1298652.0, 1298652.0, 1298651.0, 1298650.0, 1298650.0, 1298655.0, 1298663.0, 1298655.0, 1298646.0, 1298648.0, 1298646.0, 1298652.0, 1298662.0, 1298651.0]
Mem max: 1298665.000 -> 1298663.000: 1.0000x smaller
Usage over time: http://goo.gl/aoTh9I

Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: usr
      control: [37.03, 36.97, 36.99, 37.04, 36.97, 36.94, 37.02, 36.97, 37.05, 36.94, 36.92, 36.97, 37.03, 37.01, 37.04, 37.01, 36.99, 37.01, 37.07, 37.05, 36.98, 36.98, 37.05, 36.97, 36.95, 37.01, 37.0, 37.0, 37.23, 37.07, 36.78, 36.94, 37.04, 36.93, 36.98, 36.96, 36.91, 36.98, 37.05, 37.23]
   experiment: [36.96, 36.98, 36.93, 36.97, 36.94, 37.27, 37.0, 36.96, 37.03, 37.09, 36.85, 36.94, 36.99, 37.01, 37.0, 36.99, 36.98, 37.1, 37.04, 37.07, 36.93, 36.95, 36.96, 37.01, 36.97, 37.06, 36.95, 37.01, 36.98, 36.93, 37.14, 37.0, 36.92, 36.89, 36.98, 37.24, 36.97, 36.98, 36.96, 36.95]
Min: 36.780000 -> 36.850000: 1.00x slower
Avg: 37.001500 -> 36.997000: 1.00x faster
Not significant
Stddev: 0.07543 -> 0.08178: 1.0842x larger
Timeline: http://goo.gl/591YUR

Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: sys
      control: [1.29, 1.33, 1.32, 1.29, 1.32, 1.35, 1.3, 1.36, 1.25, 1.33, 1.33, 1.36, 1.28, 1.3, 1.28, 1.27, 1.29, 1.25, 1.27, 1.25, 1.29, 1.31, 1.33, 1.3, 1.3, 1.29, 1.28, 1.34, 1.3, 1.27, 1.34, 1.3, 1.28, 1.3, 1.3, 1.38, 1.37, 1.34, 1.24, 1.3]
   experiment: [1.29, 1.29, 1.3, 1.27, 1.31, 1.3, 1.3, 1.32, 1.25, 1.32, 1.34, 1.33, 1.28, 1.25, 1.3, 1.27, 1.27, 1.32, 1.27, 1.25, 1.34, 1.32, 1.33, 1.3, 1.29, 1.3, 1.28, 1.29, 1.3, 1.31, 1.23, 1.31, 1.3, 1.33, 1.34, 1.31, 1.32, 1.31, 1.3, 1.3]
Min: 1.240000 -> 1.230000: 1.01x faster
Avg: 1.304500 -> 1.298500: 1.00x faster
Not significant
Stddev: 0.03412 -> 0.02637: 1.2939x smaller
Timeline: http://goo.gl/UA1Bvh

Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: wall
      control: [38.43, 38.42, 38.43, 38.45, 38.41, 38.4, 38.43, 38.44, 38.41, 38.37, 38.37, 38.45, 38.42, 38.43, 38.43, 38.4, 38.39, 38.38, 38.45, 38.41, 38.38, 38.4, 38.49, 38.39, 38.36, 38.41, 38.39, 38.46, 38.65, 38.46, 38.23, 38.36, 38.44, 38.35, 38.39, 38.45, 38.39, 38.43, 38.41, 38.65]
   experiment: [38.36, 38.38, 38.34, 38.35, 38.36, 38.68, 38.41, 38.39, 38.38, 38.52, 38.3, 38.38, 38.38, 38.38, 38.42, 38.37, 38.36, 38.53, 38.42, 38.44, 38.37, 38.38, 38.4, 38.42, 38.38, 38.48, 38.34, 38.41, 38.4, 38.36, 38.49, 38.42, 38.33, 38.32, 38.43, 38.66, 38.41, 38.39, 38.37, 38.37]
Min: 38.230000 -> 38.300000: 1.00x slower
Avg: 38.420250 -> 38.407000: 1.00x faster
Not significant
Stddev: 0.06822 -> 0.07816: 1.1457x larger
Timeline: http://goo.gl/clfhdm

Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: ggc
      control: [662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 661798.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 661798.0, 661798.0, 662310.0, 662310.0]
   experiment: [662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0]
Mem max: 662310.000 -> 662310.000: no change
Usage over time: http://goo.gl/y77aRG

***********************
Sizes of built binaries
***********************
With --enable-checking=release, and stripping the resulting binaries:
$ for binary in cc1 cc1obj cc1plus f951 jc1 ; do ls -al test/*/*/build/gcc/$binary ; done
-rwxrwxr-x. 1 david david 15842584 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1
-rwxrwxr-x. 1 david david 15838488 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1
-rwxrwxr-x. 1 david david 16039192 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1obj
-rwxrwxr-x. 1 david david 16035096 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1obj
-rwxrwxr-x. 1 david david 17014104 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1plus
-rwxrwxr-x. 1 david david 17014104 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1plus
-rwxrwxr-x. 1 david david 16576600 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/f951
-rwxrwxr-x. 1 david david 16572504 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/f951
-rwxrwxr-x. 1 david david 15159256 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/jc1
-rwxrwxr-x. 1 david david 15159256 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/jc1

i.e. the sizes are either unchanged, or got very slightly smaller.

****
Plan
****
I'd like to commit this patch series to trunk for 4.10.  I hope the
overall plan sounds good.  May I have reviews of the individual patches?
(each patch builds on the ones before, but at any given patch in the
series they should all compile cleanly together and not affect
correctness/performance).

I have a script that tracks how many of the gimple statement accessors
take something more concrete than a plain gimple:
  https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/gimple_typesafety.py
which reports that the following statement subclasses are "done" in the
sense that all of their accessors now accept a subclass pointer, rather
than a plain gimple/const_gimple:

gimple_asm_ (19 accessors)
gimple_bind_ (10 accessors)
gimple_catch_ (6 accessors)
gimple_eh_dispatch_ (2 accessors)
gimple_eh_else_ (6 accessors)
gimple_eh_must_not_throw_ (2 accessors)
gimple_label_ (2 accessors)
gimple_omp_atomic_load_ (6 accessors)
gimple_omp_atomic_store_ (3 accessors)
gimple_omp_continue_ (6 accessors)
gimple_omp_critical_ (3 accessors)
gimple_resx_ (2 accessors)
gimple_return_ (3 accessors)
gimple_switch_ (9 accessors)
gimple_transaction_ (8 accessors)

and the following DONE/TODO breakdown by prefix:

Accessors "concretized" by prefix
---------------------------------
  %                         Prefix  DONE  TODO
100            gimple_transaction_     8     0
100                 gimple_switch_     9     0
100                 gimple_return_     3     0
100                   gimple_resx_     2     0
100           gimple_omp_critical_     3     0
100           gimple_omp_continue_     6     0
100       gimple_omp_atomic_store_     3     0
100        gimple_omp_atomic_load_     6     0
100                  gimple_label_     2     0
100      gimple_eh_must_not_throw_     2     0
100                gimple_eh_else_     6     0
100            gimple_eh_dispatch_     2     0
100                  gimple_catch_     6     0
100                   gimple_bind_    10     0
100                    gimple_asm_    19     0
 83                   gimple_cond_    15     3
 72             gimple_omp_target_     8     3
 72           gimple_omp_parallel_     8     3
 58                   gimple_call_    25    18
 57                    gimple_phi_     8     6
 50                   gimple_goto_     1     1
 40                    gimple_try_     4     6
 33              gimple_omp_teams_     1     2
 33             gimple_omp_single_     1     2
 33              gimple_eh_filter_     2     4
 11                gimple_omp_for_     3    24
  5                 gimple_assign_     1    17
  0                    gimple_wce_     0     5
  0                gimple_predict_     0     4
  0               gimple_omp_task_     0    18
  0           gimple_omp_sections_     0     6
  0            gimple_omp_section_     0     2
  0             gimple_omp_return_     0     5
  0                    gimple_omp_     0    18
  0                  gimple_debug_     0    12

Overall totals
--------------
TODO: Builder calls still returning a plain gimple: 9
TODO: Accessors not yet converted to taking a gimple: 159
DONE: Builder calls converted to returning a gimple subclass: 37
DONE: Accessors converted to taking a gimple subclass: 167
NOTE: Accessors known not to need to be converted: 67

So this patch series as-is takes us a little over halfway there.  The
remaining accessors would involve more substantial re-indenting (typically
to introduce blocks within case statements of a switch on statement code,
so I can introduce a type-checked local).  I didn't want to go down that
path until the overall approach was OKed, since those kinds of changes are
much more prone to generating conflicts as I rebase (and hence to bitrot).

Thoughts?

Dave

David Malcolm (89):
  Const-correctness fixes for some gimple accessors
  Introduce gimple_switch and use it in various places
  Introduce gimple_bind and use it for accessors.
  Introduce gimple_cond and use it in various places
  Introduce gimple_assign and use it in various places
  Introduce gimple_label and use it in a few places
  Introduce gimple_debug and use it in a few places
  Introduce gimple_phi and use it in various places
  Introduce gimple_phi_iterator
  Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
  tree-parloops.c: use gimple_phi in various places
  tree-predcom.c: use gimple_phi in various places
  tree-ssa-phiprop.c: use gimple_phi
  tree-ssa-loop-niter.c: use gimple_phi in a few places
  tree-ssa-loop-manip.c: use gimple_phi in three places
  tree-ssa-loop-ivopts.c: use gimple_phi in a few places
  Update various expressions within tree-scalar-evolution.c to be
    gimple_phi
  Concretize get_loop_exit_condition et al to working on gimple_cond
  Const-correctness of gimple_call_builtin_p
  Introduce gimple_call
  Introduce gimple_return
  Introduce gimple_goto
  Introduce gimple_asm
  Introduce gimple_transaction
  Introduce gimple_catch
  Introduce gimple_eh_filter
  Introduce gimple_eh_must_not_throw
  Introduce gimple_eh_else
  Introduce gimple_resx
  Introduce gimple_eh_dispatch
  Use subclasses of gimple in various places
  Introduce gimple_try
  Use more concrete types for various gimple statements
  Introduce gimple_omp_atomic_load
  Introduce gimple_omp_atomic_store
  Introduce gimple_omp_continue
  Introduce gimple_omp_critical
  Introduce gimple_omp_for
  Introduce gimple_omp_parallel
  tree-cfg.c: Make verify_gimple_call require a gimple_call
  Introduce gimple_omp_task
  Introduce gimple_omp_single
  Introduce gimple_omp_target
  Introduce gimple_omp_teams
  Introduce gimple_omp_sections
  tree-parloops.c: Use gimple_phi in various places
  omp-low.c: Use more concrete types of gimple statement for various
    locals
  Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a
    gimple_phi
  Make add_phi_arg require a gimple_phi
  Make gimple_phi_arg_set_location require a gimple_phi
  Update GRAPHITE to use more concrete gimple statement classes
  Make gimple_phi_arg_edge require a gimple_phi
  More gimple_phi
  Make gimple_call_return_slot_opt_p require a gimple_call.
  Use gimple_call for callgraph edges
  Various gimple to gimple_call conversions in IPA
  Concretize parameter to gimple_call_copy_skip_args
  Make gimple_label_set_label require a gimple_label
  Make gimple_goto_set_dest require a gimple_goto
  Concretize gimple_catch_types
  Concretize gimple_call_use_set and gimple_call_clobber_set
  Concretize gimple_label_label
  Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure
  Concretize gimple_try_set_catch_is_cleanup
  Concretize three gimple_try_set_ accessors
  Make gimple_phi_arg_location_from_edge require a gimple_phi
  Make gimple_phi_arg_location require a gimple_phi.
  Concretize three gimple_return_ accessors
  Make gimple_cond_set_{true|false}_label require gimple_cond.
  Concretize locals within expand_omp_for_init_counts
  Concretize gimple_cond_make_{false|true}
  Concretize gimple_switch_index and gimple_switch_index_ptr
  Concretize gimple_cond_{true|false}_label
  Concretize gimple_cond_set_code
  Concretize gimple_cond_set_{lhs|rhs}
  Concretize gimple_cond_{lhs|rhs}_ptr
  Concretize various expressions from gimple to gimple_cond
  Concretize gimple_call_set_nothrow
  Concretize gimple_call_nothrow_p
  Tweak to gimplify_modify_expr
  Concretize gimple_call_set_fn
  Concretize gimple_call_set_fntype
  Concretize gimple_call_set_tail and gimple_call_tail_p
  Concretize gimple_call_arg_flags
  Concretize gimple_assign_nontemporal_move_p
  Concretize gimple_call_copy_flags and ipa_modify_call_arguments
  Use gimple_call in some places within tree-ssa-dom.c
  Use gimple_phi in many more places.
  Convert various gimple to gimple_phi within ssa-iterators.h

 gcc/asan.c                          |   23 +-
 gcc/builtins.c                      |   11 +-
 gcc/builtins.h                      |    2 +-
 gcc/c-family/c-gimplify.c           |    4 +-
 gcc/cfgexpand.c                     |   58 +-
 gcc/cfgloop.c                       |    6 +-
 gcc/cfgloopmanip.c                  |    4 +-
 gcc/cgraph.c                        |   22 +-
 gcc/cgraph.h                        |   17 +-
 gcc/cgraphbuild.c                   |   41 +-
 gcc/cgraphclones.c                  |    6 +-
 gcc/cgraphunit.c                    |    6 +-
 gcc/coretypes.h                     |  126 ++++
 gcc/expr.h                          |    2 +-
 gcc/gdbhooks.py                     |   19 +-
 gcc/gimple-builder.c                |   16 +-
 gcc/gimple-builder.h                |   16 +-
 gcc/gimple-fold.c                   |   25 +-
 gcc/gimple-fold.h                   |    2 +-
 gcc/gimple-iterator.c               |   12 +-
 gcc/gimple-iterator.h               |   11 +-
 gcc/gimple-low.c                    |   39 +-
 gcc/gimple-pretty-print.c           |  183 +++--
 gcc/gimple-ssa-isolate-paths.c      |    6 +-
 gcc/gimple-ssa-strength-reduction.c |   30 +-
 gcc/gimple-streamer-in.c            |   34 +-
 gcc/gimple-streamer-out.c           |   46 +-
 gcc/gimple-walk.c                   |  169 +++--
 gcc/gimple.c                        |  347 +++++----
 gcc/gimple.h                        | 1379 +++++++++++++++++++++--------------
 gcc/gimplify-me.c                   |   29 +-
 gcc/gimplify.c                      |  125 ++--
 gcc/gimplify.h                      |    6 +-
 gcc/graphite-scop-detection.c       |   22 +-
 gcc/graphite-sese-to-poly.c         |  141 ++--
 gcc/internal-fn.c                   |   42 +-
 gcc/internal-fn.def                 |    2 +-
 gcc/internal-fn.h                   |    2 +-
 gcc/ipa-inline-analysis.c           |   18 +-
 gcc/ipa-prop.c                      |   37 +-
 gcc/ipa-prop.h                      |    4 +-
 gcc/ipa-pure-const.c                |   10 +-
 gcc/ipa-split.c                     |   95 +--
 gcc/java/java-gimplify.c            |    2 +-
 gcc/lto-streamer-in.c               |    4 +-
 gcc/lto-streamer-out.c              |   15 +-
 gcc/omp-low.c                       |  441 ++++++-----
 gcc/predict.c                       |   56 +-
 gcc/sese.c                          |   13 +-
 gcc/ssa-iterators.h                 |   20 +-
 gcc/stmt.c                          |    4 +-
 gcc/trans-mem.c                     |  132 ++--
 gcc/tree-call-cdce.c                |   29 +-
 gcc/tree-cfg.c                      |  407 ++++++-----
 gcc/tree-cfg.h                      |    4 +-
 gcc/tree-cfgcleanup.c               |   44 +-
 gcc/tree-complex.c                  |   39 +-
 gcc/tree-data-ref.c                 |    3 +-
 gcc/tree-dfa.c                      |   10 +-
 gcc/tree-eh.c                       |  274 ++++---
 gcc/tree-eh.h                       |    6 +-
 gcc/tree-emutls.c                   |   13 +-
 gcc/tree-if-conv.c                  |   15 +-
 gcc/tree-inline.c                   |  185 +++--
 gcc/tree-inline.h                   |    2 +-
 gcc/tree-into-ssa.c                 |   59 +-
 gcc/tree-into-ssa.h                 |    2 +-
 gcc/tree-loop-distribution.c        |   55 +-
 gcc/tree-nested.c                   |   45 +-
 gcc/tree-nrv.c                      |   11 +-
 gcc/tree-object-size.c              |   20 +-
 gcc/tree-outof-ssa.c                |   23 +-
 gcc/tree-parloops.c                 |  101 +--
 gcc/tree-phinodes.c                 |   41 +-
 gcc/tree-phinodes.h                 |    8 +-
 gcc/tree-predcom.c                  |   30 +-
 gcc/tree-profile.c                  |   19 +-
 gcc/tree-scalar-evolution.c         |   73 +-
 gcc/tree-scalar-evolution.h         |    2 +-
 gcc/tree-sra.c                      |  125 ++--
 gcc/tree-ssa-alias.c                |   16 +-
 gcc/tree-ssa-alias.h                |    2 +-
 gcc/tree-ssa-ccp.c                  |   32 +-
 gcc/tree-ssa-coalesce.c             |   29 +-
 gcc/tree-ssa-copy.c                 |   11 +-
 gcc/tree-ssa-copyrename.c           |   12 +-
 gcc/tree-ssa-dce.c                  |   37 +-
 gcc/tree-ssa-dom.c                  |   76 +-
 gcc/tree-ssa-forwprop.c             |   21 +-
 gcc/tree-ssa-ifcombine.c            |   27 +-
 gcc/tree-ssa-live.c                 |   16 +-
 gcc/tree-ssa-loop-im.c              |   65 +-
 gcc/tree-ssa-loop-ivcanon.c         |   41 +-
 gcc/tree-ssa-loop-ivopts.c          |   44 +-
 gcc/tree-ssa-loop-manip.c           |   64 +-
 gcc/tree-ssa-loop-niter.c           |   25 +-
 gcc/tree-ssa-loop-prefetch.c        |    4 +-
 gcc/tree-ssa-loop-unswitch.c        |   19 +-
 gcc/tree-ssa-math-opts.c            |   44 +-
 gcc/tree-ssa-operands.c             |    8 +-
 gcc/tree-ssa-phiopt.c               |   38 +-
 gcc/tree-ssa-phiprop.c              |   12 +-
 gcc/tree-ssa-pre.c                  |   68 +-
 gcc/tree-ssa-propagate.c            |   30 +-
 gcc/tree-ssa-propagate.h            |    2 +-
 gcc/tree-ssa-reassoc.c              |   39 +-
 gcc/tree-ssa-sccvn.c                |   25 +-
 gcc/tree-ssa-sccvn.h                |    2 +-
 gcc/tree-ssa-sink.c                 |    8 +-
 gcc/tree-ssa-strlen.c               |   13 +-
 gcc/tree-ssa-structalias.c          |   85 ++-
 gcc/tree-ssa-tail-merge.c           |   33 +-
 gcc/tree-ssa-ter.c                  |    4 +-
 gcc/tree-ssa-threadedge.c           |   19 +-
 gcc/tree-ssa-threadedge.h           |    2 +-
 gcc/tree-ssa-threadupdate.c         |   16 +-
 gcc/tree-ssa-uncprop.c              |    7 +-
 gcc/tree-ssa-uninit.c               |   57 +-
 gcc/tree-ssa.c                      |   56 +-
 gcc/tree-stdarg.c                   |   19 +-
 gcc/tree-switch-conversion.c        |   57 +-
 gcc/tree-tailcall.c                 |   46 +-
 gcc/tree-vect-data-refs.c           |    7 +-
 gcc/tree-vect-generic.c             |   13 +-
 gcc/tree-vect-loop-manip.c          |   74 +-
 gcc/tree-vect-loop.c                |   61 +-
 gcc/tree-vect-patterns.c            |    2 +-
 gcc/tree-vect-slp.c                 |   15 +-
 gcc/tree-vect-stmts.c               |   22 +-
 gcc/tree-vectorizer.h               |    2 +-
 gcc/tree-vrp.c                      |  100 +--
 gcc/tree.c                          |    5 +-
 gcc/tree.h                          |    5 +-
 gcc/ubsan.c                         |    5 +-
 gcc/value-prof.c                    |   91 ++-
 gcc/value-prof.h                    |    3 +-
 gcc/vtable-verify.c                 |    2 +-
 137 files changed, 4095 insertions(+), 3070 deletions(-)

-- 
1.8.5.3

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

* [PATCH 34/89] Introduce gimple_omp_atomic_load
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
  2014-04-21 16:56 ` [PATCH 04/89] Introduce gimple_cond and use it in various places David Malcolm
  2014-04-21 16:56 ` [PATCH 49/89] Make add_phi_arg require a gimple_phi David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:13   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 11/89] tree-parloops.c: use gimple_phi in various places David Malcolm
                   ` (88 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_atomic_load): New typedef.
	(const_gimple_omp_atomic_load): New typedef.

	* gimple-pretty-print.c (dump_gimple_omp_atomic_load): Require a
	gimple_omp_atomic_load rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_atomic_load
	within GIMPLE_OMP_ATOMIC_LOAD case of switch statement.

	* gimple-walk.c (walk_gimple_op): Likewise, introducing a new local.

	* gimple.c (gimple_build_omp_atomic_load): Return a
	gimple_omp_atomic_load rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_atomic_load):
	New.
	(gimple_build_omp_atomic_load): Return a gimple_omp_atomic_load
	rather than a plain gimple.
	(gimple_omp_atomic_load_set_lhs): Require a
	gimple_omp_atomic_load rather than a plain gimple.
	(gimple_omp_atomic_load_lhs_ptr): Likewise.
	(gimple_omp_atomic_load_set_rhs): Likewise.
	(gimple_omp_atomic_load_rhs_ptr): Likewise.
	(gimple_omp_atomic_load_lhs): Require a
	const_gimple_omp_atomic_load rather than a plain const_gimple.
	(gimple_omp_atomic_load_rhs): Likewise.

	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
	to gimple_omp_atomic_load within GIMPLE_OMP_ATOMIC_LOAD case of
	switch statement.

	* omp-low.c (expand_omp_atomic): Strengthen type of local "load"
	from gimple to gimple_omp_atomic_load.
	(lower_omp_1): Add a checked cast to gimple_omp_atomic_load within
	GIMPLE_OMP_ATOMIC_LOAD case of switch statement.
---
 gcc/coretypes.h           |  5 +++++
 gcc/gimple-pretty-print.c |  8 ++++----
 gcc/gimple-walk.c         | 19 +++++++++++--------
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 44 +++++++++++++++++++-------------------------
 gcc/gimplify-me.c         |  5 +++--
 gcc/omp-low.c             |  7 +++++--
 7 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6d5c363..2fb510f 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -145,6 +145,11 @@ struct gimple_statement_try;
 typedef struct gimple_statement_try *gimple_try;
 typedef const struct gimple_statement_try *const_gimple_try;
 
+struct gimple_statement_omp_atomic_load;
+typedef struct gimple_statement_omp_atomic_load *gimple_omp_atomic_load;
+typedef const struct gimple_statement_omp_atomic_load *
+  const_gimple_omp_atomic_load;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index f2525f4..bf0d73c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1961,8 +1961,8 @@ dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
    in dumpfile.h).  */
 
 static void
-dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple gs, int spc,
-                             int flags)
+dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple_omp_atomic_load gs,
+			     int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2150,8 +2150,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_ATOMIC_LOAD:
-      dump_gimple_omp_atomic_load (buffer, gs, spc, flags);
-
+      dump_gimple_omp_atomic_load (buffer, gs->as_a_gimple_omp_atomic_load (),
+				   spc, flags);
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index c247210..bbfc20b 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -419,15 +419,18 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_ATOMIC_LOAD:
-      ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (stmt), callback_op, wi,
-		       pset);
-      if (ret)
-	return ret;
+      {
+	gimple_omp_atomic_load omp_stmt = stmt->as_a_gimple_omp_atomic_load ();
+	ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (omp_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
 
-      ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt), callback_op, wi,
-		       pset);
-      if (ret)
-	return ret;
+	ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (omp_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e74fad3..797726b 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1079,10 +1079,11 @@ gimple_build_omp_teams (gimple_seq body, tree clauses)
 
 /* Build a GIMPLE_OMP_ATOMIC_LOAD statement.  */
 
-gimple
+gimple_omp_atomic_load
 gimple_build_omp_atomic_load (tree lhs, tree rhs)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0);
+  gimple_omp_atomic_load p =
+    gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0)->as_a_gimple_omp_atomic_load ();
   gimple_omp_atomic_load_set_lhs (p, lhs);
   gimple_omp_atomic_load_set_rhs (p, rhs);
   return p;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 931503c..f255ff0 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -336,6 +336,12 @@ public:
     return as_a <gimple_statement_try> (this);
   }
 
+  inline gimple_omp_atomic_load
+  as_a_gimple_omp_atomic_load ()
+  {
+    return as_a <gimple_statement_omp_atomic_load> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1579,7 +1585,7 @@ gimple gimple_build_omp_sections_switch (void);
 gimple gimple_build_omp_single (gimple_seq, tree);
 gimple gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
-gimple gimple_build_omp_atomic_load (tree, tree);
+gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
 gimple gimple_build_omp_atomic_store (tree);
 gimple_transaction gimple_build_transaction (gimple_seq, tree);
 gimple gimple_build_predict (enum br_predictor, enum prediction);
@@ -5589,66 +5595,54 @@ gimple_omp_atomic_store_val_ptr (gimple g)
 /* Set the LHS of an atomic load.  */
 
 static inline void
-gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
+gimple_omp_atomic_load_set_lhs (gimple_omp_atomic_load load_stmt, tree lhs)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load> (g);
-  omp_atomic_load_stmt->lhs = lhs;
+  load_stmt->lhs = lhs;
 }
 
 
 /* Get the LHS of an atomic load.  */
 
 static inline tree
-gimple_omp_atomic_load_lhs (const_gimple g)
+gimple_omp_atomic_load_lhs (const_gimple_omp_atomic_load load_stmt)
 {
-  const gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <const gimple_statement_omp_atomic_load> (g);
-  return omp_atomic_load_stmt->lhs;
+  return load_stmt->lhs;
 }
 
 
 /* Return a pointer to the LHS of an atomic load.  */
 
 static inline tree *
-gimple_omp_atomic_load_lhs_ptr (gimple g)
+gimple_omp_atomic_load_lhs_ptr (gimple_omp_atomic_load load_stmt)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load> (g);
-  return &omp_atomic_load_stmt->lhs;
+  return &load_stmt->lhs;
 }
 
 
 /* Set the RHS of an atomic load.  */
 
 static inline void
-gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
+gimple_omp_atomic_load_set_rhs (gimple_omp_atomic_load load_stmt, tree rhs)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load> (g);
-  omp_atomic_load_stmt->rhs = rhs;
+  load_stmt->rhs = rhs;
 }
 
 
 /* Get the RHS of an atomic load.  */
 
 static inline tree
-gimple_omp_atomic_load_rhs (const_gimple g)
+gimple_omp_atomic_load_rhs (const_gimple_omp_atomic_load load_stmt)
 {
-  const gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <const gimple_statement_omp_atomic_load> (g);
-  return omp_atomic_load_stmt->rhs;
+  return load_stmt->rhs;
 }
 
 
 /* Return a pointer to the RHS of an atomic load.  */
 
 static inline tree *
-gimple_omp_atomic_load_rhs_ptr (gimple g)
+gimple_omp_atomic_load_rhs_ptr (gimple_omp_atomic_load load_stmt)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load> (g);
-  return &omp_atomic_load_stmt->rhs;
+  return &load_stmt->rhs;
 }
 
 
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 7aaac08..68e7e9d 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -178,8 +178,9 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
 		     is_gimple_val, fb_rvalue);
       break;
     case GIMPLE_OMP_ATOMIC_LOAD:
-      gimplify_expr (gimple_omp_atomic_load_rhs_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
+      gimplify_expr (gimple_omp_atomic_load_rhs_ptr (
+		       stmt->as_a_gimple_omp_atomic_load ()),
+		     &pre, NULL, is_gimple_val, fb_rvalue);
       break;
     case GIMPLE_ASM:
       {
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 5054164..edcd0ec 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -7732,7 +7732,9 @@ static void
 expand_omp_atomic (struct omp_region *region)
 {
   basic_block load_bb = region->entry, store_bb = region->exit;
-  gimple load = last_stmt (load_bb), store = last_stmt (store_bb);
+  gimple_omp_atomic_load load =
+    last_stmt (load_bb)->as_a_gimple_omp_atomic_load ();
+  gimple store = last_stmt (store_bb);
   tree loaded_val = gimple_omp_atomic_load_lhs (load);
   tree addr = gimple_omp_atomic_load_rhs (load);
   tree stored_val = gimple_omp_atomic_store_val (store);
@@ -10068,7 +10070,8 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       break;
     case GIMPLE_OMP_ATOMIC_LOAD:
       if ((ctx || task_shared_vars)
-	  && walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt),
+	  && walk_tree (gimple_omp_atomic_load_rhs_ptr (
+			  stmt->as_a_gimple_omp_atomic_load ()),
 			lower_omp_regimplify_p, ctx ? NULL : &wi, NULL))
 	gimple_regimplify_operands (stmt, gsi_p);
       break;
-- 
1.8.5.3

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

* [PATCH 58/89] Make gimple_label_set_label require a gimple_label
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (6 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 65/89] Concretize three gimple_try_set_ accessors David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:24   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 20/89] Introduce gimple_call David Malcolm
                   ` (83 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_label_set_label): Require a gimple_label.
---
 gcc/gimple.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index cf21083..38f4ea7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3490,9 +3490,8 @@ gimple_label_label (const_gimple gs)
    GS.  */
 
 static inline void
-gimple_label_set_label (gimple gs, tree label)
+gimple_label_set_label (gimple_label gs, tree label)
 {
-  GIMPLE_CHECK (gs, GIMPLE_LABEL);
   gimple_set_op (gs, 0, label);
 }
 
-- 
1.8.5.3

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

* [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (10 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 02/89] Introduce gimple_switch and use it in various places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:49   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 37/89] Introduce gimple_omp_critical David Malcolm
                   ` (79 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_eh_filter_set_types): Require a gimple_eh_filter.
	(gimple_eh_filter_set_failure): Likewise.
	* gimple.c (gimple_copy): Add checked casts to gimple_eh_filter
	within GIMPLE_EH_FILTER case.
---
 gcc/gimple.c | 13 +++++++++----
 gcc/gimple.h | 14 ++++++--------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 5f75b6c..e02d24a 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1664,10 +1664,15 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_EH_FILTER:
-	  new_seq = gimple_seq_copy (gimple_eh_filter_failure (stmt));
-	  gimple_eh_filter_set_failure (copy, new_seq);
-	  t = unshare_expr (gimple_eh_filter_types (stmt));
-	  gimple_eh_filter_set_types (copy, t);
+	  {
+	    gimple_eh_filter eh_filter_stmt = stmt->as_a_gimple_eh_filter ();
+	    gimple_eh_filter eh_filter_copy = copy->as_a_gimple_eh_filter ();
+	    new_seq =
+	      gimple_seq_copy (gimple_eh_filter_failure (eh_filter_stmt));
+	    gimple_eh_filter_set_failure (eh_filter_copy, new_seq);
+	    t = unshare_expr (gimple_eh_filter_types (eh_filter_stmt));
+	    gimple_eh_filter_set_types (eh_filter_copy, t);
+	  }
 	  break;
 
 	case GIMPLE_EH_ELSE:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index d54d011..fcc3bb7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3892,25 +3892,23 @@ gimple_eh_filter_failure (gimple gs)
 }
 
 
-/* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER GS.  */
+/* Set TYPES to be the set of types handled by GIMPLE_EH_FILTER
+   EH_FILTER_STMT.  */
 
 static inline void
-gimple_eh_filter_set_types (gimple gs, tree types)
+gimple_eh_filter_set_types (gimple_eh_filter eh_filter_stmt, tree types)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter> (gs);
   eh_filter_stmt->types = types;
 }
 
 
 /* Set FAILURE to be the sequence of statements to execute on failure
-   for GIMPLE_EH_FILTER GS.  */
+   for GIMPLE_EH_FILTER EH_FILTER_STMT.  */
 
 static inline void
-gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
+gimple_eh_filter_set_failure (gimple_eh_filter eh_filter_stmt,
+			      gimple_seq failure)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter> (gs);
   eh_filter_stmt->failure = failure;
 }
 
-- 
1.8.5.3

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

* [PATCH 39/89] Introduce gimple_omp_parallel
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (16 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 28/89] Introduce gimple_eh_else David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:46   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 29/89] Introduce gimple_resx David Malcolm
                   ` (73 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_parallel): New typedef.
	(const_gimple_omp_parallel): New typedef.

	* cgraphbuild.c (build_cgraph_edges): Convert check of code
	against GIMPLE_OMP_PARALLEL to a dyn_cast_gimple_omp_parallel and
	new local.

	* gimple-pretty-print.c (dump_gimple_omp_parallel): Require a
	gimple_omp_parallel rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_parallel
	within GIMPLE_OMP_PARALLEL case of switch statement.

	* gimple-walk.c (walk_gimple_op): Likewise, introducing a local.

	* gimple.c (gimple_build_omp_parallel): Return a
	gimple_omp_parallel rather than a plain gimple.
	(gimple_copy): Add checked casts to gimple_omp_parallel within
	GIMPLE_OMP_PARALLEL case of switch statement, introducing locals.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_parallel): New.
	(gimple_statement_base::dyn_cast_gimple_omp_parallel): New.
	(gimple_build_omp_parallel): Return a gimple_omp_parallel rather
	than a plain gimple.
	(gimple_omp_parallel_clauses_ptr): Require a gimple_omp_parallel
	rather than a plain gimple.
	(gimple_omp_parallel_set_clauses): Likewise.
	(gimple_omp_parallel_data_arg_ptr): Likewise.
	(gimple_omp_parallel_set_data_arg): Likewise.
	(gimple_omp_parallel_child_fn_ptr): Likewise.
	(gimple_omp_parallel_set_child_fn): Likewise.
	(gimple_omp_parallel_child_fn): Require a
	const_gimple_omp_parallel rather than a plain const_gimple.
	(gimple_omp_parallel_data_arg): Likewise.

	* omp-low.c (scan_omp_parallel): Strengthen local "stmt" from
	gimple to gimple_omp_parallel.
	(expand_parallel_call): Require a gimple_omp_parallel for
	"entry_stmt" rather than a plain gimple.
	(remove_exit_barrier):  Strengthen local "parallel_stmt" from
	gimple to gimple_omp_parallel.
	(expand_omp_taskreg): Add checked cast to gimple_omp_parallel.

	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
	gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch
	statement, introducing local.
---
 gcc/cgraphbuild.c         | 17 ++++++------
 gcc/coretypes.h           |  4 +++
 gcc/gimple-pretty-print.c |  7 ++---
 gcc/gimple-walk.c         | 27 ++++++++++---------
 gcc/gimple.c              | 23 +++++++++++------
 gcc/gimple.h              | 66 +++++++++++++++++++++++------------------------
 gcc/omp-low.c             | 11 +++++---
 gcc/tree-inline.c         | 16 +++++++-----
 8 files changed, 96 insertions(+), 75 deletions(-)

diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 19961e2..411214a 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -343,14 +343,15 @@ build_cgraph_edges (void)
 					     bb->count, freq);
 	    }
 	  ipa_record_stmt_references (node, stmt);
-	  if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
-	      && gimple_omp_parallel_child_fn (stmt))
-	    {
-	      tree fn = gimple_omp_parallel_child_fn (stmt);
-	      ipa_record_reference (node,
-				    cgraph_get_create_node (fn),
-				    IPA_REF_ADDR, stmt);
-	    }
+	  if (gimple_omp_parallel omp_par_stmt =
+	      stmt->dyn_cast_gimple_omp_parallel ())
+	    if (gimple_omp_parallel_child_fn (omp_par_stmt))
+	      {
+		tree fn = gimple_omp_parallel_child_fn (omp_par_stmt);
+		ipa_record_reference (node,
+				      cgraph_get_create_node (fn),
+				      IPA_REF_ADDR, stmt);
+	      }
 	  if (gimple_code (stmt) == GIMPLE_OMP_TASK)
 	    {
 	      tree fn = gimple_omp_task_child_fn (stmt);
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 0a797a3..2647189 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -167,6 +167,10 @@ struct gimple_statement_omp_for;
 typedef struct gimple_statement_omp_for *gimple_omp_for;
 typedef const struct gimple_statement_omp_for *const_gimple_omp_for;
 
+struct gimple_statement_omp_parallel;
+typedef struct gimple_statement_omp_parallel *gimple_omp_parallel;
+typedef const struct gimple_statement_omp_parallel *const_gimple_omp_parallel;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 1b70885..bf77f87 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1851,8 +1851,8 @@ dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment,
    dumpfile.h).  */
 
 static void
-dump_gimple_omp_parallel (pretty_printer *buffer, gimple gs, int spc,
-                          int flags)
+dump_gimple_omp_parallel (pretty_printer *buffer, gimple_omp_parallel gs,
+			  int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2143,7 +2143,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_PARALLEL:
-      dump_gimple_omp_parallel (buffer, gs, spc, flags);
+      dump_gimple_omp_parallel (buffer, gs->as_a_gimple_omp_parallel (), spc,
+				flags);
       break;
 
     case GIMPLE_OMP_TASK:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index ae43f45..63200a2 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -347,18 +347,21 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_PARALLEL:
-      ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
-      ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op,
-		       wi, pset);
-      if (ret)
-	return ret;
+      {
+	gimple_omp_parallel omp_par_stmt = stmt->as_a_gimple_omp_parallel ();
+	ret = walk_tree (gimple_omp_parallel_clauses_ptr (omp_par_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_parallel_child_fn_ptr (omp_par_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
+	ret = walk_tree (gimple_omp_parallel_data_arg_ptr (omp_par_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_TASK:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 7f25207..0b35d00 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -864,11 +864,12 @@ gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
    CHILD_FN is the function created for the parallel threads to execute.
    DATA_ARG are the shared data argument(s).  */
 
-gimple
+gimple_omp_parallel
 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
 			   tree data_arg)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_PARALLEL, 0);
+  gimple_omp_parallel p =
+    gimple_alloc (GIMPLE_OMP_PARALLEL, 0)->as_a_gimple_omp_parallel ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_parallel_set_clauses (p, clauses);
@@ -1711,12 +1712,18 @@ gimple_copy (gimple stmt)
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_PARALLEL:
-	  t = unshare_expr (gimple_omp_parallel_clauses (stmt));
-	  gimple_omp_parallel_set_clauses (copy, t);
-	  t = unshare_expr (gimple_omp_parallel_child_fn (stmt));
-	  gimple_omp_parallel_set_child_fn (copy, t);
-	  t = unshare_expr (gimple_omp_parallel_data_arg (stmt));
-	  gimple_omp_parallel_set_data_arg (copy, t);
+	  {
+	    gimple_omp_parallel omp_par_stmt =
+	      stmt->as_a_gimple_omp_parallel ();
+	    gimple_omp_parallel omp_par_copy =
+	      copy->as_a_gimple_omp_parallel ();
+	    t = unshare_expr (gimple_omp_parallel_clauses (omp_par_stmt));
+	    gimple_omp_parallel_set_clauses (omp_par_copy, t);
+	    t = unshare_expr (gimple_omp_parallel_child_fn (omp_par_stmt));
+	    gimple_omp_parallel_set_child_fn (omp_par_copy, t);
+	    t = unshare_expr (gimple_omp_parallel_data_arg (omp_par_stmt));
+	    gimple_omp_parallel_set_data_arg (omp_par_copy, t);
+	  }
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_TASK:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index d5e9af8..d391db8 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -366,6 +366,12 @@ public:
     return as_a <gimple_statement_omp_for> (this);
   }
 
+  inline gimple_omp_parallel
+  as_a_gimple_omp_parallel ()
+  {
+    return as_a <gimple_statement_omp_parallel> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -463,6 +469,12 @@ public:
   {
     return dyn_cast <gimple_statement_omp_for> (this);
   }
+
+  inline gimple_omp_parallel
+  dyn_cast_gimple_omp_parallel ()
+  {
+    return dyn_cast <gimple_statement_omp_parallel> (this);
+  }
 };
 
 
@@ -1607,7 +1619,7 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE
   gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
 gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
 gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
-gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
+gimple_omp_parallel gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
 gimple gimple_build_omp_section (gimple_seq);
 gimple gimple_build_omp_master (gimple_seq);
@@ -4912,92 +4924,78 @@ gimple_omp_parallel_clauses (const_gimple gs)
 }
 
 
-/* Return a pointer to the clauses associated with OMP_PARALLEL GS.  */
+/* Return a pointer to the clauses associated with OMP_PARALLEL_STMT.  */
 
 static inline tree *
-gimple_omp_parallel_clauses_ptr (gimple gs)
+gimple_omp_parallel_clauses_ptr (gimple_omp_parallel omp_parallel_stmt)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   return &omp_parallel_stmt->clauses;
 }
 
 
-/* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL
-   GS.  */
+/* Set CLAUSES to be the list of clauses associated with OMP_PARALLEL_STMT.  */
 
 static inline void
-gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
+gimple_omp_parallel_set_clauses (gimple_omp_parallel omp_parallel_stmt,
+				 tree clauses)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   omp_parallel_stmt->clauses = clauses;
 }
 
 
-/* Return the child function used to hold the body of OMP_PARALLEL GS.  */
+/* Return the child function used to hold the body of OMP_PARALLEL_STMT.  */
 
 static inline tree
-gimple_omp_parallel_child_fn (const_gimple gs)
+gimple_omp_parallel_child_fn (const_gimple_omp_parallel omp_parallel_stmt)
 {
-  const gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <const gimple_statement_omp_parallel> (gs);
   return omp_parallel_stmt->child_fn;
 }
 
 /* Return a pointer to the child function used to hold the body of
-   OMP_PARALLEL GS.  */
+   OMP_PARALLEL_STMT.  */
 
 static inline tree *
-gimple_omp_parallel_child_fn_ptr (gimple gs)
+gimple_omp_parallel_child_fn_ptr (gimple_omp_parallel omp_parallel_stmt)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   return &omp_parallel_stmt->child_fn;
 }
 
 
-/* Set CHILD_FN to be the child function for OMP_PARALLEL GS.  */
+/* Set CHILD_FN to be the child function for OMP_PARALLEL_STMT.  */
 
 static inline void
-gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
+gimple_omp_parallel_set_child_fn (gimple_omp_parallel omp_parallel_stmt,
+				  tree child_fn)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   omp_parallel_stmt->child_fn = child_fn;
 }
 
 
 /* Return the artificial argument used to send variables and values
-   from the parent to the children threads in OMP_PARALLEL GS.  */
+   from the parent to the children threads in OMP_PARALLEL_STMT.  */
 
 static inline tree
-gimple_omp_parallel_data_arg (const_gimple gs)
+gimple_omp_parallel_data_arg (const_gimple_omp_parallel omp_parallel_stmt)
 {
-  const gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <const gimple_statement_omp_parallel> (gs);
   return omp_parallel_stmt->data_arg;
 }
 
 
-/* Return a pointer to the data argument for OMP_PARALLEL GS.  */
+/* Return a pointer to the data argument for OMP_PARALLEL_STMT.  */
 
 static inline tree *
-gimple_omp_parallel_data_arg_ptr (gimple gs)
+gimple_omp_parallel_data_arg_ptr (gimple_omp_parallel omp_parallel_stmt)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   return &omp_parallel_stmt->data_arg;
 }
 
 
-/* Set DATA_ARG to be the data argument for OMP_PARALLEL GS.  */
+/* Set DATA_ARG to be the data argument for OMP_PARALLEL_STMT.  */
 
 static inline void
-gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
+gimple_omp_parallel_set_data_arg (gimple_omp_parallel omp_parallel_stmt,
+				  tree data_arg)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel> (gs);
   omp_parallel_stmt->data_arg = data_arg;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 8a3b2a1..1602857 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1957,7 +1957,7 @@ scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_omp_parallel stmt = gsi_stmt (*gsi)->as_a_gimple_omp_parallel ();
 
   /* Ignore parallel directives with empty bodies, unless there
      are copyin clauses.  */
@@ -4155,7 +4155,8 @@ gimple_build_cond_empty (tree cond)
 
 static void
 expand_parallel_call (struct omp_region *region, basic_block bb,
-		      gimple entry_stmt, vec<tree, va_gc> *ws_args)
+		      gimple_omp_parallel entry_stmt,
+		      vec<tree, va_gc> *ws_args)
 {
   tree t, t1, t2, val, cond, c, clauses, flags;
   gimple_stmt_iterator gsi;
@@ -4478,7 +4479,8 @@ remove_exit_barrier (struct omp_region *region)
 	     of such a variable.  */
 	  if (any_addressable_vars < 0)
 	    {
-	      gimple parallel_stmt = last_stmt (region->entry);
+	      gimple_omp_parallel parallel_stmt =
+		last_stmt (region->entry)->as_a_gimple_omp_parallel ();
 	      tree child_fun = gimple_omp_parallel_child_fn (parallel_stmt);
 	      tree local_decls, block, decl;
 	      unsigned ix;
@@ -4869,7 +4871,8 @@ expand_omp_taskreg (struct omp_region *region)
 
   /* Emit a library call to launch the children threads.  */
   if (gimple_code (entry_stmt) == GIMPLE_OMP_PARALLEL)
-    expand_parallel_call (region, new_bb, entry_stmt, ws_args);
+    expand_parallel_call (region, new_bb,
+			  entry_stmt->as_a_gimple_omp_parallel (), ws_args);
   else
     expand_task_call (new_bb, entry_stmt);
   if (gimple_in_ssa_p (cfun))
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 34c399a..291dbf7 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1320,12 +1320,16 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_OMP_PARALLEL:
-	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy = gimple_build_omp_parallel
-	           (s1,
-		    gimple_omp_parallel_clauses (stmt),
-		    gimple_omp_parallel_child_fn (stmt),
-		    gimple_omp_parallel_data_arg (stmt));
+	  {
+	    gimple_omp_parallel omp_par_stmt =
+	      stmt->as_a_gimple_omp_parallel ();
+	    s1 = remap_gimple_seq (gimple_omp_body (omp_par_stmt), id);
+	    copy = gimple_build_omp_parallel
+	             (s1,
+		      gimple_omp_parallel_clauses (omp_par_stmt),
+		      gimple_omp_parallel_child_fn (omp_par_stmt),
+		      gimple_omp_parallel_data_arg (omp_par_stmt));
+	  }
 	  break;
 
 	case GIMPLE_OMP_TASK:
-- 
1.8.5.3

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

* [PATCH 29/89] Introduce gimple_resx
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (17 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 39/89] Introduce gimple_omp_parallel David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-04-21 16:56 ` [PATCH 01/89] Const-correctness fixes for some gimple accessors David Malcolm
                   ` (72 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_resx): New typedef.
	(const_gimple_resx): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_resx): New.
	(gimple_build_resx): Return a gimple_resx rather than a plain
	gimple.
	(gimple_resx_region): Require a const_gimple_resx rather than a
	plain const_gimple.
	(gimple_resx_set_region): Require a gimple_resx rather than a
	plain gimple.

	* gimple-pretty-print.c (dump_gimple_resx): Require a gimple_resx
	rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_resx within
	GIMPLE_RESX case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Likewise.

	* gimple-streamer-out.c (output_gimple_stmt): Likewise.

	* gimple.c (gimple_build_resx): Return a gimple_resx rather than
	a plain gimple.

	* tree-cfg.c (move_stmt_r): Add a checked cast to gimple_resx
	within GIMPLE_RESX case of switch statement, adding a new local.

	* tree-eh.c (emit_post_landing_pad): Convert local from gimple
	to gimple_resx.
	(lower_resx): Require a gimple_resx rather than a plain gimple.
	(execute_lower_resx): Add a checked cast to gimple_resx.
	(mark_reachable_handlers): Likewise.

	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
	gimple_resx within GIMPLE_RESX case of switch statement, adding
	a new local.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple-streamer-in.c  |  3 ++-
 gcc/gimple-streamer-out.c |  2 +-
 gcc/gimple.c              |  7 +++----
 gcc/gimple.h              | 19 +++++++++++--------
 gcc/tree-cfg.c            |  5 +++--
 gcc/tree-eh.c             | 10 ++++++----
 gcc/tree-inline.c         |  5 +++--
 9 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 45b157c..379ac6a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -129,6 +129,10 @@ struct gimple_statement_eh_else;
 typedef struct gimple_statement_eh_else *gimple_eh_else;
 typedef const struct gimple_statement_eh_else *const_gimple_eh_else;
 
+struct gimple_statement_resx;
+typedef struct gimple_statement_resx *gimple_resx;
+typedef const struct gimple_statement_resx *const_gimple_resx;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 63443c2..93ac677 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1047,7 +1047,7 @@ dump_gimple_eh_else (pretty_printer *buffer, gimple_eh_else gs, int spc,
    dumpfile.h).  */
 
 static void
-dump_gimple_resx (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_resx (pretty_printer *buffer, gimple_resx gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -2220,7 +2220,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_RESX:
-      dump_gimple_resx (buffer, gs, spc, flags);
+      dump_gimple_resx (buffer, gs->as_a_gimple_resx (), spc, flags);
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 949e9af..4662832 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -123,7 +123,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
   switch (code)
     {
     case GIMPLE_RESX:
-      gimple_resx_set_region (stmt, streamer_read_hwi (ib));
+      gimple_resx_set_region (stmt->as_a_gimple_resx (),
+			      streamer_read_hwi (ib));
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 52130ac..521e789 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -97,7 +97,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_RESX:
-      streamer_write_hwi (ob, gimple_resx_region (stmt));
+      streamer_write_hwi (ob, gimple_resx_region (stmt->as_a_gimple_resx ()));
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 9acfcc1..88d9203 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -706,12 +706,11 @@ gimple_build_wce (gimple_seq cleanup)
 
 /* Build a GIMPLE_RESX statement.  */
 
-gimple
+gimple_resx
 gimple_build_resx (int region)
 {
-  gimple_statement_resx *p =
-    as_a <gimple_statement_resx> (
-      gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0));
+  gimple_resx p =
+    gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0)->as_a_gimple_resx ();
   p->region = region;
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a65cdcb..fbbb676 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -312,6 +312,12 @@ public:
     return as_a <gimple_statement_eh_else> (this);
   }
 
+  inline gimple_resx
+  as_a_gimple_resx ()
+  {
+    return as_a <gimple_statement_resx> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1536,7 +1542,7 @@ gimple_eh_else gimple_build_eh_else (gimple_seq, gimple_seq);
 gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
 gimple gimple_build_wce (gimple_seq);
-gimple gimple_build_resx (int);
+gimple_resx gimple_build_resx (int);
 gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
 gimple_switch gimple_build_switch (tree, tree, vec<tree> );
 gimple gimple_build_eh_dispatch (int);
@@ -4190,22 +4196,19 @@ gimple_phi_arg_has_location (gimple gs, size_t i)
 }
 
 
-/* Return the region number for GIMPLE_RESX GS.  */
+/* Return the region number for GIMPLE_RESX RESX_STMT.  */
 
 static inline int
-gimple_resx_region (const_gimple gs)
+gimple_resx_region (const_gimple_resx resx_stmt)
 {
-  const gimple_statement_resx *resx_stmt =
-    as_a <const gimple_statement_resx> (gs);
   return resx_stmt->region;
 }
 
-/* Set REGION to be the region number for GIMPLE_RESX GS.  */
+/* Set REGION to be the region number for GIMPLE_RESX RESX_STMT.  */
 
 static inline void
-gimple_resx_set_region (gimple gs, int region)
+gimple_resx_set_region (gimple_resx resx_stmt, int region)
 {
-  gimple_statement_resx *resx_stmt = as_a <gimple_statement_resx> (gs);
   resx_stmt->region = region;
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index fcd85e3..a11f4f0 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6460,9 +6460,10 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_RESX:
       {
-	int r = gimple_resx_region (stmt);
+	gimple_resx resx_stmt = stmt->as_a_gimple_resx ();
+	int r = gimple_resx_region (resx_stmt);
 	r = move_stmt_eh_region_nr (r, p);
-	gimple_resx_set_region (stmt, r);
+	gimple_resx_set_region (resx_stmt, r);
       }
       break;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 180b195..0f2c77e 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -829,7 +829,7 @@ emit_post_landing_pad (gimple_seq *seq, eh_region region)
 static void
 emit_resx (gimple_seq *seq, eh_region region)
 {
-  gimple x = gimple_build_resx (region->index);
+  gimple_resx x = gimple_build_resx (region->index);
   gimple_seq_add_stmt (seq, x);
   if (region->outer)
     record_stmt_eh_region (region->outer, x);
@@ -3186,7 +3186,7 @@ make_pass_refactor_eh (gcc::context *ctxt)
 /* At the end of gimple optimization, we can lower RESX.  */
 
 static bool
-lower_resx (basic_block bb, gimple stmt, struct pointer_map_t *mnt_map)
+lower_resx (basic_block bb, gimple_resx stmt, struct pointer_map_t *mnt_map)
 {
   int lp_nr;
   eh_region src_r, dst_r;
@@ -3350,7 +3350,8 @@ execute_lower_resx (void)
       gimple last = last_stmt (bb);
       if (last && is_gimple_resx (last))
 	{
-	  dominance_invalidated |= lower_resx (bb, last, mnt_map);
+	  dominance_invalidated |= lower_resx (bb, last->as_a_gimple_resx (),
+					       mnt_map);
 	  any_rewritten = true;
 	}
     }
@@ -3882,7 +3883,8 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap *lp_reachablep)
 	  switch (gimple_code (stmt))
 	    {
 	    case GIMPLE_RESX:
-	      bitmap_set_bit (r_reachable, gimple_resx_region (stmt));
+	      bitmap_set_bit (r_reachable,
+			      gimple_resx_region (stmt->as_a_gimple_resx ()));
 	      break;
 	    case GIMPLE_EH_DISPATCH:
 	      bitmap_set_bit (r_reachable, gimple_eh_dispatch_region (stmt));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f516113..49d326c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1537,9 +1537,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 
 	  case GIMPLE_RESX:
 	    {
-	      int r = gimple_resx_region (copy);
+	      gimple_resx resx_stmt = copy->as_a_gimple_resx ();
+	      int r = gimple_resx_region (resx_stmt);
 	      r = remap_eh_region_nr (r, id);
-	      gimple_resx_set_region (copy, r);
+	      gimple_resx_set_region (resx_stmt, r);
 	    }
 	    break;
 
-- 
1.8.5.3

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

* [PATCH 11/89] tree-parloops.c: use gimple_phi in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (2 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 34/89] Introduce gimple_omp_atomic_load David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 18:31   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 41/89] Introduce gimple_omp_task David Malcolm
                   ` (87 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-parloops.c (struct reduction_info): Strengthen field "new_phi"
	from gimple to gimple_phi.
	(create_phi_for_local_result): Convert local "new_phi" to gimple_phi.
	(loop_has_vector_phi_nodes): Require a gimple_phi rather than a gimple.
	(gather_scalar_reductions): Convert to a gimple_phi_iterator and
	gimple_phi.
	(try_create_reduction_list): Likewise.
---
 gcc/tree-parloops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 47179a9..a142e96 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -197,7 +197,7 @@ struct reduction_info
   tree initial_value;		/* The initial value of the reduction var before entering the loop.  */
   tree field;			/*  the name of the field in the parloop data structure intended for reduction.  */
   tree init;			/* reduction initialization value.  */
-  gimple new_phi;		/* (helper field) Newly created phi node whose result
+  gimple_phi new_phi;		/* (helper field) Newly created phi node whose result
 				   will be passed to the atomic operation.  Represents
 				   the local result each thread computed for the reduction
 				   operation.  */
@@ -1036,7 +1036,7 @@ create_phi_for_local_result (reduction_info **slot, struct loop *loop)
 {
   struct reduction_info *const reduc = *slot;
   edge e;
-  gimple new_phi;
+  gimple_phi new_phi;
   basic_block store_bb;
   tree local_res;
   source_location locus;
@@ -1943,7 +1943,7 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED)
 
 static void
 build_new_reduction (reduction_info_table_type reduction_list,
-		     gimple reduc_stmt, gimple phi)
+		     gimple reduc_stmt, gimple_phi phi)
 {
   reduction_info **slot;
   struct reduction_info *new_reduction;
@@ -1983,14 +1983,14 @@ set_reduc_phi_uids (reduction_info **slot, void *data ATTRIBUTE_UNUSED)
 static void
 gather_scalar_reductions (loop_p loop, reduction_info_table_type reduction_list)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   loop_vec_info simple_loop_info;
 
   simple_loop_info = vect_analyze_loop_form (loop);
 
   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       affine_iv iv;
       tree res = PHI_RESULT (phi);
       bool double_reduc;
@@ -2046,7 +2046,7 @@ try_create_reduction_list (loop_p loop,
 			   reduction_info_table_type reduction_list)
 {
   edge exit = single_dom_exit (loop);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   gcc_assert (exit);
 
@@ -2055,7 +2055,7 @@ try_create_reduction_list (loop_p loop,
 
   for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       struct reduction_info *red;
       imm_use_iterator imm_iter;
       use_operand_p use_p;
@@ -2113,7 +2113,7 @@ try_create_reduction_list (loop_p loop,
      iteration space can be distributed efficiently.  */
   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree def = PHI_RESULT (phi);
       affine_iv iv;
 
-- 
1.8.5.3

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

* [PATCH 65/89] Concretize three gimple_try_set_ accessors
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (5 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 05/89] Introduce gimple_assign and use it in various places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:51   ` Jeff Law
  2014-05-12 17:54   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 58/89] Make gimple_label_set_label require a gimple_label David Malcolm
                   ` (84 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.c (gimple_copy): Add checked casts to gimple_try.

	* gimple.h (gimple_statement_base::dyn_cast_gimple_try): New.
	(gimple_try_set_kind): Require a gimple_try.
	(gimple_try_set_eval): Likewise.
	(gimple_try_set_cleanup): Likewise.

	* tree-eh.c (optimize_double_finally): Require a pair of gimple_try
	statements.
	(refactor_eh_r): Convert code comparisons to dynamic casts.
---
 gcc/gimple.c  | 12 ++++++++----
 gcc/gimple.h  | 19 +++++++++++--------
 gcc/tree-eh.c | 15 +++++++--------
 3 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index e02d24a..01cdc33 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1687,10 +1687,14 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_TRY:
-	  new_seq = gimple_seq_copy (gimple_try_eval (stmt));
-	  gimple_try_set_eval (copy, new_seq);
-	  new_seq = gimple_seq_copy (gimple_try_cleanup (stmt));
-	  gimple_try_set_cleanup (copy, new_seq);
+	  {
+	    gimple_try try_stmt = stmt->as_a_gimple_try ();
+	    gimple_try try_copy = copy->as_a_gimple_try ();
+	    new_seq = gimple_seq_copy (gimple_try_eval (try_stmt));
+	    gimple_try_set_eval (try_copy, new_seq);
+	    new_seq = gimple_seq_copy (gimple_try_cleanup (try_stmt));
+	    gimple_try_set_cleanup (try_copy, new_seq);
+	  }
 	  break;
 
 	case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3335dee..788e8c7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -488,6 +488,12 @@ public:
     return dyn_cast <gimple_statement_phi> (this);
   }
 
+  inline gimple_try
+  dyn_cast_gimple_try ()
+  {
+    return dyn_cast <gimple_statement_try> (this);
+  }
+
   inline gimple_omp_critical
   dyn_cast_gimple_omp_critical ()
   {
@@ -3983,9 +3989,8 @@ gimple_try_kind (const_gimple gs)
 /* Set the kind of try block represented by GIMPLE_TRY GS.  */
 
 static inline void
-gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
+gimple_try_set_kind (gimple_try gs, enum gimple_try_flags kind)
 {
-  GIMPLE_CHECK (gs, GIMPLE_TRY);
   gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
 			      || kind == GIMPLE_TRY_FINALLY);
   if (gimple_try_kind (gs) != kind)
@@ -4058,23 +4063,21 @@ gimple_try_set_catch_is_cleanup (gimple_try g, bool catch_is_cleanup)
 
 
 /* Set EVAL to be the sequence of statements to use as the body for
-   GIMPLE_TRY GS.  */
+   GIMPLE_TRY TRY_STMT.  */
 
 static inline void
-gimple_try_set_eval (gimple gs, gimple_seq eval)
+gimple_try_set_eval (gimple_try try_stmt, gimple_seq eval)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try> (gs);
   try_stmt->eval = eval;
 }
 
 
 /* Set CLEANUP to be the sequence of statements to use as the cleanup
-   body for GIMPLE_TRY GS.  */
+   body for GIMPLE_TRY TRY_STMT.  */
 
 static inline void
-gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
+gimple_try_set_cleanup (gimple_try try_stmt, gimple_seq cleanup)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try> (gs);
   try_stmt->cleanup = cleanup;
 }
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 412e79a..aad6da3 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3054,7 +3054,7 @@ same_handler_p (gimple_seq oneh, gimple_seq twoh)
    temporary used in the initializer for A.  */
 
 static void
-optimize_double_finally (gimple one, gimple two)
+optimize_double_finally (gimple_try one, gimple_try two)
 {
   gimple oneh;
   gimple_stmt_iterator gsi;
@@ -3101,13 +3101,12 @@ refactor_eh_r (gimple_seq seq)
 	two = NULL;
       else
 	two = gsi_stmt (gsi);
-      if (one
-	  && two
-	  && gimple_code (one) == GIMPLE_TRY
-	  && gimple_code (two) == GIMPLE_TRY
-	  && gimple_try_kind (one) == GIMPLE_TRY_FINALLY
-	  && gimple_try_kind (two) == GIMPLE_TRY_FINALLY)
-	optimize_double_finally (one, two);
+      if (one && two)
+	if (gimple_try try_one = one->dyn_cast_gimple_try ())
+	  if (gimple_try try_two = two->dyn_cast_gimple_try ())
+	    if (gimple_try_kind (try_one) == GIMPLE_TRY_FINALLY
+		&& gimple_try_kind (try_two) == GIMPLE_TRY_FINALLY)
+	      optimize_double_finally (try_one, try_two);
       if (one)
 	switch (gimple_code (one))
 	  {
-- 
1.8.5.3

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

* [PATCH 41/89] Introduce gimple_omp_task
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (3 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 11/89] tree-parloops.c: use gimple_phi in various places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:18   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 05/89] Introduce gimple_assign and use it in various places David Malcolm
                   ` (86 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_task): New typedef.
	(const_gimple_omp_task): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_task): New.
	(gimple_build_omp_task): Return a gimple_omp_task
	rather than a plain gimple.

	* gimple-pretty-print.c (dump_gimple_omp_task): Require a
	gimple_omp_task rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_task within
	GIMPLE_OMP_TASK case of switch statement.

	* gimple.c (gimple_build_omp_task): Return a gimple_omp_task
	rather than a plain gimple.

	* omp-low.c (finalize_task_copyfn): Require a gimple_omp_task
	rather than a plain gimple.
	(delete_omp_context): Add checked cast to gimple_omp_task.
	(scan_omp_task): Strengthen local "stmt" from gimple to
	gimple_omp_task.
	(expand_task_call): Require a gimple_omp_task rather than a plain
	gimple.
	(expand_omp_taskreg): Add checked cast to gimple_omp_task.
	(create_task_copyfn): Require a gimple_omp_task rather than a
	plain gimple.
	(lower_omp_taskreg): Add checked cast to gimple_omp_task.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              |  9 ++++++++-
 gcc/omp-low.c             | 14 +++++++-------
 5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2647189..9564ab7 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -171,6 +171,10 @@ struct gimple_statement_omp_parallel;
 typedef struct gimple_statement_omp_parallel *gimple_omp_parallel;
 typedef const struct gimple_statement_omp_parallel *const_gimple_omp_parallel;
 
+struct gimple_statement_omp_task;
+typedef struct gimple_statement_omp_task *gimple_omp_task;
+typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index bf77f87..d249373 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1905,7 +1905,7 @@ dump_gimple_omp_parallel (pretty_printer *buffer, gimple_omp_parallel gs,
    dumpfile.h).  */
 
 static void
-dump_gimple_omp_task (pretty_printer *buffer, gimple gs, int spc,
+dump_gimple_omp_task (pretty_printer *buffer, gimple_omp_task gs, int spc,
 		      int flags)
 {
   if (flags & TDF_RAW)
@@ -2148,7 +2148,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_TASK:
-      dump_gimple_omp_task (buffer, gs, spc, flags);
+      dump_gimple_omp_task (buffer, gs->as_a_gimple_omp_task (), spc, flags);
       break;
 
     case GIMPLE_OMP_ATOMIC_LOAD:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 0b35d00..1f58a03 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -889,12 +889,13 @@ gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
    COPY_FN is the optional function for firstprivate initialization.
    ARG_SIZE and ARG_ALIGN are size and alignment of the data block.  */
 
-gimple
+gimple_omp_task
 gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn,
 		       tree data_arg, tree copy_fn, tree arg_size,
 		       tree arg_align)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_TASK, 0);
+  gimple_omp_task p =
+    gimple_alloc (GIMPLE_OMP_TASK, 0)->as_a_gimple_omp_task ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_task_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index d391db8..6675d9b 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -372,6 +372,12 @@ public:
     return as_a <gimple_statement_omp_parallel> (this);
   }
 
+  inline gimple_omp_task
+  as_a_gimple_omp_task ()
+  {
+    return as_a <gimple_statement_omp_task> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1620,7 +1626,8 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE
 gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
 gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
 gimple_omp_parallel gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
-gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
+gimple_omp_task gimple_build_omp_task (gimple_seq, tree, tree, tree, tree,
+				       tree, tree);
 gimple gimple_build_omp_section (gimple_seq);
 gimple gimple_build_omp_master (gimple_seq);
 gimple gimple_build_omp_taskgroup (gimple_seq);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 1602857..990b985 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1368,7 +1368,7 @@ static gimple_seq maybe_catch_exception (gimple_seq);
 /* Finalize task copyfn.  */
 
 static void
-finalize_task_copyfn (gimple task_stmt)
+finalize_task_copyfn (gimple_omp_task task_stmt)
 {
   struct function *child_cfun;
   tree child_fn;
@@ -1430,7 +1430,7 @@ delete_omp_context (splay_tree_value value)
     }
 
   if (is_task_ctx (ctx))
-    finalize_task_copyfn (ctx->stmt);
+    finalize_task_copyfn (ctx->stmt->as_a_gimple_omp_task ());
 
   XDELETE (ctx);
 }
@@ -2037,7 +2037,7 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name, t;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_omp_task stmt = gsi_stmt (*gsi)->as_a_gimple_omp_task ();
   location_t loc = gimple_location (stmt);
 
   /* Ignore task directives with empty bodies.  */
@@ -4325,7 +4325,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb,
    generate the task operation.  BB is the block where to insert the code.  */
 
 static void
-expand_task_call (basic_block bb, gimple entry_stmt)
+expand_task_call (basic_block bb, gimple_omp_task entry_stmt)
 {
   tree t, t1, t2, t3, flags, cond, c, c2, clauses, depend;
   gimple_stmt_iterator gsi;
@@ -4874,7 +4874,7 @@ expand_omp_taskreg (struct omp_region *region)
     expand_parallel_call (region, new_bb,
 			  entry_stmt->as_a_gimple_omp_parallel (), ws_args);
   else
-    expand_task_call (new_bb, entry_stmt);
+    expand_task_call (new_bb, entry_stmt->as_a_gimple_omp_task ());
   if (gimple_in_ssa_p (cfun))
     update_ssa (TODO_update_ssa_only_virtuals);
 }
@@ -9168,7 +9168,7 @@ task_copyfn_remap_type (struct omp_taskcopy_context *tcctx, tree orig_type)
 /* Create task copyfn.  */
 
 static void
-create_task_copyfn (gimple task_stmt, omp_context *ctx)
+create_task_copyfn (gimple_omp_task task_stmt, omp_context *ctx)
 {
   struct function *child_cfun;
   tree child_fn, t, c, src, dst, f, sf, arg, sarg, decl;
@@ -9498,7 +9498,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
     }
 
   if (ctx->srecord_type)
-    create_task_copyfn (stmt, ctx);
+    create_task_copyfn (stmt->as_a_gimple_omp_task (), ctx);
 
   push_gimplify_context ();
 
-- 
1.8.5.3

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

* [PATCH 37/89] Introduce gimple_omp_critical
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (11 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:21   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 17/89] Update various expressions within tree-scalar-evolution.c to be gimple_phi David Malcolm
                   ` (78 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_critical): New typedef.
	(const_gimple_omp_critical): New typedef.

	* gimple-pretty-print.c (dump_gimple_omp_critical): Require a
	gimple_omp_critical rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_critical
	within GIMPLE_OMP_CRITICAL case of switch statement.

	* gimple-walk.c (walk_gimple_op): Likewise.

	* gimple.c (gimple_build_omp_critical): Return a gimple_omp_critical
	rather than a plain gimple.
	(gimple_copy): Add checked casts to gimple_omp_critical
	within GIMPLE_OMP_CRITICAL case of switch statement.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_critical): New.
	(gimple_statement_base::dyn_cast_gimple_omp_critical): New.
	(gimple_debug): Likewise.
	(gimple_build_omp_critical): Return a gimple_omp_critical rather
	than a plain gimple.
	(gimple_omp_critical_name): Require a const_gimple_omp_critical
	rather than a plain const_gimple.
	(gimple_omp_critical_name_ptr): Require a gimple_omp_critical
	rather than a plain gimple.
	(gimple_omp_critical_set_name): Likewise.

	* omp-low.c (check_omp_nesting_restrictions): Add a checked cast
	to gimple_omp_critical within GIMPLE_OMP_CRITICAL case of switch
	statement, introducing a new local "other_crit" for type-safety.
	(lower_omp_critical): Strengthen local "stmt" to
	gimple_omp_critical.

	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
	gimple_omp_critical within GIMPLE_OMP_CRITICAL case of switch
	statement.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  7 ++++---
 gcc/gimple-walk.c         |  5 +++--
 gcc/gimple.c              | 10 ++++++----
 gcc/gimple.h              | 34 ++++++++++++++++++++--------------
 gcc/omp-low.c             | 26 +++++++++++++++-----------
 gcc/tree-inline.c         |  6 ++++--
 7 files changed, 56 insertions(+), 36 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index e2ad76e..f527da6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -159,6 +159,10 @@ struct gimple_statement_omp_continue;
 typedef struct gimple_statement_omp_continue *gimple_omp_continue;
 typedef const struct gimple_statement_omp_continue *const_gimple_omp_continue;
 
+struct gimple_statement_omp_critical;
+typedef struct gimple_statement_omp_critical *gimple_omp_critical;
+typedef const struct gimple_statement_omp_critical *const_gimple_omp_critical;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 3de01d0..8248c67 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1435,8 +1435,8 @@ dump_gimple_omp_block (pretty_printer *buffer, gimple gs, int spc, int flags)
 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_critical (pretty_printer *buffer, gimple gs, int spc,
-			  int flags)
+dump_gimple_omp_critical (pretty_printer *buffer, gimple_omp_critical gs,
+			  int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
@@ -2202,7 +2202,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_CRITICAL:
-      dump_gimple_omp_critical (buffer, gs, spc, flags);
+      dump_gimple_omp_critical (buffer, gs->as_a_gimple_omp_critical (), spc,
+				flags);
       break;
 
     case GIMPLE_CATCH:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index f286748..ae43f45 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -313,8 +313,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_CRITICAL:
-      ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_omp_critical_name_ptr (
+			 stmt->as_a_gimple_omp_critical ()),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index a0fa31e..3b40884 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -815,10 +815,11 @@ gimple_build_debug_source_bind_stat (tree var, tree value,
    BODY is the sequence of statements for which only one thread can execute.
    NAME is optional identifier for this critical block.  */
 
-gimple
+gimple_omp_critical
 gimple_build_omp_critical (gimple_seq body, tree name)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_CRITICAL, 0);
+  gimple_omp_critical p =
+    gimple_alloc (GIMPLE_OMP_CRITICAL, 0)->as_a_gimple_omp_critical ();
   gimple_omp_critical_set_name (p, name);
   if (body)
     gimple_omp_set_body (p, body);
@@ -1736,8 +1737,9 @@ gimple_copy (gimple stmt)
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_CRITICAL:
-	  t = unshare_expr (gimple_omp_critical_name (stmt));
-	  gimple_omp_critical_set_name (copy, t);
+	  t = unshare_expr (gimple_omp_critical_name (
+			      stmt->as_a_gimple_omp_critical ()));
+	  gimple_omp_critical_set_name (copy->as_a_gimple_omp_critical (), t);
 	  goto copy_omp_body;
 
 	case GIMPLE_OMP_SECTIONS:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 5a3626e..525fb7b 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -354,6 +354,12 @@ public:
     return as_a <gimple_statement_omp_continue> (this);
   }
 
+  inline gimple_omp_critical
+  as_a_gimple_omp_critical ()
+  {
+    return as_a <gimple_statement_omp_critical> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -440,6 +446,12 @@ public:
     return dyn_cast <gimple_statement_phi> (this);
   }
 
+  inline gimple_omp_critical
+  dyn_cast_gimple_omp_critical ()
+  {
+    return dyn_cast <gimple_statement_omp_critical> (this);
+  }
+
 };
 
 
@@ -1582,7 +1594,7 @@ gimple_debug gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_source_bind(var,val,stmt)			\
   gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
-gimple gimple_build_omp_critical (gimple_seq, tree);
+gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
 gimple gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
@@ -4561,36 +4573,30 @@ gimple_omp_set_body (gimple gs, gimple_seq body)
 }
 
 
-/* Return the name associated with OMP_CRITICAL statement GS.  */
+/* Return the name associated with OMP_CRITICAL statement CRIT_STMT.  */
 
 static inline tree
-gimple_omp_critical_name (const_gimple gs)
+gimple_omp_critical_name (const_gimple_omp_critical crit_stmt)
 {
-  const gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <const gimple_statement_omp_critical> (gs);
-  return omp_critical_stmt->name;
+  return crit_stmt->name;
 }
 
 
 /* Return a pointer to the name associated with OMP critical statement GS.  */
 
 static inline tree *
-gimple_omp_critical_name_ptr (gimple gs)
+gimple_omp_critical_name_ptr (gimple_omp_critical crit_stmt)
 {
-  gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <gimple_statement_omp_critical> (gs);
-  return &omp_critical_stmt->name;
+  return &crit_stmt->name;
 }
 
 
 /* Set NAME to be the name associated with OMP critical statement GS.  */
 
 static inline void
-gimple_omp_critical_set_name (gimple gs, tree name)
+gimple_omp_critical_set_name (gimple_omp_critical crit_stmt, tree name)
 {
-  gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <gimple_statement_omp_critical> (gs);
-  omp_critical_stmt->name = name;
+  crit_stmt->name = name;
 }
 
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 1cd4731..c2ab88a 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2472,16 +2472,20 @@ check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 	  }
       break;
     case GIMPLE_OMP_CRITICAL:
-      for (; ctx != NULL; ctx = ctx->outer)
-	if (gimple_code (ctx->stmt) == GIMPLE_OMP_CRITICAL
-	    && (gimple_omp_critical_name (stmt)
-		== gimple_omp_critical_name (ctx->stmt)))
-	  {
-	    error_at (gimple_location (stmt),
-		      "critical region may not be nested inside a critical "
-		      "region with the same name");
-	    return false;
-	  }
+      {
+	tree this_stmt_name =
+	  gimple_omp_critical_name (stmt->as_a_gimple_omp_critical ());
+	for (; ctx != NULL; ctx = ctx->outer)
+	  if (gimple_omp_critical other_crit =
+	      ctx->stmt->dyn_cast_gimple_omp_critical ())
+	    if (this_stmt_name == gimple_omp_critical_name (other_crit))
+	      {
+		error_at (gimple_location (stmt),
+			  "critical region may not be nested inside a critical "
+			  "region with the same name");
+		return false;
+	      }
+      }
       break;
     case GIMPLE_OMP_TEAMS:
       if (ctx == NULL
@@ -8799,7 +8803,7 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
   tree name, lock, unlock;
-  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_omp_critical stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_critical ();
   gimple_bind bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tbody;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f1d2791..34c399a 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1411,8 +1411,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 
 	case GIMPLE_OMP_CRITICAL:
 	  s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
-	  copy
-	    = gimple_build_omp_critical (s1, gimple_omp_critical_name (stmt));
+	  copy =
+	    gimple_build_omp_critical (s1,
+				       gimple_omp_critical_name (
+				         stmt->as_a_gimple_omp_critical ()));
 	  break;
 
 	case GIMPLE_TRANSACTION:
-- 
1.8.5.3

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

* [PATCH 05/89] Introduce gimple_assign and use it in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (4 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 41/89] Introduce gimple_omp_task David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 14:16   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 65/89] Concretize three gimple_try_set_ accessors David Malcolm
                   ` (85 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_assign): New typedef.
	(const_gimple_assign): New typedef.

	* gimple.h (struct gimple_statement_assign): New subclass of
	gimple_statement_with_memory_ops, adding the invariant that
	stmt->code == GIMPLE_ASSIGN.
	(gimple_statement_base::as_a_gimple_assign): New.
	(gimple_statement_base::dyn_cast_gimple_assign): New.
	(is_a_helper <gimple_statement_assign>::test): New.

	* gdbhooks.py (build_pretty_printer): Add gimple_assign and its
	variants, using the gimple printer.

	* gimple-builder.c (build_assign): Return a gimple_assign rather
	than just a gimple from each of the overloaded variants.
	(build_type_cast): Likewise.
	* gimple-builder.h (build_assign): Likewise.
	(build_type_cast): Likewise.
	* gimple.c (gimple_build_assign_stat): Likewise.
	(gimple_build_assign_with_ops): Likewise.
	* gimple.h (gimple_build_assign_stat): Likewise.
	(gimple_build_assign_with_ops): Likewise.

	* asan.c (get_mem_ref_of_assignment): Require a const_gimple_assign
	rather than just a "const gimple" (the latter is not a
	"const_gimple").
	* gimple-pretty-print.c (dump_unary_rhs): Require a gimple_assign
	rather than just a gimple.
	(dump_binary_rhs): Likewise.
	(dump_ternary_rhs): Likewise.
	* tree-cfg.c (verify_gimple_assign_unary): Likewise.
	(verify_gimple_assign_binary): Likewise.
	(verify_gimple_assign_ternary): Likewise.
	(verify_gimple_assign_single): Likewise.
	(verify_gimple_assign): Likewise.
	* tree-ssa-sccvn.c (simplify_unary_expression): Likewise.
	(try_to_simplify): Likewise.
	* tree-tailcall.c (process_assignment): Likewise.
	* tree-vect-generic.c (expand_vector_operation): Likewise.
	* tree-vrp.c (extract_range_from_cond_expr): Likewise.
	(extract_range_from_assignment): Likewise.

	* asan.c (has_stmt_been_instrumented_p): Add checked cast to
	gimple_assign in regions where a stmt is known to have code
	GIMPLE_ASSIGN.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* tree-cfg.c (verify_gimple_stmt): Likewise.
	* tree-ssa-sccvn.c (visit_use): Likewise.
	* tree-tailcall.c (find_tail_calls): Likewise.
	* tree-vrp.c (vrp_visit_assignment_or_call): Likewise.

	* tree-vrp.c (simplify_stmt_for_jump_threading): Replace a check
	against GIMPLE_ASSIGN with a dyn_cast_gimple_assign, introducing
	a gimple_assign local.

	* tree-vect-generic.c (expand_vector_condition): Convert local to a
	gimple_assign, adding a checked cast when extracting from gsi, since
	this is only called when  underlying stmt has code GIMPLE_ASSIGN.
	(optimize_vector_constructor): Likewise.
	(lower_vec_perm): Likewise.
	(expand_vector_operations_1): Convert local to a gimple_assign,
	introducing a dyn_cast.
---
 gcc/asan.c                |  5 +++--
 gcc/coretypes.h           |  4 ++++
 gcc/gdbhooks.py           |  2 ++
 gcc/gimple-builder.c      | 16 ++++++++--------
 gcc/gimple-builder.h      | 16 ++++++++--------
 gcc/gimple-pretty-print.c | 10 +++++-----
 gcc/gimple.c              | 10 +++++-----
 gcc/gimple.h              | 41 ++++++++++++++++++++++++++++++++++++-----
 gcc/tree-cfg.c            | 12 ++++++------
 gcc/tree-ssa-sccvn.c      |  6 +++---
 gcc/tree-tailcall.c       |  5 +++--
 gcc/tree-vect-generic.c   | 13 +++++++------
 gcc/tree-vrp.c            | 12 ++++++------
 13 files changed, 96 insertions(+), 56 deletions(-)

diff --git a/gcc/asan.c b/gcc/asan.c
index 53992a8..8bfe25d 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -434,7 +434,7 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len)
    otherwise.  */
 
 static bool
-get_mem_ref_of_assignment (const gimple assignment,
+get_mem_ref_of_assignment (const_gimple_assign assignment,
 			   asan_mem_ref *ref,
 			   bool *ref_is_store)
 {
@@ -802,7 +802,8 @@ has_stmt_been_instrumented_p (gimple stmt)
       asan_mem_ref r;
       asan_mem_ref_init (&r, NULL, 1);
 
-      if (get_mem_ref_of_assignment (stmt, &r, &r_is_store))
+      if (get_mem_ref_of_assignment (stmt->as_a_gimple_assign (), &r,
+				     &r_is_store))
 	return has_mem_ref_been_instrumented (&r);
     }
   else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 68172f7..375a6b3 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -77,6 +77,10 @@ struct gimple_statement_switch;
 typedef struct gimple_statement_switch *gimple_switch;
 typedef const struct gimple_statement_switch *const_gimple_switch;
 
+struct gimple_statement_assign;
+typedef struct gimple_statement_assign *gimple_assign;
+typedef const struct gimple_statement_assign *const_gimple_assign;
+
 struct gimple_statement_bind;
 typedef struct gimple_statement_bind *gimple_bind;
 typedef const struct gimple_statement_bind *const_gimple_bind;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index e45bdd2..0ff243c 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -461,6 +461,8 @@ def build_pretty_printer():
                               'gimple_statement_cond *',
                               'gimple_switch', 'const_gimple_switch',
                               'gimple_statement_switch *',
+                              'gimple_assign', 'const_gimple_assign',
+                              'gimple_statement_assign *',
                               'gimple_bind', 'const_gimple_bind',
                               'gimple_statement_bind *'],
 
diff --git a/gcc/gimple-builder.c b/gcc/gimple-builder.c
index ba4be26..b6f439c 100644
--- a/gcc/gimple-builder.c
+++ b/gcc/gimple-builder.c
@@ -51,7 +51,7 @@ get_expr_type (enum tree_code code, tree op)
    the expression code for the RHS.  OP1 is the first operand and VAL
    is an integer value to be used as the second operand.  */
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, tree op1, int val, tree lhs)
 {
   tree op2 = build_int_cst (TREE_TYPE (op1), val);
@@ -60,7 +60,7 @@ build_assign (enum tree_code code, tree op1, int val, tree lhs)
   return gimple_build_assign_with_ops (code, lhs, op1, op2);
 }
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, gimple g, int val, tree lhs )
 {
   return build_assign (code, gimple_assign_lhs (g), val, lhs);
@@ -75,7 +75,7 @@ build_assign (enum tree_code code, gimple g, int val, tree lhs )
    in normal form depending on the type of builder invoking this
    function.  */
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
 {
   if (lhs == NULL_TREE)
@@ -83,19 +83,19 @@ build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
   return gimple_build_assign_with_ops (code, lhs, op1, op2);
 }
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, gimple op1, tree op2, tree lhs)
 {
   return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
 }
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, tree op1, gimple op2, tree lhs)
 {
   return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
 }
 
-gimple
+gimple_assign
 build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
 {
   return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
@@ -106,7 +106,7 @@ build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
 /* Create and return a type cast assignment. This creates a NOP_EXPR
    that converts OP to TO_TYPE.  */
 
-gimple
+gimple_assign
 build_type_cast (tree to_type, tree op, tree lhs)
 {
   if (lhs == NULL_TREE)
@@ -114,7 +114,7 @@ build_type_cast (tree to_type, tree op, tree lhs)
   return gimple_build_assign_with_ops (NOP_EXPR, lhs, op, NULL_TREE);
 }
 
-gimple
+gimple_assign
 build_type_cast (tree to_type, gimple op, tree lhs)
 {
   return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
diff --git a/gcc/gimple-builder.h b/gcc/gimple-builder.h
index 1b5afdc..9f9ad21 100644
--- a/gcc/gimple-builder.h
+++ b/gcc/gimple-builder.h
@@ -21,13 +21,13 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GIMPLE_BUILDER_H
 #define GCC_GIMPLE_BUILDER_H
 
-gimple build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, tree, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, gimple, tree lhs = NULL_TREE);
 
 #endif /* GCC_GIMPLE_BUILDER_H */
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 61824a6..2334d03 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -261,7 +261,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_unary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (gs);
   tree lhs = gimple_assign_lhs (gs);
@@ -345,7 +345,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_binary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
 {
   const char *p;
   enum tree_code code = gimple_assign_rhs_code (gs);
@@ -401,7 +401,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_ternary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
 {
   const char *p;
   enum tree_code code = gimple_assign_rhs_code (gs);
@@ -486,7 +486,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2095,7 +2095,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_ASSIGN:
-      dump_gimple_assign (buffer, gs, spc, flags);
+      dump_gimple_assign (buffer, gs->as_a_gimple_assign (), spc, flags);
       break;
 
     case GIMPLE_BIND:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 2cb5e2e..18130db 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -377,7 +377,7 @@ gimple_build_call_from_tree (tree t)
    LHS of the assignment.
    RHS of the assignment which can be unary or binary.  */
 
-gimple
+gimple_assign
 gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
 {
   enum tree_code subcode;
@@ -393,19 +393,19 @@ gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
    OP1 and OP2.  If OP2 is NULL then SUBCODE must be of class
    GIMPLE_UNARY_RHS or GIMPLE_SINGLE_RHS.  */
 
-gimple
+gimple_assign
 gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
 			      tree op2, tree op3 MEM_STAT_DECL)
 {
   unsigned num_ops;
-  gimple p;
+  gimple_assign p;
 
   /* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the
      code).  */
   num_ops = get_gimple_rhs_num_ops (subcode) + 1;
 
   p = gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
-  			          PASS_MEM_STAT);
+				  PASS_MEM_STAT)->as_a_gimple_assign ();
   gimple_assign_set_lhs (p, lhs);
   gimple_assign_set_rhs1 (p, op1);
   if (op2)
@@ -423,7 +423,7 @@ gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
   return p;
 }
 
-gimple
+gimple_assign
 gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
 			      tree op2 MEM_STAT_DECL)
 {
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 989f85a..cfacebe 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -226,6 +226,12 @@ public:
     return as_a <gimple_statement_switch> (this);
   }
 
+  inline gimple_assign
+  as_a_gimple_assign ()
+  {
+    return as_a <gimple_statement_assign> (this);
+  }
+
   inline gimple_bind
   as_a_gimple_bind ()
   {
@@ -252,6 +258,12 @@ public:
     return dyn_cast <gimple_statement_switch> (this);
   }
 
+  inline gimple_assign
+  dyn_cast_gimple_assign ()
+  {
+    return dyn_cast <gimple_statement_assign> (this);
+  }
+
   inline gimple_bind
   dyn_cast_gimple_bind ()
   {
@@ -843,6 +855,16 @@ struct GTY((tag("GSS_WITH_OPS")))
   /* no additional fields; this uses the layout for GSS_WITH_OPS. */
 };
 
+/* A statement with the invariant that
+      stmt->code == GIMPLE_ASSIGN
+   i.e. an assignment statement.  */
+
+struct GTY((tag("GSS_WITH_MEM_OPS")))
+  gimple_statement_assign : public gimple_statement_with_memory_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
+};
+
 template <>
 template <>
 inline bool
@@ -854,6 +876,14 @@ is_a_helper <gimple_statement_asm>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_assign>::test (gimple gs)
+{
+  return gs->code == GIMPLE_ASSIGN;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_bind>::test (gimple gs)
 {
   return gs->code == GIMPLE_BIND;
@@ -1264,12 +1294,13 @@ gimple gimple_build_call_valist (tree, unsigned, va_list);
 gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
 gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
 gimple gimple_build_call_from_tree (tree);
-gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
+gimple_assign gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
-				     tree, tree, tree CXX_MEM_STAT_INFO);
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
-				     tree, tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+					    tree, tree,
+					    tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+					    tree, tree CXX_MEM_STAT_INFO);
 gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
 gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
 void gimple_cond_set_condition_from_tree (gimple_cond, tree);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index b1355ab..6a67cdc 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3389,7 +3389,7 @@ verify_gimple_comparison (tree type, tree op0, tree op1)
    Returns true if anything is wrong.  */
 
 static bool
-verify_gimple_assign_unary (gimple stmt)
+verify_gimple_assign_unary (gimple_assign stmt)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
   tree lhs = gimple_assign_lhs (stmt);
@@ -3543,7 +3543,7 @@ verify_gimple_assign_unary (gimple stmt)
    Returns true if anything is wrong.  */
 
 static bool
-verify_gimple_assign_binary (gimple stmt)
+verify_gimple_assign_binary (gimple_assign stmt)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
   tree lhs = gimple_assign_lhs (stmt);
@@ -3817,7 +3817,7 @@ verify_gimple_assign_binary (gimple stmt)
    Returns true if anything is wrong.  */
 
 static bool
-verify_gimple_assign_ternary (gimple stmt)
+verify_gimple_assign_ternary (gimple_assign stmt)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
   tree lhs = gimple_assign_lhs (stmt);
@@ -3960,7 +3960,7 @@ verify_gimple_assign_ternary (gimple stmt)
    Returns true if anything is wrong.  */
 
 static bool
-verify_gimple_assign_single (gimple stmt)
+verify_gimple_assign_single (gimple_assign stmt)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
   tree lhs = gimple_assign_lhs (stmt);
@@ -4162,7 +4162,7 @@ verify_gimple_assign_single (gimple stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_assign (gimple stmt)
+verify_gimple_assign (gimple_assign stmt)
 {
   switch (gimple_assign_rhs_class (stmt))
     {
@@ -4401,7 +4401,7 @@ verify_gimple_stmt (gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_ASSIGN:
-      return verify_gimple_assign (stmt);
+      return verify_gimple_assign (stmt->as_a_gimple_assign ());
 
     case GIMPLE_LABEL:
       return verify_gimple_label (stmt);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index f7ec8b6..6516a4f 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -3271,7 +3271,7 @@ simplify_binary_expression (gimple stmt)
    simplified. */
 
 static tree
-simplify_unary_expression (gimple stmt)
+simplify_unary_expression (gimple_assign stmt)
 {
   tree result = NULL_TREE;
   tree orig_op0, op0 = gimple_assign_rhs1 (stmt);
@@ -3334,7 +3334,7 @@ simplify_unary_expression (gimple stmt)
 /* Try to simplify RHS using equivalences and constant folding.  */
 
 static tree
-try_to_simplify (gimple stmt)
+try_to_simplify (gimple_assign stmt)
 {
   enum tree_code code = gimple_assign_rhs_code (stmt);
   tree tem;
@@ -3422,7 +3422,7 @@ visit_use (tree use)
 	      changed = visit_copy (lhs, rhs1);
 	      goto done;
 	    }
-	  simplified = try_to_simplify (stmt);
+	  simplified = try_to_simplify (stmt->as_a_gimple_assign ());
 	  if (simplified)
 	    {
 	      if (dump_file && (dump_flags & TDF_DETAILS))
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 3488c2f..a436be7 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -267,7 +267,7 @@ independent_of_stmt_p (tree expr, gimple at, gimple_stmt_iterator gsi)
    additive factor for the real return value.  */
 
 static bool
-process_assignment (gimple stmt, gimple_stmt_iterator call, tree *m,
+process_assignment (gimple_assign stmt, gimple_stmt_iterator call, tree *m,
 		    tree *a, tree *ass_var)
 {
   tree op0, op1 = NULL_TREE, non_ass_var = NULL_TREE;
@@ -549,7 +549,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
 	return;
 
       /* This is a gimple assign. */
-      if (! process_assignment (stmt, gsi, &tmp_m, &tmp_a, &ass_var))
+      if (! process_assignment (stmt->as_a_gimple_assign (), gsi, &tmp_m,
+				&tmp_a, &ass_var))
 	return;
 
       if (tmp_a)
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index d00a4b4..c75cd28 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -837,7 +837,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
 static void
 expand_vector_condition (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
   tree type = gimple_expr_type (stmt);
   tree a = gimple_assign_rhs1 (stmt);
   tree a1 = a;
@@ -900,7 +900,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
 
 static tree
 expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type,
-			 gimple assign, enum tree_code code)
+			 gimple_assign assign, enum tree_code code)
 {
   enum machine_mode compute_mode = TYPE_MODE (compute_type);
 
@@ -1005,7 +1005,7 @@ expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
 static void
 optimize_vector_constructor (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
   tree lhs = gimple_assign_lhs (stmt);
   tree rhs = gimple_assign_rhs1 (stmt);
   tree type = TREE_TYPE (rhs);
@@ -1220,7 +1220,7 @@ vector_element (gimple_stmt_iterator *gsi, tree vect, tree idx, tree *ptmpvec)
 static void
 lower_vec_perm (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
   tree mask = gimple_assign_rhs3 (stmt);
   tree vec0 = gimple_assign_rhs1 (stmt);
   tree vec1 = gimple_assign_rhs2 (stmt);
@@ -1340,7 +1340,6 @@ lower_vec_perm (gimple_stmt_iterator *gsi)
 static void
 expand_vector_operations_1 (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
   tree lhs, rhs1, rhs2 = NULL, type, compute_type;
   enum tree_code code;
   enum machine_mode compute_mode;
@@ -1348,7 +1347,9 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
   enum gimple_rhs_class rhs_class;
   tree new_rhs;
 
-  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+  /* Only consider code == GIMPLE_ASSIGN. */
+  gimple_assign stmt = gsi_stmt (*gsi)->dyn_cast_gimple_assign ();
+  if (!stmt)
     return;
 
   code = gimple_assign_rhs_code (stmt);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index f9366b9..8c6d110 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3507,7 +3507,7 @@ extract_range_from_unary_expr (value_range_t *vr, enum tree_code code,
    the ranges of each of its operands and the expression code.  */
 
 static void
-extract_range_from_cond_expr (value_range_t *vr, gimple stmt)
+extract_range_from_cond_expr (value_range_t *vr, gimple_assign stmt)
 {
   tree op0, op1;
   value_range_t vr0 = VR_INITIALIZER;
@@ -3814,7 +3814,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
    in *VR.  */
 
 static void
-extract_range_from_assignment (value_range_t *vr, gimple stmt)
+extract_range_from_assignment (value_range_t *vr, gimple_assign stmt)
 {
   enum tree_code code = gimple_assign_rhs_code (stmt);
 
@@ -6800,7 +6800,7 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
       else if (code == GIMPLE_CALL)
 	extract_range_basic (&new_vr, stmt);
       else
-	extract_range_from_assignment (&new_vr, stmt);
+	extract_range_from_assignment (&new_vr, stmt->as_a_gimple_assign ());
 
       if (update_value_range (lhs, &new_vr))
 	{
@@ -9561,16 +9561,16 @@ simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
 				     gimple_cond_lhs (stmt),
 				     gimple_cond_rhs (stmt), within_stmt);
 
-  if (gimple_code (stmt) == GIMPLE_ASSIGN)
+  if (gimple_assign assign_stmt = stmt->dyn_cast_gimple_assign ())
     {
       value_range_t new_vr = VR_INITIALIZER;
-      tree lhs = gimple_assign_lhs (stmt);
+      tree lhs = gimple_assign_lhs (assign_stmt);
 
       if (TREE_CODE (lhs) == SSA_NAME
 	  && (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
 	      || POINTER_TYPE_P (TREE_TYPE (lhs))))
 	{
-	  extract_range_from_assignment (&new_vr, stmt);
+	  extract_range_from_assignment (&new_vr, assign_stmt);
 	  if (range_int_cst_singleton_p (&new_vr))
 	    return new_vr.min;
 	}
-- 
1.8.5.3

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

* [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (9 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-04-22  2:46   ` Trevor Saunders
  2014-04-23 20:01   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure David Malcolm
                   ` (80 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_statement_switch): New subclass of
	gimple_statement_with_ops, adding the invariant that
	stmt->code == GIMPLE_SWITCH.
	(gimple_statement_base::as_a_gimple_switch): New.
	(gimple_statement_base::dyn_cast_gimple_switch): New.
	(is_a_helper <gimple_statement_switch>::test (gimple)): New.

	* coretypes.h (gimple_switch): New typedef
	(const_gimple_switch): Likewise.

	* gdbhooks.py (build_pretty_printer): Add gimple_switch
	and its variants, using the gimple printer.

	* gimple.c (gimple_build_switch_nlabels): Return a gimple_switch
	rather than just a gimple.
	(gimple_build_switch): Likewise.
	* gimple.h (gimple_build_switch_nlabels): Likewise.
	(gimple_build_switch): Likewise.

	* gimple.h (gimple_switch_num_labels): Update type-signature to
	require a gimple_switch rather than just a gimple.
	(gimple_switch_set_num_labels): Likewise.
	(gimple_switch_set_index): Likewise.
	(gimple_switch_label): Likewise.
	(gimple_switch_set_label): Likewise.
	(gimple_switch_default_label): Likewise.
	(gimple_switch_set_default_label): Likewise.
	* expr.h (expand_case): Likewise.
	* gimple-pretty-print.c (dump_gimple_call): Likewise.
	* stmt.c (compute_cases_per_edge): Likewise.
	(expand_case): Likewise.
	* tree-cfg.h (group_case_labels_stmt): Likewise.
	* tree-cfg.c (make_gimple_switch_edges): Likewise.
	(find_taken_edge_switch_expr) Likewise.
	(find_case_label_for_value) Likewise.
	(get_cases_for_edge): Likewise.
	(group_case_labels_stmt): Likewise.
	(verify_gimple_switch): Likewise.
	* tree-eh.c (verify_norecord_switch_expr): Likewise.
	* tree-eh.c (lower_eh_constructs_2): Likewise.
	* tree-loop-distribution.c (generate_loops_for_partition): Likewise.
	* tree-ssa-dom.c (record_edge_info): Likewise.
	* tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise.
	(simplify_gimple_switch): Likewise.
	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
	(collect_switch_conv_info): Likewise.
	(build_constructors): Likewise.
	(array_value_type): Likewise.
	(build_one_array): Likewise.
	(build_arrays): Likewise.
	(gen_inbound_check): Likewise.
	* tree-vrp.c (find_switch_asserts): Likewise.
	(find_case_label_range): Likewise.
	(find_case_label_ranges): Likewise.
	(vrp_visit_switch_stmt): Likewise.
	(simplify_switch_using_ranges): Likewise.

	* tree-vrp.c (switch_update): Strengthen field "stmt" from being
	merely a gimple to being a gimple_switch.

	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to
	gimple_switch in regions where the stmt code has been tested as
	GIMPLE_SWITCH.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* tree-cfg.c (make_edges): Likewise.
	(end_recording_case_labels): Likewise.
	(cleanup_dead_labels): Likewise.
	(cleanup_dead_labels): Likewise.
	(group_case_labels): Likewise.
	(find_taken_edge): Likewise.
	(find_case_label_for_value): Likewise.
	(verify_gimple_stmt): Likewise.
	(gimple_verify_flow_info): Likewise.
	(gimple_redirect_edge_and_branch): Likewise.
	* tree-inline.c (estimate_num_insns): Likewise.
	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
	* tree-switch-conversion.c (do_switchconv): Likewise.
	* tree-vrp.c  (find_assert_locations_1): Likewise.
	(vrp_visit_stmt): Likewise.
	(simplify_stmt_using_ranges): Likewise.

	* ipa-inline-analysis.c (set_switch_stmt_execution_predicate):
	Introduce local "lastg" as a generic gimple, so that local "last"
	can be of type gimple_switch once lastg's code has been verified.

	* omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle
	the GIMPLE_SWITCH case.

	* tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch
	argument, since the caller (find_taken_edge) has checked that
	last_stmt is a switch.

Conflicts:
	gcc/coretypes.h
	gcc/tree-cfg.c
	gcc/tree-ssa-dom.c
	gcc/tree-ssa-uncprop.c
	gcc/tree-vrp.c
---
 gcc/cfgexpand.c              |  2 +-
 gcc/coretypes.h              |  8 +++++
 gcc/expr.h                   |  2 +-
 gcc/gdbhooks.py              |  7 ++++-
 gcc/gimple-pretty-print.c    |  5 ++--
 gcc/gimple.c                 | 11 +++----
 gcc/gimple.h                 | 71 ++++++++++++++++++++++++++++++++++++++------
 gcc/ipa-inline-analysis.c    |  7 +++--
 gcc/omp-low.c                |  5 ++--
 gcc/stmt.c                   |  4 +--
 gcc/tree-cfg.c               | 57 ++++++++++++++++++-----------------
 gcc/tree-cfg.h               |  2 +-
 gcc/tree-eh.c                |  5 ++--
 gcc/tree-inline.c            | 21 +++++++------
 gcc/tree-loop-distribution.c |  3 +-
 gcc/tree-ssa-dom.c           |  5 ++--
 gcc/tree-ssa-forwprop.c      |  6 ++--
 gcc/tree-ssa-uncprop.c       |  7 +++--
 gcc/tree-switch-conversion.c | 20 ++++++-------
 gcc/tree-vrp.c               | 20 ++++++-------
 20 files changed, 173 insertions(+), 95 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index b7f6360..05ab95e 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3147,7 +3147,7 @@ expand_gimple_stmt_1 (gimple stmt)
     case GIMPLE_PREDICT:
       break;
     case GIMPLE_SWITCH:
-      expand_case (stmt);
+      expand_case (stmt->as_a_gimple_switch ());
       break;
     case GIMPLE_ASM:
       expand_asm_stmt (stmt);
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d07a604..a39ae1a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -65,6 +65,14 @@ typedef struct gimple_statement_base *gimple;
 typedef const struct gimple_statement_base *const_gimple;
 typedef gimple gimple_seq;
 struct gimple_stmt_iterator;
+
+/* Typedefs for leaf gimple subclasses (for individual gimple codes).
+   Keep this in the same order as the corresponding codes in gimple.def.  */
+
+struct gimple_statement_switch;
+typedef struct gimple_statement_switch *gimple_switch;
+typedef const struct gimple_statement_switch *const_gimple_switch;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/expr.h b/gcc/expr.h
index 524da67..12c3e34 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -769,7 +769,7 @@ rtx get_personality_function (tree);
 /* In stmt.c */
 
 /* Expand a GIMPLE_SWITCH statement.  */
-extern void expand_case (gimple);
+extern void expand_case (gimple_switch);
 
 /* Like expand_case but special-case for SJLJ exception dispatching.  */
 extern void expand_sjlj_dispatch_table (rtx, vec<tree> );
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 85608dc..891877a 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -454,7 +454,12 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
-    pp.add_printer_for_types(['gimple', 'gimple_statement_base *'],
+    pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
+
+                              # Keep this in the same order as gimple.def:
+                              'gimple_switch', 'const_gimple_switch',
+                              'gimple_statement_switch *'],
+
                              'gimple',
                              GimplePrinter)
     pp.add_printer_for_types(['basic_block', 'basic_block_def *'],
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 741cd92..25abd77 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -775,7 +775,8 @@ dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
+		    int flags)
 {
   unsigned int i;
 
@@ -2126,7 +2127,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_SWITCH:
-      dump_gimple_switch (buffer, gs, spc, flags);
+      dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e9851ca..6c524c2 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -714,13 +714,14 @@ gimple_build_resx (int region)
    NLABELS is the number of labels in the switch excluding the default.
    DEFAULT_LABEL is the default label for the switch statement.  */
 
-gimple
+gimple_switch
 gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
 {
   /* nlabels + 1 default label + 1 index.  */
   gcc_checking_assert (default_label);
-  gimple p = gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
-				    1 + 1 + nlabels);
+  gimple_switch p =
+    gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
+			   1 + 1 + nlabels)->as_a_gimple_switch ();
   gimple_switch_set_index (p, index);
   gimple_switch_set_default_label (p, default_label);
   return p;
@@ -732,12 +733,12 @@ gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
    DEFAULT_LABEL is the default label
    ARGS is a vector of labels excluding the default.  */
 
-gimple
+gimple_switch
 gimple_build_switch (tree index, tree default_label, vec<tree> args)
 {
   unsigned i, nlabels = args.length ();
 
-  gimple p = gimple_build_switch_nlabels (nlabels, index, default_label);
+  gimple_switch p = gimple_build_switch_nlabels (nlabels, index, default_label);
 
   /* Copy the labels from the vector to the switch statement.  */
   for (i = 0; i < nlabels; i++)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 26e8627..b448e0e 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -199,6 +199,41 @@ struct GTY((desc ("gimple_statement_structure (&%h)"), tag ("GSS_BASE"),
      and the prev pointer being the last.  */
   gimple next;
   gimple GTY((skip)) prev;
+
+public:
+  /* Downcasting methods, where the stmt *must* be of a given kind.
+     The cast is checked in a checked build, and a no-op in an
+     unchecked build.
+
+     Writing
+       stmt->as_a_gimple_foo ()
+     is less verbose than
+       as_a <gimple_statement_foo> (stmt)
+     and makes more sense when read as an English phrase.
+
+     Keep these in the same order as the corresponding entries in
+     gimple.def.  */
+
+  inline gimple_switch
+  as_a_gimple_switch ()
+  {
+    return as_a <gimple_statement_switch> (this);
+  }
+
+  /* Dynamic casting methods, where the cast returns NULL if the
+     stmt is not of the required kind.
+
+     As above, writing
+       stmt->dyn_cast_gimple_foo ()
+     is less verbose than
+       dyn_cast <gimple_statement_foo> (stmt).  */
+
+  inline gimple_switch
+  dyn_cast_gimple_switch ()
+  {
+    return dyn_cast <gimple_statement_switch> (this);
+  }
+
 };
 
 
@@ -764,6 +799,16 @@ enum gimple_statement_structure_enum {
 };
 #undef DEFGSSTRUCT
 
+/* A statement with the invariant that
+      stmt->code == GIMPLE_SWITCH
+   i.e. a switch statement.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_switch : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
 template <>
 template <>
 inline bool
@@ -951,6 +996,14 @@ is_a_helper <gimple_statement_phi>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_switch>::test (gimple gs)
+{
+  return gs->code == GIMPLE_SWITCH;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_transaction>::test (gimple gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
@@ -1193,8 +1246,8 @@ gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
 gimple gimple_build_wce (gimple_seq);
 gimple gimple_build_resx (int);
-gimple gimple_build_switch_nlabels (unsigned, tree, tree);
-gimple gimple_build_switch (tree, tree, vec<tree> );
+gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
+gimple_switch gimple_build_switch (tree, tree, vec<tree> );
 gimple gimple_build_eh_dispatch (int);
 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)			\
@@ -3942,7 +3995,7 @@ gimple_eh_dispatch_set_region (gimple gs, int region)
 /* Return the number of labels associated with the switch statement GS.  */
 
 static inline unsigned
-gimple_switch_num_labels (const_gimple gs)
+gimple_switch_num_labels (const_gimple_switch gs)
 {
   unsigned num_ops;
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
@@ -3955,7 +4008,7 @@ gimple_switch_num_labels (const_gimple gs)
 /* Set NLABELS to be the number of labels for the switch statement GS.  */
 
 static inline void
-gimple_switch_set_num_labels (gimple g, unsigned nlabels)
+gimple_switch_set_num_labels (gimple_switch g, unsigned nlabels)
 {
   GIMPLE_CHECK (g, GIMPLE_SWITCH);
   gimple_set_num_ops (g, nlabels + 1);
@@ -3985,7 +4038,7 @@ gimple_switch_index_ptr (const_gimple gs)
 /* Set INDEX to be the index variable for switch statement GS.  */
 
 static inline void
-gimple_switch_set_index (gimple gs, tree index)
+gimple_switch_set_index (gimple_switch gs, tree index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
@@ -3997,7 +4050,7 @@ gimple_switch_set_index (gimple gs, tree index)
    labels in a switch statement.  */
 
 static inline tree
-gimple_switch_label (const_gimple gs, unsigned index)
+gimple_switch_label (const_gimple_switch gs, unsigned index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
@@ -4007,7 +4060,7 @@ gimple_switch_label (const_gimple gs, unsigned index)
 /* Set the label number INDEX to LABEL.  0 is always the default label.  */
 
 static inline void
-gimple_switch_set_label (gimple gs, unsigned index, tree label)
+gimple_switch_set_label (gimple_switch gs, unsigned index, tree label)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
@@ -4019,7 +4072,7 @@ gimple_switch_set_label (gimple gs, unsigned index, tree label)
 /* Return the default label for a switch statement.  */
 
 static inline tree
-gimple_switch_default_label (const_gimple gs)
+gimple_switch_default_label (const_gimple_switch gs)
 {
   tree label = gimple_switch_label (gs, 0);
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
@@ -4029,7 +4082,7 @@ gimple_switch_default_label (const_gimple gs)
 /* Set the default label for a switch statement.  */
 
 static inline void
-gimple_switch_set_default_label (gimple gs, tree label)
+gimple_switch_set_default_label (gimple_switch gs, tree label)
 {
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
   gimple_switch_set_label (gs, 0, label);
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 8e0f5dd..29242e0 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -1796,7 +1796,7 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
 				     struct inline_summary *summary,
 				     basic_block bb)
 {
-  gimple last;
+  gimple lastg;
   tree op;
   int index;
   struct agg_position_info aggpos;
@@ -1805,9 +1805,10 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
   size_t n;
   size_t case_idx;
 
-  last = last_stmt (bb);
-  if (!last || gimple_code (last) != GIMPLE_SWITCH)
+  lastg = last_stmt (bb);
+  if (!lastg || gimple_code (lastg) != GIMPLE_SWITCH)
     return;
+  gimple_switch last = lastg->as_a_gimple_switch ();
   op = gimple_switch_index (last);
   if (!unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos))
     return;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 11bb2d3..cd10717 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10452,10 +10452,11 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
 	unsigned int i;
-	for (i = 0; i < gimple_switch_num_labels (stmt); ++i)
+	for (i = 0; i < gimple_switch_num_labels (switch_stmt); ++i)
 	  {
-	    tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+	    tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 	    n = splay_tree_lookup (all_labels, (splay_tree_key) lab);
 	    if (n && diagnose_sb_0 (gsi_p, context, (gimple) n->value))
 	      break;
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 5d68edb..19a7f09 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1130,7 +1130,7 @@ reset_out_edges_aux (basic_block bb)
    STMT. Record this information in the aux field of the edge.  */
 
 static inline void
-compute_cases_per_edge (gimple stmt)
+compute_cases_per_edge (gimple_switch stmt)
 {
   basic_block bb = gimple_bb (stmt);
   reset_out_edges_aux (bb);
@@ -1152,7 +1152,7 @@ compute_cases_per_edge (gimple stmt)
    Generate the code to test it and jump to the right place.  */
 
 void
-expand_case (gimple stmt)
+expand_case (gimple_switch stmt)
 {
   tree minval = NULL_TREE, maxval = NULL_TREE, range = NULL_TREE;
   rtx default_label = NULL_RTX;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 56b6c35..53aced3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -150,7 +150,7 @@ static void make_blocks (gimple_seq);
 static void make_edges (void);
 static void assign_discriminators (void);
 static void make_cond_expr_edges (basic_block);
-static void make_gimple_switch_edges (basic_block);
+static void make_gimple_switch_edges (gimple_switch, basic_block);
 static bool make_goto_expr_edges (basic_block);
 static void make_gimple_asm_edges (basic_block);
 static edge gimple_redirect_edge_and_branch (edge, basic_block);
@@ -169,8 +169,8 @@ static bool gimple_can_merge_blocks_p (basic_block, basic_block);
 static void remove_bb (basic_block);
 static edge find_taken_edge_computed_goto (basic_block, tree);
 static edge find_taken_edge_cond_expr (basic_block, tree);
-static edge find_taken_edge_switch_expr (basic_block, tree);
-static tree find_case_label_for_value (gimple, tree);
+static edge find_taken_edge_switch_expr (gimple_switch, basic_block, tree);
+static tree find_case_label_for_value (gimple_switch, tree);
 
 void
 init_empty_tree_cfg_for_function (struct function *fn)
@@ -758,7 +758,7 @@ make_edges (void)
 	      fallthru = false;
 	      break;
 	    case GIMPLE_SWITCH:
-	      make_gimple_switch_edges (bb);
+	      make_gimple_switch_edges (last->as_a_gimple_switch (), bb);
 	      fallthru = false;
 	      break;
 	    case GIMPLE_RESX:
@@ -1083,7 +1083,7 @@ end_recording_case_labels (void)
 	{
 	  gimple stmt = last_stmt (bb);
 	  if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	    group_case_labels_stmt (stmt);
+	    group_case_labels_stmt (stmt->as_a_gimple_switch ());
 	}
     }
   BITMAP_FREE (touched_switch_bbs);
@@ -1095,7 +1095,7 @@ end_recording_case_labels (void)
    Otherwise return NULL.  */
 
 static tree
-get_cases_for_edge (edge e, gimple t)
+get_cases_for_edge (edge e, gimple_switch t)
 {
   void **slot;
   size_t i, n;
@@ -1134,9 +1134,8 @@ get_cases_for_edge (edge e, gimple t)
 /* Create the edges for a GIMPLE_SWITCH starting at block BB.  */
 
 static void
-make_gimple_switch_edges (basic_block bb)
+make_gimple_switch_edges (gimple_switch entry, basic_block bb)
 {
-  gimple entry = last_stmt (bb);
   size_t i, n;
 
   n = gimple_switch_num_labels (entry);
@@ -1387,12 +1386,13 @@ cleanup_dead_labels (void)
 
 	case GIMPLE_SWITCH:
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Replace all destination labels.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree case_label = gimple_switch_label (stmt, i);
+		tree case_label = gimple_switch_label (switch_stmt, i);
 		label = CASE_LABEL (case_label);
 		new_label = main_block_label (label);
 		if (new_label != label)
@@ -1489,7 +1489,7 @@ cleanup_dead_labels (void)
    Eg. three separate entries 1: 2: 3: become one entry 1..3:  */
 
 void
-group_case_labels_stmt (gimple stmt)
+group_case_labels_stmt (gimple_switch stmt)
 {
   int old_size = gimple_switch_num_labels (stmt);
   int i, j, new_size = old_size;
@@ -1577,7 +1577,7 @@ group_case_labels (void)
     {
       gimple stmt = last_stmt (bb);
       if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	group_case_labels_stmt (stmt);
+	group_case_labels_stmt (stmt->as_a_gimple_switch ());
     }
 }
 
@@ -2043,7 +2043,7 @@ find_taken_edge (basic_block bb, tree val)
     return find_taken_edge_cond_expr (bb, val);
 
   if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return find_taken_edge_switch_expr (bb, val);
+    return find_taken_edge_switch_expr (stmt->as_a_gimple_switch (), bb, val);
 
   if (computed_goto_p (stmt))
     {
@@ -2102,14 +2102,13 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
    NULL if any edge may be taken.  */
 
 static edge
-find_taken_edge_switch_expr (basic_block bb, tree val)
+find_taken_edge_switch_expr (gimple_switch switch_stmt, basic_block bb,
+			     tree val)
 {
   basic_block dest_bb;
   edge e;
-  gimple switch_stmt;
   tree taken_case;
 
-  switch_stmt = last_stmt (bb);
   taken_case = find_case_label_for_value (switch_stmt, val);
   dest_bb = label_to_block (CASE_LABEL (taken_case));
 
@@ -2124,7 +2123,7 @@ find_taken_edge_switch_expr (basic_block bb, tree val)
    sorted: We can do a binary search for a case matching VAL.  */
 
 static tree
-find_case_label_for_value (gimple switch_stmt, tree val)
+find_case_label_for_value (gimple_switch switch_stmt, tree val)
 {
   size_t low, high, n = gimple_switch_num_labels (switch_stmt);
   tree default_case = gimple_switch_default_label (switch_stmt);
@@ -4251,7 +4250,7 @@ verify_gimple_goto (gimple stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_switch (gimple stmt)
+verify_gimple_switch (gimple_switch stmt)
 {
   unsigned int i, n;
   tree elt, prev_upper_bound = NULL_TREE;
@@ -4433,7 +4432,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_goto (stmt);
 
     case GIMPLE_SWITCH:
-      return verify_gimple_switch (stmt);
+      return verify_gimple_switch (stmt->as_a_gimple_switch ());
 
     case GIMPLE_RETURN:
       return verify_gimple_return (stmt);
@@ -5165,26 +5164,27 @@ gimple_verify_flow_info (void)
 
 	case GIMPLE_SWITCH:
 	  {
+	    gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
 	    tree prev;
 	    edge e;
 	    size_t i, n;
 
-	    n = gimple_switch_num_labels (stmt);
+	    n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Mark all the destination basic blocks.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 		gcc_assert (!label_bb->aux || label_bb->aux == (void *)1);
 		label_bb->aux = (void *)1;
 	      }
 
 	    /* Verify that the case labels are sorted.  */
-	    prev = gimple_switch_label (stmt, 0);
+	    prev = gimple_switch_label (switch_stmt, 0);
 	    for (i = 1; i < n; ++i)
 	      {
-		tree c = gimple_switch_label (stmt, i);
+		tree c = gimple_switch_label (switch_stmt, i);
 		if (!CASE_LOW (c))
 		  {
 		    error ("found default case not at the start of "
@@ -5230,7 +5230,7 @@ gimple_verify_flow_info (void)
 	    /* Check that we have all of them.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 
 		if (label_bb->aux != (void *)2)
@@ -5418,8 +5418,9 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
 	tree label = gimple_block_label (dest);
-        tree cases = get_cases_for_edge (e, stmt);
+        tree cases = get_cases_for_edge (e, switch_stmt);
 
 	/* If we have a list of cases associated with E, then use it
 	   as it's a lot faster than walking the entire case vector.  */
@@ -5440,7 +5441,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	       to move all the cases associated with E to E2.  */
 	    if (e2)
 	      {
-		tree cases2 = get_cases_for_edge (e2, stmt);
+		tree cases2 = get_cases_for_edge (e2, switch_stmt);
 
 		CASE_CHAIN (last) = CASE_CHAIN (cases2);
 		CASE_CHAIN (cases2) = first;
@@ -5449,11 +5450,11 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	  }
 	else
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    for (i = 0; i < n; i++)
 	      {
-		tree elt = gimple_switch_label (stmt, i);
+		tree elt = gimple_switch_label (switch_stmt, i);
 		if (label_to_block (CASE_LABEL (elt)) == e->dest)
 		  CASE_LABEL (elt) = label;
 	      }
diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index a115df5..c15d6ab 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -32,7 +32,7 @@ extern void end_recording_case_labels (void);
 extern basic_block label_to_block_fn (struct function *, tree);
 #define label_to_block(t) (label_to_block_fn (cfun, t))
 extern void cleanup_dead_labels (void);
-extern void group_case_labels_stmt (gimple);
+extern void group_case_labels_stmt (gimple_switch);
 extern void group_case_labels (void);
 extern void replace_uses_by (tree, tree);
 extern basic_block single_noncomplex_succ (basic_block bb);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 14ed52a..c9e9be1 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -713,7 +713,8 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple stmt)
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
 
 static void
-verify_norecord_switch_expr (struct leh_state *state, gimple switch_expr)
+verify_norecord_switch_expr (struct leh_state *state,
+			     gimple_switch switch_expr)
 {
   struct leh_tf_state *tf = state->tf;
   size_t i, n;
@@ -2055,7 +2056,7 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi)
       break;
 
     case GIMPLE_SWITCH:
-      verify_norecord_switch_expr (state, stmt);
+      verify_norecord_switch_expr (state, stmt->as_a_gimple_switch ());
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 4293241..c0f93ac 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3811,15 +3811,18 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       break;
 
     case GIMPLE_SWITCH:
-      /* Take into account cost of the switch + guess 2 conditional jumps for
-         each case label.
-
-	 TODO: once the switch expansion logic is sufficiently separated, we can
-	 do better job on estimating cost of the switch.  */
-      if (weights->time_based)
-        cost = floor_log2 (gimple_switch_num_labels (stmt)) * 2;
-      else
-        cost = gimple_switch_num_labels (stmt) * 2;
+      {
+	gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
+	/* Take into account cost of the switch + guess 2 conditional jumps for
+	   each case label.
+
+	   TODO: once the switch expansion logic is sufficiently separated, we can
+	   do better job on estimating cost of the switch.  */
+	if (weights->time_based)
+	  cost = floor_log2 (gimple_switch_num_labels (switch_stmt)) * 2;
+	else
+	  cost = gimple_switch_num_labels (switch_stmt) * 2;
+      }
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 9db92db..8ce25f5 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 		}
 	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
 		{
+		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
 		  gimple_switch_set_index
-		      (stmt, CASE_LOW (gimple_switch_label (stmt, 1)));
+		      (switch_stmt, CASE_LOW (gimple_switch_label (switch_stmt, 1)));
 		  update_stmt (stmt);
 		}
 	      else
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 91253dc..2daddda 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1793,19 +1793,20 @@ record_edge_info (basic_block bb)
 
       if (gimple_code (stmt) == GIMPLE_SWITCH)
 	{
+	  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
 	  tree index = gimple_switch_index (stmt);
 
 	  if (TREE_CODE (index) == SSA_NAME)
 	    {
 	      int i;
-              int n_labels = gimple_switch_num_labels (stmt);
+              int n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 	      edge e;
 	      edge_iterator ei;
 
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block target_bb = label_to_block (CASE_LABEL (label));
 		  if (CASE_HIGH (label)
 		      || !CASE_LOW (label)
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index b229429..d34ee1f 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1284,7 +1284,7 @@ simplify_not_neg_expr (gimple_stmt_iterator *gsi_p)
    have values outside the range of the new type.  */
 
 static void
-simplify_gimple_switch_label_vec (gimple stmt, tree index_type)
+simplify_gimple_switch_label_vec (gimple_switch stmt, tree index_type)
 {
   unsigned int branch_num = gimple_switch_num_labels (stmt);
   auto_vec<tree> labels (branch_num);
@@ -1354,7 +1354,7 @@ simplify_gimple_switch_label_vec (gimple stmt, tree index_type)
    the condition which we may be able to optimize better.  */
 
 static bool
-simplify_gimple_switch (gimple stmt)
+simplify_gimple_switch (gimple_switch stmt)
 {
   tree cond = gimple_switch_index (stmt);
   tree def, to, ti;
@@ -3784,7 +3784,7 @@ ssa_forward_propagate_and_combine (void)
 	      }
 
 	    case GIMPLE_SWITCH:
-	      changed = simplify_gimple_switch (stmt);
+	      changed = simplify_gimple_switch (stmt->as_a_gimple_switch ());
 	      break;
 
 	    case GIMPLE_COND:
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index a43dd1a..5f9b3ec 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -173,12 +173,13 @@ associate_equivalences_with_edges (void)
 	 target block creates an equivalence.  */
       else if (gimple_code (stmt) == GIMPLE_SWITCH)
 	{
-	  tree cond = gimple_switch_index (stmt);
+	  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
+	  tree cond = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (cond) == SSA_NAME
 	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
 	    {
-	      int i, n_labels = gimple_switch_num_labels (stmt);
+	      int i, n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 
 	      /* Walk over the case label vector.  Record blocks
@@ -186,7 +187,7 @@ associate_equivalences_with_edges (void)
 		 a single value.  */
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block bb = label_to_block (CASE_LABEL (label));
 
 		  if (CASE_HIGH (label)
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 547ac9e..7e3461c 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -302,7 +302,7 @@ case_bit_test_cmp (const void *p1, const void *p2)
     node targets.  */
 
 static void
-emit_case_bit_tests (gimple swtch, tree index_expr,
+emit_case_bit_tests (gimple_switch swtch, tree index_expr,
 		     tree minval, tree range)
 {
   struct case_bit_test test[MAX_CASE_BIT_TESTS];
@@ -612,7 +612,7 @@ struct switch_conv_info
 /* Collect information about GIMPLE_SWITCH statement SWTCH into INFO.  */
 
 static void
-collect_switch_conv_info (gimple swtch, struct switch_conv_info *info)
+collect_switch_conv_info (gimple_switch swtch, struct switch_conv_info *info)
 {
   unsigned int branch_num = gimple_switch_num_labels (swtch);
   tree min_case, max_case;
@@ -856,7 +856,7 @@ gather_default_values (tree default_case, struct switch_conv_info *info)
    order of phi nodes.  SWTCH is the switch statement being converted.  */
 
 static void
-build_constructors (gimple swtch, struct switch_conv_info *info)
+build_constructors (gimple_switch swtch, struct switch_conv_info *info)
 {
   unsigned i, branch_num = gimple_switch_num_labels (swtch);
   tree pos = info->range_min;
@@ -948,7 +948,7 @@ constructor_contains_same_values_p (vec<constructor_elt, va_gc> *vec)
    all the constants.  */
 
 static tree
-array_value_type (gimple swtch, tree type, int num,
+array_value_type (gimple_switch swtch, tree type, int num,
 		  struct switch_conv_info *info)
 {
   unsigned int i, len = vec_safe_length (info->constructors[num]);
@@ -1025,8 +1025,8 @@ array_value_type (gimple swtch, tree type, int num,
    new array.  */
 
 static void
-build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
-		 tree tidx, struct switch_conv_info *info)
+build_one_array (gimple_switch swtch, int num, tree arr_index_type,
+		 gimple phi, tree tidx, struct switch_conv_info *info)
 {
   tree name, cst;
   gimple load;
@@ -1091,7 +1091,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
    them.  */
 
 static void
-build_arrays (gimple swtch, struct switch_conv_info *info)
+build_arrays (gimple_switch swtch, struct switch_conv_info *info)
 {
   tree arr_index_type;
   tree tidx, sub, utype;
@@ -1212,7 +1212,7 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf,
 */
 
 static void
-gen_inbound_check (gimple swtch, struct switch_conv_info *info)
+gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
 {
   tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
   tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
@@ -1332,7 +1332,7 @@ gen_inbound_check (gimple swtch, struct switch_conv_info *info)
    conversion failed.  */
 
 static const char *
-process_switch (gimple swtch)
+process_switch (gimple_switch swtch)
 {
   struct switch_conv_info info;
 
@@ -1437,7 +1437,7 @@ do_switchconv (void)
 	    putc ('\n', dump_file);
 	  }
 
-	failure_reason = process_switch (stmt);
+	failure_reason = process_switch (stmt->as_a_gimple_switch ());
 	if (! failure_reason)
 	  {
 	    if (dump_file)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 14f1526..3a31d78 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -168,7 +168,7 @@ static bool values_propagated;
 static int *vr_phi_edge_counts;
 
 typedef struct {
-  gimple stmt;
+  gimple_switch stmt;
   tree vec;
 } switch_update;
 
@@ -5662,7 +5662,7 @@ compare_case_labels (const void *p1, const void *p2)
    list of assertions for the corresponding operands.  */
 
 static bool
-find_switch_asserts (basic_block bb, gimple last)
+find_switch_asserts (basic_block bb, gimple_switch last)
 {
   bool need_assert;
   gimple_stmt_iterator bsi;
@@ -5833,7 +5833,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
   if (last
       && gimple_code (last) == GIMPLE_SWITCH
       && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
-    need_assert |= find_switch_asserts (bb, last);
+    need_assert |= find_switch_asserts (bb, last->as_a_gimple_switch ());
 
   /* Traverse all the statements in BB marking used names and looking
      for statements that may infer assertions for their used operands.  */
@@ -7315,7 +7315,7 @@ vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
    returned. */
 
 static bool
-find_case_label_index (gimple stmt, size_t start_idx, tree val, size_t *idx)
+find_case_label_index (gimple_switch stmt, size_t start_idx, tree val, size_t *idx)
 {
   size_t n = gimple_switch_num_labels (stmt);
   size_t low, high;
@@ -7365,7 +7365,7 @@ find_case_label_index (gimple stmt, size_t start_idx, tree val, size_t *idx)
    Returns true if the default label is not needed. */
 
 static bool
-find_case_label_range (gimple stmt, tree min, tree max, size_t *min_idx,
+find_case_label_range (gimple_switch stmt, tree min, tree max, size_t *min_idx,
 		       size_t *max_idx)
 {
   size_t i, j;
@@ -7421,7 +7421,7 @@ find_case_label_range (gimple stmt, tree min, tree max, size_t *min_idx,
    Returns true if the default label is not needed.  */
 
 static bool
-find_case_label_ranges (gimple stmt, value_range_t *vr, size_t *min_idx1,
+find_case_label_ranges (gimple_switch stmt, value_range_t *vr, size_t *min_idx1,
 			size_t *max_idx1, size_t *min_idx2,
 			size_t *max_idx2)
 {
@@ -7499,7 +7499,7 @@ find_case_label_ranges (gimple stmt, value_range_t *vr, size_t *min_idx1,
    SSA_PROP_VARYING.  */
 
 static enum ssa_prop_result
-vrp_visit_switch_stmt (gimple stmt, edge *taken_edge_p)
+vrp_visit_switch_stmt (gimple_switch stmt, edge *taken_edge_p)
 {
   tree op, val;
   value_range_t *vr;
@@ -7615,7 +7615,7 @@ vrp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
   else if (gimple_code (stmt) == GIMPLE_COND)
     return vrp_visit_cond_stmt (stmt, taken_edge_p);
   else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return vrp_visit_switch_stmt (stmt, taken_edge_p);
+    return vrp_visit_switch_stmt (stmt->as_a_gimple_switch (), taken_edge_p);
 
   /* All other statements produce nothing of interest for VRP, so mark
      their outputs varying and prevent further simulation.  */
@@ -9066,7 +9066,7 @@ simplify_cond_using_ranges (gimple stmt)
    argument.  */
 
 static bool
-simplify_switch_using_ranges (gimple stmt)
+simplify_switch_using_ranges (gimple_switch stmt)
 {
   tree op = gimple_switch_index (stmt);
   value_range_t *vr;
@@ -9461,7 +9461,7 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
   else if (gimple_code (stmt) == GIMPLE_COND)
     return simplify_cond_using_ranges (stmt);
   else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return simplify_switch_using_ranges (stmt);
+    return simplify_switch_using_ranges (stmt->as_a_gimple_switch ());
   else if (is_gimple_call (stmt)
 	   && gimple_call_internal_p (stmt))
     return simplify_internal_call_using_ranges (gsi, stmt);
-- 
1.8.5.3

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

* [PATCH 06/89] Introduce gimple_label and use it in a few places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (14 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-09 14:18   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 28/89] Introduce gimple_eh_else David Malcolm
                   ` (75 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_label): New typedef.
	(const_gimple_label): New typedef.

	* gimple.h (struct gimple_statement_label): New subclass of
	gimple_statement_with_ops, adding the invariant that
	stmt->code == GIMPLE_LABEL.
	(gimple_statement_base::as_a_gimple_label): New.
	(gimple_statement_base::dyn_cast_gimple_label): New.
	(is_a_helper <gimple_statement_label>::test): New.

	* gdbhooks.py (build_pretty_printer): Add gimple_label and its
	variants, reusing the gimple printer.

	* gimple-pretty-print.c (dump_gimple_label): Require a gimple_label
	rather than just a gimple.
	* tree-cfg.c (verify_gimple_label): Likewise.

	* gimple.c (gimple_build_label): Return a gimple_label rather than
	just a gimple.
	* gimple.h (gimple_build_label): Likewise.

	* gimplify.c (gimplify_case_label_expr): Update local to be a
	gimple_label.
	* tree-switch-conversion.c (gen_inbound_check): Likewise.

	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
	gimple_label in regions where a stmt is known to have code
	GIMPLE_LABEL.
	* tree-cfg.c (verify_gimple_stmt): Likewise.
---
 gcc/coretypes.h              |  4 ++++
 gcc/gdbhooks.py              |  2 ++
 gcc/gimple-pretty-print.c    |  4 ++--
 gcc/gimple.c                 |  5 +++--
 gcc/gimple.h                 | 36 +++++++++++++++++++++++++++++++++++-
 gcc/gimplify.c               |  6 +++---
 gcc/tree-cfg.c               |  4 ++--
 gcc/tree-switch-conversion.c |  2 +-
 8 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 375a6b3..cea782e 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -73,6 +73,10 @@ struct gimple_statement_cond;
 typedef struct gimple_statement_cond *gimple_cond;
 typedef const struct gimple_statement_cond *const_gimple_cond;
 
+struct gimple_statement_label;
+typedef struct gimple_statement_label *gimple_label;
+typedef const struct gimple_statement_label *const_gimple_label;
+
 struct gimple_statement_switch;
 typedef struct gimple_statement_switch *gimple_switch;
 typedef const struct gimple_statement_switch *const_gimple_switch;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 0ff243c..761141b 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -459,6 +459,8 @@ def build_pretty_printer():
                               # Keep this in the same order as gimple.def:
                               'gimple_cond', 'const_gimple_cond',
                               'gimple_statement_cond *',
+                              'gimple_label', 'const_gimple_label',
+                              'gimple_statement_label *',
                               'gimple_switch', 'const_gimple_switch',
                               'gimple_statement_switch *',
                               'gimple_assign', 'const_gimple_assign',
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 2334d03..7f3a056 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -853,7 +853,7 @@ dump_gimple_cond (pretty_printer *buffer, gimple_cond gs, int spc, int flags)
    TDF_* in dumpfils.h).  */
 
 static void
-dump_gimple_label (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags)
 {
   tree label = gimple_label_label (gs);
   if (flags & TDF_RAW)
@@ -2111,7 +2111,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_LABEL:
-      dump_gimple_label (buffer, gs, spc, flags);
+      dump_gimple_label (buffer, gs->as_a_gimple_label (), spc, flags);
       break;
 
     case GIMPLE_GOTO:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 18130db..7a4a070 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -481,10 +481,11 @@ gimple_cond_set_condition_from_tree (gimple_cond stmt, tree cond)
 
 /* Build a GIMPLE_LABEL statement for LABEL.  */
 
-gimple
+gimple_label
 gimple_build_label (tree label)
 {
-  gimple p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1);
+  gimple_label p = gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK,
+					  1)->as_a_gimple_label ();
   gimple_label_set_label (p, label);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index cfacebe..8ec8247 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -220,6 +220,12 @@ public:
     return as_a <gimple_statement_cond> (this);
   }
 
+  inline gimple_label
+  as_a_gimple_label ()
+  {
+    return as_a <gimple_statement_label> (this);
+  }
+
   inline gimple_switch
   as_a_gimple_switch ()
   {
@@ -252,6 +258,12 @@ public:
     return dyn_cast <gimple_statement_cond> (this);
   }
 
+  inline gimple_label
+  dyn_cast_gimple_label ()
+  {
+    return dyn_cast <gimple_statement_label> (this);
+  }
+
   inline gimple_switch
   dyn_cast_gimple_switch ()
   {
@@ -846,6 +858,20 @@ struct GTY((tag("GSS_WITH_OPS")))
 };
 
 /* A statement with the invariant that
+      stmt->code == GIMPLE_LABEL
+   i.e. a label statement.
+
+   This type will normally be accessed via the gimple_label and
+   const_gimple_label typedefs (in coretypes.h), which are pointers to
+   this type.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_label : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
+/* A statement with the invariant that
       stmt->code == GIMPLE_SWITCH
    i.e. a switch statement.  */
 
@@ -916,6 +942,14 @@ is_a_helper <gimple_statement_cond>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_label>::test (gimple gs)
+{
+  return gs->code == GIMPLE_LABEL;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_resx>::test (gimple gs)
 {
   return gs->code == GIMPLE_RESX;
@@ -1304,7 +1338,7 @@ gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
 gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
 gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
 void gimple_cond_set_condition_from_tree (gimple_cond, tree);
-gimple gimple_build_label (tree label);
+gimple_label gimple_build_label (tree label);
 gimple gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
 gimple_bind gimple_build_bind (tree, gimple_seq, tree);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 533766e..46dc786 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1493,7 +1493,7 @@ static enum gimplify_status
 gimplify_case_label_expr (tree *expr_p, gimple_seq *pre_p)
 {
   struct gimplify_ctx *ctxp;
-  gimple gimple_label;
+  gimple_label label_stmt;
 
   /* Invalid OpenMP programs can play Duff's Device type games with
      #pragma omp parallel.  At least in the C front end, we don't
@@ -1502,9 +1502,9 @@ gimplify_case_label_expr (tree *expr_p, gimple_seq *pre_p)
     if (ctxp->case_labels.exists ())
       break;
 
-  gimple_label = gimple_build_label (CASE_LABEL (*expr_p));
+  label_stmt = gimple_build_label (CASE_LABEL (*expr_p));
   ctxp->case_labels.safe_push (*expr_p);
-  gimplify_seq_add_stmt (pre_p, gimple_label);
+  gimplify_seq_add_stmt (pre_p, label_stmt);
 
   return GS_ALL_DONE;
 }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 6a67cdc..f42d10b 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4354,7 +4354,7 @@ verify_gimple_debug (gimple stmt ATTRIBUTE_UNUSED)
    Returns true if anything is wrong.  */
 
 static bool
-verify_gimple_label (gimple stmt)
+verify_gimple_label (gimple_label stmt)
 {
   tree decl = gimple_label_label (stmt);
   int uid;
@@ -4404,7 +4404,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_assign (stmt->as_a_gimple_assign ());
 
     case GIMPLE_LABEL:
-      return verify_gimple_label (stmt);
+      return verify_gimple_label (stmt->as_a_gimple_label ());
 
     case GIMPLE_CALL:
       return verify_gimple_call (stmt);
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 7e3461c..e88f710 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1217,7 +1217,7 @@ gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
   tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
   tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
   tree label_decl3 = create_artificial_label (UNKNOWN_LOCATION);
-  gimple label1, label2, label3;
+  gimple_label label1, label2, label3;
   tree utype, tidx;
   tree bound;
 
-- 
1.8.5.3

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

* [PATCH 01/89] Const-correctness fixes for some gimple accessors
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (18 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 29/89] Introduce gimple_resx David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-04-21 18:46   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 22/89] Introduce gimple_goto David Malcolm
                   ` (71 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_assign_single_p): Accept a const_gimple rather
	than a gimple.
	(gimple_store_p): Likewise.
	(gimple_assign_load_p): Likewise.
	(gimple_assign_cast_p): Likewise.
	(gimple_clobber_p): Likewise.
---
 gcc/gimple.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 11959a8..26e8627 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2330,7 +2330,7 @@ gimple_assign_rhs_class (const_gimple gs)
    and do not have the semantics of a copy, such as COND_EXPR.  */
 
 static inline bool
-gimple_assign_single_p (gimple gs)
+gimple_assign_single_p (const_gimple gs)
 {
   return (is_gimple_assign (gs)
           && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
@@ -2339,7 +2339,7 @@ gimple_assign_single_p (gimple gs)
 /* Return true if GS performs a store to its lhs.  */
 
 static inline bool
-gimple_store_p (gimple gs)
+gimple_store_p (const_gimple gs)
 {
   tree lhs = gimple_get_lhs (gs);
   return lhs && !is_gimple_reg (lhs);
@@ -2348,7 +2348,7 @@ gimple_store_p (gimple gs)
 /* Return true if GS is an assignment that loads from its rhs1.  */
 
 static inline bool
-gimple_assign_load_p (gimple gs)
+gimple_assign_load_p (const_gimple gs)
 {
   tree rhs;
   if (!gimple_assign_single_p (gs))
@@ -2365,7 +2365,7 @@ gimple_assign_load_p (gimple gs)
 /* Return true if S is a type-cast assignment.  */
 
 static inline bool
-gimple_assign_cast_p (gimple s)
+gimple_assign_cast_p (const_gimple s)
 {
   if (is_gimple_assign (s))
     {
@@ -2381,7 +2381,7 @@ gimple_assign_cast_p (gimple s)
 /* Return true if S is a clobber statement.  */
 
 static inline bool
-gimple_clobber_p (gimple s)
+gimple_clobber_p (const_gimple s)
 {
   return gimple_assign_single_p (s)
          && TREE_CLOBBER_P (gimple_assign_rhs1 (s));
-- 
1.8.5.3

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

* [PATCH 17/89] Update various expressions within tree-scalar-evolution.c to be gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (12 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 37/89] Introduce gimple_omp_critical David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-04-21 16:56 ` [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places David Malcolm
                   ` (77 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-scalar-evolution.c (follow_ssa_edge): Require a gimple_phi,
	rather than a gimple.
	(follow_ssa_edge_binary): Likewise.
	(follow_ssa_edge_expr): Likewise.
	(follow_ssa_edge_in_rhs): Likewise.
	(backedge_phi_arg_p): Likewise.
	(follow_ssa_edge_in_condition_phi_branch): Likewise.
	(follow_ssa_edge_in_condition_phi): Likewise.
	(follow_ssa_edge_inner_loop_phi): Likewise.
	(analyze_evolution_in_loop): Likewise.
	(analyze_initial_condition): Likewise.
	(interpret_loop_phi): Likewise.
	(interpret_condition_phi): Likewise.
	(follow_ssa_edge): Likewise; also, add checked casts to gimple_phi.

	(analyze_scalar_evolution_1): Add checked casts to gimple_phi
	within "case GIMPLE_PHI".
---
 gcc/tree-scalar-evolution.c | 46 +++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index fd51156..14dbd45 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -905,7 +905,8 @@ typedef enum t_bool {
 } t_bool;
 
 
-static t_bool follow_ssa_edge (struct loop *loop, gimple, gimple, tree *, int);
+static t_bool follow_ssa_edge (struct loop *loop, gimple, gimple_phi,
+			       tree *, int);
 
 /* Follow the ssa edge into the binary expression RHS0 CODE RHS1.
    Return true if the strongly connected component has been found.  */
@@ -913,7 +914,8 @@ static t_bool follow_ssa_edge (struct loop *loop, gimple, gimple, tree *, int);
 static t_bool
 follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
 			tree type, tree rhs0, enum tree_code code, tree rhs1,
-			gimple halting_phi, tree *evolution_of_loop, int limit)
+			gimple_phi halting_phi, tree *evolution_of_loop,
+			int limit)
 {
   t_bool res = t_false;
   tree evol;
@@ -1048,7 +1050,8 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
 
 static t_bool
 follow_ssa_edge_expr (struct loop *loop, gimple at_stmt, tree expr,
-		      gimple halting_phi, tree *evolution_of_loop, int limit)
+		      gimple_phi halting_phi, tree *evolution_of_loop,
+		      int limit)
 {
   enum tree_code code = TREE_CODE (expr);
   tree type = TREE_TYPE (expr), rhs0, rhs1;
@@ -1138,7 +1141,8 @@ follow_ssa_edge_expr (struct loop *loop, gimple at_stmt, tree expr,
 
 static t_bool
 follow_ssa_edge_in_rhs (struct loop *loop, gimple stmt,
-			gimple halting_phi, tree *evolution_of_loop, int limit)
+			gimple_phi halting_phi, tree *evolution_of_loop,
+			int limit)
 {
   enum tree_code code = gimple_assign_rhs_code (stmt);
   tree type = gimple_expr_type (stmt), rhs1, rhs2;
@@ -1178,7 +1182,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, gimple stmt,
 /* Checks whether the I-th argument of a PHI comes from a backedge.  */
 
 static bool
-backedge_phi_arg_p (gimple phi, int i)
+backedge_phi_arg_p (gimple_phi phi, int i)
 {
   const_edge e = gimple_phi_arg_edge (phi, i);
 
@@ -1198,8 +1202,8 @@ backedge_phi_arg_p (gimple phi, int i)
 static inline t_bool
 follow_ssa_edge_in_condition_phi_branch (int i,
 					 struct loop *loop,
-					 gimple condition_phi,
-					 gimple halting_phi,
+					 gimple_phi condition_phi,
+					 gimple_phi halting_phi,
 					 tree *evolution_of_branch,
 					 tree init_cond, int limit)
 {
@@ -1233,8 +1237,8 @@ follow_ssa_edge_in_condition_phi_branch (int i,
 
 static t_bool
 follow_ssa_edge_in_condition_phi (struct loop *loop,
-				  gimple condition_phi,
-				  gimple halting_phi,
+				  gimple_phi condition_phi,
+				  gimple_phi halting_phi,
 				  tree *evolution_of_loop, int limit)
 {
   int i, n;
@@ -1280,8 +1284,8 @@ follow_ssa_edge_in_condition_phi (struct loop *loop,
 
 static t_bool
 follow_ssa_edge_inner_loop_phi (struct loop *outer_loop,
-				gimple loop_phi_node,
-				gimple halting_phi,
+				gimple_phi loop_phi_node,
+				gimple_phi halting_phi,
 				tree *evolution_of_loop, int limit)
 {
   struct loop *loop = loop_containing_stmt (loop_phi_node);
@@ -1326,7 +1330,7 @@ follow_ssa_edge_inner_loop_phi (struct loop *outer_loop,
    path that is analyzed on the return walk.  */
 
 static t_bool
-follow_ssa_edge (struct loop *loop, gimple def, gimple halting_phi,
+follow_ssa_edge (struct loop *loop, gimple def, gimple_phi halting_phi,
 		 tree *evolution_of_loop, int limit)
 {
   struct loop *def_loop;
@@ -1349,7 +1353,8 @@ follow_ssa_edge (struct loop *loop, gimple def, gimple halting_phi,
 	   information and set the approximation to the main
 	   variable.  */
 	return follow_ssa_edge_in_condition_phi
-	  (loop, def, halting_phi, evolution_of_loop, limit);
+	  (loop, def->as_a_gimple_phi (), halting_phi, evolution_of_loop,
+	   limit);
 
       /* When the analyzed phi is the halting_phi, the
 	 depth-first search is over: we have found a path from
@@ -1366,7 +1371,8 @@ follow_ssa_edge (struct loop *loop, gimple def, gimple halting_phi,
       /* Inner loop.  */
       if (flow_loop_nested_p (loop, def_loop))
 	return follow_ssa_edge_inner_loop_phi
-	  (loop, def, halting_phi, evolution_of_loop, limit + 1);
+	  (loop, def->as_a_gimple_phi (), halting_phi, evolution_of_loop,
+	   limit + 1);
 
       /* Outer loop.  */
       return t_false;
@@ -1447,7 +1453,7 @@ simplify_peeled_chrec (struct loop *loop, tree arg, tree init_cond)
    function from LOOP_PHI_NODE to LOOP_PHI_NODE in the loop.  */
 
 static tree
-analyze_evolution_in_loop (gimple loop_phi_node,
+analyze_evolution_in_loop (gimple_phi loop_phi_node,
 			   tree init_cond)
 {
   int i, n = gimple_phi_num_args (loop_phi_node);
@@ -1542,7 +1548,7 @@ analyze_evolution_in_loop (gimple loop_phi_node,
    loop, and leaves this task to the on-demand tree reconstructor.  */
 
 static tree
-analyze_initial_condition (gimple loop_phi_node)
+analyze_initial_condition (gimple_phi loop_phi_node)
 {
   int i, n;
   tree init_cond = chrec_not_analyzed_yet;
@@ -1613,7 +1619,7 @@ analyze_initial_condition (gimple loop_phi_node)
 /* Analyze the scalar evolution for LOOP_PHI_NODE.  */
 
 static tree
-interpret_loop_phi (struct loop *loop, gimple loop_phi_node)
+interpret_loop_phi (struct loop *loop, gimple_phi loop_phi_node)
 {
   tree res;
   struct loop *phi_loop = loop_containing_stmt (loop_phi_node);
@@ -1662,7 +1668,7 @@ interpret_loop_phi (struct loop *loop, gimple loop_phi_node)
    analyzed.  */
 
 static tree
-interpret_condition_phi (struct loop *loop, gimple condition_phi)
+interpret_condition_phi (struct loop *loop, gimple_phi condition_phi)
 {
   int i, n = gimple_phi_num_args (condition_phi);
   tree res = chrec_not_analyzed_yet;
@@ -1990,9 +1996,9 @@ analyze_scalar_evolution_1 (struct loop *loop, tree var, tree res)
 
     case GIMPLE_PHI:
       if (loop_phi_node_p (def))
-	res = interpret_loop_phi (loop, def);
+	res = interpret_loop_phi (loop, def->as_a_gimple_phi ());
       else
-	res = interpret_condition_phi (loop, def);
+	res = interpret_condition_phi (loop, def->as_a_gimple_phi ());
       break;
 
     default:
-- 
1.8.5.3

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

* [PATCH 49/89] Make add_phi_arg require a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
  2014-04-21 16:56 ` [PATCH 04/89] Introduce gimple_cond and use it in various places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 20:32   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 34/89] Introduce gimple_omp_atomic_load David Malcolm
                   ` (89 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-phinodes.h (add_phi_arg): Require a gimple_phi rather than
	a plain gimple.
	* tree-phinodes.c (add_phi_arg): Likewise.

	* gimple-ssa-strength-reduction.c (create_phi_basis): Strengthen
	local "phi" from plain gimple to gimple_phi.

	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
	Likewise for "close_phi".

	* ipa-split.c (split_function): Convert "psi" to
	gimple_phi_iterator.

	* omp-low.c (expand_omp_for_static_nochunk): Introduce
	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
	gimple_phi.
	(expand_omp_for_static_chunk): Likewise.

	* tree-cfg.c (gimple_duplicate_bb): Make topmost "gsi" decl more
	tightly-scoped, and eliminate decls "phis", "phi", "stmt", "copy"
	in favor of more tightly-scoped gimple_phi_iterator gpi and
	gimple_phi decls "phi" and "copy", and gimple decls "stmt" and
	"copy".

	* tree-parloops.c (create_parallel_loop): Introduce
	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
	gimple_phi.

	* tree-ssa-loop-im.c (execute_sm_if_changed): Likewise.

	* tree-ssa-loop-manip.c (create_iv): Split out new gimple_phi
	local "phi" from "stmt", and convert the latter into being a
	gimple_assign.

	* tree-ssa-pre.c (insert_into_preds_of_block): Strengthen local
	"phi" to be a gimple_phi.

	* tree-ssa-tail-merge.c (vop_phi): Require a gimple_phi rather
	than a plain gimple.
	(replace_block_by): Strengthen local "bb2_phi" to be a gimple_phi.

	* tree-tailcall.c (add_successor_phi_arg): Use gsi.phi when
	invoking add_phi_arg.
	(eliminate_tail_call): Introduce gimple_phi_iterator gpi, using it
	to strengthen "phi" to be a gimple_phi.
	(create_tailcall_accumulator): Strengthen local "phi" to be a
	gimple_phi.
	(tree_optimize_tail_calls_1): Likewise.

	* tree-vect-data-refs.c (vect_setup_realignment): Strengthen
	local "phi_stmt" to be a gimple_phi.

	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
	Strengthen "gsi", "gsi_orig", "gsi_new" to be
	gimple_phi_iterators, and "phi" "orig_phi", "new_phi" to be
	gimple_phi instances.
	(slpeel_tree_peel_loop_to_edge): Strengthen local "new_phi" to be
	a gimple_phi.

	* tree-vect-loop.c (get_initial_def_for_induction): Likewise for
	"induction_phi".
	(vect_create_epilog_for_reduction): Add checked casts to
	gimple_phi; strengthen local "outer_phi" to gimple_phi and
	"new_vec_stmt" to gimple_assign.
	(vect_finalize_reduction): Strengthen local "vect_phi" to
	gimple_phi.
	(vectorizable_reduction): Likewise for "new_phi".

	* tree-vect-stmts.c (vectorizable_simd_clone_call): Likewise.
	(vectorizable_load): Likewise for "phi".
---
 gcc/gimple-ssa-strength-reduction.c |  2 +-
 gcc/graphite-scop-detection.c       |  2 +-
 gcc/ipa-split.c                     |  6 +++---
 gcc/omp-low.c                       | 12 ++++++------
 gcc/tree-cfg.c                      | 16 ++++++++++------
 gcc/tree-parloops.c                 |  5 +++--
 gcc/tree-phinodes.c                 |  2 +-
 gcc/tree-phinodes.h                 |  2 +-
 gcc/tree-ssa-loop-im.c              |  5 +++--
 gcc/tree-ssa-loop-manip.c           |  9 +++++----
 gcc/tree-ssa-pre.c                  |  2 +-
 gcc/tree-ssa-tail-merge.c           |  6 +++---
 gcc/tree-tailcall.c                 | 15 ++++++++-------
 gcc/tree-vect-data-refs.c           |  2 +-
 gcc/tree-vect-loop-manip.c          | 12 ++++++------
 gcc/tree-vect-loop.c                | 18 ++++++++++--------
 gcc/tree-vect-stmts.c               |  6 +++---
 17 files changed, 66 insertions(+), 56 deletions(-)

diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 35e15e0..f5bfc19 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2243,7 +2243,7 @@ create_phi_basis (slsr_cand_t c, gimple from_phi, tree basis_name,
 {
   int i;
   tree name, phi_arg;
-  gimple phi;
+  gimple_phi phi;
   vec<tree> phi_args;
   slsr_cand_t basis = lookup_cand (c->basis);
   int nargs = gimple_phi_num_args (from_phi);
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 1d7c748..e50cc5b 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1331,7 +1331,7 @@ canonicalize_loop_closed_ssa (loop_p loop)
 	      {
 		tree res, arg = gimple_phi_arg_def (phi, i);
 		use_operand_p use_p;
-		gimple close_phi;
+		gimple_phi close_phi;
 
 		if (TREE_CODE (arg) != SSA_NAME)
 		  continue;
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index e5d1368..e294dc3 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1391,7 +1391,7 @@ split_function (struct split_point *split_point)
 
 	  if (real_retval && split_point->split_part_set_retval)
 	    {
-	      gimple_stmt_iterator psi;
+	      gimple_phi_iterator psi;
 
 	      /* See if we need new SSA_NAME for the result.
 		 When DECL_BY_REFERENCE is true, retval is actually pointer to
@@ -1404,13 +1404,13 @@ split_function (struct split_point *split_point)
 		  /* See if there is PHI defining return value.  */
 		  for (psi = gsi_start_phis (return_bb);
 		       !gsi_end_p (psi); gsi_next (&psi))
-		    if (!virtual_operand_p (gimple_phi_result (gsi_stmt (psi))))
+		    if (!virtual_operand_p (gimple_phi_result (psi.phi ())))
 		      break;
 
 		  /* When there is PHI, just update its value.  */
 		  if (TREE_CODE (retval) == SSA_NAME
 		      && !gsi_end_p (psi))
-		    add_phi_arg (gsi_stmt (psi), retval, e, UNKNOWN_LOCATION);
+		    add_phi_arg (psi.phi (), retval, e, UNKNOWN_LOCATION);
 		  /* Otherwise update the return BB itself.
 		     find_return_bb allows at most one assignment to return value,
 		     so update first statement.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 25a1642..396ddb0 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -5852,10 +5852,10 @@ expand_omp_for_static_nochunk (struct omp_region *region,
       if (gimple_in_ssa_p (cfun))
 	{
 	  int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx;
-	  for (gsi = gsi_start_phis (fin_bb);
-	       !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gpi = gsi_start_phis (fin_bb);
+	       !gsi_end_p (gpi); gsi_next (&gpi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gpi.phi ();
 	      add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx),
 			   ep, UNKNOWN_LOCATION);
 	    }
@@ -6228,10 +6228,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
       if (gimple_in_ssa_p (cfun))
 	{
 	  int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx;
-	  for (si = gsi_start_phis (fin_bb);
-	       !gsi_end_p (si); gsi_next (&si))
+	  for (gimple_phi_iterator gpi = gsi_start_phis (fin_bb);
+	       !gsi_end_p (gpi); gsi_next (&gpi))
 	    {
-	      gimple phi = gsi_stmt (si);
+	      gimple_phi phi = gpi.phi ();
 	      add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx),
 			   se, UNKNOWN_LOCATION);
 	    }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 468c568..347b6b3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5686,17 +5686,18 @@ static basic_block
 gimple_duplicate_bb (basic_block bb)
 {
   basic_block new_bb;
-  gimple_stmt_iterator gsi, gsi_tgt;
-  gimple_seq phis = phi_nodes (bb);
-  gimple phi, stmt, copy;
+  gimple_stmt_iterator gsi_tgt;
 
   new_bb = create_empty_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb);
 
   /* Copy the PHI nodes.  We ignore PHI node arguments here because
      the incoming edges have not been setup yet.  */
-  for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+       !gsi_end_p (gpi);
+       gsi_next (&gpi))
     {
-      phi = gsi_stmt (gsi);
+      gimple_phi phi, copy;
+      phi = gpi.phi ();
       copy = create_phi_node (NULL_TREE, new_bb);
       create_new_def_for (gimple_phi_result (phi), copy,
 			  gimple_phi_result_ptr (copy));
@@ -5704,11 +5705,14 @@ gimple_duplicate_bb (basic_block bb)
     }
 
   gsi_tgt = gsi_start_bb (new_bb);
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+       !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       def_operand_p def_p;
       ssa_op_iter op_iter;
       tree lhs;
+      gimple stmt, copy;
 
       stmt = gsi_stmt (gsi);
       if (gimple_code (stmt) == GIMPLE_LABEL)
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 7eedf8c..c85baf1 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1687,11 +1687,12 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   guard = make_edge (for_bb, ex_bb, 0);
   single_succ_edge (loop->latch)->flags = 0;
   end = make_edge (loop->latch, ex_bb, EDGE_FALLTHRU);
-  for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gpi = gsi_start_phis (ex_bb);
+       !gsi_end_p (gpi); gsi_next (&gpi))
     {
       source_location locus;
       tree def;
-      phi = gsi_stmt (gsi);
+      gimple_phi phi = gpi.phi ();
       stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
 
       def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 222b4ed..5594cd4 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -363,7 +363,7 @@ create_phi_node (tree var, basic_block bb)
    PHI points to the reallocated phi node when we return.  */
 
 void
-add_phi_arg (gimple phi, tree def, edge e, source_location locus)
+add_phi_arg (gimple_phi phi, tree def, edge e, source_location locus)
 {
   basic_block bb = e->dest;
 
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index fe8b32d..dcde99e 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -25,7 +25,7 @@ extern void release_phi_node (gimple);
 extern void reserve_phi_args_for_new_edge (basic_block);
 extern void add_phi_node_to_bb (gimple_phi phi, basic_block bb);
 extern gimple_phi create_phi_node (tree, basic_block);
-extern void add_phi_arg (gimple, tree, edge, source_location);
+extern void add_phi_arg (gimple_phi, tree, edge, source_location);
 extern void remove_phi_args (edge);
 extern void remove_phi_node (gimple_stmt_iterator *, bool);
 extern void remove_phi_nodes (basic_block);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 00e6e16..f1a1b3d 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1869,9 +1869,10 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   }
 
   if (!loop_has_only_one_exit)
-    for (gsi = gsi_start_phis (old_dest); !gsi_end_p (gsi); gsi_next (&gsi))
+    for (gimple_phi_iterator gpi = gsi_start_phis (old_dest);
+	 !gsi_end_p (gpi); gsi_next (&gpi))
       {
-	gimple phi = gsi_stmt (gsi);
+	gimple_phi phi = gpi.phi ();
 	unsigned i;
 
 	for (i = 0; i < gimple_phi_num_args (phi); i++)
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 235b6fc..d74250f 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -71,7 +71,8 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
 	   gimple_stmt_iterator *incr_pos, bool after,
 	   tree *var_before, tree *var_after)
 {
-  gimple stmt;
+  gimple_assign stmt;
+  gimple_phi phi;
   tree initial, step1;
   gimple_seq stmts;
   tree vb, va;
@@ -143,9 +144,9 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
   if (stmts)
     gsi_insert_seq_on_edge_immediate (pe, stmts);
 
-  stmt = create_phi_node (vb, loop->header);
-  add_phi_arg (stmt, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
-  add_phi_arg (stmt, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
+  phi = create_phi_node (vb, loop->header);
+  add_phi_arg (phi, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
+  add_phi_arg (phi, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
 }
 
 /* Return the innermost superloop LOOP of USE_LOOP that is a superloop of
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index c7d19cd..41fe055 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3093,7 +3093,7 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
   edge_iterator ei;
   tree type = get_expr_type (expr);
   tree temp;
-  gimple phi;
+  gimple_phi phi;
 
   /* Make sure we aren't creating an induction variable.  */
   if (bb_loop_depth (block) > 0 && EDGE_COUNT (block->preds) == 2)
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 93096cc..7727cdf 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1465,10 +1465,10 @@ find_clusters (void)
 
 /* Returns the vop phi of BB, if any.  */
 
-static gimple
+static gimple_phi
 vop_phi (basic_block bb)
 {
-  gimple stmt;
+  gimple_phi stmt;
   gimple_phi_iterator gsi;
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -1489,7 +1489,7 @@ replace_block_by (basic_block bb1, basic_block bb2)
   edge e1, e2;
   edge_iterator ei;
   unsigned int i;
-  gimple bb2_phi;
+  gimple_phi bb2_phi;
 
   bb2_phi = vop_phi (bb2);
 
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 25644ad..a508511 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -618,7 +618,7 @@ add_successor_phi_arg (edge e, tree var, tree phi_arg)
       break;
 
   gcc_assert (!gsi_end_p (gsi));
-  add_phi_arg (gsi_stmt (gsi), phi_arg, e, UNKNOWN_LOCATION);
+  add_phi_arg (gsi.phi (), phi_arg, e, UNKNOWN_LOCATION);
 }
 
 /* Creates a GIMPLE statement which computes the operation specified by
@@ -811,7 +811,8 @@ eliminate_tail_call (struct tailcall *t)
   size_t idx;
   basic_block bb, first;
   edge e;
-  gimple phi;
+  gimple_phi phi;
+  gimple_phi_iterator gpi;
   gimple_stmt_iterator gsi;
   gimple orig_stmt;
 
@@ -864,7 +865,7 @@ eliminate_tail_call (struct tailcall *t)
   /* Add phi node entries for arguments.  The ordering of the phi nodes should
      be the same as the ordering of the arguments.  */
   for (param = DECL_ARGUMENTS (current_function_decl),
-	 idx = 0, gsi = gsi_start_phis (first);
+	 idx = 0, gpi = gsi_start_phis (first);
        param;
        param = DECL_CHAIN (param), idx++)
     {
@@ -872,11 +873,11 @@ eliminate_tail_call (struct tailcall *t)
 	continue;
 
       arg = gimple_call_arg (stmt, idx);
-      phi = gsi_stmt (gsi);
+      phi = gpi.phi ();
       gcc_assert (param == SSA_NAME_VAR (PHI_RESULT (phi)));
 
       add_phi_arg (phi, arg, e, gimple_location (stmt));
-      gsi_next (&gsi);
+      gsi_next (&gpi);
     }
 
   /* Update the values of accumulators.  */
@@ -938,7 +939,7 @@ create_tailcall_accumulator (const char *label, basic_block bb, tree init)
     ret_type = sizetype;
 
   tree tmp = make_temp_ssa_name (ret_type, NULL, label);
-  gimple phi;
+  gimple_phi phi;
 
   phi = create_phi_node (tmp, bb);
   /* RET_TYPE can be a float when -ffast-maths is enabled.  */
@@ -1002,7 +1003,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls)
 	      {
 		tree name = ssa_default_def (cfun, param);
 		tree new_name = make_ssa_name (param, SSA_NAME_DEF_STMT (name));
-		gimple phi;
+		gimple_phi phi;
 
 		set_ssa_default_def (cfun, param, new_name);
 		phi = create_phi_node (name, first);
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index fb4f800..4df8ab5 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4603,7 +4603,7 @@ vect_setup_realignment (gimple stmt, gimple_stmt_iterator *gsi,
   basic_block new_bb;
   tree msq_init = NULL_TREE;
   tree new_temp;
-  gimple phi_stmt;
+  gimple_phi phi_stmt;
   tree msq = NULL_TREE;
   gimple_seq stmts = NULL;
   bool inv_p;
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 566066a..686bc57 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -820,13 +820,13 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
     {
       if (scalar_loop != loop)
 	{
-	  gimple_stmt_iterator gsi;
+	  gimple_phi_iterator gsi;
 	  new_exit = redirect_edge_and_branch (new_exit, exit_dest);
 
 	  for (gsi = gsi_start_phis (exit_dest); !gsi_end_p (gsi);
 	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      tree orig_arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
 	      location_t orig_locus
 		= gimple_phi_arg_location_from_edge (phi, e);
@@ -886,7 +886,7 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
     {
       /* Update new_loop->header PHIs, so that on the preheader
 	 edge they are the ones from loop rather than scalar_loop.  */
-      gimple_stmt_iterator gsi_orig, gsi_new;
+      gimple_phi_iterator gsi_orig, gsi_new;
       edge orig_e = loop_preheader_edge (loop);
       edge new_e = loop_preheader_edge (new_loop);
 
@@ -895,8 +895,8 @@ slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
 	   !gsi_end_p (gsi_orig) && !gsi_end_p (gsi_new);
 	   gsi_next (&gsi_orig), gsi_next (&gsi_new))
 	{
-	  gimple orig_phi = gsi_stmt (gsi_orig);
-	  gimple new_phi = gsi_stmt (gsi_new);
+	  gimple_phi orig_phi = gsi_orig.phi ();
+	  gimple_phi new_phi = gsi_new.phi ();
 	  tree orig_arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, orig_e);
 	  location_t orig_locus
 	    = gimple_phi_arg_location_from_edge (orig_phi, orig_e);
@@ -1213,7 +1213,7 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
 	if (gsi_end_p (gsi))
 	  {
 	    tree new_vop = copy_ssa_name (PHI_RESULT (phi), NULL);
-	    gimple new_phi = create_phi_node (new_vop, exit_e->dest);
+	    gimple_phi new_phi = create_phi_node (new_vop, exit_e->dest);
 	    tree vop = PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0));
 	    imm_use_iterator imm_iter;
 	    gimple stmt;
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 3781d43..27627e4 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3241,7 +3241,8 @@ get_initial_def_for_induction (gimple iv_phi)
   tree new_vec, vec_init, vec_step, t;
   tree new_var;
   tree new_name;
-  gimple init_stmt, induction_phi, new_stmt;
+  gimple init_stmt, new_stmt;
+  gimple_phi induction_phi;
   tree induc_def, vec_def, vec_dest;
   tree init_expr, step_expr;
   int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -3942,14 +3943,15 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
       for (j = 0; j < ncopies; j++)
         {
           /* Set the loop-entry arg of the reduction-phi.  */
-          add_phi_arg (phi, vec_init_def, loop_preheader_edge (loop),
-                       UNKNOWN_LOCATION);
+          add_phi_arg (phi->as_a_gimple_phi (), vec_init_def,
+		       loop_preheader_edge (loop), UNKNOWN_LOCATION);
 
           /* Set the loop-latch arg for the reduction-phi.  */
           if (j > 0)
             def = vect_get_vec_def_for_stmt_copy (vect_unknown_def_type, def);
 
-          add_phi_arg (phi, def, loop_latch_edge (loop), UNKNOWN_LOCATION);
+          add_phi_arg (phi->as_a_gimple_phi (), def, loop_latch_edge (loop),
+		       UNKNOWN_LOCATION);
 
           if (dump_enabled_p ())
             {
@@ -4029,7 +4031,7 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
       FOR_EACH_VEC_ELT (new_phis, i, phi)
 	{
 	  tree new_result = copy_ssa_name (PHI_RESULT (phi), NULL);
-	  gimple outer_phi = create_phi_node (new_result, exit_bb);
+	  gimple_phi outer_phi = create_phi_node (new_result, exit_bb);
 	  SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,
 			   PHI_RESULT (phi));
 	  set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,
@@ -4116,7 +4118,7 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
     {
       tree first_vect = PHI_RESULT (new_phis[0]);
       tree tmp;
-      gimple new_vec_stmt = NULL;
+      gimple_assign new_vec_stmt = NULL;
 
       vec_dest = vect_create_destination_var (scalar_dest, vectype);
       for (k = 1; k < new_phis.length (); k++)
@@ -4492,7 +4494,7 @@ vect_finalize_reduction:
           if (outer_loop)
             {
               stmt_vec_info exit_phi_vinfo = vinfo_for_stmt (exit_phi);
-              gimple vect_phi;
+              gimple_phi vect_phi;
 
               /* FORNOW. Currently not supporting the case that an inner-loop
                  reduction is not used in the outer-loop (but only outside the
@@ -4707,7 +4709,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
   tree def;
   gimple def_stmt;
   enum vect_def_type dt;
-  gimple new_phi = NULL;
+  gimple_phi new_phi = NULL;
   tree scalar_type;
   bool is_simple_use;
   gimple orig_stmt;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 70428d9..38597f3 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2983,7 +2983,7 @@ vectorizable_simd_clone_call (gimple stmt, gimple_stmt_iterator *gsi,
 		      gcc_assert (!new_bb);
 		    }
 		  tree phi_res = copy_ssa_name (op, NULL);
-		  gimple new_phi = create_phi_node (phi_res, loop->header);
+		  gimple_phi new_phi = create_phi_node (phi_res, loop->header);
 		  set_vinfo_for_stmt (new_phi,
 				      new_stmt_vec_info (new_phi, loop_vinfo,
 							 NULL));
@@ -5603,7 +5603,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   tree msq = NULL_TREE, lsq;
   tree offset = NULL_TREE;
   tree realignment_token = NULL_TREE;
-  gimple phi = NULL;
+  gimple_phi phi = NULL;
   vec<tree> dr_chain = vNULL;
   bool grouped_load = false;
   bool load_lanes_p = false;
@@ -6262,7 +6262,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
 				    &at_loop);
       if (alignment_support_scheme == dr_explicit_realign_optimized)
 	{
-	  phi = SSA_NAME_DEF_STMT (msq);
+	  phi = SSA_NAME_DEF_STMT (msq)->as_a_gimple_phi ();
 	  offset = size_int (TYPE_VECTOR_SUBPARTS (vectype) - 1);
 	}
     }
-- 
1.8.5.3

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

* [PATCH 28/89] Introduce gimple_eh_else
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (15 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 06/89] Introduce gimple_label and use it in a few places David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-04-21 16:56 ` [PATCH 39/89] Introduce gimple_omp_parallel David Malcolm
                   ` (74 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_eh_else): New typedef.
	(const_gimple_eh_else): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_eh_else): New.
	(gimple_build_eh_else): Return a gimple_eh_else rather than a
	plain gimple.
	(gimple_eh_else_n_body_ptr): Require a gimple_eh_else rather than
	a plain gimple.
	(gimple_eh_else_n_body): Likewise.
	(gimple_eh_else_e_body_ptr): Likewise.
	(gimple_eh_else_e_body): Likewise.
	(gimple_eh_else_set_n_body): Likewise.
	(gimple_eh_else_set_e_body): Likewise.

	* gimple-low.c (lower_stmt): Add checked cast to gimple_eh_else
	within GIMPLE_EH_ELSE case of switch statement, introducing a new
	local.
	(gimple_stmt_may_fallthru): Likewise.

	* gimple-pretty-print.c (dump_gimple_eh_else): Require a
	gimple_eh_else rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_eh_else within
	GIMPLE_EH_ELSE case of switch statement

	* gimple-walk.c (walk_gimple_stmt): Add checked cast to
	gimple_eh_else within GIMPLE_EH_ELSE case of switch statement,
	introducing a new local.

	* gimple.c (gimple_build_eh_else): Return a gimple_eh_else
	rather than a plain gimple.
	(gimple_copy): Add checked casts to gimple_eh_else within
	GIMPLE_EH_ELSE case of switch statement, introducing new locals.

	* tree-cfg.c (verify_gimple_in_seq_2): Add checked cast to
	gimple_eh_else within GIMPLE_EH_ELSE case of switch statement,
	introducing a new local.

	* tree-eh.c (collect_finally_tree): Likewise.
	(replace_goto_queue_1): Likewise.
	(get_eh_else): Return a gimple_eh_else rather than a plain gimple.
	(honor_protect_cleanup_actions): Convert local "eh_else" from
	gimple to gimple_eh_else.
	(lower_try_finally_nofallthru): Likewise.
	(lower_try_finally_onedest): Introduce locals "eh_else" and
	"label_stmt", using them in favor of "x" for the gimple_eh_else
	and the gimple_label.
	(lower_try_finally_copy): Convert local "eh_else" from gimple to
	gimple_eh_else.
	(lower_try_finally_switch): Likewise.
	(decide_copy_try_finally): Likewise.
	(refactor_eh_r): Add checked cast to gimple_eh_else within
	GIMPLE_EH_ELSE case of switch statement, introducing a new local.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-low.c          | 15 +++++++++----
 gcc/gimple-pretty-print.c |  5 +++--
 gcc/gimple-walk.c         | 19 +++++++++-------
 gcc/gimple.c              | 16 ++++++++------
 gcc/gimple.h              | 32 +++++++++++++--------------
 gcc/tree-cfg.c            |  7 ++++--
 gcc/tree-eh.c             | 55 +++++++++++++++++++++++++++++++----------------
 8 files changed, 95 insertions(+), 58 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 512967c..45b157c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -125,6 +125,10 @@ struct gimple_statement_eh_mnt;
 typedef struct gimple_statement_eh_mnt *gimple_eh_must_not_throw;
 typedef const struct gimple_statement_eh_mnt *const_gimple_eh_must_not_throw;
 
+struct gimple_statement_eh_else;
+typedef struct gimple_statement_eh_else *gimple_eh_else;
+typedef const struct gimple_statement_eh_else *const_gimple_eh_else;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 3fa1c44..4056b3c 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -290,8 +290,11 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
       return;
 
     case GIMPLE_EH_ELSE:
-      lower_sequence (gimple_eh_else_n_body_ptr (stmt), data);
-      lower_sequence (gimple_eh_else_e_body_ptr (stmt), data);
+      {
+	gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	lower_sequence (gimple_eh_else_n_body_ptr (eh_else_stmt), data);
+	lower_sequence (gimple_eh_else_e_body_ptr (eh_else_stmt), data);
+      }
       break;
 
     case GIMPLE_NOP:
@@ -599,8 +602,12 @@ gimple_stmt_may_fallthru (gimple stmt)
 	      && gimple_seq_may_fallthru (gimple_try_cleanup (stmt)));
 
     case GIMPLE_EH_ELSE:
-      return (gimple_seq_may_fallthru (gimple_eh_else_n_body (stmt))
-	      || gimple_seq_may_fallthru (gimple_eh_else_e_body (stmt)));
+      {
+	gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	return (gimple_seq_may_fallthru (gimple_eh_else_n_body (eh_else_stmt))
+		|| gimple_seq_may_fallthru (gimple_eh_else_e_body (
+					      eh_else_stmt)));
+      }
 
     case GIMPLE_CALL:
       /* Functions that do not return do not fall through.  */
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 027bb94..63443c2 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1028,7 +1028,8 @@ dump_gimple_eh_must_not_throw (pretty_printer *buffer,
    dumpfile.h).  */
 
 static void
-dump_gimple_eh_else (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_eh_else (pretty_printer *buffer, gimple_eh_else gs, int spc,
+		     int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags,
@@ -2215,7 +2216,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_EH_ELSE:
-      dump_gimple_eh_else (buffer, gs, spc, flags);
+      dump_gimple_eh_else (buffer, gs->as_a_gimple_eh_else (), spc, flags);
       break;
 
     case GIMPLE_RESX:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index f9b641d..c247210 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -566,14 +566,17 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_EH_ELSE:
-      ret = walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (stmt),
-			     callback_stmt, callback_op, wi);
-      if (ret)
-	return wi->callback_result;
-      ret = walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (stmt),
-			     callback_stmt, callback_op, wi);
-      if (ret)
-	return wi->callback_result;
+      {
+	gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	ret = walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (eh_else_stmt),
+				   callback_stmt, callback_op, wi);
+	if (ret)
+	  return wi->callback_result;
+	ret = walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (eh_else_stmt),
+				   callback_stmt, callback_op, wi);
+	if (ret)
+	  return wi->callback_result;
+      }
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b487e46..9acfcc1 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -656,10 +656,10 @@ gimple_build_eh_must_not_throw (tree decl)
 
 /* Build a GIMPLE_EH_ELSE statement.  */
 
-gimple
+gimple_eh_else
 gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body)
 {
-  gimple p = gimple_alloc (GIMPLE_EH_ELSE, 0);
+  gimple_eh_else p = gimple_alloc (GIMPLE_EH_ELSE, 0)->as_a_gimple_eh_else ();
   gimple_eh_else_set_n_body (p, n_body);
   gimple_eh_else_set_e_body (p, e_body);
   return p;
@@ -1663,10 +1663,14 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_EH_ELSE:
-	  new_seq = gimple_seq_copy (gimple_eh_else_n_body (stmt));
-	  gimple_eh_else_set_n_body (copy, new_seq);
-	  new_seq = gimple_seq_copy (gimple_eh_else_e_body (stmt));
-	  gimple_eh_else_set_e_body (copy, new_seq);
+	  {
+	    gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	    gimple_eh_else eh_else_copy = copy->as_a_gimple_eh_else ();
+	    new_seq = gimple_seq_copy (gimple_eh_else_n_body (eh_else_stmt));
+	    gimple_eh_else_set_n_body (eh_else_copy, new_seq);
+	    new_seq = gimple_seq_copy (gimple_eh_else_e_body (eh_else_stmt));
+	    gimple_eh_else_set_e_body (eh_else_copy, new_seq);
+	  }
 	  break;
 
 	case GIMPLE_TRY:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 47377e9..a65cdcb 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -306,6 +306,12 @@ public:
     return as_a <gimple_statement_eh_mnt> (this);
   }
 
+  inline gimple_eh_else
+  as_a_gimple_eh_else ()
+  {
+    return as_a <gimple_statement_eh_else> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1526,7 +1532,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 gimple_catch gimple_build_catch (tree, gimple_seq);
 gimple_eh_filter gimple_build_eh_filter (tree, gimple_seq);
 gimple_eh_must_not_throw gimple_build_eh_must_not_throw (tree);
-gimple gimple_build_eh_else (gimple_seq, gimple_seq);
+gimple_eh_else gimple_build_eh_else (gimple_seq, gimple_seq);
 gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
 gimple gimple_build_wce (gimple_seq);
@@ -3834,46 +3840,38 @@ gimple_eh_must_not_throw_set_fndecl (gimple_eh_must_not_throw eh_mnt_stmt,
 /* GIMPLE_EH_ELSE accessors.  */
 
 static inline gimple_seq *
-gimple_eh_else_n_body_ptr (gimple gs)
+gimple_eh_else_n_body_ptr (gimple_eh_else eh_else_stmt)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else> (gs);
   return &eh_else_stmt->n_body;
 }
 
 static inline gimple_seq
-gimple_eh_else_n_body (gimple gs)
+gimple_eh_else_n_body (gimple_eh_else eh_else_stmt)
 {
-  return *gimple_eh_else_n_body_ptr (gs);
+  return *gimple_eh_else_n_body_ptr (eh_else_stmt);
 }
 
 static inline gimple_seq *
-gimple_eh_else_e_body_ptr (gimple gs)
+gimple_eh_else_e_body_ptr (gimple_eh_else eh_else_stmt)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else> (gs);
   return &eh_else_stmt->e_body;
 }
 
 static inline gimple_seq
-gimple_eh_else_e_body (gimple gs)
+gimple_eh_else_e_body (gimple_eh_else eh_else_stmt)
 {
-  return *gimple_eh_else_e_body_ptr (gs);
+  return *gimple_eh_else_e_body_ptr (eh_else_stmt);
 }
 
 static inline void
-gimple_eh_else_set_n_body (gimple gs, gimple_seq seq)
+gimple_eh_else_set_n_body (gimple_eh_else eh_else_stmt, gimple_seq seq)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else> (gs);
   eh_else_stmt->n_body = seq;
 }
 
 static inline void
-gimple_eh_else_set_e_body (gimple gs, gimple_seq seq)
+gimple_eh_else_set_e_body (gimple_eh_else eh_else_stmt, gimple_seq seq)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else> (gs);
   eh_else_stmt->e_body = seq;
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index c504798..fcd85e3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4564,8 +4564,11 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
 	  break;
 
 	case GIMPLE_EH_ELSE:
-	  err |= verify_gimple_in_seq_2 (gimple_eh_else_n_body (stmt));
-	  err |= verify_gimple_in_seq_2 (gimple_eh_else_e_body (stmt));
+	  {
+	    gimple_eh_else eh_else = stmt->as_a_gimple_eh_else ();
+	    err |= verify_gimple_in_seq_2 (gimple_eh_else_n_body (eh_else));
+	    err |= verify_gimple_in_seq_2 (gimple_eh_else_e_body (eh_else));
+	  }
 	  break;
 
 	case GIMPLE_CATCH:
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 5a8f9e1..180b195 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -295,8 +295,11 @@ collect_finally_tree (gimple stmt, gimple region)
       break;
 
     case GIMPLE_EH_ELSE:
-      collect_finally_tree_1 (gimple_eh_else_n_body (stmt), region);
-      collect_finally_tree_1 (gimple_eh_else_e_body (stmt), region);
+      {
+	gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	collect_finally_tree_1 (gimple_eh_else_n_body (eh_else_stmt), region);
+	collect_finally_tree_1 (gimple_eh_else_e_body (eh_else_stmt), region);
+      }
       break;
 
     default:
@@ -553,8 +556,13 @@ replace_goto_queue_1 (gimple stmt, struct leh_tf_state *tf,
       replace_goto_queue_stmt_list (gimple_eh_filter_failure_ptr (stmt), tf);
       break;
     case GIMPLE_EH_ELSE:
-      replace_goto_queue_stmt_list (gimple_eh_else_n_body_ptr (stmt), tf);
-      replace_goto_queue_stmt_list (gimple_eh_else_e_body_ptr (stmt), tf);
+      {
+	gimple_eh_else eh_else_stmt = stmt->as_a_gimple_eh_else ();
+	replace_goto_queue_stmt_list (gimple_eh_else_n_body_ptr (eh_else_stmt),
+				      tf);
+	replace_goto_queue_stmt_list (gimple_eh_else_e_body_ptr (eh_else_stmt),
+				      tf);
+      }
       break;
 
     default:
@@ -964,14 +972,14 @@ lower_try_finally_fallthru_label (struct leh_tf_state *tf)
 /* A subroutine of lower_try_finally.  If FINALLY consits of a
    GIMPLE_EH_ELSE node, return it.  */
 
-static inline gimple
+static inline gimple_eh_else
 get_eh_else (gimple_seq finally)
 {
   gimple x = gimple_seq_first_stmt (finally);
   if (gimple_code (x) == GIMPLE_EH_ELSE)
     {
       gcc_assert (gimple_seq_singleton_p (finally));
-      return x;
+      return x->as_a_gimple_eh_else ();
     }
   return NULL;
 }
@@ -1005,7 +1013,8 @@ honor_protect_cleanup_actions (struct leh_state *outer_state,
   gimple_stmt_iterator gsi;
   bool finally_may_fallthru;
   gimple_seq finally;
-  gimple x, eh_else;
+  gimple x;
+  gimple_eh_else eh_else;
 
   /* First check for nothing to do.  */
   if (lang_hooks.eh_protect_cleanup_actions == NULL)
@@ -1073,7 +1082,8 @@ lower_try_finally_nofallthru (struct leh_state *state,
 			      struct leh_tf_state *tf)
 {
   tree lab;
-  gimple x, eh_else;
+  gimple x;
+  gimple_eh_else eh_else;
   gimple_seq finally;
   struct goto_queue_node *q, *qe;
 
@@ -1137,6 +1147,8 @@ static void
 lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
 {
   struct goto_queue_node *q, *qe;
+  gimple_eh_else eh_else;
+  gimple_label label_stmt;
   gimple x;
   gimple_seq finally;
   gimple_stmt_iterator gsi;
@@ -1149,13 +1161,13 @@ lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
   /* Since there's only one destination, and the destination edge can only
      either be EH or non-EH, that implies that all of our incoming edges
      are of the same type.  Therefore we can lower EH_ELSE immediately.  */
-  x = get_eh_else (finally);
-  if (x)
+  eh_else = get_eh_else (finally);
+  if (eh_else)
     {
       if (tf->may_throw)
-	finally = gimple_eh_else_e_body (x);
+	finally = gimple_eh_else_e_body (eh_else);
       else
-	finally = gimple_eh_else_n_body (x);
+	finally = gimple_eh_else_n_body (eh_else);
     }
 
   lower_eh_constructs_1 (state, &finally);
@@ -1190,8 +1202,8 @@ lower_try_finally_onedest (struct leh_state *state, struct leh_tf_state *tf)
     }
 
   finally_label = create_artificial_label (loc);
-  x = gimple_build_label (finally_label);
-  gimple_seq_add_stmt (&tf->top_p_seq, x);
+  label_stmt = gimple_build_label (finally_label);
+  gimple_seq_add_stmt (&tf->top_p_seq, label_stmt);
 
   gimple_seq_add_seq (&tf->top_p_seq, finally);
 
@@ -1239,7 +1251,8 @@ lower_try_finally_copy (struct leh_state *state, struct leh_tf_state *tf)
   gimple_seq finally;
   gimple_seq new_stmt;
   gimple_seq seq;
-  gimple x, eh_else;
+  gimple x;
+  gimple_eh_else eh_else;
   tree tmp;
   location_t tf_loc = gimple_location (tf->try_finally_expr);
 
@@ -1372,7 +1385,8 @@ lower_try_finally_switch (struct leh_state *state, struct leh_tf_state *tf)
   tree last_case;
   vec<tree> case_label_vec;
   gimple_seq switch_body = NULL;
-  gimple x, eh_else;
+  gimple x;
+  gimple_eh_else eh_else;
   tree tmp;
   gimple switch_stmt;
   gimple_seq finally;
@@ -1587,7 +1601,7 @@ static bool
 decide_copy_try_finally (int ndests, bool may_throw, gimple_seq finally)
 {
   int f_estimate, sw_estimate;
-  gimple eh_else;
+  gimple_eh_else eh_else;
 
   /* If there's an EH_ELSE involved, the exception path is separate
      and really doesn't come into play for this computation.  */
@@ -3102,8 +3116,11 @@ refactor_eh_r (gimple_seq seq)
 	    refactor_eh_r (gimple_eh_filter_failure (one));
 	    break;
 	  case GIMPLE_EH_ELSE:
-	    refactor_eh_r (gimple_eh_else_n_body (one));
-	    refactor_eh_r (gimple_eh_else_e_body (one));
+	    {
+	      gimple_eh_else eh_else_stmt = one->as_a_gimple_eh_else ();
+	      refactor_eh_r (gimple_eh_else_n_body (eh_else_stmt));
+	      refactor_eh_r (gimple_eh_else_e_body (eh_else_stmt));
+	    }
 	    break;
 	  default:
 	    break;
-- 
1.8.5.3

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

* [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (8 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 20/89] Introduce gimple_call David Malcolm
@ 2014-04-21 16:56 ` David Malcolm
  2014-05-12 17:22   ` Jeff Law
  2014-04-21 16:56 ` [PATCH 02/89] Introduce gimple_switch and use it in various places David Malcolm
                   ` (81 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_arg_set_location): Require a gimple_phi
	rather than a plain gimple.
---
 gcc/gimple.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index e4d0455..6007516 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4275,12 +4275,12 @@ gimple_phi_arg_location_from_edge (gimple gs, edge e)
   return gimple_phi_arg (gs, e->dest_idx)->locus;
 }
 
-/* Set the source location of gimple argument I of phi node GS to LOC.  */
+/* Set the source location of gimple argument I of phi node PHI to LOC.  */
 
 static inline void
-gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
+gimple_phi_arg_set_location (gimple_phi phi, size_t i, source_location loc)
 {
-  gimple_phi_arg (gs, i)->locus = loc;
+  gimple_phi_arg (phi, i)->locus = loc;
 }
 
 /* Return TRUE if argument I of phi node PHI has a location record.  */
-- 
1.8.5.3

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

* [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (43 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:40   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 60/89] Concretize gimple_catch_types David Malcolm
                   ` (46 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_switch_index): Require a const_gimple_switch rather
	than a plain const_gimple.
	(gimple_switch_index_ptr): Likewise.

	* gimplify-me.c (gimple_regimplify_operands): Add checked cast to
	gimple_switch within "case GIMPLE_SWITCH".
	* tree-cfgcleanup.c (cleanup_control_expr_graph): Likewise.
	* tree-ssa-ccp.c (ccp_fold): Likewise.
	* tree-ssa-dom.c (optimize_stmt): Likewise.

	* tree-ssa-ccp.c (evaluate_stmt): Add checked cast to
	gimple_switch within region guarded by check for GIMPLE_SWITCH.
	* tree-ssa-dom.c (record_edge_info): Likewise.
	(eliminate_redundant_computations): Likewise.
	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise.
	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.

	* tree-ssa-dom.c (initialize_hash_element): Replace check for
	code GIMPLE_SWITCH with a dyn_cast_gimple_switch.
	(propagate_rhs_into_lhs): Likewise.
	* tree-ssa-propagate.c (may_propagate_copy_into_stmt): Likewise.
	(propagate_tree_value_into_stmt): Likewise.
---
 gcc/gimple.h                |  6 ++----
 gcc/gimplify-me.c           |  4 ++--
 gcc/tree-cfgcleanup.c       |  2 +-
 gcc/tree-ssa-ccp.c          |  4 ++--
 gcc/tree-ssa-dom.c          | 22 +++++++++++-----------
 gcc/tree-ssa-loop-ivcanon.c |  8 ++++++--
 gcc/tree-ssa-propagate.c    |  8 ++++----
 gcc/tree-ssa-threadedge.c   |  2 +-
 8 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index ed99d02..bdb2162 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4340,9 +4340,8 @@ gimple_switch_set_num_labels (gimple_switch g, unsigned nlabels)
 /* Return the index variable used by the switch statement GS.  */
 
 static inline tree
-gimple_switch_index (const_gimple gs)
+gimple_switch_index (const_gimple_switch gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   return gimple_op (gs, 0);
 }
 
@@ -4350,9 +4349,8 @@ gimple_switch_index (const_gimple gs)
 /* Return a pointer to the index variable for the switch statement GS.  */
 
 static inline tree *
-gimple_switch_index_ptr (const_gimple gs)
+gimple_switch_index_ptr (const_gimple_switch gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   return gimple_op_ptr (gs, 0);
 }
 
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 68e7e9d..5008fff 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -174,8 +174,8 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
 		     is_gimple_val, fb_rvalue);
       break;
     case GIMPLE_SWITCH:
-      gimplify_expr (gimple_switch_index_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
+      gimplify_expr (gimple_switch_index_ptr (stmt->as_a_gimple_switch ()),
+		     &pre, NULL, is_gimple_val, fb_rvalue);
       break;
     case GIMPLE_OMP_ATOMIC_LOAD:
       gimplify_expr (gimple_omp_atomic_load_rhs_ptr (
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 914cc71..1e4ceb0 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -113,7 +113,7 @@ cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi)
 	  break;
 
 	case GIMPLE_SWITCH:
-	  val = gimple_switch_index (stmt);
+	  val = gimple_switch_index (stmt->as_a_gimple_switch ());
 	  break;
 
 	default:
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index cc8c78b..c79d981 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1128,7 +1128,7 @@ ccp_fold (gimple stmt)
     case GIMPLE_SWITCH:
       {
 	/* Return the constant switch index.  */
-        return valueize_op (gimple_switch_index (stmt));
+        return valueize_op (gimple_switch_index (stmt->as_a_gimple_switch ()));
       }
 
     case GIMPLE_ASSIGN:
@@ -1650,7 +1650,7 @@ evaluate_stmt (gimple stmt)
             simplified = gimple_assign_rhs1 (stmt);
         }
       else if (code == GIMPLE_SWITCH)
-        simplified = gimple_switch_index (stmt);
+        simplified = gimple_switch_index (stmt->as_a_gimple_switch ());
       else
 	/* These cannot satisfy is_gimple_min_invariant without folding.  */
 	gcc_assert (code == GIMPLE_CALL || code == GIMPLE_COND);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 4ecab6a..8fc8e1a 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -342,11 +342,11 @@ initialize_hash_element (gimple stmt, tree lhs,
       for (i = 0; i < nargs; i++)
         expr->ops.call.args[i] = gimple_call_arg (stmt, i);
     }
-  else if (code == GIMPLE_SWITCH)
+  else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
     {
-      expr->type = TREE_TYPE (gimple_switch_index (stmt));
+      expr->type = TREE_TYPE (gimple_switch_index (swtch_stmt));
       expr->kind = EXPR_SINGLE;
-      expr->ops.single.rhs = gimple_switch_index (stmt);
+      expr->ops.single.rhs = gimple_switch_index (swtch_stmt);
     }
   else if (code == GIMPLE_GOTO)
     {
@@ -1794,7 +1794,7 @@ record_edge_info (basic_block bb)
       if (gimple_code (stmt) == GIMPLE_SWITCH)
 	{
 	  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
-	  tree index = gimple_switch_index (stmt);
+	  tree index = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (index) == SSA_NAME)
 	    {
@@ -2079,8 +2079,8 @@ eliminate_redundant_computations (gimple_stmt_iterator* gsi)
       expr_type = TREE_TYPE (gimple_call_lhs (stmt));
       assigns_var_p = true;
     }
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    expr_type = TREE_TYPE (gimple_switch_index (stmt));
+  else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+    expr_type = TREE_TYPE (gimple_switch_index (swtch_stmt));
   else if (gimple_code (stmt) == GIMPLE_PHI)
     /* We can't propagate into a phi, so the logic below doesn't apply.
        Instead record an equivalence between the cached LHS and the
@@ -2373,9 +2373,9 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
         rhs = gimple_assign_rhs1 (stmt);
       else if (gimple_code (stmt) == GIMPLE_GOTO)
         rhs = gimple_goto_dest (stmt);
-      else if (gimple_code (stmt) == GIMPLE_SWITCH)
+      else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
         /* This should never be an ADDR_EXPR.  */
-        rhs = gimple_switch_index (stmt);
+        rhs = gimple_switch_index (swtch_stmt);
 
       if (rhs && TREE_CODE (rhs) == ADDR_EXPR)
         recompute_tree_invariant_for_addr_expr (rhs);
@@ -2497,8 +2497,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
         val = fold_binary_loc (gimple_location (stmt),
 			   gimple_cond_code (stmt), boolean_type_node,
                            gimple_cond_lhs (stmt),  gimple_cond_rhs (stmt));
-      else if (gimple_code (stmt) == GIMPLE_SWITCH)
-	val = gimple_switch_index (stmt);
+      else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+	val = gimple_switch_index (swtch_stmt);
 
       if (val && TREE_CODE (val) == INTEGER_CST && find_taken_edge (bb, val))
 	cfg_altered = true;
@@ -2856,7 +2856,7 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
                                    gimple_cond_lhs (use_stmt),
                                    gimple_cond_rhs (use_stmt));
               else if (gimple_code (use_stmt) == GIMPLE_SWITCH)
-		val = gimple_switch_index (use_stmt);
+		val = gimple_switch_index (use_stmt->as_a_gimple_switch ());
 	      else
 		val = gimple_goto_dest  (use_stmt);
 
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 52f8e85..cbef59b 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -305,7 +305,9 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
 		    && constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
 		    && constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop))
 		   || (gimple_code (stmt) == GIMPLE_SWITCH
-		       && constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
+		       && constant_after_peeling (gimple_switch_index (
+						    stmt->as_a_gimple_switch ()),
+						  stmt, loop)))
 	    {
 	      if (dump_file && (dump_flags & TDF_DETAILS))
 	        fprintf (dump_file, "   Constant conditional.\n");
@@ -357,7 +359,9 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
 	        && (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
 		    || constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop)))
 	       || (gimple_code (stmt) == GIMPLE_SWITCH
-		   && !constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
+		   && !constant_after_peeling (gimple_switch_index (
+						 stmt->as_a_gimple_switch ()),
+					       stmt, loop)))
 	      && (!exit || bb != exit->src))
 	    size->num_branches_on_hot_path++;
 	}
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index ad7f008..dd8fad4 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1297,8 +1297,8 @@ may_propagate_copy_into_stmt (gimple dest, tree orig)
 
   if (gimple_assign_single_p (dest))
     return may_propagate_copy (gimple_assign_rhs1 (dest), orig);
-  else if (gimple_code (dest) == GIMPLE_SWITCH)
-    return may_propagate_copy (gimple_switch_index (dest), orig);
+  else if (gimple_switch dest_swtch = dest->dyn_cast_gimple_switch ())
+    return may_propagate_copy (gimple_switch_index (dest_swtch), orig);
 
   /* In other cases, the expression is not materialized, so there
      is no destination to pass to may_propagate_copy.  On the other
@@ -1449,8 +1449,8 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
       res = update_call_from_tree (gsi, expr);
       gcc_assert (res);
     }
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    propagate_tree_value (gimple_switch_index_ptr (stmt), val);
+  else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+    propagate_tree_value (gimple_switch_index_ptr (swtch_stmt), val);
   else
     gcc_unreachable ();
 }
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 03c6b4a..4edd9e3 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -624,7 +624,7 @@ simplify_control_stmt_condition (edge e,
     }
 
   if (code == GIMPLE_SWITCH)
-    cond = gimple_switch_index (stmt);
+    cond = gimple_switch_index (stmt->as_a_gimple_switch ());
   else if (code == GIMPLE_GOTO)
     cond = gimple_goto_dest (stmt);
   else
-- 
1.8.5.3

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

* [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (32 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 25/89] Introduce gimple_catch David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:42   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 56/89] Various gimple to gimple_call conversions in IPA David Malcolm
                   ` (57 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* ssa-iterators.h (FOR_EACH_PHI_OR_STMT_USE): Add checked cast to
	gimple_phi.
	(FOR_EACH_PHI_OR_STMT_DEF): Likewise.

	* ssa-iterators.h (single_phi_def): Require a gimple_phi.
	(op_iter_init_phiuse): Likewise.
	(op_iter_init_phidef): Likewise.
	* tree-ssa-loop-im.c (extract_true_false_args_from_phi): Likewise.

	* tree-ssa-loop-im.c (link_use_stmts_after): Replace check against
	GIMPLE_PHI with add a dyn_cast to gimple_phi, using result as needed.
	(determine_max_movement): Likewise.
	* tree-ssa-reassoc.c (is_phi_for_stmt): Likewise.
	* tree-ssa-sccvn.c (start_over:): Likewise.

	* tree-ssa-loop-im.c
	(move_computations_dom_walker::before_dom_children): Split iterator
	into gimple_stmt_iterator and a gimple_phi_iterator so that a local
	can become a gimple_phi.
---
 gcc/ssa-iterators.h    | 18 +++++++++++-------
 gcc/tree-ssa-loop-im.c | 20 +++++++++-----------
 gcc/tree-ssa-reassoc.c |  6 ++++--
 gcc/tree-ssa-sccvn.c   |  4 ++--
 4 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index 126a46e..60c0461 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -194,7 +194,9 @@ struct ssa_op_iter
    a real stmt or a PHI node, looking at the USE nodes matching FLAGS.  */
 #define FOR_EACH_PHI_OR_STMT_USE(USEVAR, STMT, ITER, FLAGS)	\
   for ((USEVAR) = (gimple_code (STMT) == GIMPLE_PHI 		\
-		   ? op_iter_init_phiuse (&(ITER), STMT, FLAGS)	\
+		   ? op_iter_init_phiuse (&(ITER),              \
+					  (STMT)->as_a_gimple_phi (), \
+					  FLAGS)		\
 		   : op_iter_init_use (&(ITER), STMT, FLAGS));	\
        !op_iter_done (&(ITER));					\
        (USEVAR) = op_iter_next_use (&(ITER)))
@@ -203,7 +205,9 @@ struct ssa_op_iter
    a real stmt or a PHI node, looking at the DEF nodes matching FLAGS.  */
 #define FOR_EACH_PHI_OR_STMT_DEF(DEFVAR, STMT, ITER, FLAGS)	\
   for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI 		\
-		   ? op_iter_init_phidef (&(ITER), STMT, FLAGS)	\
+		   ? op_iter_init_phidef (&(ITER),		\
+					  (STMT)->as_a_gimple_phi (), \
+					  FLAGS)		\
 		   : op_iter_init_def (&(ITER), STMT, FLAGS));	\
        !op_iter_done (&(ITER));					\
        (DEFVAR) = op_iter_next_def (&(ITER)))
@@ -749,7 +753,7 @@ num_ssa_operands (gimple stmt, int flags)
 /* If there is a single DEF in the PHI node which matches FLAG, return it.
    Otherwise return NULL_DEF_OPERAND_P.  */
 static inline tree
-single_phi_def (gimple stmt, int flags)
+single_phi_def (gimple_phi stmt, int flags)
 {
   tree def = PHI_RESULT (stmt);
   if ((flags & SSA_OP_DEF) && is_gimple_reg (def))
@@ -762,7 +766,7 @@ single_phi_def (gimple stmt, int flags)
 /* Initialize the iterator PTR for uses matching FLAGS in PHI.  FLAGS should
    be either SSA_OP_USES or SSA_OP_VIRTUAL_USES.  */
 static inline use_operand_p
-op_iter_init_phiuse (ssa_op_iter *ptr, gimple phi, int flags)
+op_iter_init_phiuse (ssa_op_iter *ptr, gimple_phi phi, int flags)
 {
   tree phi_def = gimple_phi_result (phi);
   int comp;
@@ -792,7 +796,7 @@ op_iter_init_phiuse (ssa_op_iter *ptr, gimple phi, int flags)
 /* Start an iterator for a PHI definition.  */
 
 static inline def_operand_p
-op_iter_init_phidef (ssa_op_iter *ptr, gimple phi, int flags)
+op_iter_init_phidef (ssa_op_iter *ptr, gimple_phi phi, int flags)
 {
   tree phi_def = PHI_RESULT (phi);
   int comp;
@@ -881,9 +885,9 @@ link_use_stmts_after (use_operand_p head, imm_use_iterator *imm)
   /* Only look at virtual or real uses, depending on the type of HEAD.  */
   flag = (is_gimple_reg (use) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
 
-  if (gimple_code (head_stmt) == GIMPLE_PHI)
+  if (gimple_phi phi = head_stmt->dyn_cast_gimple_phi ())
     {
-      FOR_EACH_PHI_ARG (use_p, head_stmt, op_iter, flag)
+      FOR_EACH_PHI_ARG (use_p, phi, op_iter, flag)
 	if (USE_FROM_PTR (use_p) == use)
 	  last_p = move_use_after_head (use_p, head, last_p);
     }
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 3a0b518..c70f32d 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -622,7 +622,7 @@ mem_ref_in_stmt (gimple stmt)
    else return false.  */
 
 static bool
-extract_true_false_args_from_phi (basic_block dom, gimple phi,
+extract_true_false_args_from_phi (basic_block dom, gimple_phi phi,
 				  tree *true_arg_p, tree *false_arg_p)
 {
   basic_block bb = gimple_bb (phi);
@@ -705,7 +705,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
     level = superloop_at_depth (loop, 1);
   lim_data->max_loop = level;
 
-  if (gimple_code (stmt) == GIMPLE_PHI)
+  if (gimple_phi phi = stmt->dyn_cast_gimple_phi ())
     {
       use_operand_p use_p;
       unsigned min_cost = UINT_MAX;
@@ -716,7 +716,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
 	 evaluated.  For this reason the PHI cost (and thus the
 	 cost we remove from the loop by doing the invariant motion)
 	 is that of the cheapest PHI argument dependency chain.  */
-      FOR_EACH_PHI_ARG (use_p, stmt, iter, SSA_OP_USE)
+      FOR_EACH_PHI_ARG (use_p, phi, iter, SSA_OP_USE)
 	{
 	  val = USE_FROM_PTR (use_p);
 	  if (TREE_CODE (val) != SSA_NAME)
@@ -733,7 +733,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
 
       lim_data->cost += min_cost;
 
-      if (gimple_phi_num_args (stmt) > 1)
+      if (gimple_phi_num_args (phi) > 1)
 	{
 	  basic_block dom = get_immediate_dominator (CDI_DOMINATORS, bb);
 	  gimple cond;
@@ -745,7 +745,7 @@ determine_max_movement (gimple stmt, bool must_preserve_exec)
 	  /* Verify that this is an extended form of a diamond and
 	     the PHI arguments are completely controlled by the
 	     predicate in DOM.  */
-	  if (!extract_true_false_args_from_phi (dom, stmt, NULL, NULL))
+	  if (!extract_true_false_args_from_phi (dom, phi, NULL, NULL))
 	    return false;
 
 	  /* Fold in dependencies and cost of the condition.  */
@@ -1152,18 +1152,16 @@ void
 move_computations_dom_walker::before_dom_children (basic_block bb)
 {
   struct loop *level;
-  gimple_stmt_iterator bsi;
-  gimple stmt;
   unsigned cost = 0;
   struct lim_aux_data *lim_data;
 
   if (!loop_outer (bb->loop_father))
     return;
 
-  for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
+  for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
     {
       gimple_assign new_stmt;
-      stmt = gsi_stmt (bsi);
+      gimple_phi stmt = bsi.phi ();
 
       lim_data = get_lim_data (stmt);
       if (lim_data == NULL)
@@ -1217,11 +1215,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
       remove_phi_node (&bsi, false);
     }
 
-  for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
+  for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); )
     {
       edge e;
 
-      stmt = gsi_stmt (bsi);
+      gimple stmt = gsi_stmt (bsi);
 
       lim_data = get_lim_data (stmt);
       if (lim_data == NULL)
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 47b7e8c..1c8cb2f 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3037,6 +3037,7 @@ static bool
 is_phi_for_stmt (gimple stmt, tree operand)
 {
   gimple def_stmt;
+  gimple_phi def_phi;
   tree lhs;
   use_operand_p arg_p;
   ssa_op_iter i;
@@ -3047,10 +3048,11 @@ is_phi_for_stmt (gimple stmt, tree operand)
   lhs = gimple_assign_lhs (stmt);
 
   def_stmt = SSA_NAME_DEF_STMT (operand);
-  if (gimple_code (def_stmt) != GIMPLE_PHI)
+  def_phi = def_stmt->dyn_cast_gimple_phi ();
+  if (!def_phi)
     return false;
 
-  FOR_EACH_PHI_ARG (arg_p, def_stmt, i, SSA_OP_USE)
+  FOR_EACH_PHI_ARG (arg_p, def_phi, i, SSA_OP_USE)
     if (lhs == USE_FROM_PTR (arg_p))
       return true;
   return false;
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 27ff70d..5d94746 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -3859,8 +3859,8 @@ start_over:
   if (!gimple_nop_p (defstmt))
     {
       /* Push a new iterator.  */
-      if (gimple_code (defstmt) == GIMPLE_PHI)
-	usep = op_iter_init_phiuse (&iter, defstmt, SSA_OP_ALL_USES);
+      if (gimple_phi phi = defstmt->dyn_cast_gimple_phi ())
+	usep = op_iter_init_phiuse (&iter, phi, SSA_OP_ALL_USES);
       else
 	usep = op_iter_init_use (&iter, defstmt, SSA_OP_ALL_USES);
     }
-- 
1.8.5.3

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

* [PATCH 31/89] Use subclasses of gimple in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (35 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 19/89] Const-correctness of gimple_call_builtin_p David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-09 19:02   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup David Malcolm
                   ` (54 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* asan.c (insert_if_then_before_iter): Require a gimple cond
	rathern than a plain gimple.
	(instrument_mem_region_access): Strengthen local from gimple to
	gimple_cond.

	* cfgloopmanip.c (create_empty_if_region_on_edge): Likewise.

	* omp-low.c (simd_clone_adjust): Strengthen local from gimple
	to gimple_phi.

	* sese.c (set_ifsese_condition): Strengthen local from gimple to
	gimple_cond.

	* tree-call-cdce.c (gen_one_condition): Strengthen locals from
	gimple to gimple_assign and gimple_cond.

	* tree-ssa-phiopt.c (minmax_replacement): Likewise.
	(cond_store_replacement): Strengthen locals from gimple to
	gimple_phi and gimple_assign.
	(cond_if_else_store_replacement_1): Likewise.

	* tree-ssa-pre.c (do_regular_insertion): Strengthen local from
	gimple to gimple_assign.

	* tree-switch-conversion.c (hoist_edge_and_branch_if_true):
	Strengthen local from gimple to gimple_cond.
	(gen_def_assigns): Return a gimple_assign rather than a plain
	gimple.
	(gen_inbound_check): Strengthen locals from gimple to gimple_cond
	and gimple_assign.

	* tree-vect-loop-manip.c (slpeel_add_loop_guard): Strengthen local
	from gimple to gimple_cond.
	(set_prologue_iterations): Strengthen locals from gimple to
	gimple_phi and gimple_cond.

	* value-prof.c (gimple_ic): Strengthen local from gimple to
	gimple_phi.
	(gimple_stringop_fixed_value): Strengthen locals from gimple to
	gimple_assign, gimple_cond, gimple_call, and gimple_phi.
---
 gcc/asan.c                   | 10 +++++-----
 gcc/cfgloopmanip.c           |  2 +-
 gcc/omp-low.c                |  2 +-
 gcc/sese.c                   |  2 +-
 gcc/tree-call-cdce.c         |  4 +++-
 gcc/tree-ssa-phiopt.c        | 11 +++++++----
 gcc/tree-ssa-pre.c           |  7 +++++--
 gcc/tree-switch-conversion.c | 10 +++++-----
 gcc/tree-vect-loop-manip.c   |  6 +++---
 gcc/value-prof.c             | 10 ++++++----
 10 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/gcc/asan.c b/gcc/asan.c
index cab4d44..773d845 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1420,7 +1420,7 @@ create_cond_insert_point (gimple_stmt_iterator *iter,
    pointing to initially.  */
 
 static void
-insert_if_then_before_iter (gimple cond,
+insert_if_then_before_iter (gimple_cond cond,
 			    gimple_stmt_iterator *iter,
 			    bool then_more_likely_p,
 			    basic_block *then_bb,
@@ -1706,10 +1706,10 @@ instrument_mem_region_access (tree base, tree len,
 	   }
 	   // falltrough instructions, starting with *ITER.  */
 
-      gimple g = gimple_build_cond (NE_EXPR,
-				    len,
-				    build_int_cst (TREE_TYPE (len), 0),
-				    NULL_TREE, NULL_TREE);
+      gimple_cond g = gimple_build_cond (NE_EXPR,
+					 len,
+					 build_int_cst (TREE_TYPE (len), 0),
+					 NULL_TREE, NULL_TREE);
       gimple_set_location (g, location);
       insert_if_then_before_iter (g, iter, /*then_more_likely_p=*/true,
 				  &then_bb, &fallthrough_bb);
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 3fa2535..b0255a0 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -690,7 +690,7 @@ create_empty_if_region_on_edge (edge entry_edge, tree condition)
 
   basic_block cond_bb, true_bb, false_bb, join_bb;
   edge e_true, e_false, exit_edge;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   tree simple_cond;
   gimple_stmt_iterator gsi;
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 8407f0e..5054164 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11557,7 +11557,7 @@ simd_clone_adjust (struct cgraph_node *node)
      make_edge (incr_bb, latch_bb, EDGE_TRUE_VALUE);  */
   FALLTHRU_EDGE (incr_bb)->flags = EDGE_TRUE_VALUE;
 
-  gimple phi = create_phi_node (iter1, body_bb);
+  gimple_phi phi = create_phi_node (iter1, body_bb);
   edge preheader_edge = find_edge (entry_bb, body_bb);
   edge latch_edge = single_succ_edge (latch_bb);
   add_phi_arg (phi, build_zero_cst (unsigned_type_node), preheader_edge,
diff --git a/gcc/sese.c b/gcc/sese.c
index eb34c41..f146238 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -783,7 +783,7 @@ set_ifsese_condition (ifsese if_region, tree condition)
   basic_block bb = entry->dest;
   gimple last = last_stmt (bb);
   gimple_stmt_iterator gsi = gsi_last_bb (bb);
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
 
   gcc_assert (gimple_code (last) == GIMPLE_COND);
 
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index d7941e3..d1f18f8 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -332,7 +332,9 @@ gen_one_condition (tree arg, int lbub,
 {
   tree lbub_real_cst, lbub_cst, float_type;
   tree temp, tempn, tempc, tempcn;
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1;
+  gimple_assign stmt2;
+  gimple_cond stmt3;
 
   float_type = TREE_TYPE (arg);
   lbub_cst = build_int_cst (integer_type_node, lbub);
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index da1cd37..9828f18 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -953,7 +953,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
 		    tree arg0, tree arg1)
 {
   tree result, type;
-  gimple cond, new_stmt;
+  gimple_cond cond;
+  gimple_assign new_stmt;
   edge true_edge, false_edge;
   enum tree_code cmp, minmax, ass_code;
   tree smaller, larger, arg_true, arg_false;
@@ -965,7 +966,7 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
   if (HONOR_NANS (TYPE_MODE (type)))
     return false;
 
-  cond = last_stmt (cond_bb);
+  cond = last_stmt (cond_bb)->as_a_gimple_cond ();
   cmp = gimple_cond_code (cond);
 
   /* This transformation is only valid for order comparisons.  Record which
@@ -1677,7 +1678,8 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb,
 {
   gimple assign = last_and_only_stmt (middle_bb);
   tree lhs, rhs, name, name2;
-  gimple newphi, new_stmt;
+  gimple_phi newphi;
+  gimple_assign new_stmt;
   gimple_stmt_iterator gsi;
   source_location locus;
 
@@ -1750,7 +1752,8 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
   tree lhs_base, lhs, then_rhs, else_rhs, name;
   source_location then_locus, else_locus;
   gimple_stmt_iterator gsi;
-  gimple newphi, new_stmt;
+  gimple_phi newphi;
+  gimple_assign new_stmt;
 
   if (then_assign == NULL
       || !gimple_assign_single_p (then_assign)
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 044d59d..e7b3ca2 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3443,8 +3443,11 @@ do_regular_insertion (basic_block block, basic_block dom)
 
 	      tree temp = make_temp_ssa_name (get_expr_type (expr),
 					      NULL, "pretmp");
-	      gimple assign = gimple_build_assign (temp,
-						   edoubleprime->kind == CONSTANT ? PRE_EXPR_CONSTANT (edoubleprime) : PRE_EXPR_NAME (edoubleprime));
+	      gimple_assign assign =
+		gimple_build_assign (temp,
+				     edoubleprime->kind == CONSTANT ?
+				       PRE_EXPR_CONSTANT (edoubleprime) :
+				       PRE_EXPR_NAME (edoubleprime));
 	      gimple_stmt_iterator gsi = gsi_after_labels (block);
 	      gsi_insert_before (&gsi, assign, GSI_NEW_STMT);
 
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 86e7840..de3045a 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -85,7 +85,7 @@ hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip,
 			       bool update_dominators)
 {
   tree tmp;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   edge e_false;
   basic_block new_bb, split_bb = gsi_bb (*gsip);
   bool dominated_e_true = false;
@@ -1130,11 +1130,11 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info)
 /* Generates and appropriately inserts loads of default values at the position
    given by BSI.  Returns the last inserted statement.  */
 
-static gimple
+static gimple_assign
 gen_def_assigns (gimple_stmt_iterator *gsi, struct switch_conv_info *info)
 {
   int i;
-  gimple assign = NULL;
+  gimple_assign assign = NULL;
 
   for (i = 0; i < info->phi_count; i++)
     {
@@ -1221,9 +1221,9 @@ gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
   tree utype, tidx;
   tree bound;
 
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
 
-  gimple last_assign;
+  gimple_assign last_assign;
   gimple_stmt_iterator gsi;
   basic_block bb0, bb1, bb2, bbf, bbd;
   edge e01, e02, e21, e1d, e1f, e2f;
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index b0b6bbe..b14bf01 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -929,7 +929,7 @@ slpeel_add_loop_guard (basic_block guard_bb, tree cond,
 {
   gimple_stmt_iterator gsi;
   edge new_e, enter_e;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   gimple_seq gimplify_stmt_list = NULL;
 
   enter_e = EDGE_SUCC (guard_bb, 0);
@@ -1042,9 +1042,9 @@ set_prologue_iterations (basic_block bb_before_first_loop,
   basic_block cond_bb, then_bb;
   tree var, prologue_after_cost_adjust_name;
   gimple_stmt_iterator gsi;
-  gimple newphi;
+  gimple_phi newphi;
   edge e_true, e_false, e_fallthru;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   gimple_seq stmts = NULL;
   tree cost_pre_condition = NULL_TREE;
   tree scalar_loop_iters =
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index a635bf7..eabd84c 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1418,7 +1418,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
       && (dflags & ECF_NORETURN) == 0)
     {
       tree result = gimple_call_lhs (icall_stmt);
-      gimple phi = create_phi_node (result, join_bb);
+      gimple_phi phi = create_phi_node (result, join_bb);
       gimple_call_set_lhs (icall_stmt,
 			   duplicate_ssa_name (result, icall_stmt));
       add_phi_arg (phi, gimple_call_lhs (icall_stmt), e_ij, UNKNOWN_LOCATION);
@@ -1586,7 +1586,9 @@ static void
 gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
 			     gcov_type count, gcov_type all)
 {
-  gimple tmp_stmt, cond_stmt, icall_stmt;
+  gimple_assign tmp_stmt;
+  gimple_cond cond_stmt;
+  gimple_call icall_stmt;
   tree tmp0, tmp1, vcall_size, optype;
   basic_block cond_bb, icall_bb, vcall_bb, join_bb;
   edge e_ci, e_cv, e_iv, e_ij, e_vj;
@@ -1618,7 +1620,7 @@ gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
   gimple_set_vdef (vcall_stmt, NULL);
   gimple_set_vuse (vcall_stmt, NULL);
   update_stmt (vcall_stmt);
-  icall_stmt = gimple_copy (vcall_stmt);
+  icall_stmt = gimple_copy (vcall_stmt)->as_a_gimple_call ();
   gimple_call_set_arg (icall_stmt, size_arg, icall_size);
   gsi_insert_before (&gsi, icall_stmt, GSI_SAME_STMT);
 
@@ -1658,7 +1660,7 @@ gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
       && TREE_CODE (gimple_call_lhs (vcall_stmt)) == SSA_NAME)
     {
       tree result = gimple_call_lhs (vcall_stmt);
-      gimple phi = create_phi_node (result, join_bb);
+      gimple_phi phi = create_phi_node (result, join_bb);
       gimple_call_set_lhs (vcall_stmt,
 			   duplicate_ssa_name (result, vcall_stmt));
       add_phi_arg (phi, gimple_call_lhs (vcall_stmt), e_vj, UNKNOWN_LOCATION);
-- 
1.8.5.3

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

* [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (45 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 60/89] Concretize gimple_catch_types David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-04-23 21:12   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 84/89] Concretize gimple_call_arg_flags David Malcolm
                   ` (44 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

This updates all of the gimple_bind_* accessors in gimple.h from taking a
plain gimple to taking a gimple_bind (or const_gimple_bind), with the
checking happening at the point of cast.

Various other types are strengthened from gimple to gimple_bind, and from
plain vec<gimple> to vec<gimple_bind>.

gcc/
	* coretypes.h (gimple_bind): New typedef.
	(const_gimple_bind): New typedef.

	* gdbhooks.py (build_pretty_printer): Add gimple_bind
	and its variants, using the gimple printer.

	* gimple-pretty-print.c (dump_gimple_bind): Update type-signature to
	require a gimple_bind rather than just a gimple.

	* gimple.c (gimple_build_bind): Return a gimple_bind rather than
	just a gimple.
	* gimple.h (gimple_build_bind): Likewise.

	* gimple.h (gimple_statement_base::as_a_gimple_bind): New.
	(gimple_statement_base::dyn_cast_gimple_bind): New.
	(gimple_seq_first_stmt_as_a_bind): New.

	* gimple.h (gimple_bind_vars): Update type-signature to
	require a gimple_bind rather than just a gimple, removing
	as_a and hence run-time check.
	(gimple_bind_set_vars): Likewise.
	(gimple_bind_append_vars): Likewise.
	(gimple_bind_body_ptr): Likewise.
	(gimple_bind_body): Likewise.
	(gimple_bind_set_body): Likewise.
	(gimple_bind_add_stmt): Likewise.
	(gimple_bind_add_seq): Likewise.
	(gimple_bind_block): Likewise.
	(gimple_bind_set_block): Likewise.
	* gimplify.c (gimple_push_bind_expr): Likewise.
	(gimple_current_bind_expr): Likewise.
	* tree-inline.c (copy_gimple_bind): Likewise.

	* gimplify.h (gimple_current_bind_expr): Return a gimple_bind
	rather than a plain gimple.
	(gimplify_body): Likewise.
	(gimple_bind_expr_stack): Return a vec<gimple_bind> rather than
	a vec<gimple>.

	* gimplify.c (struct gimplify_ctx): Strengthen field
	"bind_expr_stack" from vec<gimple> to vec<gimple_bind>.
	(gimple_bind_expr_stack): Likewise for type of returned value.

	* gimplify.c (gimplify_body): Strengthen various types from gimple
	to gimple_bind, including the return type.

	* gimplify.c (declare_vars): Introduce "gs" as a generic gimple,
	so that local "scope" can be of type gimple_bind once we've reached
	the region where it must be of code GIMPLE_BIND.

	* gimple-low.c (lower_gimple_bind): Add checked cast to
	gimple_bind, since both callers (lower_function_body and
	lower_stmt) have checked the code for us.

	* gimple.c (gimple_copy): Add checked cast to gimple_bind in
	region guarded by check for code GIMPLE_BIND.
	* gimple-low.c (gimple_stmt_may_fallthru): Likewise.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* omp-low.c (scan_omp_1_stmt): Likewise.
	(lower_omp_1): Likewise.
	(lower_omp_for): Likewise.
	* tree-cfg.c (verify_gimple_in_seq_2): Likewise.
	(do_warn_unused_result): Likewise.
	* tree-inline.c (remap_gimple_stmt): Likewise.
	(estimate_num_insns): Likewise.
	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.

	* gimplify.c (gimplify_bind_expr): Update local(s) to be a
	gimple_bind rather than just a gimple.
	(gimplify_function_tree): Likewise.
	* omp-low.c (lower_omp_sections): Likewise.
	(lower_omp_single): Likewise.
	(lower_omp_master): Likewise.
	(lower_omp_taskgroup): Likewise.
	(lower_omp_ordered): Likewise.
	(lower_omp_critical): Likewise.
	(lower_omp_taskreg): Likewise.
	(lower_omp_teams): Likewise.
	* omp-low.c (lower_omp_for): Likewise; use
	gimple_seq_first_stmt_as_a_bind to encapsulate the checked cast.
	(lower_omp_target): Likewise.
	* tree-nested.c (finalize_nesting_tree_1): Likewise.

	* gimple.c (empty_stmt_p): Add dyn_cast to a gimple_bind.
	* tree-inline.c (replace_locals_stmt): Add dyn_cast to gimple_bind.

gcc/c-family/
	* c-gimplify.c (add_block_to_enclosing): Strengthen local "stack"
	from being just a vec<gimple> to a vec<gimple_bind>.

gcc/java/
	* java-gimplify.c (java_gimplify_block): Update local to be a
	gimple_bind rather than just a gimple.

Conflicts:
	gcc/omp-low.c
	gcc/tree-nested.c
---
 gcc/c-family/c-gimplify.c |  4 ++--
 gcc/coretypes.h           |  4 ++++
 gcc/gdbhooks.py           |  4 +++-
 gcc/gimple-low.c          |  5 +++--
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple-walk.c         |  5 +++--
 gcc/gimple.c              | 21 +++++++++++-------
 gcc/gimple.h              | 55 ++++++++++++++++++++++++++++-------------------
 gcc/gimplify.c            | 37 +++++++++++++++----------------
 gcc/gimplify.h            |  6 +++---
 gcc/java/java-gimplify.c  |  2 +-
 gcc/omp-low.c             | 40 +++++++++++++++++++++-------------
 gcc/tree-cfg.c            |  5 +++--
 gcc/tree-inline.c         | 12 ++++++-----
 gcc/tree-nested.c         | 22 +++++++++++--------
 15 files changed, 134 insertions(+), 92 deletions(-)

diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 737be4d..460a413 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -112,8 +112,8 @@ add_block_to_enclosing (tree block)
 {
   unsigned i;
   tree enclosing;
-  gimple bind;
-  vec<gimple> stack = gimple_bind_expr_stack ();
+  gimple_bind bind;
+  vec<gimple_bind> stack = gimple_bind_expr_stack ();
 
   FOR_EACH_VEC_ELT (stack, i, bind)
     if (gimple_bind_block (bind))
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index a39ae1a..a39900f 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -73,6 +73,10 @@ struct gimple_statement_switch;
 typedef struct gimple_statement_switch *gimple_switch;
 typedef const struct gimple_statement_switch *const_gimple_switch;
 
+struct gimple_statement_bind;
+typedef struct gimple_statement_bind *gimple_bind;
+typedef const struct gimple_statement_bind *const_gimple_bind;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 891877a..5dcc76f 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -458,7 +458,9 @@ def build_pretty_printer():
 
                               # Keep this in the same order as gimple.def:
                               'gimple_switch', 'const_gimple_switch',
-                              'gimple_statement_switch *'],
+                              'gimple_statement_switch *',
+                              'gimple_bind', 'const_gimple_bind',
+                              'gimple_statement_bind *'],
 
                              'gimple',
                              GimplePrinter)
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 80fd786..d56ff0a 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -380,7 +380,7 @@ static void
 lower_gimple_bind (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
   tree old_block = data->block;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_bind stmt = gsi_stmt (*gsi)->as_a_gimple_bind ();
   tree new_block = gimple_bind_block (stmt);
 
   if (new_block)
@@ -574,7 +574,8 @@ gimple_stmt_may_fallthru (gimple stmt)
       return false;
 
     case GIMPLE_BIND:
-      return gimple_seq_may_fallthru (gimple_bind_body (stmt));
+      return gimple_seq_may_fallthru (
+	       gimple_bind_body (stmt->as_a_gimple_bind ()));
 
     case GIMPLE_TRY:
       if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 25abd77..22d927f 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -889,7 +889,7 @@ dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
    TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_bind (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_bind (pretty_printer *buffer, gimple_bind gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
@@ -2099,7 +2099,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_BIND:
-      dump_gimple_bind (buffer, gs, spc, flags);
+      dump_gimple_bind (buffer, gs->as_a_gimple_bind (), spc, flags);
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index b6f0495..85b6dcd 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -541,8 +541,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
   switch (gimple_code (stmt))
     {
     case GIMPLE_BIND:
-      ret = walk_gimple_seq_mod (gimple_bind_body_ptr (stmt), callback_stmt,
-				 callback_op, wi);
+      ret =
+	walk_gimple_seq_mod (gimple_bind_body_ptr (stmt->as_a_gimple_bind ()),
+			     callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 6c524c2..b3fbb0f 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -513,10 +513,10 @@ gimple_build_nop (void)
    VARS are the variables in BODY.
    BLOCK is the containing block.  */
 
-gimple
+gimple_bind
 gimple_build_bind (tree vars, gimple_seq body, tree block)
 {
-  gimple p = gimple_alloc (GIMPLE_BIND, 0);
+  gimple_bind p = gimple_alloc (GIMPLE_BIND, 0)->as_a_gimple_bind ();
   gimple_bind_set_vars (p, vars);
   if (body)
     gimple_bind_set_body (p, body);
@@ -1248,8 +1248,8 @@ empty_stmt_p (gimple stmt)
 {
   if (gimple_code (stmt) == GIMPLE_NOP)
     return true;
-  if (gimple_code (stmt) == GIMPLE_BIND)
-    return empty_body_p (gimple_bind_body (stmt));
+  if (gimple_bind bind_stmt = stmt->dyn_cast_gimple_bind ())
+    return empty_body_p (gimple_bind_body (bind_stmt));
   return false;
 }
 
@@ -1621,10 +1621,15 @@ gimple_copy (gimple stmt)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_BIND:
-	  new_seq = gimple_seq_copy (gimple_bind_body (stmt));
-	  gimple_bind_set_body (copy, new_seq);
-	  gimple_bind_set_vars (copy, unshare_expr (gimple_bind_vars (stmt)));
-	  gimple_bind_set_block (copy, gimple_bind_block (stmt));
+	  {
+	    gimple_bind bind_stmt = stmt->as_a_gimple_bind ();
+	    gimple_bind bind_copy = copy->as_a_gimple_bind ();
+	    new_seq = gimple_seq_copy (gimple_bind_body (bind_stmt));
+	    gimple_bind_set_body (bind_copy, new_seq);
+	    gimple_bind_set_vars (bind_copy,
+				  unshare_expr (gimple_bind_vars (bind_stmt)));
+	    gimple_bind_set_block (bind_copy, gimple_bind_block (bind_stmt));
+	  }
 	  break;
 
 	case GIMPLE_CATCH:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index b448e0e..620495d 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -220,6 +220,12 @@ public:
     return as_a <gimple_statement_switch> (this);
   }
 
+  inline gimple_bind
+  as_a_gimple_bind ()
+  {
+    return as_a <gimple_statement_bind> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -234,6 +240,12 @@ public:
     return dyn_cast <gimple_statement_switch> (this);
   }
 
+  inline gimple_bind
+  dyn_cast_gimple_bind ()
+  {
+    return dyn_cast <gimple_statement_bind> (this);
+  }
+
 };
 
 
@@ -1234,7 +1246,7 @@ void gimple_cond_set_condition_from_tree (gimple, tree);
 gimple gimple_build_label (tree label);
 gimple gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
-gimple gimple_build_bind (tree, gimple_seq, tree);
+gimple_bind gimple_build_bind (tree, gimple_seq, tree);
 gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 			     vec<tree, va_gc> *, vec<tree, va_gc> *,
 			     vec<tree, va_gc> *);
@@ -1369,6 +1381,16 @@ gimple_seq_first_stmt (gimple_seq s)
   return n;
 }
 
+/* Return the first statement in GIMPLE sequence S as a gimple_bind,
+   verifying that it has code GIMPLE_BIND in a checked build.  */
+
+static inline gimple_bind
+gimple_seq_first_stmt_as_a_bind (gimple_seq s)
+{
+  gimple_seq_node n = gimple_seq_first (s);
+  return as_a <gimple_statement_bind> (n);
+}
+
 
 /* Return the last node in GIMPLE sequence S.  */
 
@@ -3128,10 +3150,8 @@ gimple_goto_set_dest (gimple gs, tree dest)
 /* Return the variables declared in the GIMPLE_BIND statement GS.  */
 
 static inline tree
-gimple_bind_vars (const_gimple gs)
+gimple_bind_vars (const_gimple_bind bind_stmt)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind> (gs);
   return bind_stmt->vars;
 }
 
@@ -3140,9 +3160,8 @@ gimple_bind_vars (const_gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_vars (gimple gs, tree vars)
+gimple_bind_set_vars (gimple_bind bind_stmt, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->vars = vars;
 }
 
@@ -3151,24 +3170,22 @@ gimple_bind_set_vars (gimple gs, tree vars)
    statement GS.  */
 
 static inline void
-gimple_bind_append_vars (gimple gs, tree vars)
+gimple_bind_append_vars (gimple_bind bind_stmt, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->vars = chainon (bind_stmt->vars, vars);
 }
 
 
 static inline gimple_seq *
-gimple_bind_body_ptr (gimple gs)
+gimple_bind_body_ptr (gimple_bind bind_stmt)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   return &bind_stmt->body;
 }
 
 /* Return the GIMPLE sequence contained in the GIMPLE_BIND statement GS.  */
 
 static inline gimple_seq
-gimple_bind_body (gimple gs)
+gimple_bind_body (gimple_bind gs)
 {
   return *gimple_bind_body_ptr (gs);
 }
@@ -3178,9 +3195,8 @@ gimple_bind_body (gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_body (gimple gs, gimple_seq seq)
+gimple_bind_set_body (gimple_bind bind_stmt, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   bind_stmt->body = seq;
 }
 
@@ -3188,9 +3204,8 @@ gimple_bind_set_body (gimple gs, gimple_seq seq)
 /* Append a statement to the end of a GIMPLE_BIND's body.  */
 
 static inline void
-gimple_bind_add_stmt (gimple gs, gimple stmt)
+gimple_bind_add_stmt (gimple_bind bind_stmt, gimple stmt)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gimple_seq_add_stmt (&bind_stmt->body, stmt);
 }
 
@@ -3198,9 +3213,8 @@ gimple_bind_add_stmt (gimple gs, gimple stmt)
 /* Append a sequence of statements to the end of a GIMPLE_BIND's body.  */
 
 static inline void
-gimple_bind_add_seq (gimple gs, gimple_seq seq)
+gimple_bind_add_seq (gimple_bind bind_stmt, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gimple_seq_add_seq (&bind_stmt->body, seq);
 }
 
@@ -3209,10 +3223,8 @@ gimple_bind_add_seq (gimple gs, gimple_seq seq)
    GS.  This is analogous to the BIND_EXPR_BLOCK field in trees.  */
 
 static inline tree
-gimple_bind_block (const_gimple gs)
+gimple_bind_block (const_gimple_bind bind_stmt)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind> (gs);
   return bind_stmt->block;
 }
 
@@ -3221,9 +3233,8 @@ gimple_bind_block (const_gimple gs)
    statement GS.  */
 
 static inline void
-gimple_bind_set_block (gimple gs, tree block)
+gimple_bind_set_block (gimple_bind bind_stmt, tree block)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind> (gs);
   gcc_gimple_checking_assert (block == NULL_TREE
 			      || TREE_CODE (block) == BLOCK);
   bind_stmt->block = block;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index ad2178d..533766e 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -112,7 +112,7 @@ struct gimplify_ctx
 {
   struct gimplify_ctx *prev_context;
 
-  vec<gimple> bind_expr_stack;
+  vec<gimple_bind> bind_expr_stack;
   tree temps;
   gimple_seq conditional_cleanups;
   tree exit_label;
@@ -262,10 +262,10 @@ pop_gimplify_context (gimple body)
 /* Push a GIMPLE_BIND tuple onto the stack of bindings.  */
 
 static void
-gimple_push_bind_expr (gimple gimple_bind)
+gimple_push_bind_expr (gimple_bind bind_stmt)
 {
   gimplify_ctxp->bind_expr_stack.reserve (8);
-  gimplify_ctxp->bind_expr_stack.safe_push (gimple_bind);
+  gimplify_ctxp->bind_expr_stack.safe_push (bind_stmt);
 }
 
 /* Pop the first element off the stack of bindings.  */
@@ -278,7 +278,7 @@ gimple_pop_bind_expr (void)
 
 /* Return the first element of the stack of bindings.  */
 
-gimple
+gimple_bind
 gimple_current_bind_expr (void)
 {
   return gimplify_ctxp->bind_expr_stack.last ();
@@ -286,7 +286,7 @@ gimple_current_bind_expr (void)
 
 /* Return the stack of bindings created during gimplification.  */
 
-vec<gimple> 
+vec<gimple_bind>
 gimple_bind_expr_stack (void)
 {
   return gimplify_ctxp->bind_expr_stack;
@@ -564,14 +564,14 @@ get_initialized_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p)
    generate debug info for them; otherwise don't.  */
 
 void
-declare_vars (tree vars, gimple scope, bool debug_info)
+declare_vars (tree vars, gimple gs, bool debug_info)
 {
   tree last = vars;
   if (last)
     {
       tree temps, block;
 
-      gcc_assert (gimple_code (scope) == GIMPLE_BIND);
+      gimple_bind scope = gs->as_a_gimple_bind ();
 
       temps = nreverse (last);
 
@@ -1024,7 +1024,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
   tree bind_expr = *expr_p;
   bool old_save_stack = gimplify_ctxp->save_stack;
   tree t;
-  gimple gimple_bind;
+  gimple_bind gimple_bind;
   gimple_seq body, cleanup;
   gimple stack_save;
 
@@ -8520,12 +8520,13 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
    containing the sequence of corresponding GIMPLE statements.  If DO_PARMS
    is true, also gimplify the parameters.  */
 
-gimple
+gimple_bind
 gimplify_body (tree fndecl, bool do_parms)
 {
   location_t saved_location = input_location;
   gimple_seq parm_stmts, seq;
-  gimple outer_bind;
+  gimple outer_stmt;
+  gimple_bind outer_bind;
   struct cgraph_node *cgn;
 
   timevar_push (TV_TREE_GIMPLIFY);
@@ -8565,18 +8566,18 @@ gimplify_body (tree fndecl, bool do_parms)
   /* Gimplify the function's body.  */
   seq = NULL;
   gimplify_stmt (&DECL_SAVED_TREE (fndecl), &seq);
-  outer_bind = gimple_seq_first_stmt (seq);
-  if (!outer_bind)
+  outer_stmt = gimple_seq_first_stmt (seq);
+  if (!outer_stmt)
     {
-      outer_bind = gimple_build_nop ();
-      gimplify_seq_add_stmt (&seq, outer_bind);
+      outer_stmt = gimple_build_nop ();
+      gimplify_seq_add_stmt (&seq, outer_stmt);
     }
 
   /* The body must contain exactly one statement, a GIMPLE_BIND.  If this is
      not the case, wrap everything in a GIMPLE_BIND to make it so.  */
-  if (gimple_code (outer_bind) == GIMPLE_BIND
+  if (gimple_code (outer_stmt) == GIMPLE_BIND
       && gimple_seq_first (seq) == gimple_seq_last (seq))
-    ;
+    outer_bind = as_a<gimple_statement_bind> (outer_stmt);
   else
     outer_bind = gimple_build_bind (NULL_TREE, seq, NULL);
 
@@ -8690,7 +8691,7 @@ gimplify_function_tree (tree fndecl)
 {
   tree parm, ret;
   gimple_seq seq;
-  gimple bind;
+  gimple_bind bind;
 
   gcc_assert (!gimple_body (fndecl));
 
@@ -8734,7 +8735,7 @@ gimplify_function_tree (tree fndecl)
       && !flag_instrument_functions_exclude_p (fndecl))
     {
       tree x;
-      gimple new_bind;
+      gimple_bind new_bind;
       gimple tf;
       gimple_seq cleanup = NULL, body = NULL;
       tree tmp_var;
diff --git a/gcc/gimplify.h b/gcc/gimplify.h
index 6bc0057..c37b5ab 100644
--- a/gcc/gimplify.h
+++ b/gcc/gimplify.h
@@ -53,8 +53,8 @@ extern void free_gimplify_stack (void);
 extern void push_gimplify_context (bool in_ssa = false,
 				   bool rhs_cond_ok = false);
 extern void pop_gimplify_context (gimple);
-extern gimple gimple_current_bind_expr (void);
-extern vec<gimple> gimple_bind_expr_stack (void);
+extern gimple_bind gimple_current_bind_expr (void);
+extern vec<gimple_bind> gimple_bind_expr_stack (void);
 extern void gimplify_and_add (tree, gimple_seq *);
 extern tree get_formal_tmp_var (tree, gimple_seq *);
 extern tree get_initialized_tmp_var (tree, gimple_seq *, gimple_seq *);
@@ -75,7 +75,7 @@ extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
 
 extern void gimplify_type_sizes (tree, gimple_seq *);
 extern void gimplify_one_sizepos (tree *, gimple_seq *);
-extern gimple gimplify_body (tree, bool);
+extern gimple_bind gimplify_body (tree, bool);
 extern void gimplify_function_tree (tree);
 extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
 						  gimple_seq *);
diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c
index 6c7a1b6..4565482 100644
--- a/gcc/java/java-gimplify.c
+++ b/gcc/java/java-gimplify.c
@@ -128,7 +128,7 @@ java_gimplify_block (tree java_block)
 {
   tree decls = BLOCK_VARS (java_block);
   tree body = BLOCK_EXPR_BODY (java_block);
-  gimple outer = gimple_current_bind_expr ();
+  gimple_bind outer = gimple_current_bind_expr ();
   tree block;
 
   /* Don't bother with empty blocks.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cd10717..59e632f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2674,7 +2674,9 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 
 	*handled_ops_p = false;
 	if (ctx)
-	  for (var = gimple_bind_vars (stmt); var ; var = DECL_CHAIN (var))
+	  for (var = gimple_bind_vars (stmt->as_a_gimple_bind ());
+	       var ;
+	       var = DECL_CHAIN (var))
 	    insert_decl_map (&ctx->cb, var, var);
       }
       break;
@@ -8407,7 +8409,8 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, control;
   gimple_stmt_iterator tgsi;
-  gimple stmt, new_stmt, bind, t;
+  gimple stmt, t;
+  gimple_bind new_stmt, bind;
   gimple_seq ilist, dlist, olist, new_body;
 
   stmt = gsi_stmt (*gsi_p);
@@ -8616,7 +8619,8 @@ static void
 lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple t, bind, single_stmt = gsi_stmt (*gsi_p);
+  gimple t, single_stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   gimple_seq bind_body, bind_body_tail = NULL, dlist;
 
   push_gimplify_context ();
@@ -8674,7 +8678,8 @@ static void
 lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, lab = NULL, x, bfn_decl;
-  gimple stmt = gsi_stmt (*gsi_p), bind;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tseq;
 
@@ -8714,7 +8719,8 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 static void
 lower_omp_taskgroup (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
-  gimple stmt = gsi_stmt (*gsi_p), bind, x;
+  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple_bind bind;
   tree block = make_node (BLOCK);
 
   bind = gimple_build_bind (NULL, NULL, block);
@@ -8742,7 +8748,8 @@ static void
 lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple stmt = gsi_stmt (*gsi_p), bind, x;
+  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple_bind bind;
 
   push_gimplify_context ();
 
@@ -8785,7 +8792,8 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
   tree name, lock, unlock;
-  gimple stmt = gsi_stmt (*gsi_p), bind;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind bind;
   location_t loc = gimple_location (stmt);
   gimple_seq tbody;
 
@@ -8927,7 +8935,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree *rhs_p, block;
   struct omp_for_data fd, *fdp = NULL;
-  gimple stmt = gsi_stmt (*gsi_p), new_stmt;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_bind new_stmt;
   gimple_seq omp_for_body, body, dlist;
   size_t i;
 
@@ -8948,7 +8957,8 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   if (!gimple_seq_empty_p (omp_for_body)
       && gimple_code (gimple_seq_first_stmt (omp_for_body)) == GIMPLE_BIND)
     {
-      gimple inner_bind = gimple_seq_first_stmt (omp_for_body);
+      gimple_bind inner_bind =
+	gimple_seq_first_stmt (omp_for_body)->as_a_gimple_bind ();
       tree vars = gimple_bind_vars (inner_bind);
       gimple_bind_append_vars (new_stmt, vars);
       /* bind_vars/BLOCK_VARS are being moved to new_stmt/block, don't
@@ -9442,12 +9452,12 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   tree clauses;
   tree child_fn, t;
   gimple stmt = gsi_stmt (*gsi_p);
-  gimple par_bind, bind, dep_bind = NULL;
+  gimple_bind par_bind, bind, dep_bind = NULL;
   gimple_seq par_body, olist, ilist, par_olist, par_rlist, par_ilist, new_body;
   location_t loc = gimple_location (stmt);
 
   clauses = gimple_omp_taskreg_clauses (stmt);
-  par_bind = gimple_seq_first_stmt (gimple_omp_body (stmt));
+  par_bind = gimple_seq_first_stmt_as_a_bind (gimple_omp_body (stmt));
   par_body = gimple_bind_body (par_bind);
   child_fn = ctx->cb.dst_fn;
   if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
@@ -9564,7 +9574,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   tree clauses;
   tree child_fn, t, c;
   gimple stmt = gsi_stmt (*gsi_p);
-  gimple tgt_bind = NULL, bind;
+  gimple_bind tgt_bind = NULL, bind;
   gimple_seq tgt_body = NULL, olist, ilist, new_body;
   location_t loc = gimple_location (stmt);
   int kind = gimple_omp_target_kind (stmt);
@@ -9573,7 +9583,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   clauses = gimple_omp_target_clauses (stmt);
   if (kind == GF_OMP_TARGET_KIND_REGION)
     {
-      tgt_bind = gimple_seq_first_stmt (gimple_omp_body (stmt));
+      tgt_bind = gimple_seq_first_stmt_as_a_bind (gimple_omp_body (stmt));
       tgt_body = gimple_bind_body (tgt_bind);
     }
   else if (kind == GF_OMP_TARGET_KIND_DATA)
@@ -9876,7 +9886,7 @@ lower_omp_teams (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   push_gimplify_context ();
 
   tree block = make_node (BLOCK);
-  gimple bind = gimple_build_bind (NULL, NULL, block);
+  gimple_bind bind = gimple_build_bind (NULL, NULL, block);
   gsi_replace (gsi_p, bind, true);
   gimple_seq bind_body = NULL;
   gimple_seq dlist = NULL;
@@ -10005,7 +10015,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       lower_omp (gimple_transaction_body_ptr (stmt), ctx);
       break;
     case GIMPLE_BIND:
-      lower_omp (gimple_bind_body_ptr (stmt), ctx);
+      lower_omp (gimple_bind_body_ptr (stmt->as_a_gimple_bind ()), ctx);
       break;
     case GIMPLE_OMP_PARALLEL:
     case GIMPLE_OMP_TASK:
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 53aced3..b1355ab 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4547,7 +4547,8 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
       switch (gimple_code (stmt))
         {
 	case GIMPLE_BIND:
-	  err |= verify_gimple_in_seq_2 (gimple_bind_body (stmt));
+	  err |= verify_gimple_in_seq_2 (
+                   gimple_bind_body (stmt->as_a_gimple_bind ()));
 	  break;
 
 	case GIMPLE_TRY:
@@ -8292,7 +8293,7 @@ do_warn_unused_result (gimple_seq seq)
       switch (gimple_code (g))
 	{
 	case GIMPLE_BIND:
-	  do_warn_unused_result (gimple_bind_body (g));
+	  do_warn_unused_result (gimple_bind_body (g->as_a_gimple_bind ()));
 	  break;
 	case GIMPLE_TRY:
 	  do_warn_unused_result (gimple_try_eval (g));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index c0f93ac..bf1c3c7 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -744,7 +744,7 @@ remap_gimple_seq (gimple_seq body, copy_body_data *id)
    block using the mapping information in ID.  */
 
 static gimple
-copy_gimple_bind (gimple stmt, copy_body_data *id)
+copy_gimple_bind (gimple_bind stmt, copy_body_data *id)
 {
   gimple new_bind;
   tree new_block, new_vars;
@@ -1292,7 +1292,7 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_BIND:
-	  copy = copy_gimple_bind (stmt, id);
+	  copy = copy_gimple_bind (stmt->as_a_gimple_bind (), id);
 	  break;
 
 	case GIMPLE_CATCH:
@@ -3914,7 +3914,9 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       return 10;
 
     case GIMPLE_BIND:
-      return estimate_num_insns_seq (gimple_bind_body (stmt), weights);
+      return estimate_num_insns_seq (
+	       gimple_bind_body (stmt->as_a_gimple_bind ()),
+	       weights);
 
     case GIMPLE_EH_FILTER:
       return estimate_num_insns_seq (gimple_eh_filter_failure (stmt), weights);
@@ -4834,9 +4836,9 @@ replace_locals_stmt (gimple_stmt_iterator *gsip,
 		     struct walk_stmt_info *wi)
 {
   copy_body_data *id = (copy_body_data *) wi->info;
-  gimple stmt = gsi_stmt (*gsip);
+  gimple gs = gsi_stmt (*gsip);
 
-  if (gimple_code (stmt) == GIMPLE_BIND)
+  if (gimple_bind stmt = dyn_cast <gimple_statement_bind> (gs))
     {
       tree block = gimple_bind_block (stmt);
 
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index df6923f..78de464 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1328,10 +1328,12 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_BIND:
-      if (!optimize && gimple_bind_block (stmt))
-	note_nonlocal_block_vlas (info, gimple_bind_block (stmt));
+      {
+      gimple_bind bind_stmt = stmt->as_a_gimple_bind ();
+      if (!optimize && gimple_bind_block (bind_stmt))
+	note_nonlocal_block_vlas (info, gimple_bind_block (bind_stmt));
 
-      for (tree var = gimple_bind_vars (stmt); var; var = DECL_CHAIN (var))
+      for (tree var = gimple_bind_vars (bind_stmt); var; var = DECL_CHAIN (var))
 	if (TREE_CODE (var) == NAMELIST_DECL)
 	  {
 	    /* Adjust decls mentioned in NAMELIST_DECL.  */
@@ -1352,7 +1354,7 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 
       *handled_ops_p = false;
       return NULL_TREE;
-
+      }
     case GIMPLE_COND:
       wi->val_only = true;
       wi->is_lhs = false;
@@ -1807,7 +1809,9 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       return NULL_TREE;
 
     case GIMPLE_BIND:
-      for (tree var = gimple_bind_vars (stmt); var; var = DECL_CHAIN (var))
+      for (tree var = gimple_bind_vars (stmt->as_a_gimple_bind ());
+	   var;
+	   var = DECL_CHAIN (var))
 	if (TREE_CODE (var) == NAMELIST_DECL)
 	  {
 	    /* Adjust decls mentioned in NAMELIST_DECL.  */
@@ -2526,9 +2530,9 @@ finalize_nesting_tree_1 (struct nesting_info *root)
   /* If we created initialization statements, insert them.  */
   if (stmt_list)
     {
-      gimple bind;
+      gimple_bind bind;
       annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
-      bind = gimple_seq_first_stmt (gimple_body (context));
+      bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context));
       gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
       gimple_bind_set_body (bind, stmt_list);
     }
@@ -2557,7 +2561,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
   if (root->debug_var_chain)
     {
       tree debug_var;
-      gimple scope;
+      gimple_bind scope;
 
       remap_vla_decls (DECL_INITIAL (root->context), root);
 
@@ -2612,7 +2616,7 @@ finalize_nesting_tree_1 (struct nesting_info *root)
 	  pointer_map_destroy (id.cb.decl_map);
 	}
 
-      scope = gimple_seq_first_stmt (gimple_body (root->context));
+      scope = gimple_seq_first_stmt_as_a_bind (gimple_body (root->context));
       if (gimple_bind_block (scope))
 	declare_vars (root->debug_var_chain, scope, true);
       else
-- 
1.8.5.3

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

* [PATCH 19/89] Const-correctness of gimple_call_builtin_p
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (34 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 56/89] Various gimple to gimple_call conversions in IPA David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-07 19:39   ` Committed: " David Malcolm
  2014-05-09  6:34   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 31/89] Use subclasses of gimple in various places David Malcolm
                   ` (55 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_builtin_call_types_compatible_p): Accept a
	const_gimple, rather than a gimple.
	(gimple_call_builtin_p): Likewise, for the three variants.

	* gimple.c (gimple_builtin_call_types_compatible_p): Likewise.
	(gimple_call_builtin_p): Likewise, for the three variants.
---
 gcc/gimple.c | 8 ++++----
 gcc/gimple.h | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 13c5a08..943fa7c 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2383,7 +2383,7 @@ validate_type (tree type1, tree type2)
    a decl of a builtin function.  */
 
 bool
-gimple_builtin_call_types_compatible_p (gimple stmt, tree fndecl)
+gimple_builtin_call_types_compatible_p (const_gimple stmt, tree fndecl)
 {
   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
 
@@ -2412,7 +2412,7 @@ gimple_builtin_call_types_compatible_p (gimple stmt, tree fndecl)
 /* Return true when STMT is builtins call.  */
 
 bool
-gimple_call_builtin_p (gimple stmt)
+gimple_call_builtin_p (const_gimple stmt)
 {
   tree fndecl;
   if (is_gimple_call (stmt)
@@ -2425,7 +2425,7 @@ gimple_call_builtin_p (gimple stmt)
 /* Return true when STMT is builtins call to CLASS.  */
 
 bool
-gimple_call_builtin_p (gimple stmt, enum built_in_class klass)
+gimple_call_builtin_p (const_gimple stmt, enum built_in_class klass)
 {
   tree fndecl;
   if (is_gimple_call (stmt)
@@ -2438,7 +2438,7 @@ gimple_call_builtin_p (gimple stmt, enum built_in_class klass)
 /* Return true when STMT is builtins call to CODE of CLASS.  */
 
 bool
-gimple_call_builtin_p (gimple stmt, enum built_in_function code)
+gimple_call_builtin_p (const_gimple stmt, enum built_in_function code)
 {
   tree fndecl;
   if (is_gimple_call (stmt)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a8a8d72..62f9756 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1458,10 +1458,10 @@ extern tree gimple_unsigned_type (tree);
 extern tree gimple_signed_type (tree);
 extern alias_set_type gimple_get_alias_set (tree);
 extern bool gimple_ior_addresses_taken (bitmap, gimple);
-extern bool gimple_builtin_call_types_compatible_p (gimple, tree);
-extern bool gimple_call_builtin_p (gimple);
-extern bool gimple_call_builtin_p (gimple, enum built_in_class);
-extern bool gimple_call_builtin_p (gimple, enum built_in_function);
+extern bool gimple_builtin_call_types_compatible_p (const_gimple, tree);
+extern bool gimple_call_builtin_p (const_gimple);
+extern bool gimple_call_builtin_p (const_gimple, enum built_in_class);
+extern bool gimple_call_builtin_p (const_gimple, enum built_in_function);
 extern bool gimple_asm_clobbers_memory_p (const_gimple);
 extern void dump_decl_set (FILE *, bitmap);
 extern bool nonfreeing_call_p (gimple);
-- 
1.8.5.3

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

* [PATCH 73/89] Concretize gimple_cond_{true|false}_label
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (30 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 70/89] Concretize locals within expand_omp_for_init_counts David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 18:37   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 25/89] Introduce gimple_catch David Malcolm
                   ` (59 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_true_label): Require a const_gimple_cond
	rather than just a const_gimple.
	(gimple_cond_false_label): Likewise.

	* omp-low.c (diagnose_sb_2): Add checked cast to gimple_cond within
	case GIMPLE_COND.
	* tree-eh.c (maybe_record_in_goto_queue): Likewise.

	* tree-cfg.c (verify_gimple_stmt): Add a checked cast to gimple_cond
	within "case GIMPLE_COND", splitting it out into...
	(verify_gimple_label): New.
---
 gcc/gimple.h   |  7 +++----
 gcc/omp-low.c  |  5 +++--
 gcc/tree-cfg.c | 43 ++++++++++++++++++++++++++-----------------
 gcc/tree-eh.c  | 17 +++++++++++------
 4 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index bdb2162..9e60c4f 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3358,9 +3358,8 @@ gimple_cond_set_rhs (gimple gs, tree rhs)
    predicate evaluates to true.  */
 
 static inline tree
-gimple_cond_true_label (const_gimple gs)
+gimple_cond_true_label (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op (gs, 2);
 }
 
@@ -3389,9 +3388,9 @@ gimple_cond_set_false_label (gimple_cond gs, tree label)
    predicate evaluates to false.  */
 
 static inline tree
-gimple_cond_false_label (const_gimple gs)
+gimple_cond_false_label (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
+
   return gimple_op (gs, 3);
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d5df743..b6d5674 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10457,7 +10457,8 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_COND:
 	{
-	  tree lab = gimple_cond_true_label (stmt);
+	  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	  tree lab = gimple_cond_true_label (cond_stmt);
 	  if (lab)
 	    {
 	      n = splay_tree_lookup (all_labels,
@@ -10465,7 +10466,7 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 	      diagnose_sb_0 (gsi_p, context,
 			     n ? (gimple) n->value : NULL);
 	    }
-	  lab = gimple_cond_false_label (stmt);
+	  lab = gimple_cond_false_label (cond_stmt);
 	  if (lab)
 	    {
 	      n = splay_tree_lookup (all_labels,
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 1000bbb..355c4ac 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4406,6 +4406,31 @@ verify_gimple_label (gimple_label stmt)
   return err;
 }
 
+/* Verify a gimple cond statement STMT.
+   Returns true if anything is wrong.  */
+
+static bool
+verify_gimple_cond (gimple_cond stmt)
+{
+  if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
+    {
+      error ("invalid comparison code in gimple cond");
+      return true;
+    }
+  if (!(!gimple_cond_true_label (stmt)
+	|| TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL)
+      || !(!gimple_cond_false_label (stmt)
+	   || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL))
+    {
+      error ("invalid labels in gimple cond");
+      return true;
+    }
+
+  return verify_gimple_comparison (boolean_type_node,
+				   gimple_cond_lhs (stmt),
+				   gimple_cond_rhs (stmt));
+}
+
 /* Verify the GIMPLE statement STMT.  Returns true if there is an
    error, otherwise false.  */
 
@@ -4424,23 +4449,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_call (stmt->as_a_gimple_call ());
 
     case GIMPLE_COND:
-      if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
-	{
-	  error ("invalid comparison code in gimple cond");
-	  return true;
-	}
-      if (!(!gimple_cond_true_label (stmt)
-	    || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL)
-	  || !(!gimple_cond_false_label (stmt)
-	       || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL))
-	{
-	  error ("invalid labels in gimple cond");
-	  return true;
-	}
-	  
-      return verify_gimple_comparison (boolean_type_node,
-				       gimple_cond_lhs (stmt),
-				       gimple_cond_rhs (stmt));
+      return verify_gimple_cond (stmt->as_a_gimple_cond ());
 
     case GIMPLE_GOTO:
       return verify_gimple_goto (stmt->as_a_gimple_goto ());
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index aad6da3..46dcc20 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -695,12 +695,17 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      new_stmt.tp = gimple_op_ptr (stmt, 2);
-      record_in_goto_queue_label (tf, new_stmt, gimple_cond_true_label (stmt),
-				  EXPR_LOCATION (*new_stmt.tp));
-      new_stmt.tp = gimple_op_ptr (stmt, 3);
-      record_in_goto_queue_label (tf, new_stmt, gimple_cond_false_label (stmt),
-				  EXPR_LOCATION (*new_stmt.tp));
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	new_stmt.tp = gimple_op_ptr (cond_stmt, 2);
+	record_in_goto_queue_label (tf, new_stmt,
+				    gimple_cond_true_label (cond_stmt),
+				    EXPR_LOCATION (*new_stmt.tp));
+	new_stmt.tp = gimple_op_ptr (cond_stmt, 3);
+	record_in_goto_queue_label (tf, new_stmt,
+				    gimple_cond_false_label (cond_stmt),
+				    EXPR_LOCATION (*new_stmt.tp));
+      }
       break;
     case GIMPLE_GOTO:
       new_stmt.g = stmt;
-- 
1.8.5.3

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

* [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (37 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:29   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 80/89] Tweak to gimplify_modify_expr David Malcolm
                   ` (52 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-parloops.c (reduction_info::keep_res): Strengthen field
	from plain gimple to gimple_phi.
	(transform_to_exit_first_loop): Strengthen locals "phi", "nphi"
	to gimple_phi.  Eliminate early decl of gimple_stmt_iterator gsi
	in favor of more tightly scoped gimple_phi_iterators, and a final
	later decl as a gimple_stmt_iterator.
---
 gcc/tree-parloops.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 84fd451..7eedf8c 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -192,7 +192,7 @@ struct reduction_info
   enum tree_code reduction_code;/* code for the reduction operation.  */
   unsigned reduc_version;	/* SSA_NAME_VERSION of original reduc_phi
 				   result.  */
-  gimple keep_res;		/* The PHI_RESULT of this phi is the resulting value
+  gimple_phi keep_res;		/* The PHI_RESULT of this phi is the resulting value
 				   of the reduction variable when existing the loop. */
   tree initial_value;		/* The initial value of the reduction var before entering the loop.  */
   tree field;			/*  the name of the field in the parloop data structure intended for reduction.  */
@@ -1512,8 +1512,8 @@ transform_to_exit_first_loop (struct loop *loop,
   bool ok;
   edge exit = single_dom_exit (loop), hpred;
   tree control, control_name, res, t;
-  gimple phi, nphi, cond_stmt, stmt, cond_nit;
-  gimple_stmt_iterator gsi;
+  gimple_phi phi, nphi;
+  gimple cond_stmt, stmt, cond_nit;
   tree nit_1;
 
   split_block_after_labels (loop->header);
@@ -1526,9 +1526,11 @@ transform_to_exit_first_loop (struct loop *loop,
 
   /* Make sure that we have phi nodes on exit for all loop header phis
      (create_parallel_loop requires that).  */
-  for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (loop->header);
+       !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       res = PHI_RESULT (phi);
       t = copy_ssa_name (res, phi);
       SET_PHI_RESULT (phi, t);
@@ -1559,9 +1561,10 @@ transform_to_exit_first_loop (struct loop *loop,
      out of the loop is the control variable.  */
   exit = single_dom_exit (loop);
   control_name = NULL_TREE;
-  for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); )
+  for (gimple_phi_iterator gsi = gsi_start_phis (ex_bb);
+       !gsi_end_p (gsi); )
     {
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       res = PHI_RESULT (phi);
       if (virtual_operand_p (res))
 	{
@@ -1596,7 +1599,7 @@ transform_to_exit_first_loop (struct loop *loop,
 
   /* Initialize the control variable to number of iterations
      according to the rhs of the exit condition.  */
-  gsi = gsi_after_labels (ex_bb);
+  gimple_stmt_iterator gsi = gsi_after_labels (ex_bb);
   cond_nit = last_stmt (exit->src);
   nit_1 =  gimple_cond_rhs (cond_nit);
   nit_1 = force_gimple_operand_gsi (&gsi,
-- 
1.8.5.3

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

* [PATCH 21/89] Introduce gimple_return
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (28 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-09 18:45   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 70/89] Concretize locals within expand_omp_for_init_counts David Malcolm
                   ` (61 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_return): New typedef.
	(const_gimple_return): New typedef.

	* gimple.h (gimple_statement_return): New subclass of
	gimple_statement_with_memory_ops, adding the invariant that
	stmt->code == GIMPLE_RETURN.
	(gimple_statement_base::as_a_gimple_return): New.
	(gimple_statement_base::dyn_cast_gimple_return): New.
	(is_a_helper <gimple_statement_return>::test): New.
	(gimple_build_return): Return a gimple_return rather
	than a plain gimple.

	* gimple.c (gimple_build_return): Return a gimple_return rather
	than a plain gimple.

	* cgraphunit.c (expand_thunk): Convert local from a gimple to
	a gimple_return.

	* gimple-low.c (struct return_statements_t): Convert field "stmt"
	from a gimple to a gimple_return.
	(lower_gimple_return): Convert local from a gimple to a
	gimple_return.

	* gimple-pretty-print.c (dump_gimple_return): Require a
	gimple_return rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_return within
	case GIMPLE_RETURN of switch statement.

	* gimplify.c (gimplify_return_expr): Convert locals from
	gimple to gimple_return.

	* ipa-split.c (split_function): Likewise.

	* tree-cfg.c (verify_gimple_assign): Require a gimple_return
	rather than a plain gimple.
	(verify_gimple_stmt): Add checked cast to gimple_return within
	case GIMPLE_RETURN of switch statement.

	* tree-tailcall.c (adjust_return_value): Convert local from
	gimple to gimple_return.
---
 gcc/cgraphunit.c          |  2 +-
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-low.c          |  4 ++--
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 32 +++++++++++++++++++++++++++++++-
 gcc/gimplify.c            |  4 ++--
 gcc/ipa-split.c           |  2 +-
 gcc/tree-cfg.c            |  4 ++--
 gcc/tree-tailcall.c       |  3 ++-
 10 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 588fe13..dea6335 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1532,7 +1532,7 @@ expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
       tree restmp = NULL;
 
       gimple_call call;
-      gimple ret;
+      gimple_return ret;
 
       if (in_lto_p)
 	cgraph_get_body (node);
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 0f884fd..d5c62b9 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -93,6 +93,10 @@ struct gimple_statement_call;
 typedef struct gimple_statement_call *gimple_call;
 typedef const struct gimple_statement_call *const_gimple_call;
 
+struct gimple_statement_return;
+typedef struct gimple_statement_return *gimple_return;
+typedef const struct gimple_statement_return *const_gimple_return;
+
 struct gimple_statement_bind;
 typedef struct gimple_statement_bind *gimple_bind;
 typedef const struct gimple_statement_bind *const_gimple_bind;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index d56ff0a..98e001d 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -60,7 +60,7 @@ along with GCC; see the file COPYING3.  If not see
 struct return_statements_t
 {
   tree label;
-  gimple stmt;
+  gimple_return stmt;
 };
 typedef struct return_statements_t return_statements_t;
 
@@ -621,7 +621,7 @@ gimple_seq_may_fallthru (gimple_seq seq)
 static void
 lower_gimple_return (gimple_stmt_iterator *gsi, struct lower_data *data)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_return stmt = gsi_stmt (*gsi)->as_a_gimple_return ();
   gimple t;
   int i;
   return_statements_t tmp_rs;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 6b903aa..90baded 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -545,7 +545,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_return (pretty_printer *buffer, gimple_return gs, int spc, int flags)
 {
   tree t;
 
@@ -2123,7 +2123,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_RETURN:
-      dump_gimple_return (buffer, gs, spc, flags);
+      dump_gimple_return (buffer, gs->as_a_gimple_return (), spc, flags);
       break;
 
     case GIMPLE_SWITCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 6acf60b..222c068 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -177,10 +177,11 @@ gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode,
 
 /* Build a GIMPLE_RETURN statement returning RETVAL.  */
 
-gimple
+gimple_return
 gimple_build_return (tree retval)
 {
-  gimple s = gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK, 1);
+  gimple_return s = gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK,
+					   1)->as_a_gimple_return ();
   if (retval)
     gimple_return_set_retval (s, retval);
   return s;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 4e0be1f..39ac2dc 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -246,6 +246,12 @@ public:
     return as_a <gimple_statement_call> (this);
   }
 
+  inline gimple_return
+  as_a_gimple_return ()
+  {
+    return as_a <gimple_statement_return> (this);
+  }
+
   inline const_gimple_call
   as_a_gimple_call () const
   {
@@ -308,6 +314,12 @@ public:
     return dyn_cast <gimple_statement_call> (this);
   }
 
+  inline gimple_return
+  dyn_cast_gimple_return ()
+  {
+    return dyn_cast <gimple_statement_return> (this);
+  }
+
   inline gimple_bind
   dyn_cast_gimple_bind ()
   {
@@ -943,6 +955,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_RETURN
+   i.e. a return statement.  */
+
+struct GTY((tag("GSS_WITH_MEM_OPS")))
+  gimple_statement_return : public gimple_statement_with_memory_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
+};
+
 template <>
 template <>
 inline bool
@@ -1162,6 +1184,14 @@ is_a_helper <gimple_statement_phi>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_return>::test (gimple gs)
+{
+  return gs->code == GIMPLE_RETURN;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_switch>::test (gimple gs)
 {
   return gs->code == GIMPLE_SWITCH;
@@ -1380,7 +1410,7 @@ extern gimple currently_expanding_gimple_stmt;
 
 #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
 gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
-gimple gimple_build_return (tree);
+gimple_return gimple_build_return (tree);
 void gimple_call_reset_alias_info (gimple_call);
 gimple_call gimple_build_call_vec (tree, vec<tree> );
 gimple_call gimple_build_call (tree, unsigned, ...);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index bfb8f98..b24ce70 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1153,7 +1153,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
 static enum gimplify_status
 gimplify_return_expr (tree stmt, gimple_seq *pre_p)
 {
-  gimple ret;
+  gimple_return ret;
   tree ret_expr = TREE_OPERAND (stmt, 0);
   tree result_decl, result;
 
@@ -1173,7 +1173,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p)
       || TREE_CODE (ret_expr) == RESULT_DECL
       || ret_expr == error_mark_node)
     {
-      gimple ret = gimple_build_return (ret_expr);
+      gimple_return ret = gimple_build_return (ret_expr);
       gimple_set_no_warning (ret, TREE_NO_WARNING (stmt));
       gimplify_seq_add_stmt (pre_p, ret);
       return GS_ALL_DONE;
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index dbcc787..e5d1368 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1465,7 +1465,7 @@ split_function (struct split_point *split_point)
 	 */
       else
 	{
-	  gimple ret;
+	  gimple_return ret;
 	  if (split_point->split_part_set_retval
 	      && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
 	    {
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 8168d97..1bfed7d 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4187,7 +4187,7 @@ verify_gimple_assign (gimple_assign stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_return (gimple stmt)
+verify_gimple_return (gimple_return stmt)
 {
   tree op = gimple_return_retval (stmt);
   tree restype = TREE_TYPE (TREE_TYPE (cfun->decl));
@@ -4435,7 +4435,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_switch (stmt->as_a_gimple_switch ());
 
     case GIMPLE_RETURN:
-      return verify_gimple_return (stmt);
+      return verify_gimple_return (stmt->as_a_gimple_return ());
 
     case GIMPLE_ASM:
       return false;
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 71e3c3b..e89f9ba 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -737,7 +737,8 @@ static void
 adjust_return_value (basic_block bb, tree m, tree a)
 {
   tree retval;
-  gimple ret_stmt = gimple_seq_last_stmt (bb_seq (bb));
+  gimple_return ret_stmt =
+    gimple_seq_last_stmt (bb_seq (bb))->as_a_gimple_return ();
   gimple_stmt_iterator gsi = gsi_last_bb (bb);
 
   gcc_assert (gimple_code (ret_stmt) == GIMPLE_RETURN);
-- 
1.8.5.3

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

* [PATCH 80/89] Tweak to gimplify_modify_expr
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (38 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 18:21   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 07/89] Introduce gimple_debug and use it in a few places David Malcolm
                   ` (51 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimplify.c (gimplify_modify_expr): Introduce local "call_stmt".
---
 gcc/gimplify.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 031834b..d43304e 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4567,22 +4567,24 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
       CALL_EXPR_FN (*from_p) = TREE_OPERAND (CALL_EXPR_FN (*from_p), 0);
       STRIP_USELESS_TYPE_CONVERSION (CALL_EXPR_FN (*from_p));
       tree fndecl = get_callee_fndecl (*from_p);
+      gimple_call call_stmt;
       if (fndecl
 	  && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 	  && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
 	  && call_expr_nargs (*from_p) == 3)
-	assign = gimple_build_call_internal (IFN_BUILTIN_EXPECT, 3,
-					     CALL_EXPR_ARG (*from_p, 0),
-					     CALL_EXPR_ARG (*from_p, 1),
-					     CALL_EXPR_ARG (*from_p, 2));
+	call_stmt = gimple_build_call_internal (IFN_BUILTIN_EXPECT, 3,
+						CALL_EXPR_ARG (*from_p, 0),
+						CALL_EXPR_ARG (*from_p, 1),
+						CALL_EXPR_ARG (*from_p, 2));
       else
 	{
-	  assign = gimple_build_call_from_tree (*from_p);
-	  gimple_call_set_fntype (assign, TREE_TYPE (fnptrtype));
+	  call_stmt = gimple_build_call_from_tree (*from_p);
+	  gimple_call_set_fntype (call_stmt, TREE_TYPE (fnptrtype));
 	}
-      notice_special_calls (assign->as_a_gimple_call ());
-      if (!gimple_call_noreturn_p (assign))
-	gimple_call_set_lhs (assign, *to_p);
+      notice_special_calls (call_stmt);
+      if (!gimple_call_noreturn_p (call_stmt))
+	gimple_call_set_lhs (call_stmt, *to_p);
+      assign = call_stmt;
     }
   else
     {
-- 
1.8.5.3

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

* [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi.
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (27 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:21   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 21/89] Introduce gimple_return David Malcolm
                   ` (62 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_arg_location): Require a gimple_phi.

	* tree-into-ssa.c (rewrite_update_phi_arguments): Replace a check
	for code GIMPLE_PHI with a dyn_cast and a new local.
	* tree-ssa-ter.c (ter_is_replaceable_p): Likewise.

	* tree-ssa-live.c (remove_unused_locals): Replace a
	gimple_stmt_iterator with a gimple_phi_iterator, using it to make
	local "phi" be a gimple_phi.
	* tree-ssa-phiopt.c (tree_ssa_phiopt_worker): Likewise.

	* tree-ssa-phiopt.c (conditional_replacement): Require a gimple_phi.
	(single_non_singleton_phi_for_edges): Return a gimple_phi; update
	local to be a gimple_phi, adding checked casts since we're working
	on a sequence of gimple_phi.
	(conditional_replacement): Require a gimple_phi.
---
 gcc/gimple.h          |  6 +++---
 gcc/tree-into-ssa.c   |  7 ++++---
 gcc/tree-ssa-live.c   |  6 ++++--
 gcc/tree-ssa-phiopt.c | 17 +++++++++--------
 gcc/tree-ssa-ter.c    |  4 ++--
 5 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index becd273..db3f425 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4250,12 +4250,12 @@ gimple_phi_arg_edge (gimple_phi phi, size_t i)
   return EDGE_PRED (gimple_bb (phi), i);
 }
 
-/* Return the source location of gimple argument I of phi node GS.  */
+/* Return the source location of gimple argument I of phi node PHI.  */
 
 static inline source_location
-gimple_phi_arg_location (gimple gs, size_t i)
+gimple_phi_arg_location (gimple_phi phi, size_t i)
 {
-  return gimple_phi_arg (gs, i)->locus;
+  return gimple_phi_arg (phi, i)->locus;
 }
 
 /* Return the source location of the argument on edge E of phi node PHI.  */
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 217adeb..47f6832 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2044,12 +2044,13 @@ rewrite_update_phi_arguments (basic_block bb)
 	      else
 		{
 		  gimple stmt = SSA_NAME_DEF_STMT (reaching_def);
+		  gimple_phi other_phi = stmt->dyn_cast_gimple_phi ();
 
 		  /* Single element PHI nodes  behave like copies, so get the
 		     location from the phi argument.  */
-		  if (gimple_code (stmt) == GIMPLE_PHI
-		      && gimple_phi_num_args (stmt) == 1)
-		    locus = gimple_phi_arg_location (stmt, 0);
+		  if (other_phi
+		      && gimple_phi_num_args (other_phi) == 1)
+		    locus = gimple_phi_arg_location (other_phi, 0);
 		  else
 		    locus = gimple_location (stmt);
 		}
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 3223a71..3274552 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -821,12 +821,14 @@ remove_unused_locals (void)
 	    mark_all_vars_used (gimple_op_ptr (gsi_stmt (gsi), i));
 	}
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+	   !gsi_end_p (gpi);
+	   gsi_next (&gpi))
         {
           use_operand_p arg_p;
           ssa_op_iter i;
 	  tree def;
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gpi.phi ();
 
 	  if (virtual_operand_p (gimple_phi_result (phi)))
 	    continue;
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index b8ed719..6fa68cd 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -62,7 +62,7 @@ along with GCC; see the file COPYING3.  If not see
 static unsigned int tree_ssa_phiopt (void);
 static unsigned int tree_ssa_phiopt_worker (bool, bool);
 static bool conditional_replacement (basic_block, basic_block,
-				     edge, edge, gimple, tree, tree);
+				     edge, edge, gimple_phi, tree, tree);
 static int value_replacement (basic_block, basic_block,
 			      edge, edge, gimple, tree, tree);
 static bool minmax_replacement (basic_block, basic_block,
@@ -294,16 +294,16 @@ tree_ssa_cs_elim (void)
 
 /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
 
-static gimple
+static gimple_phi
 single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1)
 {
   gimple_stmt_iterator i;
-  gimple phi = NULL;
+  gimple_phi phi = NULL;
   if (gimple_seq_singleton_p (seq))
-    return gsi_stmt (gsi_start (seq));
+    return gsi_stmt (gsi_start (seq))->as_a_gimple_phi ();
   for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
     {
-      gimple p = gsi_stmt (i);
+      gimple_phi p = gsi_stmt (i)->as_a_gimple_phi ();
       /* If the PHI arguments are equal then we can skip this PHI. */
       if (operand_equal_for_phi_arg_p (gimple_phi_arg_def (p, e0->dest_idx),
 				       gimple_phi_arg_def (p, e1->dest_idx)))
@@ -367,7 +367,8 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
 
   for (i = 0; i < n; i++)
     {
-      gimple cond_stmt, phi;
+      gimple cond_stmt;
+      gimple_phi phi;
       basic_block bb1, bb2;
       edge e1, e2;
       tree arg0, arg1;
@@ -478,7 +479,7 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads)
 	     so try that first. */
 	  for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      phi = gsi_stmt (gsi);
+	      phi = gsi_stmt (gsi)->as_a_gimple_phi ();
 	      arg0 = gimple_phi_arg_def (phi, e1->dest_idx);
 	      arg1 = gimple_phi_arg_def (phi, e2->dest_idx);
 	      if (value_replacement (bb, bb1, e1, e2, phi, arg0, arg1) == 2)
@@ -589,7 +590,7 @@ replace_phi_edge_with_variable (basic_block cond_block,
 
 static bool
 conditional_replacement (basic_block cond_bb, basic_block middle_bb,
-			 edge e0, edge e1, gimple phi,
+			 edge e0, edge e1, gimple_phi phi,
 			 tree arg0, tree arg1)
 {
   tree result;
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 09dc313..3c8c531 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -428,8 +428,8 @@ ter_is_replaceable_p (gimple stmt)
       block1 = LOCATION_BLOCK (locus1);
       locus1 = LOCATION_LOCUS (locus1);
 
-      if (gimple_code (use_stmt) == GIMPLE_PHI)
-	locus2 = gimple_phi_arg_location (use_stmt, 
+      if (gimple_phi phi = use_stmt->dyn_cast_gimple_phi ())
+	locus2 = gimple_phi_arg_location (phi,
 					  PHI_ARG_INDEX_FROM_USE (use_p));
       else
 	locus2 = gimple_location (use_stmt);
-- 
1.8.5.3

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

* [PATCH 88/89] Use gimple_phi in many more places.
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (25 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 20:38   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr David Malcolm
                   ` (64 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

This patch converts almost every usage of gsi_start_phis to act on a
gimple_phi_iterator: everywhere (I believe) where the underlying
statements are then accessed via a gimple_phi_ accessor.

There are some places where the phi nodes then just go through
generic gimple APIs; in these cases I didn't bother converting
the iterators.

gcc/
	* gimple-ssa-strength-reduction.c (slsr_process_phi): Require a
	gimple_phi.
	* ipa-inline-analysis.c (predicate_for_phi_result): Likewise.
	* tree-emutls.c (lower_emutls_phi_arg): Likewise.
	* tree-if-conv.c (predicate_scalar_phi): Likewise.
	* tree-into-ssa.c (mark_virtual_phi_result_for_renaming): Likewise.
	* tree-into-ssa.h (mark_virtual_phi_result_for_renaming): Likewise.
	* tree-phinodes.c (degenerate_phi_result): Likewise.
	* tree-phinodes.h (degenerate_phi_result): Likewise.
	* tree-ssa.c (verify_use): Likewise.
	* tree-switch-conversion.c (array_value_type): Likewise.

	* graphite-scop-detection.c (same_close_phi_node): Require a pair
	of gimple_phi.
	(remove_duplicate_close_phi): Require a gimple_phi and a
	gimple_phi_iterator.
	(make_close_phi_nodes_unique): Convert a local into a
	gimple_phi_iterator.

	* gimple-pretty-print.c (gimple_dump_bb_for_graph): Split iterator
	into gimple_stmt_iterator and gimple_phi_iterator, converting local
	from gimple to gimple_phi.
	* gimple-ssa-strength-reduction.c
	(find_candidates_dom_walker::before_dom_children): Likewise.
	* ipa-inline-analysis.c (estimate_function_body_sizes): Likewise.
	* ipa-split.c (verify_non_ssa_vars): Likewise.
	(visit_bb): Likewise.
	(split_function): Likewise.
	* lto-streamer-out.c (output_function): Likewise.
	* sese.c (sese_build_liveouts_bb): Likewise.
	* tree-cfg.c (gimple_can_merge_blocks_p): Likewise.
	* tree-complex.c (init_dont_simulate_again): Likewise.
	* tree-dfa.c (collect_dfa_stats): Likewise.
	* tree-eh.c (sink_clobbers): Likewise.
	* tree-emutls.c (lower_emutls_function_body): Likewise.
	* tree-into-ssa.c (rewrite_dom_walker::before_dom_children):
	Likewise.
	(rewrite_update_dom_walker::before_dom_children): Likewise.
	(prepare_block_for_update): Likewise.
	* tree-loop-distribution.c (stmts_from_loop): Likewise.
	(generate_loops_for_partition): Likewise.
	(destroy_loop): Likewise.
	(tree_loop_distribution): Likewise.
	* tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise.
	* tree-ssa-copy.c (init_copy_prop): Likewise.
	* tree-ssa-copyrename.c (rename_ssa_copies): Likewise.
	* tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): Likewise.
	* tree-ssa-loop-manip.c (find_uses_to_rename_bb): Likewise.
	(verify_loop_closed_ssa): Likewise.
	* tree-ssa-math-opts.c (execute_cse_reciprocals): Likewise.
	* tree-ssa-pre.c (compute_avail): Likewise.
	(eliminate_dom_walker::before_dom_children): Likewise.
	* tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Likewise.
	* tree-ssa-structalias.c (compute_points_to_sets): Likewise.
	(ipa_pta_execute): Likewise.
	* tree-ssa-tail-merge.c (same_succ_hash): Likewise.
	(release_last_vdef): Likewise.
	* tree-ssa.c (verify_ssa): Likewise.
	(execute_update_addresses_taken): Likewise.
	* tree-stdarg.c (check_all_va_list_escapes): Likewise.
	(execute_optimize_stdarg): Likewise.
	* tree-switch-conversion.c (build_arrays): Likewise.
	* tree-vect-loop-manip.c (rename_variables_in_bb): Likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
	(vect_analyze_loop_operations): Likewise.
	(vect_transform_loop): Likewise.
	* tree-vrp.c (find_assert_locations_1): Likewise.
	(vrp_initialize): Likewise.

	* graphite-sese-to-poly.c (gsi_for_phi_node): Convert psi to a
	gimple_phi_iterator.
	(rewrite_degenerate_phi): Require a gimple_phi_iterator; strengthen
	local "phi" from gimple to gimple-phi.

	* ipa-split.c (consider_split): Convert local psi to a
	gimple_phi_iterator.
	* tree-cfg.c (gimple_merge_blocks): Likewise.

	* tree-eh.c (unsplit_eh): Replace reuse of gsi with a new
	gimple_phi_iterator gpi, using it to convert statement from gimple
	to a gimple_phi.
	(cleanup_empty_eh_merge_phis): Strengthen ophi from gimple to
	gimple_phi.
	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace reuse of
	gsi with a new gimple_phi_iterator gpi, using it to convert
	expressions from gimple to gimple_phi; add a checked cast to
	gimple_phi.

	* tree-if-conv.c (predicate_all_scalar_phis): Convert local phi_gsi
	to be a gimple_phi_iterator; convert "phi" to be a gimple_phi.
	* tree-parloops.c (loop_has_vector_phi_nodes): Convert local to be a
	gimple_phi_iterator.
	* tree-ssa-ccp.c (ccp_initialize): Likewise.

	* tree-scalar-evolution.c (analyze_initial_condition): Add checked cast
	to a gimple_phi.
	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
	* tree-ssa-dom.c (get_rhs_or_phi_arg): Likewise.
---
 gcc/gimple-pretty-print.c           | 10 ++++----
 gcc/gimple-ssa-strength-reduction.c | 11 +++++----
 gcc/graphite-scop-detection.c       | 16 ++++++-------
 gcc/graphite-sese-to-poly.c         |  6 ++---
 gcc/ipa-inline-analysis.c           | 11 +++++----
 gcc/ipa-split.c                     | 47 ++++++++++++++++++++----------------
 gcc/lto-streamer-out.c              | 15 ++++++------
 gcc/sese.c                          |  9 +++----
 gcc/tree-cfg.c                      | 12 ++++++----
 gcc/tree-complex.c                  | 10 ++++----
 gcc/tree-dfa.c                      | 10 ++++----
 gcc/tree-eh.c                       | 18 +++++++-------
 gcc/tree-emutls.c                   | 11 +++++----
 gcc/tree-if-conv.c                  |  9 +++----
 gcc/tree-into-ssa.c                 | 28 ++++++++++++----------
 gcc/tree-into-ssa.h                 |  2 +-
 gcc/tree-loop-distribution.c        | 48 ++++++++++++++++++++-----------------
 gcc/tree-parloops.c                 |  4 ++--
 gcc/tree-phinodes.c                 |  2 +-
 gcc/tree-phinodes.h                 |  2 +-
 gcc/tree-scalar-evolution.c         |  2 +-
 gcc/tree-ssa-ccp.c                  |  4 ++--
 gcc/tree-ssa-coalesce.c             | 10 ++++----
 gcc/tree-ssa-copy.c                 |  9 +++----
 gcc/tree-ssa-copyrename.c           | 12 +++++-----
 gcc/tree-ssa-dce.c                  | 10 ++++----
 gcc/tree-ssa-dom.c                  |  2 +-
 gcc/tree-ssa-loop-ivcanon.c         |  8 +++----
 gcc/tree-ssa-loop-manip.c           | 19 ++++++++-------
 gcc/tree-ssa-math-opts.c            | 13 +++++-----
 gcc/tree-ssa-pre.c                  | 22 ++++++++---------
 gcc/tree-ssa-strlen.c               | 13 +++++-----
 gcc/tree-ssa-structalias.c          | 19 +++++++--------
 gcc/tree-ssa-tail-merge.c           | 19 ++++++++-------
 gcc/tree-ssa.c                      | 24 +++++++++----------
 gcc/tree-stdarg.c                   | 19 +++++++--------
 gcc/tree-switch-conversion.c        |  9 +++----
 gcc/tree-vect-loop-manip.c          |  9 +++----
 gcc/tree-vect-loop.c                | 34 +++++++++++++-------------
 gcc/tree-vrp.c                      | 19 ++++++++-------
 40 files changed, 294 insertions(+), 263 deletions(-)

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 887093f..60d34fe 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2492,14 +2492,13 @@ gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
 void
 gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
 {
-  gimple_stmt_iterator gsi;
-
   pp_printf (pp, "<bb %d>:\n", bb->index);
   pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
 
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       if (!virtual_operand_p (gimple_phi_result (phi))
 	  || (dump_flags & TDF_VOPS))
 	{
@@ -2512,7 +2511,8 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
 	}
     }
 
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       gimple stmt = gsi_stmt (gsi);
       pp_bar (pp);
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index f5bfc19..13d259f 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -746,7 +746,7 @@ add_cand_for_stmt (gimple gs, slsr_cand_t c)
    is used to help find a basis for subsequent candidates.  */
 
 static void
-slsr_process_phi (gimple phi, bool speed)
+slsr_process_phi (gimple_phi phi, bool speed)
 {
   unsigned i;
   tree arg0_base = NULL_TREE, base_type;
@@ -1674,12 +1674,13 @@ void
 find_candidates_dom_walker::before_dom_children (basic_block bb)
 {
   bool speed = optimize_bb_for_speed_p (bb);
-  gimple_stmt_iterator gsi;
 
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-    slsr_process_phi (gsi_stmt (gsi), speed);
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
+    slsr_process_phi (gsi.phi (), speed);
 
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       gimple gs = gsi_stmt (gsi);
 
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index af04dd0..747f0c7 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1233,7 +1233,7 @@ limit_scops (vec<scop_p> *scops)
    argument.  */
 
 static inline bool
-same_close_phi_node (gimple p1, gimple p2)
+same_close_phi_node (gimple_phi p1, gimple_phi p2)
 {
   return operand_equal_p (gimple_phi_arg_def (p1, 0),
 			  gimple_phi_arg_def (p2, 0), 0);
@@ -1243,15 +1243,15 @@ same_close_phi_node (gimple p1, gimple p2)
    of PHI.  */
 
 static void
-remove_duplicate_close_phi (gimple phi, gimple_stmt_iterator *gsi)
+remove_duplicate_close_phi (gimple_phi phi, gimple_phi_iterator *gsi)
 {
   gimple use_stmt;
   use_operand_p use_p;
   imm_use_iterator imm_iter;
   tree res = gimple_phi_result (phi);
-  tree def = gimple_phi_result (gsi_stmt (*gsi));
+  tree def = gimple_phi_result (gsi->phi ());
 
-  gcc_assert (same_close_phi_node (phi, gsi_stmt (*gsi)));
+  gcc_assert (same_close_phi_node (phi, gsi->phi ()));
 
   FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
     {
@@ -1276,12 +1276,12 @@ remove_duplicate_close_phi (gimple phi, gimple_stmt_iterator *gsi)
 static void
 make_close_phi_nodes_unique (basic_block bb)
 {
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
     {
-      gimple_stmt_iterator gsi = psi;
-      gimple phi = gsi_stmt (psi);
+      gimple_phi_iterator gsi = psi;
+      gimple_phi phi = psi.phi ();
 
       /* At this point, PHI should be a close phi in normal form.  */
       gcc_assert (gimple_phi_num_args (phi) == 1);
@@ -1289,7 +1289,7 @@ make_close_phi_nodes_unique (basic_block bb)
       /* Iterate over the next phis and remove duplicates.  */
       gsi_next (&gsi);
       while (!gsi_end_p (gsi))
-	if (same_close_phi_node (phi, gsi_stmt (gsi)))
+	if (same_close_phi_node (phi, gsi.phi ()))
 	  remove_duplicate_close_phi (phi, &gsi);
 	else
 	  gsi_next (&gsi);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 11ea1d3..78d5915 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1939,7 +1939,7 @@ gsi_for_phi_node (gimple_phi stmt)
   basic_block bb = gimple_bb (stmt);
 
   for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
-    if (stmt == gsi_stmt (psi))
+    if (stmt == psi.phi ())
       return psi;
 
   gcc_unreachable ();
@@ -2267,12 +2267,12 @@ rewrite_phi_out_of_ssa (scop_p scop, gimple_phi_iterator *psi)
    form "x = phi (y, y, ..., y)" to "x = y".  */
 
 static void
-rewrite_degenerate_phi (gimple_stmt_iterator *psi)
+rewrite_degenerate_phi (gimple_phi_iterator *psi)
 {
   tree rhs;
   gimple stmt;
   gimple_stmt_iterator gsi;
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   tree res = gimple_phi_result (phi);
   basic_block bb;
 
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 29242e0..ccd3811 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2258,7 +2258,7 @@ phi_result_unknown_predicate (struct ipa_node_params *info,
    NONCONSTANT_NAMES, if possible.  */
 
 static void
-predicate_for_phi_result (struct inline_summary *summary, gimple phi,
+predicate_for_phi_result (struct inline_summary *summary, gimple_phi phi,
 			  struct predicate *p,
 			  vec<predicate_t> nonconstant_names)
 {
@@ -2441,7 +2441,6 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
   /* Benefits are scaled by probability of elimination that is in range
      <0,2>.  */
   basic_block bb;
-  gimple_stmt_iterator bsi;
   struct function *my_function = DECL_STRUCT_FUNCTION (node->decl);
   int freq;
   struct inline_summary *info = inline_summary (node);
@@ -2522,7 +2521,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
 	  struct predicate phi_predicate;
 	  bool first_phi = true;
 
-	  for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	  for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+	       gsi_next (&bsi))
 	    {
 	      if (first_phi
 		  && !phi_result_unknown_predicate (parms_info, info, bb,
@@ -2535,14 +2535,15 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
 		  fprintf (dump_file, "  ");
 		  print_gimple_stmt (dump_file, gsi_stmt (bsi), 0, 0);
 		}
-	      predicate_for_phi_result (info, gsi_stmt (bsi), &phi_predicate,
+	      predicate_for_phi_result (info, bsi.phi (), &phi_predicate,
 					nonconstant_names);
 	    }
 	}
 
       fix_builtin_expect_stmt = find_foldable_builtin_expect (bb);
 
-      for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	{
 	  gimple stmt = gsi_stmt (bsi);
 	  int this_size = estimate_num_insns (stmt, &eni_size_weights);
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 0808f9c..2788289 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -224,7 +224,6 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
 
   while (!worklist.is_empty ())
     {
-      gimple_stmt_iterator bsi;
       basic_block bb = worklist.pop ();
 
       FOR_EACH_EDGE (e, ei, bb->preds)
@@ -235,7 +234,8 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
 					        e->src->index));
 	    worklist.safe_push (e->src);
 	  }
-      for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	{
 	  gimple stmt = gsi_stmt (bsi);
 	  if (is_gimple_debug (stmt))
@@ -257,7 +257,8 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
 		}
 	    }
 	}
-      for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	{
 	  if (walk_stmt_load_store_addr_ops
 	      (gsi_stmt (bsi), non_ssa_vars, test_nonssa_use, test_nonssa_use,
@@ -271,10 +272,11 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
 	{
 	  if (e->dest != return_bb)
 	    continue;
-	  for (bsi = gsi_start_phis (return_bb); !gsi_end_p (bsi);
+	  for (gimple_phi_iterator bsi = gsi_start_phis (return_bb);
+	       !gsi_end_p (bsi);
 	       gsi_next (&bsi))
 	    {
-	      gimple stmt = gsi_stmt (bsi);
+	      gimple_phi stmt = bsi.phi ();
 	      tree op = gimple_phi_arg_def (stmt, e->dest_idx);
 
 	      if (virtual_operand_p (gimple_phi_result (stmt)))
@@ -594,15 +596,15 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
      for the return value.  If there are other PHIs, give up.  */
   if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
     {
-      gimple_stmt_iterator psi;
+      gimple_phi_iterator psi;
 
       for (psi = gsi_start_phis (return_bb); !gsi_end_p (psi); gsi_next (&psi))
-	if (!virtual_operand_p (gimple_phi_result (gsi_stmt (psi)))
+	if (!virtual_operand_p (gimple_phi_result (psi.phi ()))
 	    && !(retval
 		 && current->split_part_set_retval
 		 && TREE_CODE (retval) == SSA_NAME
 		 && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl))
-		 && SSA_NAME_DEF_STMT (retval) == gsi_stmt (psi)))
+		 && SSA_NAME_DEF_STMT (retval) == psi.phi ()))
 	  {
 	    if (dump_file && (dump_flags & TDF_DETAILS))
 	      fprintf (dump_file,
@@ -769,12 +771,12 @@ visit_bb (basic_block bb, basic_block return_bb,
 	  bitmap set_ssa_names, bitmap used_ssa_names,
 	  bitmap non_ssa_vars)
 {
-  gimple_stmt_iterator bsi;
   edge e;
   edge_iterator ei;
   bool can_split = true;
 
-  for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+  for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+       gsi_next (&bsi))
     {
       gimple stmt = gsi_stmt (bsi);
       tree op;
@@ -843,9 +845,10 @@ visit_bb (basic_block bb, basic_block return_bb,
 						   mark_nonssa_use,
 						   mark_nonssa_use);
     }
-  for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+  for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+       gsi_next (&bsi))
     {
-      gimple stmt = gsi_stmt (bsi);
+      gimple_phi stmt = bsi.phi ();
       unsigned int i;
 
       if (virtual_operand_p (gimple_phi_result (stmt)))
@@ -867,9 +870,11 @@ visit_bb (basic_block bb, basic_block return_bb,
   FOR_EACH_EDGE (e, ei, bb->succs)
     if (e->dest == return_bb)
       {
-	for (bsi = gsi_start_phis (return_bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	for (gimple_phi_iterator bsi = gsi_start_phis (return_bb);
+	     !gsi_end_p (bsi);
+	     gsi_next (&bsi))
 	  {
-	    gimple stmt = gsi_stmt (bsi);
+	    gimple_phi stmt = bsi.phi ();
 	    tree op = gimple_phi_arg_def (stmt, e->dest_idx);
 
 	    if (virtual_operand_p (gimple_phi_result (stmt)))
@@ -1093,7 +1098,6 @@ split_function (struct split_point *split_point)
   struct cgraph_node *node, *cur_node = cgraph_get_node (current_function_decl);
   basic_block return_bb = find_return_bb ();
   basic_block call_bb;
-  gimple_stmt_iterator gsi;
   gimple_call call;
   edge e;
   edge_iterator ei;
@@ -1197,9 +1201,10 @@ split_function (struct split_point *split_point)
   if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
     {
       bool phi_p = false;
-      for (gsi = gsi_start_phis (return_bb); !gsi_end_p (gsi);)
+      for (gimple_phi_iterator gsi = gsi_start_phis (return_bb);
+	   !gsi_end_p (gsi);)
 	{
-	  gimple stmt = gsi_stmt (gsi);
+	  gimple_phi stmt = gsi.phi ();
 	  if (!virtual_operand_p (gimple_phi_result (stmt)))
 	    {
 	      gsi_next (&gsi);
@@ -1218,7 +1223,9 @@ split_function (struct split_point *split_point)
          entry of the SESE region as the vuse of the call and the reaching
 	 vdef of the exit of the SESE region as the vdef of the call.  */
       if (!phi_p)
-	for (gsi = gsi_start_bb (return_bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	for (gimple_stmt_iterator gsi = gsi_start_bb (return_bb);
+	     !gsi_end_p (gsi);
+	     gsi_next (&gsi))
 	  {
 	    gimple stmt = gsi_stmt (gsi);
 	    if (gimple_vuse (stmt))
@@ -1264,7 +1271,7 @@ split_function (struct split_point *split_point)
   /* Create the basic block we place call into.  It is the entry basic block
      split after last label.  */
   call_bb = split_point->entry_bb;
-  for (gsi = gsi_start_bb (call_bb); !gsi_end_p (gsi);)
+  for (gimple_stmt_iterator gsi = gsi_start_bb (call_bb); !gsi_end_p (gsi);)
     if (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
       {
 	last_stmt = gsi_stmt (gsi);
@@ -1276,7 +1283,7 @@ split_function (struct split_point *split_point)
   remove_edge (e);
 
   /* Produce the call statement.  */
-  gsi = gsi_last_bb (call_bb);
+  gimple_stmt_iterator gsi = gsi_last_bb (call_bb);
   FOR_EACH_VEC_ELT (args_to_pass, i, arg)
     if (!is_gimple_val (arg))
       {
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 0f37f1c..158d830 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1861,16 +1861,17 @@ output_function (struct cgraph_node *node)
       set_gimple_stmt_max_uid (cfun, 0);
       FOR_ALL_BB_FN (bb, cfun)
 	{
-	  gimple_stmt_iterator gsi;
-	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
-	      gimple stmt = gsi_stmt (gsi);
+	      gimple_phi stmt = gsi.phi ();
 
 	      /* Virtual PHIs are not going to be streamed.  */
 	      if (!virtual_operand_p (gimple_phi_result (stmt)))
 	        gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
 	    }
-	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
 	      gimple stmt = gsi_stmt (gsi);
 	      gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
@@ -1880,10 +1881,10 @@ output_function (struct cgraph_node *node)
 	 virtual phis now.  */
       FOR_ALL_BB_FN (bb, cfun)
 	{
-	  gimple_stmt_iterator gsi;
-	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
-	      gimple stmt = gsi_stmt (gsi);
+	      gimple_phi stmt = gsi.phi ();
 	      if (virtual_operand_p (gimple_phi_result (stmt)))
 	        gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
 	    }
diff --git a/gcc/sese.c b/gcc/sese.c
index f146238..976f5cc 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -214,18 +214,19 @@ sese_build_liveouts_use (sese region, bitmap liveouts, basic_block bb,
 static void
 sese_build_liveouts_bb (sese region, bitmap liveouts, basic_block bb)
 {
-  gimple_stmt_iterator bsi;
   edge e;
   edge_iterator ei;
   ssa_op_iter iter;
   use_operand_p use_p;
 
   FOR_EACH_EDGE (e, ei, bb->succs)
-    for (bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); gsi_next (&bsi))
+    for (gimple_phi_iterator bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi);
+	 gsi_next (&bsi))
       sese_build_liveouts_use (region, liveouts, bb,
-			       PHI_ARG_DEF_FROM_EDGE (gsi_stmt (bsi), e));
+			       PHI_ARG_DEF_FROM_EDGE (bsi.phi (), e));
 
-  for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+  for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+       gsi_next (&bsi))
     {
       gimple stmt = gsi_stmt (bsi);
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 355c4ac..187fa570 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1599,7 +1599,6 @@ static bool
 gimple_can_merge_blocks_p (basic_block a, basic_block b)
 {
   gimple stmt;
-  gimple_stmt_iterator gsi;
 
   if (!single_succ_p (a))
     return false;
@@ -1629,7 +1628,8 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
 	return false;
 
   /* Examine the labels at the beginning of B.  */
-  for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (b); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       tree lab;
       gimple_label label_stmt = gsi_stmt (gsi)->dyn_cast_gimple_label ();
@@ -1649,9 +1649,10 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
   /* It must be possible to eliminate all phi nodes in B.  If ssa form
      is not up-to-date and a name-mapping is registered, we cannot eliminate
      any phis.  Symbols marked for renaming are never a problem though.  */
-  for (gsi = gsi_start_phis (b); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       /* Technically only new names matter.  */
       if (name_registered_for_update_p (PHI_RESULT (phi)))
 	return false;
@@ -1763,7 +1764,8 @@ replace_uses_by (tree name, tree val)
 static void
 gimple_merge_blocks (basic_block a, basic_block b)
 {
-  gimple_stmt_iterator last, gsi, psi;
+  gimple_stmt_iterator last, gsi;
+  gimple_phi_iterator psi;
 
   if (dump_file)
     fprintf (dump_file, "Merging blocks %d and %d\n", a->index, b->index);
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 425fcbe..e29973b 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -203,20 +203,20 @@ static bool
 init_dont_simulate_again (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
-  gimple phi;
   bool saw_a_complex_op = false;
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  prop_set_simulate_again (phi,
 				   is_complex_reg (gimple_phi_result (phi)));
 	}
 
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  gimple stmt;
 	  tree op0, op1;
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index fcf8d80..8f11dac 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -281,18 +281,18 @@ collect_dfa_stats (struct dfa_stats_d *dfa_stats_p ATTRIBUTE_UNUSED)
   /* Walk all the statements in the function counting references.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator si;
-
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
-	  gimple phi = gsi_stmt (si);
+	  gimple_phi phi = si.phi ();
 	  dfa_stats_p->num_phis++;
 	  dfa_stats_p->num_phi_args += gimple_phi_num_args (phi);
 	  if (gimple_phi_num_args (phi) > dfa_stats_p->max_num_phi_args)
 	    dfa_stats_p->max_num_phi_args = gimple_phi_num_args (phi);
 	}
 
-      for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
 	  gimple stmt = gsi_stmt (si);
 	  dfa_stats_p->num_defs += NUM_SSA_OPERANDS (stmt, SSA_OP_DEF);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 5e4eef8..6bfd973 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3523,14 +3523,15 @@ sink_clobbers (basic_block bb)
 
   /* See if there is a virtual PHI node to take an updated virtual
      operand from.  */
-  gimple vphi = NULL;
+  gimple_phi vphi = NULL;
   tree vuse = NULL_TREE;
-  for (gsi = gsi_start_phis (succbb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gpi = gsi_start_phis (succbb);
+       !gsi_end_p (gpi); gsi_next (&gpi))
     {
-      tree res = gimple_phi_result (gsi_stmt (gsi));
+      tree res = gimple_phi_result (gpi.phi ());
       if (virtual_operand_p (res))
 	{
-	  vphi = gsi_stmt (gsi);
+	  vphi = gpi.phi ();
 	  vuse = res;
 	  break;
 	}
@@ -4094,9 +4095,10 @@ unsplit_eh (eh_landing_pad lp)
      that doesn't appear to handle virtuals.  Propagate by hand.  */
   if (!gimple_seq_empty_p (phi_nodes (bb)))
     {
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); )
 	{
-	  gimple use_stmt, phi = gsi_stmt (gsi);
+	  gimple use_stmt;
+	  gimple_phi phi = gpi.phi ();
 	  tree lhs = gimple_phi_result (phi);
 	  tree rhs = gimple_phi_arg_def (phi, 0);
 	  use_operand_p use_p;
@@ -4111,7 +4113,7 @@ unsplit_eh (eh_landing_pad lp)
 	  if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
 	    SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs) = 1;
 
-	  remove_phi_node (&gsi, true);
+	  remove_phi_node (&gpi, true);
 	}
     }
 
@@ -4254,7 +4256,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
      we don't know what values from the other edges into NEW_BB to use.  */
   for (ogsi = gsi_start_phis (old_bb); !gsi_end_p (ogsi); gsi_next (&ogsi))
     {
-      gimple ophi = gsi_stmt (ogsi);
+      gimple_phi ophi = ogsi.phi ();
       tree oresult = gimple_phi_result (ophi);
       if (!bitmap_bit_p (ophi_handled, SSA_NAME_VERSION (oresult)))
 	goto fail;
diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
index 993eaf7..76ff411 100644
--- a/gcc/tree-emutls.c
+++ b/gcc/tree-emutls.c
@@ -588,7 +588,8 @@ lower_emutls_stmt (gimple stmt, struct lower_emutls_data *d)
 /* Lower the I'th operand of PHI.  */
 
 static void
-lower_emutls_phi_arg (gimple phi, unsigned int i, struct lower_emutls_data *d)
+lower_emutls_phi_arg (gimple_phi phi, unsigned int i,
+		      struct lower_emutls_data *d)
 {
   struct walk_stmt_info wi;
   struct phi_arg_d *pd = gimple_phi_arg (phi, i);
@@ -640,7 +641,6 @@ lower_emutls_function_body (struct cgraph_node *node)
 
   FOR_EACH_BB_FN (d.bb, cfun)
     {
-      gimple_stmt_iterator gsi;
       unsigned int i, nedge;
 
       /* Lower each of the PHI nodes of the block, as we may have 
@@ -662,10 +662,10 @@ lower_emutls_function_body (struct cgraph_node *node)
 	      clear_access_vars ();
 	      d.seq = NULL;
 
-	      for (gsi = gsi_start_phis (d.bb);
+	      for (gimple_phi_iterator gsi = gsi_start_phis (d.bb);
 		   !gsi_end_p (gsi);
 		   gsi_next (&gsi))
-		lower_emutls_phi_arg (gsi_stmt (gsi), i, &d);
+		lower_emutls_phi_arg (gsi.phi (), i, &d);
 
 	      /* Insert all statements generated by all phi nodes for this
 		 particular edge all at once.  */
@@ -683,7 +683,8 @@ lower_emutls_function_body (struct cgraph_node *node)
       clear_access_vars ();
 
       /* Lower each of the statements of the block.  */
-      for (gsi = gsi_start_bb (d.bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (d.bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
           d.seq = NULL;
 	  lower_emutls_stmt (gsi_stmt (gsi), &d);
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 6fe69ae..9fefc2c 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1400,7 +1400,7 @@ find_phi_replacement_condition (basic_block bb, tree *cond,
    TRUE_BB is selected.  */
 
 static void
-predicate_scalar_phi (gimple phi, tree cond,
+predicate_scalar_phi (gimple_phi phi, tree cond,
 		      basic_block true_bb,
 		      gimple_stmt_iterator *gsi)
 {
@@ -1468,9 +1468,10 @@ predicate_all_scalar_phis (struct loop *loop)
 
   for (i = 1; i < orig_loop_num_nodes; i++)
     {
-      gimple phi;
+      gimple_phi phi;
       tree cond = NULL_TREE;
-      gimple_stmt_iterator gsi, phi_gsi;
+      gimple_stmt_iterator gsi;
+      gimple_phi_iterator phi_gsi;
       basic_block true_bb = NULL;
       bb = ifc_bbs[i];
 
@@ -1488,7 +1489,7 @@ predicate_all_scalar_phis (struct loop *loop)
 
       while (!gsi_end_p (phi_gsi))
 	{
-	  phi = gsi_stmt (phi_gsi);
+	  phi = phi_gsi.phi ();
 	  predicate_scalar_phi (phi, cond, true_bb, &gsi);
 	  release_phi_node (phi);
 	  gsi_next (&phi_gsi);
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 47f6832..c7f841d 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1433,8 +1433,6 @@ public:
 void
 rewrite_dom_walker::before_dom_children (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
-
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index);
 
@@ -1444,7 +1442,8 @@ rewrite_dom_walker::before_dom_children (basic_block bb)
   /* Step 1.  Register new definitions for every PHI node in the block.
      Conceptually, all the PHI nodes are executed in parallel and each PHI
      node introduces a new version for the associated variable.  */
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       tree result = gimple_phi_result (gsi_stmt (gsi));
       register_new_def (result, SSA_NAME_VAR (result));
@@ -1454,7 +1453,8 @@ rewrite_dom_walker::before_dom_children (basic_block bb)
      with its immediate reaching definitions.  Update the current definition
      of a variable when a new real or virtual definition is found.  */
   if (bitmap_bit_p (interesting_blocks, bb->index))
-    for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+    for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	 gsi_next (&gsi))
       rewrite_stmt (&gsi);
 
   /* Step 3.  Visit all the successor blocks of BB looking for PHI nodes.
@@ -2083,7 +2083,6 @@ void
 rewrite_update_dom_walker::before_dom_children (basic_block bb)
 {
   bool is_abnormal_phi;
-  gimple_stmt_iterator gsi;
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "Registering new PHI nodes in block #%d\n",
@@ -2104,10 +2103,11 @@ rewrite_update_dom_walker::before_dom_children (basic_block bb)
      register it as a new definition for its corresponding name.  Also
      register definitions for names whose underlying symbols are
      marked for renaming.  */
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       tree lhs, lhs_sym;
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       if (!register_defs_p (phi))
 	continue;
@@ -2139,7 +2139,8 @@ rewrite_update_dom_walker::before_dom_children (basic_block bb)
   if (bitmap_bit_p (interesting_blocks, bb->index))
     {
       gcc_checking_assert (bitmap_bit_p (blocks_to_update, bb->index));
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
         rewrite_update_stmt (gsi_stmt (gsi), gsi);
     }
 
@@ -2499,7 +2500,6 @@ static void
 prepare_block_for_update (basic_block bb, bool insert_phi_p)
 {
   basic_block son;
-  gimple_stmt_iterator si;
   edge e;
   edge_iterator ei;
 
@@ -2507,9 +2507,10 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p)
 
   /* Process PHI nodes marking interesting those that define or use
      the symbols that we are interested in.  */
-  for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+  for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+       gsi_next (&si))
     {
-      gimple phi = gsi_stmt (si);
+      gimple_phi phi = si.phi ();
       tree lhs_sym, lhs = gimple_phi_result (phi);
 
       if (TREE_CODE (lhs) == SSA_NAME
@@ -2533,7 +2534,8 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p)
     }
 
   /* Process the statements.  */
-  for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+  for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+       gsi_next (&si))
     {
       gimple stmt;
       ssa_op_iter i;
@@ -2912,7 +2914,7 @@ mark_virtual_operand_for_renaming (tree name)
    removed.  */
 
 void
-mark_virtual_phi_result_for_renaming (gimple phi)
+mark_virtual_phi_result_for_renaming (gimple_phi phi)
 {
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
diff --git a/gcc/tree-into-ssa.h b/gcc/tree-into-ssa.h
index 977f6e7..8d82074 100644
--- a/gcc/tree-into-ssa.h
+++ b/gcc/tree-into-ssa.h
@@ -26,7 +26,7 @@ void delete_update_ssa (void);
 tree create_new_def_for (tree, gimple, def_operand_p);
 void mark_virtual_operands_for_renaming (struct function *);
 void mark_virtual_operand_for_renaming (tree);
-void mark_virtual_phi_result_for_renaming (gimple);
+void mark_virtual_phi_result_for_renaming (gimple_phi);
 bool need_ssa_update_p (struct function *);
 bool name_registered_for_update_p (tree);
 void release_ssa_name_after_update_ssa (tree);
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 2d25277..6834e46 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -393,16 +393,16 @@ stmts_from_loop (struct loop *loop, vec<gimple> *stmts)
   for (i = 0; i < loop->num_nodes; i++)
     {
       basic_block bb = bbs[i];
-      gimple_stmt_iterator bsi;
-      gimple stmt;
 
-      for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
-	if (!virtual_operand_p (gimple_phi_result (gsi_stmt (bsi))))
-	  stmts->safe_push (gsi_stmt (bsi));
+      for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
+	if (!virtual_operand_p (gimple_phi_result (bsi.phi ())))
+	  stmts->safe_push (bsi.phi ());
 
-      for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	{
-	  stmt = gsi_stmt (bsi);
+	  gimple stmt = gsi_stmt (bsi);
 	  if (gimple_code (stmt) != GIMPLE_LABEL && !is_gimple_debug (stmt))
 	    stmts->safe_push (stmt);
 	}
@@ -620,7 +620,6 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 			      bool copy_p)
 {
   unsigned i;
-  gimple_stmt_iterator bsi;
   basic_block *bbs;
 
   if (copy_p)
@@ -639,15 +638,16 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
       {
 	basic_block bb = bbs[i];
 
-	for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+	     gsi_next (&bsi))
 	  {
-	    gimple phi = gsi_stmt (bsi);
+	    gimple_phi phi = bsi.phi ();
 	    if (!virtual_operand_p (gimple_phi_result (phi))
 		&& !bitmap_bit_p (partition->stmts, gimple_uid (phi)))
 	      reset_debug_uses (phi);
 	  }
 
-	for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	  {
 	    gimple stmt = gsi_stmt (bsi);
 	    if (gimple_code (stmt) != GIMPLE_LABEL
@@ -661,9 +661,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
     {
       basic_block bb = bbs[i];
 
-      for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi);)
+      for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);)
 	{
-	  gimple phi = gsi_stmt (bsi);
+	  gimple_phi phi = bsi.phi ();
 	  if (!virtual_operand_p (gimple_phi_result (phi))
 	      && !bitmap_bit_p (partition->stmts, gimple_uid (phi)))
 	    remove_phi_node (&bsi, true);
@@ -671,7 +671,7 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 	    gsi_next (&bsi);
 	}
 
-      for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi);)
+      for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);)
 	{
 	  gimple stmt = gsi_stmt (bsi);
 	  if (gimple_code (stmt) != GIMPLE_LABEL
@@ -902,14 +902,15 @@ destroy_loop (struct loop *loop)
 	 Make sure we replace all uses of virtual defs that will remain
 	 outside of the loop with the bare symbol as delete_basic_block
 	 will release them.  */
-      gimple_stmt_iterator gsi;
-      for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  if (virtual_operand_p (gimple_phi_result (phi)))
 	    mark_virtual_phi_result_for_renaming (phi);
 	}
-      for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  gimple stmt = gsi_stmt (gsi);
 	  tree vdef = gimple_vdef (stmt);
@@ -1709,10 +1710,11 @@ tree_loop_distribution (void)
       bbs = get_loop_body_in_dom_order (loop);
       for (i = 0; i < loop->num_nodes; ++i)
 	{
-	  gimple_stmt_iterator gsi;
-	  for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gsi = gsi_start_phis (bbs[i]);
+	       !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      if (virtual_operand_p (gimple_phi_result (phi)))
 		continue;
 	      /* Distribute stmts which have defs that are used outside of
@@ -1721,7 +1723,9 @@ tree_loop_distribution (void)
 		continue;
 	      work_list.safe_push (phi);
 	    }
-	  for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]);
+	       !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
 	      gimple stmt = gsi_stmt (gsi);
 
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 521e050..ddd7d66 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1939,12 +1939,12 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED)
 {
   unsigned i;
   basic_block *bbs = get_loop_body_in_dom_order (loop);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   bool res = true;
 
   for (i = 0; i < loop->num_nodes; i++)
     for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
-      if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi_stmt (gsi)))) == VECTOR_TYPE)
+      if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi.phi ()))) == VECTOR_TYPE)
 	goto end;
 
   res = false;
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 5594cd4..06ce540 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -479,7 +479,7 @@ remove_phi_nodes (basic_block bb)
    NULL.  */
 
 tree
-degenerate_phi_result (gimple phi)
+degenerate_phi_result (gimple_phi phi)
 {
   tree lhs = gimple_phi_result (phi);
   tree val = NULL;
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index dcde99e..0ff7fda 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -29,7 +29,7 @@ extern void add_phi_arg (gimple_phi, tree, edge, source_location);
 extern void remove_phi_args (edge);
 extern void remove_phi_node (gimple_stmt_iterator *, bool);
 extern void remove_phi_nodes (basic_block);
-extern tree degenerate_phi_result (gimple);
+extern tree degenerate_phi_result (gimple_phi);
 extern void set_phi_nodes (basic_block, gimple_seq);
 
 static inline use_operand_p
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 998c06c..4fa3709 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -1599,7 +1599,7 @@ analyze_initial_condition (gimple_phi loop_phi_node)
       gimple def = SSA_NAME_DEF_STMT (init_cond);
       tree res;
       if (gimple_code (def) == GIMPLE_PHI
-	  && (res = degenerate_phi_result (def)) != NULL_TREE
+	  && (res = degenerate_phi_result (def->as_a_gimple_phi ())) != NULL_TREE
 	  /* Only allow invariants here, otherwise we may break
 	     loop-closed SSA form.  */
 	  && is_gimple_min_invariant (res))
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index c79d981..484996a 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -815,11 +815,11 @@ ccp_initialize (void)
      except for phi nodes for virtual operands when we do not do store ccp.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator i;
+      gimple_phi_iterator i;
 
       for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
         {
-          gimple phi = gsi_stmt (i);
+          gimple_phi phi = i.phi ();
 
 	  if (virtual_operand_p (gimple_phi_result (phi)))
             prop_set_simulate_again (phi, false);
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index cd4f5a1..ee076bd 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -823,12 +823,11 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
-
       /* Start with live on exit temporaries.  */
       live_track_init (live, live_on_exit (liveinfo, bb));
 
-      for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_last_bb (bb); !gsi_end_p (gsi);
+	   gsi_prev (&gsi))
         {
 	  tree var;
 	  gimple stmt = gsi_stmt (gsi);
@@ -865,9 +864,10 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo)
 	 There must be a conflict recorded between the result of the PHI and
 	 any variables that are live.  Otherwise the out-of-ssa translation
 	 may create incorrect code.  */
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree result = PHI_RESULT (phi);
 	  if (live_track_live_p (live, result))
 	    live_track_process_def (live, result, graph);
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 0892126..1ff296b 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -471,10 +471,10 @@ init_copy_prop (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator si;
       int depth = bb_loop_depth (bb);
 
-      for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
 	  gimple stmt = gsi_stmt (si);
 	  ssa_op_iter iter;
@@ -509,9 +509,10 @@ init_copy_prop (void)
 	      set_copy_of_val (def, def);
 	}
 
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
-          gimple phi = gsi_stmt (si);
+          gimple_phi phi = si.phi ();
           tree def;
 
 	  def = gimple_phi_result (phi);
diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c
index bc947b6..2608123 100644
--- a/gcc/tree-ssa-copyrename.c
+++ b/gcc/tree-ssa-copyrename.c
@@ -310,9 +310,8 @@ rename_ssa_copies (void)
 {
   var_map map;
   basic_block bb;
-  gimple_stmt_iterator gsi;
   tree var, part_var;
-  gimple stmt, phi;
+  gimple stmt;
   unsigned x;
   FILE *debug;
 
@@ -328,7 +327,8 @@ rename_ssa_copies (void)
   FOR_EACH_BB_FN (bb, cfun)
     {
       /* Scan for real copies.  */
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  stmt = gsi_stmt (gsi);
 	  if (gimple_assign_ssa_name_copy_p (stmt))
@@ -344,12 +344,12 @@ rename_ssa_copies (void)
   FOR_EACH_BB_FN (bb, cfun)
     {
       /* Treat PHI nodes as copies between the result and each argument.  */
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
         {
           size_t i;
 	  tree res;
-
-	  phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  res = gimple_phi_result (phi);
 
 	  /* Do not process virtual SSA_NAMES.  */
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 907db1a..9609faf 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1273,13 +1273,15 @@ eliminate_unnecessary_stmts (void)
 	  if (!bitmap_bit_p (bb_contains_live_stmts, bb->index)
 	      || !(bb->flags & BB_REACHABLE))
 	    {
-	      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-		if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
+	      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+		   gsi_next (&gsi))
+		if (virtual_operand_p (gimple_phi_result (gsi.phi ())))
 		  {
 		    bool found = false;
 		    imm_use_iterator iter;
 
-		    FOR_EACH_IMM_USE_STMT (stmt, iter, gimple_phi_result (gsi_stmt (gsi)))
+		    FOR_EACH_IMM_USE_STMT (stmt, iter,
+					   gimple_phi_result (gsi.phi ()))
 		      {
 			if (!(gimple_bb (stmt)->flags & BB_REACHABLE))
 			  continue;
@@ -1291,7 +1293,7 @@ eliminate_unnecessary_stmts (void)
 			  }
 		      }
 		    if (found)
-		      mark_virtual_phi_result_for_renaming (gsi_stmt (gsi));
+		      mark_virtual_phi_result_for_renaming (gsi.phi ());
 		  }
 
 	      if (!(bb->flags & BB_REACHABLE))
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 82e937e..a0ee43b 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -2660,7 +2660,7 @@ static tree
 get_rhs_or_phi_arg (gimple stmt)
 {
   if (gimple_code (stmt) == GIMPLE_PHI)
-    return degenerate_phi_result (stmt);
+    return degenerate_phi_result (stmt->as_a_gimple_phi ());
   else if (gimple_assign_single_p (stmt))
     return gimple_assign_rhs1 (stmt);
   else
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index c0087e3..19029f4 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1068,12 +1068,10 @@ propagate_into_all_uses (tree ssa_name, tree val)
 static void
 propagate_constants_for_unrolling (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
-
   /* Look for degenerate PHI nodes with constant argument.  */
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree result = gimple_phi_result (phi);
       tree arg = gimple_phi_arg_def (phi, 0);
 
@@ -1088,7 +1086,7 @@ propagate_constants_for_unrolling (basic_block bb)
     }
 
   /* Look for assignments to SSA names with constant RHS.  */
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
     {
       gimple stmt = gsi_stmt (gsi);
       tree lhs;
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index fe63700..6ab7a64 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -431,20 +431,21 @@ find_uses_to_rename_stmt (gimple stmt, bitmap *use_blocks, bitmap need_phis)
 static void
 find_uses_to_rename_bb (basic_block bb, bitmap *use_blocks, bitmap need_phis)
 {
-  gimple_stmt_iterator bsi;
   edge e;
   edge_iterator ei;
 
   FOR_EACH_EDGE (e, ei, bb->succs)
-    for (bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); gsi_next (&bsi))
+    for (gimple_phi_iterator bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi);
+	 gsi_next (&bsi))
       {
-        gimple phi = gsi_stmt (bsi);
+        gimple_phi phi = bsi.phi ();
 	if (! virtual_operand_p (gimple_phi_result (phi)))
 	  find_uses_to_rename_use (bb, PHI_ARG_DEF_FROM_EDGE (phi, e),
 				   use_blocks, need_phis);
       }
 
-  for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+  for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+       gsi_next (&bsi))
     find_uses_to_rename_stmt (gsi_stmt (bsi), use_blocks, need_phis);
 }
 
@@ -590,8 +591,6 @@ DEBUG_FUNCTION void
 verify_loop_closed_ssa (bool verify_ssa_p)
 {
   basic_block bb;
-  gimple_stmt_iterator bsi;
-  gimple phi;
   edge e;
   edge_iterator ei;
 
@@ -605,15 +604,17 @@ verify_loop_closed_ssa (bool verify_ssa_p)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	{
-	  phi = gsi_stmt (bsi);
+	  gimple_phi phi = bsi.phi ();
 	  FOR_EACH_EDGE (e, ei, bb->preds)
 	    check_loop_closed_ssa_use (e->src,
 				       PHI_ARG_DEF_FROM_EDGE (phi, e));
 	}
 
-      for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);
+	   gsi_next (&bsi))
 	check_loop_closed_ssa_stmt (bb, gsi_stmt (bsi));
     }
 
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 8102768..a557a75 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -542,20 +542,20 @@ execute_cse_reciprocals (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
-      gimple phi;
       tree def;
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  def = PHI_RESULT (phi);
 	  if (! virtual_operand_p (def)
 	      && FLOAT_TYPE_P (TREE_TYPE (def)))
 	    execute_cse_reciprocals_1 (NULL, def);
 	}
 
-      for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_after_labels (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
         {
 	  gimple stmt = gsi_stmt (gsi);
 
@@ -570,7 +570,8 @@ execute_cse_reciprocals (void)
         continue;
 
       /* Scan for a/func(b) and convert it to reciprocal a*rfunc(b).  */
-      for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_after_labels (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
         {
 	  gimple stmt = gsi_stmt (gsi);
 	  tree fndecl;
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index b8047a4..e90184a 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3741,7 +3741,6 @@ compute_avail (void)
   /* Loop until the worklist is empty.  */
   while (sp)
     {
-      gimple_stmt_iterator gsi;
       gimple stmt;
       basic_block dom;
 
@@ -3755,9 +3754,10 @@ compute_avail (void)
 	bitmap_set_copy (AVAIL_OUT (block), AVAIL_OUT (dom));
 
       /* Generate values for PHI nodes.  */
-      for (gsi = gsi_start_phis (block); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (block); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  tree result = gimple_phi_result (gsi_stmt (gsi));
+	  tree result = gimple_phi_result (gsi.phi ());
 
 	  /* We have no need for virtual phis, as they don't represent
 	     actual computations.  */
@@ -3774,7 +3774,8 @@ compute_avail (void)
 
       /* Now compute value numbers and populate value sets with all
 	 the expressions computed in BLOCK.  */
-      for (gsi = gsi_start_bb (block); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (block); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  ssa_op_iter iter;
 	  tree op;
@@ -4069,15 +4070,13 @@ public:
 void
 eliminate_dom_walker::before_dom_children (basic_block b)
 {
-  gimple_stmt_iterator gsi;
-  gimple stmt;
-
   /* Mark new bb.  */
   el_avail_stack.safe_push (NULL_TREE);
 
-  for (gsi = gsi_start_phis (b); !gsi_end_p (gsi);)
+  for (gimple_phi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi);)
     {
-      gimple stmt, phi = gsi_stmt (gsi);
+      gimple stmt;
+      gimple_phi phi = gsi.phi ();
       tree sprime = NULL_TREE, res = PHI_RESULT (phi);
       gimple_stmt_iterator gsi2;
 
@@ -4139,12 +4138,13 @@ eliminate_dom_walker::before_dom_children (basic_block b)
 	pre_stats.eliminations++;
     }
 
-  for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (b); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       tree lhs = NULL_TREE;
       tree rhs = NULL_TREE;
 
-      stmt = gsi_stmt (gsi);
+      gimple stmt = gsi_stmt (gsi);
 
       if (gimple_has_lhs (stmt))
 	lhs = gimple_get_lhs (stmt);
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index f55b7ee..4a381e4 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -1958,7 +1958,6 @@ public:
 void
 strlen_dom_walker::before_dom_children (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
   basic_block dombb = get_immediate_dominator (CDI_DOMINATORS, bb);
 
   if (dombb == NULL)
@@ -1968,9 +1967,10 @@ strlen_dom_walker::before_dom_children (basic_block bb)
       stridx_to_strinfo = ((vec<strinfo, va_heap, vl_embed> *) dombb->aux);
       if (stridx_to_strinfo)
 	{
-	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      if (virtual_operand_p (gimple_phi_result (phi)))
 		{
 		  bitmap visited = BITMAP_ALLOC (NULL);
@@ -2007,9 +2007,10 @@ strlen_dom_walker::before_dom_children (basic_block bb)
 
   /* If all PHI arguments have the same string index, the PHI result
      has it as well.  */
-  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree result = gimple_phi_result (phi);
       if (!virtual_operand_p (result) && POINTER_TYPE_P (TREE_TYPE (result)))
 	{
@@ -2027,7 +2028,7 @@ strlen_dom_walker::before_dom_children (basic_block bb)
     }
 
   /* Attempt to optimize individual statements.  */
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
     if (strlen_optimize_stmt (&gsi))
       gsi_next (&gsi);
 
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index fa77c30..22eab13 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -6810,17 +6810,17 @@ compute_points_to_sets (void)
   /* Now walk all statements and build the constraint set.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
-
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 
 	  if (! virtual_operand_p (gimple_phi_result (phi)))
 	    find_func_aliases (phi);
 	}
 
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  gimple stmt = gsi_stmt (gsi);
 
@@ -7218,18 +7218,17 @@ ipa_pta_execute (void)
       /* Build constriants for the function body.  */
       FOR_EACH_BB_FN (bb, func)
 	{
-	  gimple_stmt_iterator gsi;
-
-	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	  for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 
 	      if (! virtual_operand_p (gimple_phi_result (phi)))
 		find_func_aliases (phi);
 	    }
 
-	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	       gsi_next (&gsi))
 	    {
 	      gimple stmt = gsi_stmt (gsi);
 
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 7727cdf..b6d677c 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -456,13 +456,12 @@ same_succ_hash (const_same_succ e)
   unsigned int first = bitmap_first_set_bit (e->bbs);
   basic_block bb = BASIC_BLOCK_FOR_FN (cfun, first);
   int size = 0;
-  gimple_stmt_iterator gsi;
   gimple stmt;
   tree arg;
   unsigned int s;
   bitmap_iterator bs;
 
-  for (gsi = gsi_start_nondebug_bb (bb);
+  for (gimple_stmt_iterator gsi = gsi_start_nondebug_bb (bb);
        !gsi_end_p (gsi); gsi_next_nondebug (&gsi))
     {
       stmt = gsi_stmt (gsi);
@@ -503,10 +502,12 @@ same_succ_hash (const_same_succ e)
   EXECUTE_IF_SET_IN_BITMAP (e->succs, 0, s, bs)
     {
       int n = find_edge (bb, BASIC_BLOCK_FOR_FN (cfun, s))->dest_idx;
-      for (gsi = gsi_start_phis (BASIC_BLOCK_FOR_FN (cfun, s)); !gsi_end_p (gsi);
+      for (gimple_phi_iterator gsi =
+	     gsi_start_phis (BASIC_BLOCK_FOR_FN (cfun, s));
+	   !gsi_end_p (gsi);
 	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree lhs = gimple_phi_result (phi);
 	  tree val = gimple_phi_arg_def (phi, n);
 
@@ -842,9 +843,8 @@ same_succ_flush_bbs (bitmap bbs)
 static void
 release_last_vdef (basic_block bb)
 {
-  gimple_stmt_iterator i;
-
-  for (i = gsi_last_bb (bb); !gsi_end_p (i); gsi_prev_nondebug (&i))
+  for (gimple_stmt_iterator i = gsi_last_bb (bb); !gsi_end_p (i);
+       gsi_prev_nondebug (&i))
     {
       gimple stmt = gsi_stmt (i);
       if (gimple_vdef (stmt) == NULL_TREE)
@@ -854,9 +854,10 @@ release_last_vdef (basic_block bb)
       return;
     }
 
-  for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
+  for (gimple_phi_iterator i = gsi_start_phis (bb); !gsi_end_p (i);
+       gsi_next (&i))
     {
-      gimple phi = gsi_stmt (i);
+      gimple_phi phi = i.phi ();
       tree res = gimple_phi_result (phi);
 
       if (!virtual_operand_p (res))
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index bbf042c..8713f89 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -399,7 +399,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
      we'll have to drop debug information.  */
   if (gimple_code (def_stmt) == GIMPLE_PHI)
     {
-      value = degenerate_phi_result (def_stmt);
+      value = degenerate_phi_result (def_stmt->as_a_gimple_phi ());
       if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL))
 	value = NULL;
       /* error_mark_node is what fixup_noreturn_call changes PHI arguments
@@ -871,7 +871,7 @@ verify_use (basic_block bb, basic_block def_bb, use_operand_p use_p,
       definition of SSA_NAME.  */
 
 static bool
-verify_phi_args (gimple phi, basic_block bb, basic_block *definition_block)
+verify_phi_args (gimple_phi phi, basic_block bb, basic_block *definition_block)
 {
   edge e;
   bool err = false;
@@ -1002,9 +1002,7 @@ verify_ssa (bool check_modified_stmt)
   FOR_EACH_BB_FN (bb, cfun)
     {
       edge e;
-      gimple phi;
       edge_iterator ei;
-      gimple_stmt_iterator gsi;
 
       /* Make sure that all edges have a clear 'aux' field.  */
       FOR_EACH_EDGE (e, ei, bb->preds)
@@ -1018,9 +1016,9 @@ verify_ssa (bool check_modified_stmt)
 	}
 
       /* Verify the arguments for every PHI node in the block.  */
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  if (verify_phi_args (phi, bb, definition_block))
 	    goto err;
 
@@ -1029,7 +1027,8 @@ verify_ssa (bool check_modified_stmt)
 	}
 
       /* Now verify all the uses and vuses in every statement of the block.  */
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  gimple stmt = gsi_stmt (gsi);
 	  use_operand_p use_p;
@@ -1444,7 +1443,6 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs,
 void
 execute_update_addresses_taken (void)
 {
-  gimple_stmt_iterator gsi;
   basic_block bb;
   bitmap addresses_taken = BITMAP_ALLOC (NULL);
   bitmap not_reg_needs = BITMAP_ALLOC (NULL);
@@ -1458,7 +1456,8 @@ execute_update_addresses_taken (void)
      the function body.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  gimple stmt = gsi_stmt (gsi);
 	  enum gimple_code code = gimple_code (stmt);
@@ -1528,10 +1527,11 @@ execute_update_addresses_taken (void)
 	    }
 	}
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
 	{
 	  size_t i;
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 
 	  for (i = 0; i < gimple_phi_num_args (phi); i++)
 	    {
@@ -1560,7 +1560,7 @@ execute_update_addresses_taken (void)
   if (!bitmap_empty_p (suitable_for_renaming))
     {
       FOR_EACH_BB_FN (bb, cfun)
-	for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
+	for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
 	  {
 	    gimple stmt = gsi_stmt (gsi);
 
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index feb6ece..f1e097c 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -538,14 +538,13 @@ check_all_va_list_escapes (struct stdarg_info *si)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator i;
-
-      for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
+      for (gimple_phi_iterator i = gsi_start_phis (bb); !gsi_end_p (i);
+	   gsi_next (&i))
 	{
 	  tree lhs;
 	  use_operand_p uop;
 	  ssa_op_iter soi;
-	  gimple phi = gsi_stmt (i);
+	  gimple_phi phi = i.phi ();
 
 	  lhs = PHI_RESULT (phi);
 	  if (virtual_operand_p (lhs)
@@ -571,7 +570,8 @@ check_all_va_list_escapes (struct stdarg_info *si)
 	    }
 	}
 
-      for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
+      for (gimple_stmt_iterator i = gsi_start_bb (bb); !gsi_end_p (i);
+	   gsi_next (&i))
 	{
 	  gimple stmt = gsi_stmt (i);
 	  tree use;
@@ -815,8 +815,6 @@ execute_optimize_stdarg (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator i;
-
       si.compute_sizes = -1;
       si.bb = bb;
 
@@ -830,9 +828,10 @@ execute_optimize_stdarg (void)
 	  use_operand_p uop;
 	  ssa_op_iter soi;
 
-	  for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
+	  for (gimple_phi_iterator i = gsi_start_phis (bb); !gsi_end_p (i);
+	       gsi_next (&i))
 	    {
-	      gimple phi = gsi_stmt (i);
+	      gimple_phi phi = i.phi ();
 	      lhs = PHI_RESULT (phi);
 
 	      if (virtual_operand_p (lhs))
@@ -862,7 +861,7 @@ execute_optimize_stdarg (void)
 	    }
 	}
 
-      for (i = gsi_start_bb (bb);
+      for (gimple_stmt_iterator i = gsi_start_bb (bb);
 	   !gsi_end_p (i) && !va_list_escapes;
 	   gsi_next (&i))
 	{
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index e84d0b5..f7b2dcb 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1026,7 +1026,7 @@ array_value_type (gimple_switch swtch, tree type, int num,
 
 static void
 build_one_array (gimple_switch swtch, int num, tree arr_index_type,
-		 gimple phi, tree tidx, struct switch_conv_info *info)
+		 gimple_phi phi, tree tidx, struct switch_conv_info *info)
 {
   tree name, cst;
   gimple load;
@@ -1097,6 +1097,7 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info)
   tree tidx, sub, utype;
   gimple stmt;
   gimple_stmt_iterator gsi;
+  gimple_phi_iterator gpi;
   int i;
   location_t loc = gimple_location (swtch);
 
@@ -1122,9 +1123,9 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info)
   update_stmt (stmt);
   info->arr_ref_first = stmt;
 
-  for (gsi = gsi_start_phis (info->final_bb), i = 0;
-       !gsi_end_p (gsi); gsi_next (&gsi), i++)
-    build_one_array (swtch, i, arr_index_type, gsi_stmt (gsi), tidx, info);
+  for (gpi = gsi_start_phis (info->final_bb), i = 0;
+       !gsi_end_p (gpi); gsi_next (&gpi), i++)
+    build_one_array (swtch, i, arr_index_type, gpi.phi (), tidx, info);
 }
 
 /* Generates and appropriately inserts loads of default values at the position
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 686bc57..cd54377 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -85,7 +85,6 @@ rename_use_op (use_operand_p op_p)
 static void
 rename_variables_in_bb (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
   gimple stmt;
   use_operand_p use_p;
   ssa_op_iter iter;
@@ -93,7 +92,8 @@ rename_variables_in_bb (basic_block bb)
   edge_iterator ei;
   struct loop *loop = bb->loop_father;
 
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       stmt = gsi_stmt (gsi);
       FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
@@ -104,8 +104,9 @@ rename_variables_in_bb (basic_block bb)
     {
       if (!flow_bb_inside_loop_p (loop, e->src))
 	continue;
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-        rename_use_op (PHI_ARG_DEF_PTR_FROM_EDGE (gsi_stmt (gsi), e));
+      for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+	   gsi_next (&gsi))
+        rename_use_op (PHI_ARG_DEF_PTR_FROM_EDGE (gsi.phi (), e));
     }
 }
 
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 27627e4..3823c12 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -187,10 +187,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
   int nbbs = loop->num_nodes;
-  gimple_stmt_iterator si;
   unsigned int vectorization_factor = 0;
   tree scalar_type;
-  gimple phi;
+  gimple_phi phi;
   tree vectype;
   unsigned int nunits;
   stmt_vec_info stmt_info;
@@ -209,9 +208,10 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
     {
       basic_block bb = bbs[i];
 
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
-	  phi = gsi_stmt (si);
+	  phi = si.phi ();
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (dump_enabled_p ())
 	    {
@@ -269,7 +269,8 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
 	    }
 	}
 
-      for (si = gsi_start_bb (bb); !gsi_end_p (si) || analyze_pattern_stmt;)
+      for (gimple_stmt_iterator si = gsi_start_bb (bb);
+	   !gsi_end_p (si) || analyze_pattern_stmt;)
         {
           tree vf_vectype;
 
@@ -1333,10 +1334,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
   int nbbs = loop->num_nodes;
-  gimple_stmt_iterator si;
   unsigned int vectorization_factor = 0;
   int i;
-  gimple phi;
   stmt_vec_info stmt_info;
   bool need_to_vectorize = false;
   int min_profitable_iters;
@@ -1363,7 +1362,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
       for (i = 0; i < nbbs; i++)
 	{
 	  basic_block bb = bbs[i];
-	  for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+	  for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+	       gsi_next (&si))
 	    {
 	      gimple stmt = gsi_stmt (si);
 	      stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
@@ -1393,9 +1393,10 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
     {
       basic_block bb = bbs[i];
 
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
         {
-          phi = gsi_stmt (si);
+          gimple_phi phi = si.phi ();
           ok = true;
 
           stmt_info = vinfo_for_stmt (phi);
@@ -1498,7 +1499,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
             }
         }
 
-      for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+	   gsi_next (&si))
         {
           gimple stmt = gsi_stmt (si);
 	  if (!gimple_clobber_p (stmt)
@@ -5751,7 +5753,6 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
   int nbbs = loop->num_nodes;
-  gimple_stmt_iterator si;
   int i;
   tree ratio = NULL;
   int vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -5862,11 +5863,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
     {
       basic_block bb = bbs[i];
       stmt_vec_info stmt_info;
-      gimple phi;
 
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
         {
-	  phi = gsi_stmt (si);
+	  gimple_phi phi = si.phi ();
 	  if (dump_enabled_p ())
 	    {
 	      dump_printf_loc (MSG_NOTE, vect_location,
@@ -5900,7 +5901,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	}
 
       pattern_stmt = NULL;
-      for (si = gsi_start_bb (bb); !gsi_end_p (si) || transform_pattern_stmt;)
+      for (gimple_stmt_iterator si = gsi_start_bb (bb);
+	   !gsi_end_p (si) || transform_pattern_stmt;)
 	{
 	  bool is_store;
 
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 5b701a6..5345b9b 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5813,7 +5813,6 @@ find_switch_asserts (basic_block bb, gimple_switch last)
 static bool
 find_assert_locations_1 (basic_block bb, sbitmap live)
 {
-  gimple_stmt_iterator si;
   gimple last;
   bool need_assert;
 
@@ -5837,7 +5836,8 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
 
   /* Traverse all the statements in BB marking used names and looking
      for statements that may infer assertions for their used operands.  */
-  for (si = gsi_last_bb (bb); !gsi_end_p (si); gsi_prev (&si))
+  for (gimple_stmt_iterator si = gsi_last_bb (bb); !gsi_end_p (si);
+       gsi_prev (&si))
     {
       gimple stmt;
       tree op;
@@ -5910,11 +5910,12 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
     }
 
   /* Traverse all PHI nodes in BB, updating live.  */
-  for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+  for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+       gsi_next (&si))
     {
       use_operand_p arg_p;
       ssa_op_iter i;
-      gimple phi = gsi_stmt (si);
+      gimple_phi phi = si.phi ();
       tree res = gimple_phi_result (phi);
 
       if (virtual_operand_p (res))
@@ -6716,11 +6717,10 @@ vrp_initialize (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator si;
-
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+	   gsi_next (&si))
 	{
-	  gimple phi = gsi_stmt (si);
+	  gimple_phi phi = si.phi ();
 	  if (!stmt_interesting_for_vrp (phi))
 	    {
 	      tree lhs = PHI_RESULT (phi);
@@ -6731,7 +6731,8 @@ vrp_initialize (void)
 	    prop_set_simulate_again (phi, true);
 	}
 
-      for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+      for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
+	   gsi_next (&si))
         {
 	  gimple stmt = gsi_stmt (si);
 
-- 
1.8.5.3

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

* [PATCH 25/89] Introduce gimple_catch
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (31 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 73/89] Concretize gimple_cond_{true|false}_label David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-04-21 16:57 ` [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h David Malcolm
                   ` (58 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_catch): New typedef.
	(const_gimple_catch): New typedef.

	* gimple-low.c (lower_try_catch): Add checked cast to gimple_catch.
	(gimple_try_catch_may_fallthru): Likewise.

	* gimple-pretty-print.c (dump_gimple_catch): Require a gimple_catch
	rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_catch within
	GIMPLE_CATCH case of switch statement.

	* gimple-walk.c (walk_gimple_op): Likewise.
	(walk_gimple_stmt): Likewise.

	* gimple.c (gimple_build_catch): Return a gimple_catch rather than
	a plain gimple.
	(gimple_copy): Add checked casts to gimple_catch within
	GIMPLE_CATCH case of switch statement, introducing new locals.

	* gimple.h (gimple_statement_base::as_a_gimple_catch): New
	(gimple_statement_base::dyn_cast_gimple_catch): New.
	(gimple_build_catch): Return a gimple_catch rather than
	a plain gimple.
	(gimple_catch_types_ptr): Require a gimple_catch rather than a
	plain gimple.
	(gimple_catch_handler_ptr): Likewise.
	(gimple_catch_handler): Likewise.
	(gimple_catch_set_types): Likewise.
	(gimple_catch_set_handler): Likewise.

	* omp-low.c (lower_omp_1): Add checked cast to gimple_catch within
	GIMPLE_CATCH case of switch statement.

	* 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_catch): Convert local from gimple to gimple_catch.
	(refactor_eh_r): Add checked cast to gimple_catch within
	GIMPLE_CATCH case of switch statement.

	* tree-inline.c (remap_gimple_stmt): Likewise.
	(estimate_num_insns): Add checked cast to gimple_catch within
	GIMPLE_CATCH case of switch statement, introducing new local.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-low.c          |  7 +++++--
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple-walk.c         |  9 +++++----
 gcc/gimple.c              | 16 ++++++++++------
 gcc/gimple.h              | 40 ++++++++++++++++++++++++----------------
 gcc/omp-low.c             |  2 +-
 gcc/tree-cfg.c            |  5 +++--
 gcc/tree-eh.c             | 14 +++++++++-----
 gcc/tree-inline.c         | 11 ++++++++---
 10 files changed, 71 insertions(+), 41 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 284fcb6..1dd36fb 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -113,6 +113,10 @@ struct gimple_statement_bind;
 typedef struct gimple_statement_bind *gimple_bind;
 typedef const struct gimple_statement_bind *const_gimple_bind;
 
+struct gimple_statement_catch;
+typedef struct gimple_statement_catch *gimple_catch;
+typedef const struct gimple_statement_catch *const_gimple_catch;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 5f19f6e..3fa1c44 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -455,7 +455,9 @@ lower_try_catch (gimple_stmt_iterator *gsi, struct lower_data *data)
       for (; !gsi_end_p (i); gsi_next (&i))
 	{
 	  data->cannot_fallthru = false;
-	  lower_sequence (gimple_catch_handler_ptr (gsi_stmt (i)), data);
+	  lower_sequence (gimple_catch_handler_ptr (
+                            gsi_stmt (i)->as_a_gimple_catch ()),
+			  data);
 	  if (!data->cannot_fallthru)
 	    cannot_fallthru = false;
 	}
@@ -517,7 +519,8 @@ gimple_try_catch_may_fallthru (gimple stmt)
 	 through iff any of the catch bodies falls through.  */
       for (; !gsi_end_p (i); gsi_next (&i))
 	{
-	  if (gimple_seq_may_fallthru (gimple_catch_handler (gsi_stmt (i))))
+	  if (gimple_seq_may_fallthru (gimple_catch_handler (
+				         gsi_stmt (i)->as_a_gimple_catch ())))
 	    return true;
 	}
       return false;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index dfb6459..ec16f13 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -978,7 +978,7 @@ dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_catch (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_catch (pretty_printer *buffer, gimple_catch gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
@@ -2200,7 +2200,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_CATCH:
-      dump_gimple_catch (buffer, gs, spc, flags);
+      dump_gimple_catch (buffer, gs->as_a_gimple_catch (), spc, flags);
       break;
 
     case GIMPLE_EH_FILTER:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 2d987c6..f9b641d 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -278,8 +278,8 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_CATCH:
-      ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi,
-		       pset);
+      ret = walk_tree (gimple_catch_types_ptr (stmt->as_a_gimple_catch ()),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
@@ -551,8 +551,9 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_CATCH:
-      ret = walk_gimple_seq_mod (gimple_catch_handler_ptr (stmt), callback_stmt,
-				 callback_op, wi);
+      ret = walk_gimple_seq_mod (gimple_catch_handler_ptr (
+				   stmt->as_a_gimple_catch ()),
+				 callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 7ee7da1..4bc844b 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -610,10 +610,10 @@ gimple_build_asm_vec (const char *string, vec<tree, va_gc> *inputs,
   TYPES are the catch types.
   HANDLER is the exception handler.  */
 
-gimple
+gimple_catch
 gimple_build_catch (tree types, gimple_seq handler)
 {
-  gimple p = gimple_alloc (GIMPLE_CATCH, 0);
+  gimple_catch p = gimple_alloc (GIMPLE_CATCH, 0)->as_a_gimple_catch ();
   gimple_catch_set_types (p, types);
   if (handler)
     gimple_catch_set_handler (p, handler);
@@ -1642,10 +1642,14 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_CATCH:
-	  new_seq = gimple_seq_copy (gimple_catch_handler (stmt));
-	  gimple_catch_set_handler (copy, new_seq);
-	  t = unshare_expr (gimple_catch_types (stmt));
-	  gimple_catch_set_types (copy, t);
+	  {
+	    gimple_catch catch_stmt = stmt->as_a_gimple_catch ();
+	    gimple_catch catch_copy = copy->as_a_gimple_catch ();
+	    new_seq = gimple_seq_copy (gimple_catch_handler (catch_stmt));
+	    gimple_catch_set_handler (catch_copy, new_seq);
+	    t = unshare_expr (gimple_catch_types (catch_stmt));
+	    gimple_catch_set_types (catch_copy, t);
+	  }
 	  break;
 
 	case GIMPLE_EH_FILTER:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 7cb778d..e12e066 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -288,6 +288,12 @@ public:
     return as_a <gimple_statement_bind> (this);
   }
 
+  inline gimple_catch
+  as_a_gimple_catch ()
+  {
+    return as_a <gimple_statement_catch> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -368,6 +374,12 @@ public:
     return dyn_cast <gimple_statement_bind> (this);
   }
 
+  inline gimple_catch
+  dyn_cast_gimple_catch ()
+  {
+    return dyn_cast <gimple_statement_catch> (this);
+  }
+
   inline gimple_phi
   dyn_cast_gimple_phi ()
   {
@@ -1499,7 +1511,7 @@ gimple_bind gimple_build_bind (tree, gimple_seq, tree);
 gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *);
-gimple gimple_build_catch (tree, gimple_seq);
+gimple_catch gimple_build_catch (tree, gimple_seq);
 gimple gimple_build_eh_filter (tree, gimple_seq);
 gimple gimple_build_eh_must_not_throw (tree);
 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
@@ -3676,53 +3688,49 @@ gimple_catch_types (const_gimple gs)
 }
 
 
-/* Return a pointer to the types handled by GIMPLE_CATCH statement GS.  */
+/* Return a pointer to the types handled by GIMPLE_CATCH statement CATCH_STMT.  */
 
 static inline tree *
-gimple_catch_types_ptr (gimple gs)
+gimple_catch_types_ptr (gimple_catch catch_stmt)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch> (gs);
   return &catch_stmt->types;
 }
 
 
 /* Return a pointer to the GIMPLE sequence representing the body of
-   the handler of GIMPLE_CATCH statement GS.  */
+   the handler of GIMPLE_CATCH statement CATCH_STMT.  */
 
 static inline gimple_seq *
-gimple_catch_handler_ptr (gimple gs)
+gimple_catch_handler_ptr (gimple_catch catch_stmt)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch> (gs);
   return &catch_stmt->handler;
 }
 
 
 /* Return the GIMPLE sequence representing the body of the handler of
-   GIMPLE_CATCH statement GS.  */
+   GIMPLE_CATCH statement CATCH_STMT.  */
 
 static inline gimple_seq
-gimple_catch_handler (gimple gs)
+gimple_catch_handler (gimple_catch catch_stmt)
 {
-  return *gimple_catch_handler_ptr (gs);
+  return *gimple_catch_handler_ptr (catch_stmt);
 }
 
 
-/* Set T to be the set of types handled by GIMPLE_CATCH GS.  */
+/* Set T to be the set of types handled by GIMPLE_CATCH CATCH_STMT.  */
 
 static inline void
-gimple_catch_set_types (gimple gs, tree t)
+gimple_catch_set_types (gimple_catch catch_stmt, tree t)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch> (gs);
   catch_stmt->types = t;
 }
 
 
-/* Set HANDLER to be the body of GIMPLE_CATCH GS.  */
+/* Set HANDLER to be the body of GIMPLE_CATCH CATCH_STMT.  */
 
 static inline void
-gimple_catch_set_handler (gimple gs, gimple_seq handler)
+gimple_catch_set_handler (gimple_catch catch_stmt, gimple_seq handler)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch> (gs);
   catch_stmt->handler = handler;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b1eb22d..8407f0e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10002,7 +10002,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	gimple_regimplify_operands (stmt, gsi_p);
       break;
     case GIMPLE_CATCH:
-      lower_omp (gimple_catch_handler_ptr (stmt), ctx);
+      lower_omp (gimple_catch_handler_ptr (stmt->as_a_gimple_catch ()), ctx);
       break;
     case GIMPLE_EH_FILTER:
       lower_omp (gimple_eh_filter_failure_ptr (stmt), ctx);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a2557e4..c504798 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4569,7 +4569,8 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
 	  break;
 
 	case GIMPLE_CATCH:
-	  err |= verify_gimple_in_seq_2 (gimple_catch_handler (stmt));
+	  err |= verify_gimple_in_seq_2 (gimple_catch_handler (
+					   stmt->as_a_gimple_catch ()));
 	  break;
 
 	case GIMPLE_TRANSACTION:
@@ -8305,7 +8306,7 @@ do_warn_unused_result (gimple_seq seq)
 	  do_warn_unused_result (gimple_try_cleanup (g));
 	  break;
 	case GIMPLE_CATCH:
-	  do_warn_unused_result (gimple_catch_handler (g));
+	  do_warn_unused_result (gimple_catch_handler (g->as_a_gimple_catch ()));
 	  break;
 	case GIMPLE_EH_FILTER:
 	  do_warn_unused_result (gimple_eh_filter_failure (g));
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index c5eda1f..940b565 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -285,7 +285,9 @@ collect_finally_tree (gimple stmt, gimple region)
       break;
 
     case GIMPLE_CATCH:
-      collect_finally_tree_1 (gimple_catch_handler (stmt), region);
+      collect_finally_tree_1 (gimple_catch_handler (
+				 stmt->as_a_gimple_catch ()),
+			      region);
       break;
 
     case GIMPLE_EH_FILTER:
@@ -543,7 +545,9 @@ replace_goto_queue_1 (gimple stmt, struct leh_tf_state *tf,
       replace_goto_queue_stmt_list (gimple_try_cleanup_ptr (stmt), tf);
       break;
     case GIMPLE_CATCH:
-      replace_goto_queue_stmt_list (gimple_catch_handler_ptr (stmt), tf);
+      replace_goto_queue_stmt_list (gimple_catch_handler_ptr (
+				      stmt->as_a_gimple_catch ()),
+				    tf);
       break;
     case GIMPLE_EH_FILTER:
       replace_goto_queue_stmt_list (gimple_eh_filter_failure_ptr (stmt), tf);
@@ -1791,10 +1795,10 @@ lower_catch (struct leh_state *state, gimple tp)
        gsi_next (&gsi))
     {
       eh_catch c;
-      gimple gcatch;
+      gimple_catch gcatch;
       gimple_seq handler;
 
-      gcatch = gsi_stmt (gsi);
+      gcatch = gsi_stmt (gsi)->as_a_gimple_catch ();
       c = gen_eh_region_catch (try_region, gimple_catch_types (gcatch));
 
       handler = gimple_catch_handler (gcatch);
@@ -3091,7 +3095,7 @@ refactor_eh_r (gimple_seq seq)
 	    refactor_eh_r (gimple_try_cleanup (one));
 	    break;
 	  case GIMPLE_CATCH:
-	    refactor_eh_r (gimple_catch_handler (one));
+	    refactor_eh_r (gimple_catch_handler (one->as_a_gimple_catch ()));
 	    break;
 	  case GIMPLE_EH_FILTER:
 	    refactor_eh_r (gimple_eh_filter_failure (one));
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 69d5953..f516113 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1296,8 +1296,11 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_CATCH:
-	  s1 = remap_gimple_seq (gimple_catch_handler (stmt), id);
-	  copy = gimple_build_catch (gimple_catch_types (stmt), s1);
+	  {
+	    gimple_catch catch_stmt = stmt->as_a_gimple_catch ();
+	    s1 = remap_gimple_seq (gimple_catch_handler (catch_stmt), id);
+	    copy = gimple_build_catch (gimple_catch_types (catch_stmt), s1);
+	  }
 	  break;
 
 	case GIMPLE_EH_FILTER:
@@ -3935,7 +3938,9 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       return estimate_num_insns_seq (gimple_eh_filter_failure (stmt), weights);
 
     case GIMPLE_CATCH:
-      return estimate_num_insns_seq (gimple_catch_handler (stmt), weights);
+      return estimate_num_insns_seq (gimple_catch_handler (
+				       stmt->as_a_gimple_catch ()),
+				     weights);
 
     case GIMPLE_TRY:
       return (estimate_num_insns_seq (gimple_try_eval (stmt), weights)
-- 
1.8.5.3

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

* [PATCH 70/89] Concretize locals within expand_omp_for_init_counts
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (29 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 21/89] Introduce gimple_return David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:59   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 73/89] Concretize gimple_cond_{true|false}_label David Malcolm
                   ` (60 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* omp-low.c (expand_omp_for_init_counts): Eliminate local "stmt"
	in favor of new locals "cond_stmt" and "assign_stmt" with more
	concrete types.
---
 gcc/omp-low.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index fd3a545..d5df743 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4940,7 +4940,6 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 			    basic_block &l2_dom_bb)
 {
   tree t, type = TREE_TYPE (fd->loop.v);
-  gimple stmt;
   edge e, ne;
   int i;
 
@@ -4979,6 +4978,7 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 				fold_convert (itype, fd->loops[i].n2)))
 	      == NULL_TREE || !integer_onep (t)))
 	{
+	  gimple_cond cond_stmt;
 	  tree n1, n2;
 	  n1 = fold_convert (itype, unshare_expr (fd->loops[i].n1));
 	  n1 = force_gimple_operand_gsi (gsi, n1, true, NULL_TREE,
@@ -4986,28 +4986,29 @@ expand_omp_for_init_counts (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 	  n2 = fold_convert (itype, unshare_expr (fd->loops[i].n2));
 	  n2 = force_gimple_operand_gsi (gsi, n2, true, NULL_TREE,
 					 true, GSI_SAME_STMT);
-	  stmt = gimple_build_cond (fd->loops[i].cond_code, n1, n2,
-				    NULL_TREE, NULL_TREE);
-	  gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
-	  if (walk_tree (gimple_cond_lhs_ptr (stmt),
+	  cond_stmt = gimple_build_cond (fd->loops[i].cond_code, n1, n2,
+					 NULL_TREE, NULL_TREE);
+	  gsi_insert_before (gsi, cond_stmt, GSI_SAME_STMT);
+	  if (walk_tree (gimple_cond_lhs_ptr (cond_stmt),
 			 expand_omp_regimplify_p, NULL, NULL)
-	      || walk_tree (gimple_cond_rhs_ptr (stmt),
+	      || walk_tree (gimple_cond_rhs_ptr (cond_stmt),
 			    expand_omp_regimplify_p, NULL, NULL))
 	    {
-	      *gsi = gsi_for_stmt (stmt);
-	      gimple_regimplify_operands (stmt, gsi);
+	      *gsi = gsi_for_stmt (cond_stmt);
+	      gimple_regimplify_operands (cond_stmt, gsi);
 	    }
-	  e = split_block (entry_bb, stmt);
+	  e = split_block (entry_bb, cond_stmt);
 	  if (zero_iter_bb == NULL)
 	    {
+	      gimple_assign assign_stmt;
 	      first_zero_iter = i;
 	      zero_iter_bb = create_empty_bb (entry_bb);
 	      if (current_loops)
 		add_bb_to_loop (zero_iter_bb, entry_bb->loop_father);
 	      *gsi = gsi_after_labels (zero_iter_bb);
-	      stmt = gimple_build_assign (fd->loop.n2,
-					  build_zero_cst (type));
-	      gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
+	      assign_stmt = gimple_build_assign (fd->loop.n2,
+						 build_zero_cst (type));
+	      gsi_insert_before (gsi, assign_stmt, GSI_SAME_STMT);
 	      set_immediate_dominator (CDI_DOMINATORS, zero_iter_bb,
 				       entry_bb);
 	    }
-- 
1.8.5.3

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

* [PATCH 78/89] Concretize gimple_call_set_nothrow
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (22 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:59   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 82/89] Concretize gimple_call_set_fntype David Malcolm
                   ` (67 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_set_nothrow): Require a gimple_call.

	* trans-mem.c (ipa_tm_insert_gettmclone_call): Likewise.
	(ipa_tm_transform_calls_redirect): Add checked cast to gimple call; this
	is only called for gsi on a GIMPLE_CALL statement.
---
 gcc/gimple.h    | 3 +--
 gcc/trans-mem.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index accd4e9..f3242c4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3190,9 +3190,8 @@ gimple_call_noreturn_p (gimple s)
    even if the called function can throw in other cases.  */
 
 static inline void
-gimple_call_set_nothrow (gimple s, bool nothrow_p)
+gimple_call_set_nothrow (gimple_call s, bool nothrow_p)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (nothrow_p)
     s->subcode |= GF_CALL_NOTHROW;
   else
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index f3b9a8d..8ec892c 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -5014,7 +5014,7 @@ ipa_tm_insert_irr_call (struct cgraph_node *node, struct tm_region *region,
 static bool
 ipa_tm_insert_gettmclone_call (struct cgraph_node *node,
 			       struct tm_region *region,
-			       gimple_stmt_iterator *gsi, gimple stmt)
+			       gimple_stmt_iterator *gsi, gimple_call stmt)
 {
   tree gettm_fn, ret, old_fn, callfn;
   gimple_call g;
@@ -5111,7 +5111,7 @@ ipa_tm_transform_calls_redirect (struct cgraph_node *node,
 				 gimple_stmt_iterator *gsi,
 				 bool *need_ssa_rename_p)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_call stmt = gsi_stmt (*gsi)->as_a_gimple_call ();
   struct cgraph_node *new_node;
   struct cgraph_edge *e = cgraph_edge (node, stmt);
   tree fndecl = gimple_call_fndecl (stmt);
-- 
1.8.5.3

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

* [PATCH 07/89] Introduce gimple_debug and use it in a few places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (39 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 80/89] Tweak to gimplify_modify_expr David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-09 14:18   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p David Malcolm
                   ` (50 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_debug): New typedef.
	(const_gimple_debug): New typedef.

	* gimple.h (struct gimple_statement_debug): New subclass of
	gimple_statement_with_ops, adding the invariant that
	stmt->code == GIMPLE_DEBUG.
	(gimple_statement_base::as_a_gimple_debug): New.
	(gimple_statement_base::dyn_cast_gimple_debug): New.
	(is_a_helper <gimple_statement_debug>::test): New.

	* gdbhooks.py (build_pretty_printer): Add gimple_debug and its
	variants, using the gimple printer.

	* gimple-pretty-print.c (dump_gimple_debug): Require a gimple_debug
	rather than just a gimple.
	* tree-inline.c (copy_debug_stmt): Likewise.

	* tree-inline.h (struct copy_body_data): Strengthen field
	"debug_stmts" from a vec<gimple> to a vec<gimple_debug>.

	* gimple.c (gimple_build_debug_bind_stat): Return a gimple_debug
	rather than just a gimple.
	(gimple_build_debug_source_bind_stat): Likewise.
	* gimple.h (gimple_build_debug_bind_stat): Likewise.
	(gimple_build_debug_source_bind_stat): Likewise.

	* tree-inline.c (remap_gimple_stmt): Update locals to be a
	gimple_debug.
	(maybe_move_debug_stmts_to_successors): Likewise.
	(copy_debug_stmts): Likewise.

	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
	gimple_debug in regions where a stmt is known to have code
	GIMPLE_DEBUG.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gdbhooks.py           |  2 ++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              | 19 +++++++++++--------
 gcc/gimple.h              | 38 ++++++++++++++++++++++++++++++++++++--
 gcc/tree-inline.c         | 16 +++++++++-------
 gcc/tree-inline.h         |  2 +-
 7 files changed, 65 insertions(+), 20 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index cea782e..a9df731 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -73,6 +73,10 @@ struct gimple_statement_cond;
 typedef struct gimple_statement_cond *gimple_cond;
 typedef const struct gimple_statement_cond *const_gimple_cond;
 
+struct gimple_statement_debug;
+typedef struct gimple_statement_debug *gimple_debug;
+typedef const struct gimple_statement_debug *const_gimple_debug;
+
 struct gimple_statement_label;
 typedef struct gimple_statement_label *gimple_label;
 typedef const struct gimple_statement_label *const_gimple_label;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 761141b..b7d6015 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -459,6 +459,8 @@ def build_pretty_printer():
                               # Keep this in the same order as gimple.def:
                               'gimple_cond', 'const_gimple_cond',
                               'gimple_statement_cond *',
+                              'gimple_debug', 'const_gimple_debug',
+                              'gimple_statement_debug *',
                               'gimple_label', 'const_gimple_label',
                               'gimple_statement_label *',
                               'gimple_switch', 'const_gimple_switch',
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 7f3a056..cda33b3 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1072,7 +1072,7 @@ dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
    in dumpfile.h).  */
 
 static void
-dump_gimple_debug (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_debug (pretty_printer *buffer, gimple_debug gs, int spc, int flags)
 {
   switch (gs->subcode)
     {
@@ -2223,7 +2223,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_DEBUG:
-      dump_gimple_debug (buffer, gs, spc, flags);
+      dump_gimple_debug (buffer, gs->as_a_gimple_debug (), spc, flags);
       break;
 
     case GIMPLE_PREDICT:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 7a4a070..13c5a08 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -764,12 +764,13 @@ gimple_build_eh_dispatch (int region)
 
    VAR is bound to VALUE; block and location are taken from STMT.  */
 
-gimple
+gimple_debug
 gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL)
 {
-  gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG,
-					 (unsigned)GIMPLE_DEBUG_BIND, 2
-					 PASS_MEM_STAT);
+  gimple_debug p =
+    gimple_build_with_ops_stat (GIMPLE_DEBUG,
+				(unsigned)GIMPLE_DEBUG_BIND, 2
+				PASS_MEM_STAT)->as_a_gimple_debug ();
 
   gimple_debug_bind_set_var (p, var);
   gimple_debug_bind_set_value (p, value);
@@ -784,13 +785,15 @@ gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL)
 
    VAR is bound to VALUE; block and location are taken from STMT.  */
 
-gimple
+gimple_debug
 gimple_build_debug_source_bind_stat (tree var, tree value,
 				     gimple stmt MEM_STAT_DECL)
 {
-  gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG,
-					 (unsigned)GIMPLE_DEBUG_SOURCE_BIND, 2
-					 PASS_MEM_STAT);
+  gimple_debug p =
+    gimple_build_with_ops_stat (
+		    GIMPLE_DEBUG,
+		    (unsigned)GIMPLE_DEBUG_SOURCE_BIND, 2
+		    PASS_MEM_STAT)->as_a_gimple_debug ();
 
   gimple_debug_source_bind_set_var (p, var);
   gimple_debug_source_bind_set_value (p, value);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 8ec8247..962e956 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -220,6 +220,12 @@ public:
     return as_a <gimple_statement_cond> (this);
   }
 
+  inline gimple_debug
+  as_a_gimple_debug ()
+  {
+    return as_a <gimple_statement_debug> (this);
+  }
+
   inline gimple_label
   as_a_gimple_label ()
   {
@@ -258,6 +264,12 @@ public:
     return dyn_cast <gimple_statement_cond> (this);
   }
 
+  inline gimple_debug
+  dyn_cast_gimple_debug ()
+  {
+    return dyn_cast <gimple_statement_debug> (this);
+  }
+
   inline gimple_label
   dyn_cast_gimple_label ()
   {
@@ -858,6 +870,20 @@ struct GTY((tag("GSS_WITH_OPS")))
 };
 
 /* A statement with the invariant that
+      stmt->code == GIMPLE_DEBUG
+   i.e. a debug statement.
+
+   This type will normally be accessed via the gimple_debug and
+   const_gimple_debug typedefs (in coretypes.h), which are pointers to
+   this type.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_debug : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
+/* A statement with the invariant that
       stmt->code == GIMPLE_LABEL
    i.e. a label statement.
 
@@ -942,6 +968,14 @@ is_a_helper <gimple_statement_cond>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_debug>::test (gimple gs)
+{
+  return gs->code == GIMPLE_DEBUG;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_label>::test (gimple gs)
 {
   return gs->code == GIMPLE_LABEL;
@@ -1356,10 +1390,10 @@ gimple gimple_build_resx (int);
 gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
 gimple_switch gimple_build_switch (tree, tree, vec<tree> );
 gimple gimple_build_eh_dispatch (int);
-gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
+gimple_debug gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)			\
   gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
-gimple gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
+gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_source_bind(var,val,stmt)			\
   gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
 gimple gimple_build_omp_critical (gimple_seq, tree);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index bf1c3c7..4d3c2ff 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1467,15 +1467,16 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 
       if (gimple_debug_bind_p (stmt))
 	{
-	  copy = gimple_build_debug_bind (gimple_debug_bind_get_var (stmt),
-					  gimple_debug_bind_get_value (stmt),
-					  stmt);
+	  gimple_debug copy =
+	    gimple_build_debug_bind (gimple_debug_bind_get_var (stmt),
+				     gimple_debug_bind_get_value (stmt),
+				     stmt);
 	  id->debug_stmts.safe_push (copy);
 	  return copy;
 	}
       if (gimple_debug_source_bind_p (stmt))
 	{
-	  copy = gimple_build_debug_source_bind
+	  gimple_debug copy = gimple_build_debug_source_bind
 		   (gimple_debug_source_bind_get_var (stmt),
 		    gimple_debug_source_bind_get_value (stmt), stmt);
 	  id->debug_stmts.safe_push (copy);
@@ -2270,7 +2271,8 @@ maybe_move_debug_stmts_to_successors (copy_body_data *id, basic_block new_bb)
       gimple_stmt_iterator dsi = gsi_after_labels (e->dest);
       while (is_gimple_debug (gsi_stmt (ssi)))
 	{
-	  gimple stmt = gsi_stmt (ssi), new_stmt;
+	  gimple stmt = gsi_stmt (ssi);
+	  gimple_debug new_stmt;
 	  tree var;
 	  tree value;
 
@@ -2600,7 +2602,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
    this arises, we drop the VALUE expression altogether.  */
 
 static void
-copy_debug_stmt (gimple stmt, copy_body_data *id)
+copy_debug_stmt (gimple_debug stmt, copy_body_data *id)
 {
   tree t, *n;
   struct walk_stmt_info wi;
@@ -2692,7 +2694,7 @@ static void
 copy_debug_stmts (copy_body_data *id)
 {
   size_t i;
-  gimple stmt;
+  gimple_debug stmt;
 
   if (!id->debug_stmts.exists ())
     return;
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index 13c5516..63b3f53 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -124,7 +124,7 @@ struct copy_body_data
   bitmap blocks_to_copy;
 
   /* Debug statements that need processing.  */
-  vec<gimple> debug_stmts;
+  vec<gimple_debug> debug_stmts;
 
   /* A map from local declarations in the inlined function to
      equivalents in the function into which it is being inlined, where
-- 
1.8.5.3

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

* [PATCH 60/89] Concretize gimple_catch_types
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (44 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:25   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 03/89] Introduce gimple_bind and use it for accessors David Malcolm
                   ` (45 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_catch_types): Require a const_gimple_catch
	rather than a const_gimple.
---
 gcc/gimple.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 7dfd512..3c54119 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3794,13 +3794,11 @@ gimple_asm_input_p (const_gimple_asm asm_stmt)
 }
 
 
-/* Return the types handled by GIMPLE_CATCH statement GS.  */
+/* Return the types handled by GIMPLE_CATCH statement CATCH_STMT.  */
 
 static inline tree
-gimple_catch_types (const_gimple gs)
+gimple_catch_types (const_gimple_catch catch_stmt)
 {
-  const gimple_statement_catch *catch_stmt =
-    as_a <const gimple_statement_catch> (gs);
   return catch_stmt->types;
 }
 
-- 
1.8.5.3

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

* [PATCH 56/89] Various gimple to gimple_call conversions in IPA
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (33 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:34   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 19/89] Const-correctness of gimple_call_builtin_p David Malcolm
                   ` (56 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* ipa-prop.c (detect_type_change): Require a gimple_call rather
	than a plain gimple.
	(detect_type_change_ssa): Likewise.
	(compute_complex_assign_jump_func): Likewise.
	(compute_complex_ancestor_jump_func): Likewise.
	(compute_known_type_jump_func): Likewise.
	(determine_known_aggregate_parts): Likewise.
	(ipa_compute_jump_functions_for_edge): Strengthen local "call" to
	a gimple_call; add checked cast to gimple_phi.
	(ipa_note_param_call): Require a gimple_call rather than a plain
	gimple.
	(ipa_analyze_indirect_call_uses): Likewise.
	(ipa_analyze_virtual_call_uses): Likewise.
	(ipa_analyze_call_uses): Likewise.
	(ipa_analyze_stmt_uses):Add checked cast to gimple_call.
	(ipa_intraprocedural_devirtualization): Require a gimple_call
	rather than a plain gimple.

	* ipa-prop.h (ipa_intraprocedural_devirtualization): Require a
	gimple_call rather than a plain gimple.

	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
	Replace use of is_gimple_call with dyn_cast_gimple_call and a
	new local "call_stmt".
---
 gcc/ipa-prop.c     | 33 +++++++++++++++++++--------------
 gcc/ipa-prop.h     |  2 +-
 gcc/tree-ssa-pre.c | 10 +++++-----
 3 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 45d540e..5f2f02f 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -679,7 +679,7 @@ check_stmt_for_type_change (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data)
    returned by get_ref_base_and_extent, as is the offset.  */
 
 static bool
-detect_type_change (tree arg, tree base, tree comp_type, gimple call,
+detect_type_change (tree arg, tree base, tree comp_type, gimple_call call,
 		    struct ipa_jump_func *jfunc, HOST_WIDE_INT offset)
 {
   struct type_change_info tci;
@@ -744,7 +744,7 @@ detect_type_change (tree arg, tree base, tree comp_type, gimple call,
 
 static bool
 detect_type_change_ssa (tree arg, tree comp_type,
-			gimple call, struct ipa_jump_func *jfunc)
+			gimple_call call, struct ipa_jump_func *jfunc)
 {
   gcc_checking_assert (TREE_CODE (arg) == SSA_NAME);
   if (!flag_devirtualize
@@ -1034,7 +1034,7 @@ static void
 compute_complex_assign_jump_func (struct ipa_node_params *info,
 				  struct param_analysis_info *parms_ainfo,
 				  struct ipa_jump_func *jfunc,
-				  gimple call, gimple stmt, tree name,
+				  gimple_call call, gimple stmt, tree name,
 				  tree param_type)
 {
   HOST_WIDE_INT offset, size, max_size;
@@ -1190,7 +1190,8 @@ static void
 compute_complex_ancestor_jump_func (struct ipa_node_params *info,
 				    struct param_analysis_info *parms_ainfo,
 				    struct ipa_jump_func *jfunc,
-				    gimple call, gimple phi, tree param_type)
+				    gimple_call call, gimple_phi phi,
+				    tree param_type)
 {
   HOST_WIDE_INT offset;
   gimple assign, cond;
@@ -1259,7 +1260,7 @@ compute_complex_ancestor_jump_func (struct ipa_node_params *info,
 
 static void
 compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
-			      gimple call, tree expected_type)
+			      gimple_call call, tree expected_type)
 {
   HOST_WIDE_INT offset, size, max_size;
   tree base;
@@ -1363,7 +1364,7 @@ struct ipa_known_agg_contents_list
    JFUNC is the jump function into which the constants are subsequently stored.  */
 
 static void
-determine_known_aggregate_parts (gimple call, tree arg, tree arg_type,
+determine_known_aggregate_parts (gimple_call call, tree arg, tree arg_type,
 				 struct ipa_jump_func *jfunc)
 {
   struct ipa_known_agg_contents_list *list = NULL;
@@ -1599,7 +1600,7 @@ ipa_compute_jump_functions_for_edge (struct param_analysis_info *parms_ainfo,
 {
   struct ipa_node_params *info = IPA_NODE_REF (cs->caller);
   struct ipa_edge_args *args = IPA_EDGE_REF (cs);
-  gimple call = cs->call_stmt;
+  gimple_call call = cs->call_stmt;
   int n, arg_num = gimple_call_num_args (call);
 
   if (arg_num == 0 || args->jump_functions)
@@ -1662,7 +1663,9 @@ ipa_compute_jump_functions_for_edge (struct param_analysis_info *parms_ainfo,
 						  call, stmt, arg, param_type);
 	      else if (gimple_code (stmt) == GIMPLE_PHI)
 		compute_complex_ancestor_jump_func (info, parms_ainfo, jfunc,
-						    call, stmt, param_type);
+						    call,
+						    stmt->as_a_gimple_phi (),
+						    param_type);
 	    }
 	}
       else
@@ -1784,7 +1787,8 @@ ipa_is_ssa_with_stmt_def (tree t)
    indirect call graph edge.  */
 
 static struct cgraph_edge *
-ipa_note_param_call (struct cgraph_node *node, int param_index, gimple stmt)
+ipa_note_param_call (struct cgraph_node *node, int param_index,
+		     gimple_call stmt)
 {
   struct cgraph_edge *cs;
 
@@ -1858,7 +1862,7 @@ static void
 ipa_analyze_indirect_call_uses (struct cgraph_node *node,
 				struct ipa_node_params *info,
 				struct param_analysis_info *parms_ainfo,
-				gimple call, tree target)
+				gimple_call call, tree target)
 {
   gimple def;
   tree n1, n2;
@@ -2001,7 +2005,7 @@ ipa_analyze_indirect_call_uses (struct cgraph_node *node,
 
 static void
 ipa_analyze_virtual_call_uses (struct cgraph_node *node,
-			       struct ipa_node_params *info, gimple call,
+			       struct ipa_node_params *info, gimple_call call,
 			       tree target)
 {
   struct cgraph_edge *cs;
@@ -2060,7 +2064,8 @@ ipa_analyze_virtual_call_uses (struct cgraph_node *node,
 static void
 ipa_analyze_call_uses (struct cgraph_node *node,
 		       struct ipa_node_params *info,
-		       struct param_analysis_info *parms_ainfo, gimple call)
+		       struct param_analysis_info *parms_ainfo,
+		       gimple_call call)
 {
   tree target = gimple_call_fn (call);
   struct cgraph_edge *cs;
@@ -2092,7 +2097,7 @@ ipa_analyze_stmt_uses (struct cgraph_node *node, struct ipa_node_params *info,
 		       struct param_analysis_info *parms_ainfo, gimple stmt)
 {
   if (is_gimple_call (stmt))
-    ipa_analyze_call_uses (node, info, parms_ainfo, stmt);
+    ipa_analyze_call_uses (node, info, parms_ainfo, stmt->as_a_gimple_call ());
 }
 
 /* Callback of walk_stmt_load_store_addr_ops for the visit_load.
@@ -2256,7 +2261,7 @@ ipa_analyze_node (struct cgraph_node *node)
    target function declaration, otherwise return NULL.  */
 
 tree
-ipa_intraprocedural_devirtualization (gimple call)
+ipa_intraprocedural_devirtualization (gimple_call call)
 {
   tree binfo, token, fndecl;
   struct ipa_jump_func jfunc;
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 8fdd92c..bf3602c 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -584,7 +584,7 @@ tree ipa_get_indirect_edge_target (struct cgraph_edge *ie,
 				   vec<ipa_agg_jump_function_p> );
 struct cgraph_edge *ipa_make_edge_direct_to_target (struct cgraph_edge *, tree);
 tree ipa_binfo_from_known_type_jfunc (struct ipa_jump_func *);
-tree ipa_intraprocedural_devirtualization (gimple);
+tree ipa_intraprocedural_devirtualization (gimple_call);
 
 /* Functions related to both.  */
 void ipa_analyze_node (struct cgraph_node *);
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 41fe055..f081349 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -4339,9 +4339,9 @@ eliminate_dom_walker::before_dom_children (basic_block b)
 	}
       /* Visit indirect calls and turn them into direct calls if
 	 possible.  */
-      if (is_gimple_call (stmt))
+      if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	{
-	  tree orig_fn = gimple_call_fn (stmt);
+	  tree orig_fn = gimple_call_fn (call_stmt);
 	  tree fn;
 	  if (!orig_fn)
 	    continue;
@@ -4353,7 +4353,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
 	      fn = VN_INFO (OBJ_TYPE_REF_EXPR (orig_fn))->valnum;
 	      if (!gimple_call_addr_fndecl (fn))
 		{
-		  fn = ipa_intraprocedural_devirtualization (stmt);
+		  fn = ipa_intraprocedural_devirtualization (call_stmt);
 		  if (fn)
 		    fn = build_fold_addr_expr (fn);
 		}
@@ -4376,12 +4376,12 @@ eliminate_dom_walker::before_dom_children (basic_block b)
 		  print_gimple_stmt (dump_file, stmt, 0, 0);
 		}
 
-	      gimple_call_set_fn (stmt, fn);
+	      gimple_call_set_fn (call_stmt, fn);
 	      el_to_update.safe_push (stmt);
 
 	      /* When changing a call into a noreturn call, cfg cleanup
 		 is needed to fix up the noreturn call.  */
-	      if (!was_noreturn && gimple_call_noreturn_p (stmt))
+	      if (!was_noreturn && gimple_call_noreturn_p (call_stmt))
 		el_todo |= TODO_cleanup_cfg;
 
 	      /* If we removed EH side-effects from the statement, clean
-- 
1.8.5.3

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

* [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (40 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 07/89] Introduce gimple_debug and use it in a few places David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:38   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c David Malcolm
                   ` (49 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_set_tail): Require a gimple_call.
	(gimple_call_tail_p): Likewise.

	* cfgexpand.c (expand_gimple_tailcall): Likewise.
	(expand_gimple_basic_block): Convert calls to is_gimple_call to a
	dyn_cast, introducing a new "call_stmt" local.

	* trans-mem.c (expand_block_edges): Likewise, for comparison against
	GIMPLE_CALL.

	* tree-tailcall.c (optimize_tail_call): Add checked cast to gimple_call
	for t->call_gsi.
---
 gcc/cfgexpand.c     | 13 +++++++------
 gcc/gimple.h        |  6 ++----
 gcc/trans-mem.c     | 20 ++++++++++++--------
 gcc/tree-tailcall.c |  2 +-
 4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 4768a69..983cec0 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3345,7 +3345,7 @@ expand_gimple_stmt (gimple stmt)
    tailcall) and the normal result happens via a sqrt instruction.  */
 
 static basic_block
-expand_gimple_tailcall (basic_block bb, gimple stmt, bool *can_fallthru)
+expand_gimple_tailcall (basic_block bb, gimple_call stmt, bool *can_fallthru)
 {
   rtx last2, last;
   edge e;
@@ -5115,15 +5115,16 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
 	}
       else
 	{
-	  if (is_gimple_call (stmt)
-	      && gimple_call_tail_p (stmt)
+	  gimple_call call_stmt = stmt->dyn_cast_gimple_call ();
+	  if (call_stmt
+	      && gimple_call_tail_p (call_stmt)
 	      && disable_tail_calls)
-	    gimple_call_set_tail (stmt, false);
+	    gimple_call_set_tail (call_stmt, false);
 
-	  if (is_gimple_call (stmt) && gimple_call_tail_p (stmt))
+	  if (call_stmt && gimple_call_tail_p (call_stmt))
 	    {
 	      bool can_fallthru;
-	      new_bb = expand_gimple_tailcall (bb, stmt, &can_fallthru);
+	      new_bb = expand_gimple_tailcall (bb, call_stmt, &can_fallthru);
 	      if (new_bb)
 		{
 		  if (can_fallthru)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 328fdf3..a7829a4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3086,9 +3086,8 @@ gimple_call_set_arg (gimple gs, unsigned index, tree arg)
    candidate for tail call optimization.  */
 
 static inline void
-gimple_call_set_tail (gimple s, bool tail_p)
+gimple_call_set_tail (gimple_call s, bool tail_p)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   if (tail_p)
     s->subcode |= GF_CALL_TAILCALL;
   else
@@ -3099,9 +3098,8 @@ gimple_call_set_tail (gimple s, bool tail_p)
 /* Return true if GIMPLE_CALL S is marked as a tail call.  */
 
 static inline bool
-gimple_call_tail_p (gimple s)
+gimple_call_tail_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (s->subcode & GF_CALL_TAILCALL) != 0;
 }
 
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index febc817..f336985 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -3131,23 +3131,26 @@ expand_block_edges (struct tm_region *const region, basic_block bb)
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi = next_gsi)
     {
       gimple stmt = gsi_stmt (gsi);
+      gimple_call call_stmt;
 
       next_gsi = gsi;
       gsi_next (&next_gsi);
 
       // ??? Shouldn't we split for any non-pure, non-irrevocable function?
-      if (gimple_code (stmt) != GIMPLE_CALL
-	  || (gimple_call_flags (stmt) & ECF_TM_BUILTIN) == 0)
+      call_stmt = stmt->dyn_cast_gimple_call ();
+      if ((!call_stmt)
+	  || (gimple_call_flags (call_stmt) & ECF_TM_BUILTIN) == 0)
 	continue;
 
-      if (DECL_FUNCTION_CODE (gimple_call_fndecl (stmt)) == BUILT_IN_TM_ABORT)
+      if (DECL_FUNCTION_CODE (gimple_call_fndecl (call_stmt))
+	  == BUILT_IN_TM_ABORT)
 	{
 	  // If we have a ``_transaction_cancel [[outer]]'', there is only
 	  // one abnormal edge: to the transaction marked OUTER.
 	  // All compiler-generated instances of BUILT_IN_TM_ABORT have a
 	  // constant argument, which we can examine here.  Users invoking
 	  // TM_ABORT directly get what they deserve.
-	  tree arg = gimple_call_arg (stmt, 0);
+	  tree arg = gimple_call_arg (call_stmt, 0);
 	  if (TREE_CODE (arg) == INTEGER_CST
 	      && (TREE_INT_CST_LOW (arg) & AR_OUTERABORT) != 0
 	      && !decl_is_tm_clone (current_function_decl))
@@ -3156,7 +3159,7 @@ expand_block_edges (struct tm_region *const region, basic_block bb)
 	      for (struct tm_region *o = region; o; o = o->outer)
 		if (o->original_transaction_was_outer)
 		  {
-		    split_bb_make_tm_edge (stmt, o->restart_block,
+		    split_bb_make_tm_edge (call_stmt, o->restart_block,
 					   gsi, &next_gsi);
 		    break;
 		  }
@@ -3169,7 +3172,8 @@ expand_block_edges (struct tm_region *const region, basic_block bb)
 
 	  // Non-outer, TM aborts have an abnormal edge to the inner-most
 	  // transaction, the one being aborted;
-	  split_bb_make_tm_edge (stmt, region->restart_block, gsi, &next_gsi);
+	  split_bb_make_tm_edge (call_stmt, region->restart_block, gsi,
+				 &next_gsi);
 	}
 
       // All TM builtins have an abnormal edge to the outer-most transaction.
@@ -3187,14 +3191,14 @@ expand_block_edges (struct tm_region *const region, basic_block bb)
       for (struct tm_region *o = region; o; o = o->outer)
 	if (!o->outer)
 	  {
-            split_bb_make_tm_edge (stmt, o->restart_block, gsi, &next_gsi);
+            split_bb_make_tm_edge (call_stmt, o->restart_block, gsi, &next_gsi);
 	    break;
 	  }
 
       // Delete any tail-call annotation that may have been added.
       // The tail-call pass may have mis-identified the commit as being
       // a candidate because we had not yet added this restart edge.
-      gimple_call_set_tail (stmt, false);
+      gimple_call_set_tail (call_stmt, false);
     }
 }
 
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index d3f2504..8aed535 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -910,7 +910,7 @@ optimize_tail_call (struct tailcall *t, bool opt_tailcalls)
 
   if (opt_tailcalls)
     {
-      gimple stmt = gsi_stmt (t->call_gsi);
+      gimple_call stmt = gsi_stmt (t->call_gsi)->as_a_gimple_call ();
 
       gimple_call_set_tail (stmt, true);
       cfun->tail_call_marked = true;
-- 
1.8.5.3

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

* [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (21 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 45/89] Introduce gimple_omp_sections David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:30   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 78/89] Concretize gimple_call_set_nothrow David Malcolm
                   ` (68 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_copy_flags): Require gimple_calls.

	* ipa-prop.c (ipa_modify_call_arguments): Require a gimple_call.
	* ipa-prop.h (ipa_modify_call_arguments): Likewise.

	* tree-inline.c (copy_bb): Replace is_gimple_call with new local
	and call to dyn_cast_gimple_call, updating gimple_call_ uses to use
	the type-checked local.

	* tree-sra.c (convert_callers): Replace check for GIMPLE_CALL with
	a dyn_cast.
---
 gcc/gimple.h      |  4 +---
 gcc/ipa-prop.c    |  2 +-
 gcc/ipa-prop.h    |  2 +-
 gcc/tree-inline.c | 20 +++++++++++---------
 gcc/tree-sra.c    |  5 +++--
 5 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index d487629..feecc0d 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3226,10 +3226,8 @@ gimple_call_alloca_for_var_p (gimple_call s)
 /* Copy all the GF_CALL_* flags from ORIG_CALL to DEST_CALL.  */
 
 static inline void
-gimple_call_copy_flags (gimple dest_call, gimple orig_call)
+gimple_call_copy_flags (gimple_call dest_call, gimple_call orig_call)
 {
-  GIMPLE_CHECK (dest_call, GIMPLE_CALL);
-  GIMPLE_CHECK (orig_call, GIMPLE_CALL);
   dest_call->subcode = orig_call->subcode;
 }
 
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 5f2f02f..a521525 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -3664,7 +3664,7 @@ ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec adjustments)
    contain the corresponding call graph edge.  */
 
 void
-ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
+ipa_modify_call_arguments (struct cgraph_edge *cs, gimple_call stmt,
 			   ipa_parm_adjustment_vec adjustments)
 {
   struct cgraph_node *current_node = cgraph_get_node (current_function_decl);
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index bf3602c..676db02 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -687,7 +687,7 @@ typedef vec<ipa_parm_adjustment> ipa_parm_adjustment_vec;
 vec<tree> ipa_get_vector_of_formal_parms (tree fndecl);
 vec<tree> ipa_get_vector_of_formal_parm_types (tree fntype);
 void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec);
-void ipa_modify_call_arguments (struct cgraph_edge *, gimple,
+void ipa_modify_call_arguments (struct cgraph_edge *, gimple_call,
 				ipa_parm_adjustment_vec);
 ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
 						 ipa_parm_adjustment_vec);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 274b073..dbc024d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1678,10 +1678,12 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
       do
 	{
 	  tree fn;
+	  gimple_call call_stmt;
 
 	  stmt = gsi_stmt (copy_gsi);
-	  if (is_gimple_call (stmt)
-	      && gimple_call_va_arg_pack_p (stmt->as_a_gimple_call ())
+	  call_stmt = stmt->dyn_cast_gimple_call ();
+	  if (call_stmt
+	      && gimple_call_va_arg_pack_p (call_stmt)
 	      && id->gimple_call)
 	    {
 	      /* __builtin_va_arg_pack () should be replaced by
@@ -1696,33 +1698,33 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 		nargs--;
 
 	      /* Create the new array of arguments.  */
-	      n = nargs + gimple_call_num_args (stmt);
+	      n = nargs + gimple_call_num_args (call_stmt);
 	      argarray.create (n);
 	      argarray.safe_grow_cleared (n);
 
 	      /* Copy all the arguments before '...'  */
 	      memcpy (argarray.address (),
-		      gimple_call_arg_ptr (stmt, 0),
-		      gimple_call_num_args (stmt) * sizeof (tree));
+		      gimple_call_arg_ptr (call_stmt, 0),
+		      gimple_call_num_args (call_stmt) * sizeof (tree));
 
 	      /* Append the arguments passed in '...'  */
-	      memcpy (argarray.address () + gimple_call_num_args (stmt),
+	      memcpy (argarray.address () + gimple_call_num_args (call_stmt),
 		      gimple_call_arg_ptr (id->gimple_call, 0)
 			+ (gimple_call_num_args (id->gimple_call) - nargs),
 		      nargs * sizeof (tree));
 
-	      new_call = gimple_build_call_vec (gimple_call_fn (stmt),
+	      new_call = gimple_build_call_vec (gimple_call_fn (call_stmt),
 						argarray);
 
 	      argarray.release ();
 
 	      /* Copy all GIMPLE_CALL flags, location and block, except
 		 GF_CALL_VA_ARG_PACK.  */
-	      gimple_call_copy_flags (new_call, stmt);
+	      gimple_call_copy_flags (new_call, call_stmt);
 	      gimple_call_set_va_arg_pack (new_call, false);
 	      gimple_set_location (new_call, gimple_location (stmt));
 	      gimple_set_block (new_call, gimple_block (stmt));
-	      gimple_call_set_lhs (new_call, gimple_call_lhs (stmt));
+	      gimple_call_set_lhs (new_call, gimple_call_lhs (call_stmt));
 
 	      gsi_replace (&copy_gsi, new_call, false);
 	      stmt = new_call;
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 223909e..b591b39 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4847,9 +4847,10 @@ convert_callers (struct cgraph_node *node, tree old_decl,
 
       for (gsi = gsi_start_bb (this_block); !gsi_end_p (gsi); gsi_next (&gsi))
         {
-	  gimple stmt = gsi_stmt (gsi);
+	  gimple_call stmt;
 	  tree call_fndecl;
-	  if (gimple_code (stmt) != GIMPLE_CALL)
+	  stmt = gsi_stmt (gsi)->dyn_cast_gimple_call ();
+	  if (!stmt)
 	    continue;
 	  call_fndecl = gimple_call_fndecl (stmt);
 	  if (call_fndecl == old_decl)
-- 
1.8.5.3

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

* [PATCH 82/89] Concretize gimple_call_set_fntype
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (23 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 78/89] Concretize gimple_call_set_nothrow David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 18:04   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places David Malcolm
                   ` (66 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_set_fntype): Require a gimple_call.

	* omp-low.c (lower_omp_1): Add a new local gimple_call "call_stmt",
	from a checked cast to gimple_call within the "case GIMPLE_CALL",
	for the regions where "stmt" is not subsequently overwritten.
---
 gcc/gimple.h  |  7 +++----
 gcc/omp-low.c | 12 +++++++-----
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index fb7b5d3..328fdf3 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2922,13 +2922,12 @@ gimple_call_fntype (const_gimple gs)
   return call_stmt->u.fntype;
 }
 
-/* Set the type of the function called by GS to FNTYPE.  */
+/* Set the type of the function called by CALL_STMT to FNTYPE.  */
 
 static inline void
-gimple_call_set_fntype (gimple gs, tree fntype)
+gimple_call_set_fntype (gimple_call call_stmt, tree fntype)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call> (gs);
-  gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
+  gcc_gimple_checking_assert (!gimple_call_internal_p (call_stmt));
   call_stmt->u.fntype = fntype;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 5ae014c..790e132 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -9998,6 +9998,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   gimple stmt = gsi_stmt (*gsi_p);
   struct walk_stmt_info wi;
+  gimple_call call_stmt;
 
   if (gimple_has_location (stmt))
     input_location = gimple_location (stmt);
@@ -10113,7 +10114,8 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       break;
     case GIMPLE_CALL:
       tree fndecl;
-      fndecl = gimple_call_fndecl (stmt);
+      call_stmt = stmt->as_a_gimple_call ();
+      fndecl = gimple_call_fndecl (call_stmt);
       if (fndecl
 	  && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
 	switch (DECL_FUNCTION_CODE (fndecl))
@@ -10128,7 +10130,7 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	    cctx = ctx;
 	    if (gimple_code (cctx->stmt) == GIMPLE_OMP_SECTION)
 	      cctx = cctx->outer;
-	    gcc_assert (gimple_call_lhs (stmt) == NULL_TREE);
+	    gcc_assert (gimple_call_lhs (call_stmt) == NULL_TREE);
 	    if (!cctx->cancellable)
 	      {
 		if (DECL_FUNCTION_CODE (fndecl)
@@ -10144,10 +10146,10 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 	    if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_GOMP_BARRIER)
 	      {
 		fndecl = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER_CANCEL);
-		gimple_call_set_fndecl (stmt, fndecl);
-		gimple_call_set_fntype (stmt, TREE_TYPE (fndecl));
+		gimple_call_set_fndecl (call_stmt, fndecl);
+		gimple_call_set_fntype (call_stmt, TREE_TYPE (fndecl));
 	      }
-	    gimple_call_set_lhs (stmt, lhs);
+	    gimple_call_set_lhs (call_stmt, lhs);
 	    tree fallthru_label;
 	    fallthru_label = create_artificial_label (UNKNOWN_LOCATION);
 	    gimple g;
-- 
1.8.5.3

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

* [PATCH 22/89] Introduce gimple_goto
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (19 preceding siblings ...)
  2014-04-21 16:56 ` [PATCH 01/89] Const-correctness fixes for some gimple accessors David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-04-22 11:49   ` Trevor Saunders
  2014-04-21 16:57 ` [PATCH 45/89] Introduce gimple_omp_sections David Malcolm
                   ` (70 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_goto): New typedef.
	(const_gimple_goto): New typedef.

	* gimple.h (gimple_statement_goto): New subclass of
	gimple_statement_with_ops, adding the invariant that
	stmt->code == GIMPLE_GOTO.
	(gimple_statement_base::as_a_gimple_goto): New.
	(gimple_statement_base::dyn_cast_gimple_goto): New.
	(is_a_helper <gimple_statement_goto>::test): New.
	(gimple_build_goto): Return a gimple_goto rather than a
	plain gimple.

	* gimple-pretty-print.c (dump_gimple_goto): Require a gimple_goto
	rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_goto within
	GIMPLE_GOTO case of switch statement.

	* gimple.c (gimple_build_goto): Return a gimple_goto rather than a
	plain gimple.

	* tree-cfg.c (verify_gimple_goto): Require a gimple_goto rather
	than a plain gimple.
	(verify_gimple_stmt): Add a checked cast to gimple_goto within
	GIMPLE_GOTO case of switch statement.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 36 +++++++++++++++++++++++++++++++++++-
 gcc/tree-cfg.c            |  4 ++--
 5 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d5c62b9..1d04d07 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -77,6 +77,10 @@ struct gimple_statement_debug;
 typedef struct gimple_statement_debug *gimple_debug;
 typedef const struct gimple_statement_debug *const_gimple_debug;
 
+struct gimple_statement_goto;
+typedef struct gimple_statement_goto *gimple_goto;
+typedef const struct gimple_statement_goto *const_gimple_goto;
+
 struct gimple_statement_label;
 typedef struct gimple_statement_label *gimple_label;
 typedef const struct gimple_statement_label *const_gimple_label;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 90baded..6ee6ce9 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -874,7 +874,7 @@ dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags)
    TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_goto (pretty_printer *buffer, gimple_goto gs, int spc, int flags)
 {
   tree label = gimple_goto_dest (gs);
   if (flags & TDF_RAW)
@@ -2115,7 +2115,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_GOTO:
-      dump_gimple_goto (buffer, gs, spc, flags);
+      dump_gimple_goto (buffer, gs->as_a_gimple_goto (), spc, flags);
       break;
 
     case GIMPLE_NOP:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 222c068..b73fc74 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -495,10 +495,11 @@ gimple_build_label (tree label)
 
 /* Build a GIMPLE_GOTO statement to label DEST.  */
 
-gimple
+gimple_goto
 gimple_build_goto (tree dest)
 {
-  gimple p = gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1);
+  gimple_goto p = gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK,
+					 1)->as_a_gimple_goto ();
   gimple_goto_set_dest (p, dest);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 39ac2dc..a4c7b30 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -222,6 +222,12 @@ public:
     return as_a <gimple_statement_debug> (this);
   }
 
+  inline gimple_goto
+  as_a_gimple_goto ()
+  {
+    return as_a <gimple_statement_goto> (this);
+  }
+
   inline gimple_label
   as_a_gimple_label ()
   {
@@ -290,6 +296,12 @@ public:
     return dyn_cast <gimple_statement_debug> (this);
   }
 
+  inline gimple_goto
+  dyn_cast_gimple_goto ()
+  {
+    return dyn_cast <gimple_statement_goto> (this);
+  }
+
   inline gimple_label
   dyn_cast_gimple_label ()
   {
@@ -922,6 +934,20 @@ struct GTY((tag("GSS_WITH_OPS")))
 };
 
 /* A statement with the invariant that
+      stmt->code == GIMPLE_GOTO
+   i.e. a goto statement.
+
+   This type will normally be accessed via the gimple_goto and
+   const_gimple_goto typedefs (in coretypes.h), which are pointers to
+   this type.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_goto : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
+/* A statement with the invariant that
       stmt->code == GIMPLE_LABEL
    i.e. a label statement.
 
@@ -1024,6 +1050,14 @@ is_a_helper <gimple_statement_debug>::test (gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_statement_goto>::test (gimple gs)
+{
+  return gs->code == GIMPLE_GOTO;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_statement_label>::test (gimple gs)
 {
   return gs->code == GIMPLE_LABEL;
@@ -1429,7 +1463,7 @@ gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
 gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
 void gimple_cond_set_condition_from_tree (gimple_cond, tree);
 gimple_label gimple_build_label (tree label);
-gimple gimple_build_goto (tree dest);
+gimple_goto gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
 gimple_bind gimple_build_bind (tree, gimple_seq, tree);
 gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 1bfed7d..8b8020e 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4229,7 +4229,7 @@ verify_gimple_return (gimple_return stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_goto (gimple stmt)
+verify_gimple_goto (gimple_goto stmt)
 {
   tree dest = gimple_goto_dest (stmt);
 
@@ -4429,7 +4429,7 @@ verify_gimple_stmt (gimple stmt)
 				       gimple_cond_rhs (stmt));
 
     case GIMPLE_GOTO:
-      return verify_gimple_goto (stmt);
+      return verify_gimple_goto (stmt->as_a_gimple_goto ());
 
     case GIMPLE_SWITCH:
       return verify_gimple_switch (stmt->as_a_gimple_switch ());
-- 
1.8.5.3

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

* [PATCH 45/89] Introduce gimple_omp_sections
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (20 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 22/89] Introduce gimple_goto David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:32   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments David Malcolm
                   ` (69 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_sections): New typedef.
	(const_gimple_omp_sections): New typedef.

	* gimple-pretty-print.c (dump_gimple_omp_sections): Require a
	gimple_omp_sections rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_sections within
	GIMPLE_OMP_SECTIONS case of switch statement.

	* gimple.c (gimple_build_omp_sections): Return a
	gimple_omp_sections rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_sections): New.
	(gimple_build_omp_sections): Return a gimple_omp_sections rather
	than a plain gimple.

	* omp-low.c (scan_omp_sections): Require a gimple_omp_sections
	rather than a plain gimple.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_sections within
	GIMPLE_OMP_SECTIONS case of switch statement.
	(expand_omp_sections): Strengthen local "sections_stmt" from gimple
	to gimple_omp_sections.
	(lower_omp_sections): Likewise for "stmt".
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  7 ++++---
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              |  8 +++++++-
 gcc/omp-low.c             | 14 ++++++++------
 5 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 529dc96..bcea3c1 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -175,6 +175,10 @@ struct gimple_statement_omp_task;
 typedef struct gimple_statement_omp_task *gimple_omp_task;
 typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
 
+struct gimple_statement_omp_sections;
+typedef struct gimple_statement_omp_sections *gimple_omp_sections;
+typedef const struct gimple_statement_omp_sections *const_gimple_omp_sections;
+
 struct gimple_statement_omp_single;
 typedef struct gimple_statement_omp_single *gimple_omp_single;
 typedef const struct gimple_statement_omp_single *const_gimple_omp_single;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 3787136..f375a61 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1362,8 +1362,8 @@ dump_gimple_omp_teams (pretty_printer *buffer, gimple_omp_teams gs, int spc,
 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_sections (pretty_printer *buffer, gimple gs, int spc,
-			  int flags)
+dump_gimple_omp_sections (pretty_printer *buffer, gimple_omp_sections gs,
+			  int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2194,7 +2194,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      dump_gimple_omp_sections (buffer, gs, spc, flags);
+      dump_gimple_omp_sections (buffer, gs->as_a_gimple_omp_sections (),
+				spc, flags);
       break;
 
     case GIMPLE_OMP_SECTIONS_SWITCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 310839f..6de651d 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1006,10 +1006,11 @@ gimple_build_omp_return (bool wait_p)
    CLAUSES are any of the OMP sections contsruct's clauses: private,
    firstprivate, lastprivate, reduction, and nowait.  */
 
-gimple
+gimple_omp_sections
 gimple_build_omp_sections (gimple_seq body, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_SECTIONS, 0);
+  gimple_omp_sections p =
+    gimple_alloc (GIMPLE_OMP_SECTIONS, 0)->as_a_gimple_omp_sections ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_sections_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 0a06620..155fca7 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -378,6 +378,12 @@ public:
     return as_a <gimple_statement_omp_task> (this);
   }
 
+  inline gimple_omp_sections
+  as_a_gimple_omp_sections ()
+  {
+    return as_a <gimple_statement_omp_sections> (this);
+  }
+
   inline gimple_omp_single
   as_a_gimple_omp_single ()
   {
@@ -1652,7 +1658,7 @@ gimple gimple_build_omp_taskgroup (gimple_seq);
 gimple_omp_continue gimple_build_omp_continue (tree, tree);
 gimple gimple_build_omp_ordered (gimple_seq);
 gimple gimple_build_omp_return (bool);
-gimple gimple_build_omp_sections (gimple_seq, tree);
+gimple_omp_sections gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
 gimple_omp_single gimple_build_omp_single (gimple_seq, tree);
 gimple_omp_target gimple_build_omp_target (gimple_seq, int, tree);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 680c21f..6d24927 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2143,7 +2143,7 @@ scan_omp_for (gimple_omp_for stmt, omp_context *outer_ctx)
 /* Scan an OpenMP sections directive.  */
 
 static void
-scan_omp_sections (gimple stmt, omp_context *outer_ctx)
+scan_omp_sections (gimple_omp_sections stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
 
@@ -2647,7 +2647,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      scan_omp_sections (stmt, ctx);
+      scan_omp_sections (stmt->as_a_gimple_omp_sections (), ctx);
       break;
 
     case GIMPLE_OMP_SINGLE:
@@ -6967,7 +6967,8 @@ expand_omp_sections (struct omp_region *region)
   unsigned len;
   basic_block entry_bb, l0_bb, l1_bb, l2_bb, default_bb;
   gimple_stmt_iterator si, switch_si;
-  gimple sections_stmt, stmt;
+  gimple_omp_sections sections_stmt;
+  gimple stmt;
   gimple_omp_continue cont;
   edge_iterator ei;
   edge e;
@@ -7022,7 +7023,7 @@ expand_omp_sections (struct omp_region *region)
   /* The call to GOMP_sections_start goes in ENTRY_BB, replacing the
      GIMPLE_OMP_SECTIONS statement.  */
   si = gsi_last_bb (entry_bb);
-  sections_stmt = gsi_stmt (si);
+  sections_stmt = gsi_stmt (si)->as_a_gimple_omp_sections ();
   gcc_assert (gimple_code (sections_stmt) == GIMPLE_OMP_SECTIONS);
   vin = gimple_omp_sections_control (sections_stmt);
   if (!is_combined_parallel (region))
@@ -8424,11 +8425,12 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block, control;
   gimple_stmt_iterator tgsi;
-  gimple stmt, t;
+  gimple_omp_sections stmt;
+  gimple t;
   gimple_bind new_stmt, bind;
   gimple_seq ilist, dlist, olist, new_body;
 
-  stmt = gsi_stmt (*gsi_p);
+  stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_sections ();
 
   push_gimplify_context ();
 
-- 
1.8.5.3

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

* [PATCH 84/89] Concretize gimple_call_arg_flags
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (46 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 03/89] Introduce gimple_bind and use it for accessors David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 18:02   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p David Malcolm
                   ` (43 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_arg_flags): Require a const_gimple_call
	rather than a const_gimple.

	* gimple.c (gimple_call_fnspec): Likewise.
	(gimple_call_arg_flags): Likewise.
---
 gcc/gimple.c | 4 ++--
 gcc/gimple.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 69c639a..582f0f0 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1351,7 +1351,7 @@ gimple_call_flags (const_gimple stmt)
 /* Return the "fn spec" string for call STMT.  */
 
 static tree
-gimple_call_fnspec (const_gimple stmt)
+gimple_call_fnspec (const_gimple_call stmt)
 {
   tree type, attr;
 
@@ -1369,7 +1369,7 @@ gimple_call_fnspec (const_gimple stmt)
 /* Detects argument flags for argument number ARG on call STMT.  */
 
 int
-gimple_call_arg_flags (const_gimple stmt, unsigned arg)
+gimple_call_arg_flags (const_gimple_call stmt, unsigned arg)
 {
   tree attr = gimple_call_fnspec (stmt);
 
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a7829a4..dd6dd38 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1683,7 +1683,7 @@ bool empty_body_p (gimple_seq);
 gimple_seq gimple_seq_copy (gimple_seq);
 bool gimple_call_same_target_p (const_gimple, const_gimple);
 int gimple_call_flags (const_gimple);
-int gimple_call_arg_flags (const_gimple, unsigned);
+int gimple_call_arg_flags (const_gimple_call, unsigned);
 int gimple_call_return_flags (const_gimple_call);
 bool gimple_assign_copy_p (gimple);
 bool gimple_assign_ssa_name_copy_p (gimple);
-- 
1.8.5.3

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

* [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (24 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 82/89] Concretize gimple_call_set_fntype David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-09 18:32   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 88/89] Use gimple_phi in many more places David Malcolm
                   ` (65 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-loop-niter.c (chain_of_csts_start): Return a gimple_phi
	rather than a gimple.
	(get_base_for): Likewise; convert local "phi" to be a gimple_phi.
	(loop_niter_by_eval): Convert local "phi" to be a gimple_phi.
---
 gcc/tree-ssa-loop-niter.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 76113dd..1d0ed34 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2155,7 +2155,7 @@ finite_loop_p (struct loop *loop)
    result by a chain of operations such that all but exactly one of their
    operands are constants.  */
 
-static gimple
+static gimple_phi
 chain_of_csts_start (struct loop *loop, tree x)
 {
   gimple stmt = SSA_NAME_DEF_STMT (x);
@@ -2170,7 +2170,7 @@ chain_of_csts_start (struct loop *loop, tree x)
   if (gimple_code (stmt) == GIMPLE_PHI)
     {
       if (bb == loop->header)
-	return stmt;
+	return stmt->as_a_gimple_phi ();
 
       return NULL;
     }
@@ -2203,10 +2203,10 @@ chain_of_csts_start (struct loop *loop, tree x)
 
    If such phi node exists, it is returned, otherwise NULL is returned.  */
 
-static gimple
+static gimple_phi
 get_base_for (struct loop *loop, tree x)
 {
-  gimple phi;
+  gimple_phi phi;
   tree init, next;
 
   if (is_gimple_min_invariant (x))
@@ -2297,7 +2297,8 @@ loop_niter_by_eval (struct loop *loop, edge exit)
 {
   tree acnd;
   tree op[2], val[2], next[2], aval[2];
-  gimple phi, cond;
+  gimple_phi phi;
+  gimple cond;
   unsigned i, j;
   enum tree_code cmp;
 
-- 
1.8.5.3

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

* [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (36 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 31/89] Use subclasses of gimple in various places David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:28   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places David Malcolm
                   ` (53 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_try_set_catch_is_cleanup): Require a gimple_try.

	* gimplify.c (gimplify_expr): Convert local "try_" from a gimple
	to a gimple_try.
---
 gcc/gimple.h   | 2 +-
 gcc/gimplify.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index fcc3bb7..3335dee 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4047,7 +4047,7 @@ gimple_try_cleanup (gimple gs)
 /* Set the GIMPLE_TRY_CATCH_IS_CLEANUP flag.  */
 
 static inline void
-gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
+gimple_try_set_catch_is_cleanup (gimple_try g, bool catch_is_cleanup)
 {
   gcc_gimple_checking_assert (gimple_try_kind (g) == GIMPLE_TRY_CATCH);
   if (catch_is_cleanup)
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 1c7481d..031834b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7784,7 +7784,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	case TRY_CATCH_EXPR:
 	  {
 	    gimple_seq eval, cleanup;
-	    gimple try_;
+	    gimple_try try_;
 
 	    /* Calls to destructors are generated automatically in FINALLY/CATCH
 	       block. They should have location as UNKNOWN_LOCATION. However,
-- 
1.8.5.3

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

* [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (41 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:32   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto David Malcolm
                   ` (48 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-dom.c (struct hashable_expr): Strengthen field
	call.fn_from from gimple to gimple_call.
	(initialize_hash_element): Replace check against GIMPLE_CALL
	with dyn_cast_gimple_call and update gimple_call_ uses to use
	new gimple_call local, along with fn_from initializer.
	(iterative_hash_hashable_expr): Strengthen type of local "fn_from"
	from gimple to gimple_call.
	(print_expr_hash_elt): Likewise.
---
 gcc/tree-ssa-dom.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 8fc8e1a..82e937e 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -79,7 +79,7 @@ struct hashable_expr
     struct { enum tree_code op;  tree opnd; } unary;
     struct { enum tree_code op;  tree opnd0, opnd1; } binary;
     struct { enum tree_code op;  tree opnd0, opnd1, opnd2; } ternary;
-    struct { gimple fn_from; bool pure; size_t nargs; tree *args; } call;
+    struct { gimple_call fn_from; bool pure; size_t nargs; tree *args; } call;
     struct { size_t nargs; tree *args; } phi;
   } ops;
 };
@@ -321,18 +321,18 @@ initialize_hash_element (gimple stmt, tree lhs,
       expr->ops.binary.opnd0 = gimple_cond_lhs (stmt);
       expr->ops.binary.opnd1 = gimple_cond_rhs (stmt);
     }
-  else if (code == GIMPLE_CALL)
+  else if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
     {
-      size_t nargs = gimple_call_num_args (stmt);
+      size_t nargs = gimple_call_num_args (call_stmt);
       size_t i;
 
-      gcc_assert (gimple_call_lhs (stmt));
+      gcc_assert (gimple_call_lhs (call_stmt));
 
-      expr->type = TREE_TYPE (gimple_call_lhs (stmt));
+      expr->type = TREE_TYPE (gimple_call_lhs (call_stmt));
       expr->kind = EXPR_CALL;
-      expr->ops.call.fn_from = stmt;
+      expr->ops.call.fn_from = call_stmt;
 
-      if (gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE))
+      if (gimple_call_flags (call_stmt) & (ECF_CONST | ECF_PURE))
         expr->ops.call.pure = true;
       else
         expr->ops.call.pure = false;
@@ -340,7 +340,7 @@ initialize_hash_element (gimple stmt, tree lhs,
       expr->ops.call.nargs = nargs;
       expr->ops.call.args = XCNEWVEC (tree, nargs);
       for (i = 0; i < nargs; i++)
-        expr->ops.call.args[i] = gimple_call_arg (stmt, i);
+        expr->ops.call.args[i] = gimple_call_arg (call_stmt, i);
     }
   else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
     {
@@ -626,7 +626,7 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
       {
         size_t i;
         enum tree_code code = CALL_EXPR;
-        gimple fn_from;
+        gimple_call fn_from;
 
         val = iterative_hash_object (code, val);
         fn_from = expr->ops.call.fn_from;
@@ -703,7 +703,7 @@ print_expr_hash_elt (FILE * stream, const struct expr_hash_elt *element)
         {
           size_t i;
           size_t nargs = element->expr.ops.call.nargs;
-          gimple fn_from;
+          gimple_call fn_from;
 
           fn_from = element->expr.ops.call.fn_from;
           if (gimple_call_internal_p (fn_from))
-- 
1.8.5.3

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

* [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (42 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 17:24   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr David Malcolm
                   ` (47 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_goto_set_dest): Require a gimple_goto.

	* tree-cfg.c (factor_computed_gotos): Add checked cast to gimple_goto.
	(cleanup_dead_labels): Likewise.
---
 gcc/gimple.h   | 3 +--
 gcc/tree-cfg.c | 5 +++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 38f4ea7..7dfd512 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3509,9 +3509,8 @@ gimple_goto_dest (const_gimple gs)
 /* Set DEST to be the destination of the unconditonal jump GS.  */
 
 static inline void
-gimple_goto_set_dest (gimple gs, tree dest)
+gimple_goto_set_dest (gimple_goto gs, tree dest)
 {
-  GIMPLE_CHECK (gs, GIMPLE_GOTO);
   gimple_set_op (gs, 0, dest);
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 9efb01c..efc3367 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1422,10 +1422,11 @@ cleanup_dead_labels (void)
 	case GIMPLE_GOTO:
 	  if (!computed_goto_p (stmt))
 	    {
-	      label = gimple_goto_dest (stmt);
+	      gimple_goto goto_stmt = stmt->as_a_gimple_goto ();
+	      label = gimple_goto_dest (goto_stmt);
 	      new_label = main_block_label (label);
 	      if (new_label != label)
-		gimple_goto_set_dest (stmt, new_label);
+		gimple_goto_set_dest (goto_stmt, new_label);
 	    }
 	  break;
 
-- 
1.8.5.3

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

* [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (26 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 88/89] Use gimple_phi in many more places David Malcolm
@ 2014-04-21 16:57 ` David Malcolm
  2014-05-12 19:26   ` Jeff Law
  2014-04-21 16:57 ` [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi David Malcolm
                   ` (63 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_lhs_ptr): Require a const_gimple_cond
	rather than just a const_gimple_cond.
	(gimple_cond_rhs_ptr): Likewise.

	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
	to gimple_cond within "case GIMPLE_COND".
	* omp-low.c (lower_omp_1): Likewise.

	* omp-low.c (expand_omp_simd): Introduce a new local cond_stmt
	to express that the conditional is indeed a gimple_cond.

	* tree-ssa-loop-ivopts.c (extract_cond_operands): Add a checked
	cast to gimple_cond within a region where the code is known to
	be GIMPLE_COND.
---
 gcc/gimple.h               |  6 ++----
 gcc/gimplify-me.c          | 11 +++++++----
 gcc/omp-low.c              | 30 ++++++++++++++++++------------
 gcc/tree-ssa-loop-ivopts.c |  5 +++--
 4 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index a8da0c4..accd4e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3305,9 +3305,8 @@ gimple_cond_lhs (const_gimple gs)
    statement GS.  */
 
 static inline tree *
-gimple_cond_lhs_ptr (const_gimple gs)
+gimple_cond_lhs_ptr (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op_ptr (gs, 0);
 }
 
@@ -3334,9 +3333,8 @@ gimple_cond_rhs (const_gimple gs)
    conditional GS.  */
 
 static inline tree *
-gimple_cond_rhs_ptr (const_gimple gs)
+gimple_cond_rhs_ptr (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op_ptr (gs, 1);
 }
 
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 5008fff..9cf0cc4 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -168,10 +168,13 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      gimplify_expr (gimple_cond_lhs_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
-      gimplify_expr (gimple_cond_rhs_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	gimplify_expr (gimple_cond_lhs_ptr (cond_stmt), &pre, NULL,
+		       is_gimple_val, fb_rvalue);
+	gimplify_expr (gimple_cond_rhs_ptr (cond_stmt), &pre, NULL,
+		       is_gimple_val, fb_rvalue);
+      }
       break;
     case GIMPLE_SWITCH:
       gimplify_expr (gimple_switch_index_ptr (stmt->as_a_gimple_switch ()),
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b6d5674..5ae014c 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6621,6 +6621,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
   basic_block entry_bb, cont_bb, exit_bb, l0_bb, l1_bb, l2_bb, l2_dom_bb;
   gimple_stmt_iterator gsi;
   gimple stmt;
+  gimple_cond cond_stmt;
   bool broken_loop = region->cont == NULL;
   edge e, ne;
   tree *counts = NULL;
@@ -6780,15 +6781,15 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
   t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
 				false, GSI_CONTINUE_LINKING);
   t = build2 (fd->loop.cond_code, boolean_type_node, fd->loop.v, t);
-  stmt = gimple_build_cond_empty (t);
-  gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
-  if (walk_tree (gimple_cond_lhs_ptr (stmt), expand_omp_regimplify_p,
+  cond_stmt = gimple_build_cond_empty (t);
+  gsi_insert_after (&gsi, cond_stmt, GSI_CONTINUE_LINKING);
+  if (walk_tree (gimple_cond_lhs_ptr (cond_stmt), expand_omp_regimplify_p,
 		 NULL, NULL)
-      || walk_tree (gimple_cond_rhs_ptr (stmt), expand_omp_regimplify_p,
+      || walk_tree (gimple_cond_rhs_ptr (cond_stmt), expand_omp_regimplify_p,
 		    NULL, NULL))
     {
-      gsi = gsi_for_stmt (stmt);
-      gimple_regimplify_operands (stmt, &gsi);
+      gsi = gsi_for_stmt (cond_stmt);
+      gimple_regimplify_operands (cond_stmt, &gsi);
     }
 
   /* Remove GIMPLE_OMP_RETURN.  */
@@ -10016,12 +10017,17 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      if ((ctx || task_shared_vars)
-	  && (walk_tree (gimple_cond_lhs_ptr (stmt), lower_omp_regimplify_p,
-	      		 ctx ? NULL : &wi, NULL)
-	      || walk_tree (gimple_cond_rhs_ptr (stmt), lower_omp_regimplify_p,
-			    ctx ? NULL : &wi, NULL)))
-	gimple_regimplify_operands (stmt, gsi_p);
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	if ((ctx || task_shared_vars)
+	    && (walk_tree (gimple_cond_lhs_ptr (cond_stmt),
+			   lower_omp_regimplify_p,
+			   ctx ? NULL : &wi, NULL)
+		|| walk_tree (gimple_cond_rhs_ptr (cond_stmt),
+			      lower_omp_regimplify_p,
+			      ctx ? NULL : &wi, NULL)))
+	  gimple_regimplify_operands (cond_stmt, gsi_p);
+      }
       break;
     case GIMPLE_CATCH:
       lower_omp (gimple_catch_handler_ptr (stmt->as_a_gimple_catch ()), ctx);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 2be1a6d..ea4dca9 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1351,8 +1351,9 @@ extract_cond_operands (struct ivopts_data *data, gimple stmt,
 
   if (gimple_code (stmt) == GIMPLE_COND)
     {
-      op0 = gimple_cond_lhs_ptr (stmt);
-      op1 = gimple_cond_rhs_ptr (stmt);
+      gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+      op0 = gimple_cond_lhs_ptr (cond_stmt);
+      op1 = gimple_cond_rhs_ptr (cond_stmt);
     }
   else
     {
-- 
1.8.5.3

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

* [PATCH 43/89] Introduce gimple_omp_target
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (50 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location " David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:36   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals David Malcolm
                   ` (39 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_target): New typedef.
	(const_gimple_omp_target): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_target): New.
	(gimple_build_omp_target): Return a gimple_omp_target
	rather than a plain gimple.
	(gimple_omp_target_set_clauses): Require a gimple_omp_target
	rather than a plain gimple.
	(gimple_omp_target_set_kind): Likewise.
	(gimple_omp_target_child_fn_ptr): Likewise.
	(gimple_omp_target_set_child_fn): Likewise.
	(gimple_omp_target_data_arg_ptr): Likewise.
	(gimple_omp_target_set_data_arg): Likewise.
	(gimple_omp_target_child_fn): Require a const_gimple_omp_target
	rather than a plain const_gimple.
	(gimple_omp_target_data_arg): Likewise.

	* gimple-pretty-print.c (dump_gimple_omp_target): Require a
	gimple_omp_target rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_target within
	GIMPLE_OMP_TARGET case of switch statement.

	* gimple.c (gimple_build_omp_target): Return a gimple_omp_target
	rather than a plain gimple.

	* gimplify.c (gimplify_omp_target_update): Strengthen local "stmt"
	from gimple to gimple_omp_target.

	* omp-low.c (scan_omp_target): Require a gimple_omp_target rather
	than a plain gimple.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_target within
	GIMPLE_OMP_TARGET case of switch statement.
	(expand_omp_target): Strengthen local "entry_stmt" from gimple to
	gimple_omp_target.
	(lower_omp_target): Likewise for "stmt".
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  6 ++++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 54 +++++++++++++++++++++--------------------------
 gcc/gimplify.c            |  2 +-
 gcc/omp-low.c             | 11 +++++-----
 6 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 6d7bb0f..1ac8765 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -179,6 +179,10 @@ struct gimple_statement_omp_single;
 typedef struct gimple_statement_omp_single *gimple_omp_single;
 typedef const struct gimple_statement_omp_single *const_gimple_omp_single;
 
+struct gimple_statement_omp_target;
+typedef struct gimple_statement_omp_target *gimple_omp_target;
+typedef const struct gimple_statement_omp_target *const_gimple_omp_target;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d024730..a5d8706 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1281,7 +1281,8 @@ dump_gimple_omp_single (pretty_printer *buffer, gimple_omp_single gs,
 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_target (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_target (pretty_printer *buffer, gimple_omp_target gs,
+			int spc, int flags)
 {
   const char *kind;
   switch (gimple_omp_target_kind (gs))
@@ -2178,7 +2179,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_TARGET:
-      dump_gimple_omp_target (buffer, gs, spc, flags);
+      dump_gimple_omp_target (buffer, gs->as_a_gimple_omp_target (), spc,
+			      flags);
       break;
 
     case GIMPLE_OMP_TEAMS:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index ba9adb8..2ba7c5b 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1051,10 +1051,11 @@ gimple_build_omp_single (gimple_seq body, tree clauses)
    BODY is the sequence of statements that will be executed.
    CLAUSES are any of the OMP target construct's clauses.  */
 
-gimple
+gimple_omp_target
 gimple_build_omp_target (gimple_seq body, int kind, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_TARGET, 0);
+  gimple_omp_target p =
+    gimple_alloc (GIMPLE_OMP_TARGET, 0)->as_a_gimple_omp_target ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_target_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 485cec4..d791a28 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -384,6 +384,12 @@ public:
     return as_a <gimple_statement_omp_single> (this);
   }
 
+  inline gimple_omp_target
+  as_a_gimple_omp_target ()
+  {
+    return as_a <gimple_statement_omp_target> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1643,7 +1649,7 @@ gimple gimple_build_omp_return (bool);
 gimple gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
 gimple_omp_single gimple_build_omp_single (gimple_seq, tree);
-gimple gimple_build_omp_target (gimple_seq, int, tree);
+gimple_omp_target gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
 gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
 gimple_omp_atomic_store gimple_build_omp_atomic_store (tree);
@@ -5367,13 +5373,12 @@ gimple_omp_target_clauses_ptr (gimple gs)
 }
 
 
-/* Set CLAUSES to be the clauses associated with OMP_TARGET GS.  */
+/* Set CLAUSES to be the clauses associated with OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_clauses (gimple gs, tree clauses)
+gimple_omp_target_set_clauses (gimple_omp_target omp_target_stmt,
+			       tree clauses)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->clauses = clauses;
 }
 
@@ -5391,55 +5396,47 @@ gimple_omp_target_kind (const_gimple g)
 /* Set the OMP target kind.  */
 
 static inline void
-gimple_omp_target_set_kind (gimple g, int kind)
+gimple_omp_target_set_kind (gimple_omp_target g, int kind)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_TARGET);
   g->subcode = (g->subcode & ~GF_OMP_TARGET_KIND_MASK)
 		      | (kind & GF_OMP_TARGET_KIND_MASK);
 }
 
 
-/* Return the child function used to hold the body of OMP_TARGET GS.  */
+/* Return the child function used to hold the body of OMP_TARGET_STMT.  */
 
 static inline tree
-gimple_omp_target_child_fn (const_gimple gs)
+gimple_omp_target_child_fn (const_gimple_omp_target omp_target_stmt)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target> (gs);
   return omp_target_stmt->child_fn;
 }
 
 /* Return a pointer to the child function used to hold the body of
-   OMP_TARGET GS.  */
+   OMP_TARGET_STMT.  */
 
 static inline tree *
-gimple_omp_target_child_fn_ptr (gimple gs)
+gimple_omp_target_child_fn_ptr (gimple_omp_target omp_target_stmt)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   return &omp_target_stmt->child_fn;
 }
 
 
-/* Set CHILD_FN to be the child function for OMP_TARGET GS.  */
+/* Set CHILD_FN to be the child function for OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
+gimple_omp_target_set_child_fn (gimple_omp_target omp_target_stmt,
+				tree child_fn)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->child_fn = child_fn;
 }
 
 
 /* Return the artificial argument used to send variables and values
-   from the parent to the children threads in OMP_TARGET GS.  */
+   from the parent to the children threads in OMP_TARGET_STMT.  */
 
 static inline tree
-gimple_omp_target_data_arg (const_gimple gs)
+gimple_omp_target_data_arg (const_gimple_omp_target omp_target_stmt)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target> (gs);
   return omp_target_stmt->data_arg;
 }
 
@@ -5447,21 +5444,18 @@ gimple_omp_target_data_arg (const_gimple gs)
 /* Return a pointer to the data argument for OMP_TARGET GS.  */
 
 static inline tree *
-gimple_omp_target_data_arg_ptr (gimple gs)
+gimple_omp_target_data_arg_ptr (gimple_omp_target omp_target_stmt)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   return &omp_target_stmt->data_arg;
 }
 
 
-/* Set DATA_ARG to be the data argument for OMP_TARGET GS.  */
+/* Set DATA_ARG to be the data argument for OMP_TARGET_STMT.  */
 
 static inline void
-gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
+gimple_omp_target_set_data_arg (gimple_omp_target omp_target_stmt,
+				tree data_arg)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target> (gs);
   omp_target_stmt->data_arg = data_arg;
 }
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 763b3c0..1c7481d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6971,7 +6971,7 @@ static void
 gimplify_omp_target_update (tree *expr_p, gimple_seq *pre_p)
 {
   tree expr = *expr_p;
-  gimple stmt;
+  gimple_omp_target stmt;
 
   gimplify_scan_omp_clauses (&OMP_TARGET_UPDATE_CLAUSES (expr), pre_p,
 			     ORT_WORKSHARE);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index f17226b..9809cf4 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2180,7 +2180,7 @@ scan_omp_single (gimple_omp_single stmt, omp_context *outer_ctx)
 /* Scan an OpenMP target{, data, update} directive.  */
 
 static void
-scan_omp_target (gimple stmt, omp_context *outer_ctx)
+scan_omp_target (gimple_omp_target stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name;
@@ -2664,7 +2664,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TARGET:
-      scan_omp_target (stmt, ctx);
+      scan_omp_target (stmt->as_a_gimple_omp_target (), ctx);
       break;
 
     case GIMPLE_OMP_TEAMS:
@@ -7810,10 +7810,11 @@ expand_omp_target (struct omp_region *region)
   struct function *child_cfun = NULL;
   tree child_fn = NULL_TREE, block, t;
   gimple_stmt_iterator gsi;
-  gimple entry_stmt, stmt;
+  gimple_omp_target entry_stmt;
+  gimple stmt;
   edge e;
 
-  entry_stmt = last_stmt (region->entry);
+  entry_stmt = last_stmt (region->entry)->as_a_gimple_omp_target ();
   new_bb = region->entry;
   int kind = gimple_omp_target_kind (entry_stmt);
   if (kind == GF_OMP_TARGET_KIND_REGION)
@@ -9589,7 +9590,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree clauses;
   tree child_fn, t, c;
-  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_omp_target stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_target ();
   gimple_bind tgt_bind = NULL, bind;
   gimple_seq tgt_body = NULL, olist, ilist, new_body;
   location_t loc = gimple_location (stmt);
-- 
1.8.5.3

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

* [PATCH 77/89] Concretize various expressions from gimple to gimple_cond
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (53 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 53/89] More gimple_phi David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 19:36   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond David Malcolm
                   ` (36 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* ipa-split.c (check_forbidden_calls): Replace check against
	GIMPLE_COND with a dyn_cast_gimple_cond, introducing a gimple_cond
	local.
	* predict.c (predict_extra_loop_exits): Likewise.
	* tree-vrp.c (fold_predicate_in): Likewise.
	(simplify_stmt_for_jump_threading): Likewise.

	* predict.c (is_comparison_with_loop_invariant_p): Require a
	gimple_cond.
	(predict_iv_comparison): Add checked cast to gimple_cond once we
	know the code is GIMPLE_COND.
	(predict_loops): Change type of "stmt" to gimple_cond,
	adding checked casts to its assignments (which are both guarded by
	checks against GIMPLE_COND).

	* tree-vrp.c (find_conditional_asserts): Require a gimple_cond.
	(vrp_evaluate_conditional): Likewise.
	(find_assert_locations_1): Add checked cast to gimple_cond.
	(vrp_visit_stmt): Likewise.
---
 gcc/ipa-split.c |  5 +++--
 gcc/predict.c   | 21 ++++++++++++++-------
 gcc/tree-vrp.c  | 25 +++++++++++++------------
 3 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 1287757..0808f9c 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -326,9 +326,10 @@ check_forbidden_calls (gimple stmt)
       basic_block use_bb, forbidden_bb;
       enum tree_code code;
       edge true_edge, false_edge;
-      gimple use_stmt = USE_STMT (use_p);
+      gimple_cond use_stmt;
 
-      if (gimple_code (use_stmt) != GIMPLE_COND)
+      use_stmt = USE_STMT (use_p)->dyn_cast_gimple_cond ();
+      if (!use_stmt)
 	continue;
 
       /* Assuming canonical form for GIMPLE_COND here, with constant
diff --git a/gcc/predict.c b/gcc/predict.c
index 7fa31d8..c3ab183 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1107,7 +1107,7 @@ get_base_value (tree t)
    Otherwise return false and set LOOP_INVAIANT to NULL.  */
 
 static bool
-is_comparison_with_loop_invariant_p (gimple stmt, struct loop *loop,
+is_comparison_with_loop_invariant_p (gimple_cond stmt, struct loop *loop,
 				     tree *loop_invariant,
 				     enum tree_code *compare_code,
 				     tree *loop_step,
@@ -1272,7 +1272,8 @@ predict_iv_comparison (struct loop *loop, basic_block bb,
   stmt = last_stmt (bb);
   if (!stmt || gimple_code (stmt) != GIMPLE_COND)
     return;
-  if (!is_comparison_with_loop_invariant_p (stmt, loop, &compare_var,
+  if (!is_comparison_with_loop_invariant_p (stmt->as_a_gimple_cond (),
+					    loop, &compare_var,
 					    &compare_code,
 					    &compare_step_var,
 					    &compare_base))
@@ -1465,10 +1466,16 @@ predict_extra_loop_exits (edge exit_edge)
   gimple lhs_def_stmt;
   gimple_phi phi_stmt;
   tree cmp_rhs, cmp_lhs;
-  gimple cmp_stmt = last_stmt (exit_edge->src);
+  gimple last;
+  gimple_cond cmp_stmt;
 
-  if (!cmp_stmt || gimple_code (cmp_stmt) != GIMPLE_COND)
+  last = last_stmt (exit_edge->src);
+  if (!last)
+    return;
+  cmp_stmt = last->dyn_cast_gimple_cond ();
+  if (!cmp_stmt)
     return;
+
   cmp_rhs = gimple_cond_rhs (cmp_stmt);
   cmp_lhs = gimple_cond_lhs (cmp_stmt);
   if (!TREE_CONSTANT (cmp_rhs)
@@ -1535,7 +1542,7 @@ predict_loops (void)
       tree loop_bound_step = NULL;
       tree loop_bound_var = NULL;
       tree loop_iv_base = NULL;
-      gimple stmt = NULL;
+      gimple_cond stmt = NULL;
 
       exits = get_loop_exit_edges (loop);
       n_exits = exits.length ();
@@ -1602,12 +1609,12 @@ predict_loops (void)
 	if (nb_iter->stmt
 	    && gimple_code (nb_iter->stmt) == GIMPLE_COND)
 	  {
-	    stmt = nb_iter->stmt;
+	    stmt = nb_iter->stmt->as_a_gimple_cond ();
 	    break;
 	  }
       if (!stmt && last_stmt (loop->header)
 	  && gimple_code (last_stmt (loop->header)) == GIMPLE_COND)
-	stmt = last_stmt (loop->header);
+	stmt = last_stmt (loop->header)->as_a_gimple_cond ();
       if (stmt)
 	is_comparison_with_loop_invariant_p (stmt, loop,
 					     &loop_bound_var,
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 62ec9f5..5b701a6 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5584,7 +5584,7 @@ register_edge_assert_for (tree name, edge e, gimple_stmt_iterator si,
    list of assertions for the corresponding operands.  */
 
 static bool
-find_conditional_asserts (basic_block bb, gimple last)
+find_conditional_asserts (basic_block bb, gimple_cond last)
 {
   bool need_assert;
   gimple_stmt_iterator bsi;
@@ -5826,7 +5826,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
       && gimple_code (last) == GIMPLE_COND
       && !fp_predicate (last)
       && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
-    need_assert |= find_conditional_asserts (bb, last);
+    need_assert |= find_conditional_asserts (bb, last->as_a_gimple_cond ());
 
   /* If BB's last statement is a switch statement involving integer
      operands, determine if we need to add ASSERT_EXPRs.  */
@@ -7200,7 +7200,7 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt)
    SSA_PROP_VARYING.  */
 
 static enum ssa_prop_result
-vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
+vrp_visit_cond_stmt (gimple_cond stmt, edge *taken_edge_p)
 {
   tree val;
   bool sop;
@@ -7613,7 +7613,7 @@ vrp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
   else if (is_gimple_assign (stmt) || is_gimple_call (stmt))
     return vrp_visit_assignment_or_call (stmt, output_p);
   else if (gimple_code (stmt) == GIMPLE_COND)
-    return vrp_visit_cond_stmt (stmt, taken_edge_p);
+    return vrp_visit_cond_stmt (stmt->as_a_gimple_cond (), taken_edge_p);
   else if (gimple_code (stmt) == GIMPLE_SWITCH)
     return vrp_visit_switch_stmt (stmt->as_a_gimple_switch (), taken_edge_p);
 
@@ -9490,10 +9490,10 @@ fold_predicate_in (gimple_stmt_iterator *si)
 				      gimple_assign_rhs2 (stmt),
 				      stmt);
     }
-  else if (gimple_code (stmt) == GIMPLE_COND)
-    val = vrp_evaluate_conditional (gimple_cond_code (stmt),
-				    gimple_cond_lhs (stmt),
-				    gimple_cond_rhs (stmt),
+  else if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
+    val = vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
+				    gimple_cond_lhs (cond_stmt),
+				    gimple_cond_rhs (cond_stmt),
 				    stmt);
   else
     return false;
@@ -9558,10 +9558,11 @@ static vec<tree> equiv_stack;
 static tree
 simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
 {
-  if (gimple_code (stmt) == GIMPLE_COND)
-    return vrp_evaluate_conditional (gimple_cond_code (stmt),
-				     gimple_cond_lhs (stmt),
-				     gimple_cond_rhs (stmt), within_stmt);
+  if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
+    return vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
+				     gimple_cond_lhs (cond_stmt),
+				     gimple_cond_rhs (cond_stmt),
+				     within_stmt);
 
   if (gimple_assign assign_stmt = stmt->dyn_cast_gimple_assign ())
     {
-- 
1.8.5.3

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

* [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (48 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:54   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location " David Malcolm
                   ` (41 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_arg_location_from_edge): Require a
	gimple_phi.

	* tree-parloops.c (create_parallel_loop): Split up local variable
	"stmt", introducing other locals for the various statements created
	by this function.  Reuse "stmt" within the phi-handling code, and
	change to type gimple_phi, since this is the only remaining
	"non-phi" user of gimple_phi_arg_location_from_edge.
---
 gcc/gimple.h        |  6 +++---
 gcc/tree-parloops.c | 46 +++++++++++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 788e8c7..becd273 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4258,12 +4258,12 @@ gimple_phi_arg_location (gimple gs, size_t i)
   return gimple_phi_arg (gs, i)->locus;
 }
 
-/* Return the source location of the argument on edge E of phi node GS.  */
+/* Return the source location of the argument on edge E of phi node PHI.  */
 
 static inline source_location
-gimple_phi_arg_location_from_edge (gimple gs, edge e)
+gimple_phi_arg_location_from_edge (gimple_phi phi, edge e)
 {
-  return gimple_phi_arg (gs, e->dest_idx)->locus;
+  return gimple_phi_arg (phi, e->dest_idx)->locus;
 }
 
 /* Set the source location of gimple argument I of phi node PHI to LOC.  */
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index c85baf1..94af311 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1622,8 +1622,11 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   gimple_stmt_iterator gsi;
   basic_block bb, paral_bb, for_bb, ex_bb;
   tree t, param;
-  gimple stmt, phi, cond_stmt;
+  gimple_omp_parallel omp_par_stmt;
+  gimple omp_return_stmt1, omp_return_stmt2;
+  gimple phi, cond_stmt;
   gimple_omp_for for_stmt;
+  gimple_omp_continue omp_cont_stmt;
   tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
   edge exit, nexit, guard, end, e;
 
@@ -1635,31 +1638,33 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS);
   OMP_CLAUSE_NUM_THREADS_EXPR (t)
     = build_int_cst (integer_type_node, n_threads);
-  stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
-  gimple_set_location (stmt, loc);
+  omp_par_stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
+  gimple_set_location (omp_par_stmt, loc);
 
-  gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+  gsi_insert_after (&gsi, omp_par_stmt, GSI_NEW_STMT);
 
   /* Initialize NEW_DATA.  */
   if (data)
     {
+      gimple_assign assign_stmt;
+
       gsi = gsi_after_labels (bb);
 
       param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL);
-      stmt = gimple_build_assign (param, build_fold_addr_expr (data));
-      gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+      assign_stmt = gimple_build_assign (param, build_fold_addr_expr (data));
+      gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
 
-      stmt = gimple_build_assign (new_data,
+      assign_stmt = gimple_build_assign (new_data,
 				  fold_convert (TREE_TYPE (new_data), param));
-      gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+      gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
     }
 
   /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL.  */
   bb = split_loop_exit_edge (single_dom_exit (loop));
   gsi = gsi_last_bb (bb);
-  stmt = gimple_build_omp_return (false);
-  gimple_set_location (stmt, loc);
-  gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+  omp_return_stmt1 = gimple_build_omp_return (false);
+  gimple_set_location (omp_return_stmt1, loc);
+  gsi_insert_after (&gsi, omp_return_stmt1, GSI_NEW_STMT);
 
   /* Extract data for GIMPLE_OMP_FOR.  */
   gcc_assert (loop->header == single_dom_exit (loop)->src);
@@ -1693,7 +1698,10 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
       source_location locus;
       tree def;
       gimple_phi phi = gpi.phi ();
-      stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
+      gimple_phi stmt;
+
+      stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit))
+	       ->as_a_gimple_phi ();
 
       def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
       locus = gimple_phi_arg_location_from_edge (stmt,
@@ -1729,16 +1737,16 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
 
   /* Emit GIMPLE_OMP_CONTINUE.  */
   gsi = gsi_last_bb (loop->latch);
-  stmt = gimple_build_omp_continue (cvar_next, cvar);
-  gimple_set_location (stmt, loc);
-  gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
-  SSA_NAME_DEF_STMT (cvar_next) = stmt;
+  omp_cont_stmt = gimple_build_omp_continue (cvar_next, cvar);
+  gimple_set_location (omp_cont_stmt, loc);
+  gsi_insert_after (&gsi, omp_cont_stmt, GSI_NEW_STMT);
+  SSA_NAME_DEF_STMT (cvar_next) = omp_cont_stmt;
 
   /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR.  */
   gsi = gsi_last_bb (ex_bb);
-  stmt = gimple_build_omp_return (true);
-  gimple_set_location (stmt, loc);
-  gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+  omp_return_stmt2 = gimple_build_omp_return (true);
+  gimple_set_location (omp_return_stmt2, loc);
+  gsi_insert_after (&gsi, omp_return_stmt2, GSI_NEW_STMT);
 
   /* After the above dom info is hosed.  Re-compute it.  */
   free_dominance_info (CDI_DOMINATORS);
-- 
1.8.5.3

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

* [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond.
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (54 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 77/89] Concretize various expressions from gimple to gimple_cond David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:58   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args David Malcolm
                   ` (35 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_set_true_label): Require a gimple_cond.
	(gimple_cond_set_false_label): Likewise.

	* tree-cfg.c (make_cond_expr_edges): Convert "entry" from gimple to
	a gimple_cond.
	(cleanup_dead_labels): Introduce a checked cast to a gimple_cond within
	the GIMPLE_COND case.
---
 gcc/gimple.h   |  6 ++----
 gcc/tree-cfg.c | 33 ++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 15e09db..395c432 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3369,9 +3369,8 @@ gimple_cond_true_label (const_gimple gs)
    predicate evaluates to true.  */
 
 static inline void
-gimple_cond_set_true_label (gimple gs, tree label)
+gimple_cond_set_true_label (gimple_cond gs, tree label)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   gimple_set_op (gs, 2, label);
 }
 
@@ -3380,9 +3379,8 @@ gimple_cond_set_true_label (gimple gs, tree label)
    predicate evaluates to false.  */
 
 static inline void
-gimple_cond_set_false_label (gimple gs, tree label)
+gimple_cond_set_false_label (gimple_cond gs, tree label)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   gimple_set_op (gs, 3, label);
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index caa11c1..68093de 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -999,7 +999,7 @@ assign_discriminators (void)
 static void
 make_cond_expr_edges (basic_block bb)
 {
-  gimple entry = last_stmt (bb);
+  gimple_cond entry = last_stmt (bb)->as_a_gimple_cond ();
   gimple then_stmt, else_stmt;
   basic_block then_bb, else_bb;
   tree then_label, else_label;
@@ -1370,21 +1370,24 @@ cleanup_dead_labels (void)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_COND:
-	  label = gimple_cond_true_label (stmt);
-	  if (label)
-	    {
-	      new_label = main_block_label (label);
-	      if (new_label != label)
-		gimple_cond_set_true_label (stmt, new_label);
-	    }
+	  {
+	    gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	    label = gimple_cond_true_label (cond_stmt);
+	    if (label)
+	      {
+		new_label = main_block_label (label);
+		if (new_label != label)
+		  gimple_cond_set_true_label (cond_stmt, new_label);
+	      }
 
-	  label = gimple_cond_false_label (stmt);
-	  if (label)
-	    {
-	      new_label = main_block_label (label);
-	      if (new_label != label)
-		gimple_cond_set_false_label (stmt, new_label);
-	    }
+	    label = gimple_cond_false_label (cond_stmt);
+	    if (label)
+	      {
+		new_label = main_block_label (label);
+		if (new_label != label)
+		  gimple_cond_set_false_label (cond_stmt, new_label);
+	      }
+	  }
 	  break;
 
 	case GIMPLE_SWITCH:
-- 
1.8.5.3

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

* [PATCH 53/89] More gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (52 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:23   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 77/89] Concretize various expressions from gimple to gimple_cond David Malcolm
                   ` (37 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_set_result): Require a gimple_phi rather
	than a plain gimple.
	(gimple_phi_set_arg): Likewise.

	* tree-outof-ssa.c (remove_gimple_phi_args): Likewise; add a checked
	cast to gimple_phi.

	* tree-sra.c (replace_removed_params_ssa_names): Add a checked
	cast to gimple_phi.
---
 gcc/gimple.h         | 18 ++++++++----------
 gcc/tree-outof-ssa.c |  4 ++--
 gcc/tree-sra.c       |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 72f67ce..c48b3d5 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4181,15 +4181,14 @@ gimple_phi_result_ptr (gimple gs)
   return &phi_stmt->result;
 }
 
-/* Set RESULT to be the SSA name created by GIMPLE_PHI GS.  */
+/* Set RESULT to be the SSA name created by GIMPLE_PHI PHI.  */
 
 static inline void
-gimple_phi_set_result (gimple gs, tree result)
+gimple_phi_set_result (gimple_phi phi, tree result)
 {
-  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
-  phi_stmt->result = result;
+  phi->result = result;
   if (result && TREE_CODE (result) == SSA_NAME)
-    SSA_NAME_DEF_STMT (result) = gs;
+    SSA_NAME_DEF_STMT (result) = phi;
 }
 
 
@@ -4205,14 +4204,13 @@ gimple_phi_arg (gimple gs, unsigned index)
 }
 
 /* Set PHIARG to be the argument corresponding to incoming edge INDEX
-   for GIMPLE_PHI GS.  */
+   for GIMPLE_PHI PHI.  */
 
 static inline void
-gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
+gimple_phi_set_arg (gimple_phi phi, unsigned index, struct phi_arg_d * phiarg)
 {
-  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
-  gcc_gimple_checking_assert (index <= phi_stmt->nargs);
-  phi_stmt->args[index] = *phiarg;
+  gcc_gimple_checking_assert (index <= phi->nargs);
+  phi->args[index] = *phiarg;
 }
 
 /* Return the PHI nodes for basic block BB, or NULL if there are no
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 026b048..d1f91dd 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -788,7 +788,7 @@ eliminate_phi (edge e, elim_graph g)
    check to see if this allows another PHI node to be removed.  */
 
 static void
-remove_gimple_phi_args (gimple phi)
+remove_gimple_phi_args (gimple_phi phi)
 {
   use_operand_p arg_p;
   ssa_op_iter iter;
@@ -816,7 +816,7 @@ remove_gimple_phi_args (gimple phi)
 	      /* Also remove the def if it is a PHI node.  */
 	      if (gimple_code (stmt) == GIMPLE_PHI)
 		{
-		  remove_gimple_phi_args (stmt);
+		  remove_gimple_phi_args (stmt->as_a_gimple_phi ());
 		  gsi = gsi_for_stmt (stmt);
 		  remove_phi_node (&gsi, true);
 		}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 52198a8..e6e0629 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4517,7 +4517,7 @@ replace_removed_params_ssa_names (gimple stmt,
   else if (is_gimple_call (stmt))
     gimple_call_set_lhs (stmt, name);
   else
-    gimple_phi_set_result (stmt, name);
+    gimple_phi_set_result (stmt->as_a_gimple_phi (), name);
 
   replace_uses_by (lhs, name);
   release_ssa_name (lhs);
-- 
1.8.5.3

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

* [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (49 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:48   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 43/89] Introduce gimple_omp_target David Malcolm
                   ` (40 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_arg_def_ptr): Require a gimple_phi rather
	than a plain gimple.
	(gimple_phi_arg_has_location): Likewise.

	* gimple-streamer-in.c (input_phi): Return a gimple_phi rather
	than a plain gimple.
	* gimple-streamer-out.c (output_phi): Require a gimple_phi rather
	than a plain gimple.
	(output_bb): Convert iteration to a gimple_phi_iterator, and local
	"phi" to gimple_phi.

	* omp-low.c (expand_omp_for_static_chunk): Convert iterator "psi"
	to a gimple_phi_iterator; convert locals "phi" and "nphi" to be
	gimple_phi.

	* tree-cfg.c (gimple_duplicate_sese_tail): Likewise for "psi" and
	"phi".
	(move_block_to_fn): Introduce new gimple_phi_iterator "psi", using
	it in place of "gsi" where necessary.  Convert "phi" to be a
	gimple_phi.

	* tree-cfgcleanup.c (remove_forwarder_block): Likewise.

	* tree-vect-loop-manip.c (vect_loop_versioning): Convert "gsi" to
	a gimple_phi_iterator, and "orig_phi" and "new_phi" to be
	gimple_phi.

	* tree.c (find_decls_types_in_node): Introduce new
	gimple_phi_iterator "psi", using it in place of "si" where
	necessary.  Convert "phi" to be a gimple_phi.
---
 gcc/gimple-streamer-in.c   |  4 ++--
 gcc/gimple-streamer-out.c  |  8 +++++---
 gcc/gimple.h               | 12 ++++++------
 gcc/omp-low.c              |  8 ++++----
 gcc/tree-cfg.c             | 15 ++++++++-------
 gcc/tree-cfgcleanup.c      |  8 ++++----
 gcc/tree-vect-loop-manip.c |  7 ++++---
 gcc/tree.c                 |  5 +++--
 8 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 4fb0b41..69a20a1 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -44,14 +44,14 @@ along with GCC; see the file COPYING3.  If not see
 /* Read a PHI function for basic block BB in function FN.  DATA_IN is
    the file being read.  IB is the input block to use for reading.  */
 
-static gimple
+static gimple_phi
 input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
 	   struct function *fn)
 {
   unsigned HOST_WIDE_INT ix;
   tree phi_result;
   int i, len;
-  gimple result;
+  gimple_phi result;
 
   ix = streamer_read_uhwi (ib);
   phi_result = (*SSANAMES (fn))[ix];
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 5d3adf8..b27d4de 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -41,7 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Output PHI function PHI to the main stream in OB.  */
 
 static void
-output_phi (struct output_block *ob, gimple phi)
+output_phi (struct output_block *ob, gimple_phi phi)
 {
   unsigned i, len = gimple_phi_num_args (phi);
 
@@ -238,9 +238,11 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
 
       streamer_write_record_start (ob, LTO_null);
 
-      for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+      for (gimple_phi_iterator psi = gsi_start_phis (bb);
+	   !gsi_end_p (psi);
+	   gsi_next (&psi))
 	{
-	  gimple phi = gsi_stmt (bsi);
+	  gimple_phi phi = psi.phi ();
 
 	  /* Only emit PHIs for gimple registers.  PHI nodes for .MEM
 	     will be filled in on reading when the SSA form is
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 155fca7..e4d0455 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4243,12 +4243,12 @@ gimple_phi_arg_def (gimple gs, size_t index)
 }
 
 
-/* Return a pointer to the tree operand for argument I of PHI node GS.  */
+/* Return a pointer to the tree operand for argument I of phi node PHI.  */
 
 static inline tree *
-gimple_phi_arg_def_ptr (gimple gs, size_t index)
+gimple_phi_arg_def_ptr (gimple_phi phi, size_t index)
 {
-  return &gimple_phi_arg (gs, index)->def;
+  return &gimple_phi_arg (phi, index)->def;
 }
 
 /* Return the edge associated with argument I of phi node GS.  */
@@ -4283,12 +4283,12 @@ gimple_phi_arg_set_location (gimple gs, size_t i, source_location loc)
   gimple_phi_arg (gs, i)->locus = loc;
 }
 
-/* Return TRUE if argument I of phi node GS has a location record.  */
+/* Return TRUE if argument I of phi node PHI has a location record.  */
 
 static inline bool
-gimple_phi_arg_has_location (gimple gs, size_t i)
+gimple_phi_arg_has_location (gimple_phi phi, size_t i)
 {
-  return gimple_phi_arg_location (gs, i) != UNKNOWN_LOCATION;
+  return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION;
 }
 
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d3fcba0..25a1642 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6465,8 +6465,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
 
   if (gimple_in_ssa_p (cfun))
     {
-      gimple_stmt_iterator psi;
-      gimple phi;
+      gimple_phi_iterator psi;
+      gimple_phi phi;
       edge re, ene;
       edge_var_map_vector *head;
       edge_var_map *vm;
@@ -6486,10 +6486,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
       for (i = 0; !gsi_end_p (psi) && head->iterate (i, &vm);
 	   gsi_next (&psi), ++i)
 	{
-	  gimple nphi;
+	  gimple_phi nphi;
 	  source_location locus;
 
-	  phi = gsi_stmt (psi);
+	  phi = psi.phi ();
 	  t = gimple_phi_result (phi);
 	  gcc_assert (t == redirect_edge_var_map_result (vm));
 	  nphi = create_phi_node (t, iter_part_bb);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index b2cca43..468c568 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6061,8 +6061,8 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
   gimple cond_stmt;
   edge sorig, snew;
   basic_block exit_bb;
-  gimple_stmt_iterator psi;
-  gimple phi;
+  gimple_phi_iterator psi;
+  gimple_phi phi;
   tree def;
   struct loop *target, *aloop, *cloop;
 
@@ -6182,7 +6182,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU
 	     !gsi_end_p (psi);
 	     gsi_next (&psi))
 	  {
-	    phi = gsi_stmt (psi);
+	    phi = psi.phi ();
 	    def = PHI_ARG_DEF (phi, nexits[0]->dest_idx);
 	    add_phi_arg (phi, def, e, gimple_phi_arg_location_from_edge (phi, e));
 	  }
@@ -6565,9 +6565,10 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
   (*cfg->x_basic_block_info)[bb->index] = bb;
 
   /* Remap the variables in phi nodes.  */
-  for (si = gsi_start_phis (bb); !gsi_end_p (si); )
+  for (gimple_phi_iterator psi = gsi_start_phis (bb);
+       !gsi_end_p (psi); )
     {
-      gimple phi = gsi_stmt (si);
+      gimple_phi phi = psi.phi ();
       use_operand_p use;
       tree op = PHI_RESULT (phi);
       ssa_op_iter oi;
@@ -6577,7 +6578,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
 	{
 	  /* Remove the phi nodes for virtual operands (alias analysis will be
 	     run for the new function, anyway).  */
-          remove_phi_node (&si, true);
+          remove_phi_node (&psi, true);
 	  continue;
 	}
 
@@ -6607,7 +6608,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
 	    }
 	}
 
-      gsi_next (&si);
+      gsi_next (&psi);
     }
 
   for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 64aeb6a..3c879f5 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -448,11 +448,11 @@ remove_forwarder_block (basic_block bb)
 	{
 	  /* Create arguments for the phi nodes, since the edge was not
 	     here before.  */
-	  for (gsi = gsi_start_phis (dest);
-	       !gsi_end_p (gsi);
-	       gsi_next (&gsi))
+	  for (gimple_phi_iterator psi = gsi_start_phis (dest);
+	       !gsi_end_p (psi);
+	       gsi_next (&psi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = psi.phi ();
 	      source_location l = gimple_phi_arg_location_from_edge (phi, succ);
 	      tree def = gimple_phi_arg_def (phi, succ->dest_idx);
 	      add_phi_arg (phi, unshare_expr (def), s, l);
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index b14bf01..566066a 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -2317,11 +2317,12 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   struct loop *scalar_loop = LOOP_VINFO_SCALAR_LOOP (loop_vinfo);
   basic_block condition_bb;
-  gimple_stmt_iterator gsi, cond_exp_gsi;
+  gimple_phi_iterator gsi;
+  gimple_stmt_iterator cond_exp_gsi;
   basic_block merge_bb;
   basic_block new_exit_bb;
   edge new_exit_e, e;
-  gimple orig_phi, new_phi;
+  gimple_phi orig_phi, new_phi;
   tree cond_expr = NULL_TREE;
   gimple_seq cond_expr_stmt_list = NULL;
   tree arg;
@@ -2425,7 +2426,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
       for (gsi = gsi_start_phis (merge_bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
 	  tree new_res;
-	  orig_phi = gsi_stmt (gsi);
+	  orig_phi = gsi.phi ();
 	  new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
 	  new_phi = create_phi_node (new_res, new_exit_bb);
 	  arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
diff --git a/gcc/tree.c b/gcc/tree.c
index efee5e6..39bf1d0 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5438,12 +5438,13 @@ find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld)
   /* Traverse every statement in FN.  */
   FOR_EACH_BB_FN (bb, fn)
     {
+      gimple_phi_iterator psi;
       gimple_stmt_iterator si;
       unsigned i;
 
-      for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
+      for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
 	{
-	  gimple phi = gsi_stmt (si);
+	  gimple_phi phi = psi.phi ();
 
 	  for (i = 0; i < gimple_phi_num_args (phi); i++)
 	    {
-- 
1.8.5.3

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

* [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (51 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 43/89] Introduce gimple_omp_target David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 17:22   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 53/89] More gimple_phi David Malcolm
                   ` (38 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* omp-low.c (finalize_task_copyfn): Strengthen local "bind" from
	plain gimple to gimple_bind.
	(lower_rec_input_clauses): Strengthen local "g" from
	plain gimple to gimple_assign.
	(lower_lastprivate_clauses): Likewise for "stmt" to gimple_cond
	and "g" to gimple_call.
	(expand_omp_for_init_vars): Likewise, for two decls of "stmt" to
	gimple_assign.
	(expand_omp_atomic_pipeline): Likewise for one decl of "stmt".
	(expand_omp_atomic_mutex): Likewise.
	(lower_omp_master): Likewise for "x" to gimple_call.
	(lower_omp_ordered): Likewise.
---
 gcc/omp-low.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 6d24927..d3fcba0 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1373,7 +1373,7 @@ finalize_task_copyfn (gimple_omp_task task_stmt)
   struct function *child_cfun;
   tree child_fn;
   gimple_seq seq = NULL, new_seq;
-  gimple bind;
+  gimple_bind bind;
 
   child_fn = gimple_omp_task_copy_fn (task_stmt);
   if (child_fn == NULL_TREE)
@@ -3402,7 +3402,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
 			  gimplify_and_add (x, ilist);
 			  gimple_stmt_iterator gsi
 			    = gsi_start_1 (gimple_omp_body_ptr (ctx->stmt));
-			  gimple g
+			  gimple_assign g
 			    = gimple_build_assign (unshare_expr (lvar), iv);
 			  gsi_insert_before_without_update (&gsi, g,
 							    GSI_SAME_STMT);
@@ -3740,7 +3740,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
 
   if (predicate)
     {
-      gimple stmt;
+      gimple_cond stmt;
       tree label_true, arm1, arm2;
 
       label = create_artificial_label (UNKNOWN_LOCATION);
@@ -3787,7 +3787,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list,
 		  if (lastlane == NULL)
 		    {
 		      lastlane = create_tmp_var (unsigned_type_node, NULL);
-		      gimple g
+		      gimple_call g
 			= gimple_build_call_internal (IFN_GOMP_SIMD_LAST_LANE,
 						      2, simduid,
 						      TREE_OPERAND (val, 1));
@@ -5108,7 +5108,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 	      tree t = fold_convert (TREE_TYPE (tem), counts[i]);
 	      t = force_gimple_operand_gsi (gsi, t, false, NULL_TREE,
 					    false, GSI_CONTINUE_LINKING);
-	      gimple stmt = gimple_build_assign (tem, t);
+	      gimple_assign stmt = gimple_build_assign (tem, t);
 	      gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
 	    }
 	}
@@ -5117,7 +5117,7 @@ expand_omp_for_init_vars (struct omp_for_data *fd, gimple_stmt_iterator *gsi,
 
   tree type = TREE_TYPE (fd->loop.v);
   tree tem = create_tmp_reg (type, ".tem");
-  gimple stmt = gimple_build_assign (tem, startvar);
+  gimple_assign stmt = gimple_build_assign (tem, startvar);
   gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
 
   for (i = fd->collapse - 1; i >= 0; i--)
@@ -7589,7 +7589,7 @@ expand_omp_atomic_pipeline (basic_block load_bb, basic_block store_bb,
       gsi2 = gsi_start_bb (loop_header);
       if (gimple_in_ssa_p (cfun))
 	{
-	  gimple stmt;
+	  gimple_assign stmt;
 	  x = force_gimple_operand_gsi (&gsi2, x, true, NULL_TREE,
 					true, GSI_SAME_STMT);
 	  stmt = gimple_build_assign (loaded_val, x);
@@ -7702,7 +7702,7 @@ expand_omp_atomic_mutex (basic_block load_bb, basic_block store_bb,
 			 tree addr, tree loaded_val, tree stored_val)
 {
   gimple_stmt_iterator si;
-  gimple stmt;
+  gimple_assign stmt;
   tree t;
 
   si = gsi_last_bb (load_bb);
@@ -8738,7 +8738,8 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 static void
 lower_omp_taskgroup (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
-  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_call x;
   gimple_bind bind;
   tree block = make_node (BLOCK);
 
@@ -8767,7 +8768,8 @@ static void
 lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple stmt = gsi_stmt (*gsi_p), x;
+  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_call x;
   gimple_bind bind;
 
   push_gimplify_context ();
-- 
1.8.5.3

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

* [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (47 preceding siblings ...)
  2014-04-21 16:57 ` [PATCH 84/89] Concretize gimple_call_arg_flags David Malcolm
@ 2014-04-21 17:12 ` David Malcolm
  2014-05-12 19:28   ` Jeff Law
  2014-04-21 17:12 ` [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi David Malcolm
                   ` (42 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_assign_nontemporal_move_p): Require a
	const_gimple_assign rather than a const_gimple.

	* cfgexpand.c (expand_gimple_stmt_1): Add local assign_stmt and
	checked cast within "case GIMPLE_ASSIGN".

	* gimple-streamer-out.c (output_gimple_stmt): Add checked cast to
	gimple_assign.
---
 gcc/cfgexpand.c           | 18 ++++++++++--------
 gcc/gimple-streamer-out.c |  5 ++++-
 gcc/gimple.h              |  3 +--
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 983cec0..4447ca0 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3189,7 +3189,8 @@ expand_gimple_stmt_1 (gimple stmt)
 
     case GIMPLE_ASSIGN:
       {
-	tree lhs = gimple_assign_lhs (stmt);
+	gimple_assign assign_stmt = stmt->as_a_gimple_assign ();
+	tree lhs = gimple_assign_lhs (assign_stmt);
 
 	/* Tree expand used to fiddle with |= and &= of two bitfield
 	   COMPONENT_REFs here.  This can't happen with gimple, the LHS
@@ -3199,7 +3200,7 @@ expand_gimple_stmt_1 (gimple stmt)
 	    || get_gimple_rhs_class (gimple_expr_code (stmt))
 	       == GIMPLE_SINGLE_RHS)
 	  {
-	    tree rhs = gimple_assign_rhs1 (stmt);
+	    tree rhs = gimple_assign_rhs1 (assign_stmt);
 	    gcc_assert (get_gimple_rhs_class (gimple_expr_code (stmt))
 			== GIMPLE_SINGLE_RHS);
 	    if (gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (rhs))
@@ -3210,12 +3211,13 @@ expand_gimple_stmt_1 (gimple stmt)
 	      ;
 	    else
 	      expand_assignment (lhs, rhs,
-				 gimple_assign_nontemporal_move_p (stmt));
+				 gimple_assign_nontemporal_move_p (
+				   assign_stmt));
 	  }
 	else
 	  {
 	    rtx target, temp;
-	    bool nontemporal = gimple_assign_nontemporal_move_p (stmt);
+	    bool nontemporal = gimple_assign_nontemporal_move_p (assign_stmt);
 	    struct separate_ops ops;
 	    bool promoted = false;
 
@@ -3223,18 +3225,18 @@ expand_gimple_stmt_1 (gimple stmt)
 	    if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
 	      promoted = true;
 
-	    ops.code = gimple_assign_rhs_code (stmt);
+	    ops.code = gimple_assign_rhs_code (assign_stmt);
 	    ops.type = TREE_TYPE (lhs);
 	    switch (get_gimple_rhs_class (gimple_expr_code (stmt)))
 	      {
 		case GIMPLE_TERNARY_RHS:
-		  ops.op2 = gimple_assign_rhs3 (stmt);
+		  ops.op2 = gimple_assign_rhs3 (assign_stmt);
 		  /* Fallthru */
 		case GIMPLE_BINARY_RHS:
-		  ops.op1 = gimple_assign_rhs2 (stmt);
+		  ops.op1 = gimple_assign_rhs2 (assign_stmt);
 		  /* Fallthru */
 		case GIMPLE_UNARY_RHS:
-		  ops.op0 = gimple_assign_rhs1 (stmt);
+		  ops.op0 = gimple_assign_rhs1 (assign_stmt);
 		  break;
 		default:
 		  gcc_unreachable ();
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index b27d4de..22cc03a 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -80,7 +80,10 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
   bp_pack_var_len_unsigned (&bp, gimple_num_ops (stmt));
   bp_pack_value (&bp, gimple_no_warning_p (stmt), 1);
   if (is_gimple_assign (stmt))
-    bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1);
+    bp_pack_value (&bp,
+		   gimple_assign_nontemporal_move_p (
+		     stmt->as_a_gimple_assign ()),
+		   1);
   bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1);
   hist = gimple_histogram_value (cfun, stmt);
   bp_pack_value (&bp, hist != NULL, 1);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index dd6dd38..d487629 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2727,9 +2727,8 @@ gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
 /* Returns true if GS is a nontemporal move.  */
 
 static inline bool
-gimple_assign_nontemporal_move_p (const_gimple gs)
+gimple_assign_nontemporal_move_p (const_gimple_assign gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
   return gs->nontemporal_move;
 }
 
-- 
1.8.5.3

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

* [PATCH 32/89] Introduce gimple_try
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (59 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 74/89] Concretize gimple_cond_set_code David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-09 19:05   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 42/89] Introduce gimple_omp_single David Malcolm
                   ` (30 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_try): New typedef.
	(const_gimple_try): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_try): New.

	* gimple-low.c (gimple_try_catch_may_fallthru): Require a
	gimple_try rather than a plain gimple.
	(gimple_stmt_may_fallthru): Add checked cast to gimple_try.

	* gimple-pretty-print.c (dump_gimple_try): Require a gimple_try
	rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_try within
	GIMPLE_TRY case of switch statement.

	* tree-eh.c (finally_tree_node::parent): Strengthen field from
	gimple to gimple_try.
	(record_in_finally_tree): Require a gimple_try rather than a plain
	gimple.
	(collect_finally_tree): Likewise.
	(collect_finally_tree_1): Likewise.
	(struct leh_tf_state::try_finally_expr): Strengthen field from
	gimple to gimple_try.
	(struct leh_tf_state::top_p): Likewise.
	(lower_eh_must_not_throw): Require a gimple_try rather than a
	plain gimple.
	(frob_into_branch_around): Likewise.
	(lower_try_finally_dup_block): Strengthen local from gimple to
	gimple_try.
	(honor_protect_cleanup_actions): Split out uses of "x" into new
	locals "eh_mnt" and "try_stmt" with stronger types.
	(lower_try_finally): Require a gimple_try rather than a plain
	gimple.
	(lower_catch): Likewise.
	(lower_eh_filter): Likewise.
	(lower_eh_must_not_throw): Likewise.
	(lower_cleanup): Likewise.
	(lower_eh_constructs_2): Add checked cast to gimple_try within
	GIMPLE_TRY case of switch statement, introducing new local
	"try_stmt", using it for type-safety.
---
 gcc/coretypes.h           |  4 ++
 gcc/gimple-low.c          |  4 +-
 gcc/gimple-pretty-print.c |  4 +-
 gcc/gimple.h              |  6 +++
 gcc/tree-eh.c             | 94 +++++++++++++++++++++++++----------------------
 5 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index b997a8d..6d5c363 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -141,6 +141,10 @@ struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
 
+struct gimple_statement_try;
+typedef struct gimple_statement_try *gimple_try;
+typedef const struct gimple_statement_try *const_gimple_try;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 4056b3c..0efb844 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -501,7 +501,7 @@ lower_try_catch (gimple_stmt_iterator *gsi, struct lower_data *data)
    This is a subroutine of gimple_stmt_may_fallthru.  */
 
 static bool
-gimple_try_catch_may_fallthru (gimple stmt)
+gimple_try_catch_may_fallthru (gimple_try stmt)
 {
   gimple_stmt_iterator i;
 
@@ -587,7 +587,7 @@ gimple_stmt_may_fallthru (gimple stmt)
 
     case GIMPLE_TRY:
       if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
-        return gimple_try_catch_may_fallthru (stmt);
+        return gimple_try_catch_may_fallthru (stmt->as_a_gimple_try ());
 
       /* It must be a GIMPLE_TRY_FINALLY.  */
 
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 28234cb..f2525f4 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -922,7 +922,7 @@ dump_gimple_bind (pretty_printer *buffer, gimple_bind gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_try (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_try (pretty_printer *buffer, gimple_try gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2134,7 +2134,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_TRY:
-      dump_gimple_try (buffer, gs, spc, flags);
+      dump_gimple_try (buffer, gs->as_a_gimple_try (), spc, flags);
       break;
 
     case GIMPLE_PHI:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 1ee15e9..931503c 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -330,6 +330,12 @@ public:
     return as_a <gimple_statement_phi> (this);
   }
 
+  inline gimple_try
+  as_a_gimple_try ()
+  {
+    return as_a <gimple_statement_try> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index ee810b0..ca8d4aa 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -199,7 +199,7 @@ struct finally_tree_node
      tree) leaves the TRY block, its necessary to record a tree in
      this field.  Thus a treemple is used. */
   treemple child;
-  gimple parent;
+  gimple_try parent;
 };
 
 /* Hashtable helpers.  */
@@ -228,7 +228,7 @@ finally_tree_hasher::equal (const value_type *v, const compare_type *c)
 static hash_table <finally_tree_hasher> finally_tree;
 
 static void
-record_in_finally_tree (treemple child, gimple parent)
+record_in_finally_tree (treemple child, gimple_try parent)
 {
   struct finally_tree_node *n;
   finally_tree_node **slot;
@@ -243,13 +243,13 @@ record_in_finally_tree (treemple child, gimple parent)
 }
 
 static void
-collect_finally_tree (gimple stmt, gimple region);
+collect_finally_tree (gimple stmt, gimple_try region);
 
 /* Go through the gimple sequence.  Works with collect_finally_tree to
    record all GIMPLE_LABEL and GIMPLE_TRY statements. */
 
 static void
-collect_finally_tree_1 (gimple_seq seq, gimple region)
+collect_finally_tree_1 (gimple_seq seq, gimple_try region)
 {
   gimple_stmt_iterator gsi;
 
@@ -258,7 +258,7 @@ collect_finally_tree_1 (gimple_seq seq, gimple region)
 }
 
 static void
-collect_finally_tree (gimple stmt, gimple region)
+collect_finally_tree (gimple stmt, gimple_try region)
 {
   treemple temp;
 
@@ -274,7 +274,8 @@ collect_finally_tree (gimple stmt, gimple region)
         {
           temp.g = stmt;
           record_in_finally_tree (temp, region);
-          collect_finally_tree_1 (gimple_try_eval (stmt), stmt);
+          collect_finally_tree_1 (gimple_try_eval (stmt),
+				  stmt->as_a_gimple_try ());
 	  collect_finally_tree_1 (gimple_try_cleanup (stmt), region);
         }
       else if (gimple_try_kind (stmt) == GIMPLE_TRY_CATCH)
@@ -391,8 +392,8 @@ struct leh_tf_state
      try_finally_expr is the original GIMPLE_TRY_FINALLY.  We need to retain
      this so that outside_finally_tree can reliably reference the tree used
      in the collect_finally_tree data structures.  */
-  gimple try_finally_expr;
-  gimple top_p;
+  gimple_try try_finally_expr;
+  gimple_try top_p;
 
   /* While lowering a top_p usually it is expanded into multiple statements,
      thus we need the following field to store them. */
@@ -432,7 +433,7 @@ struct leh_tf_state
   bool may_throw;
 };
 
-static gimple_seq lower_eh_must_not_throw (struct leh_state *, gimple);
+static gimple_seq lower_eh_must_not_throw (struct leh_state *, gimple_try);
 
 /* Search for STMT in the goto queue.  Return the replacement,
    or null if the statement isn't in the queue.  */
@@ -885,7 +886,7 @@ eh_region_may_contain_throw (eh_region r)
    an existing label that should be put at the exit, or NULL.  */
 
 static gimple_seq
-frob_into_branch_around (gimple tp, eh_region region, tree over)
+frob_into_branch_around (gimple_try tp, eh_region region, tree over)
 {
   gimple x;
   gimple_seq cleanup, result;
@@ -922,7 +923,7 @@ static gimple_seq
 lower_try_finally_dup_block (gimple_seq seq, struct leh_state *outer_state,
 			     location_t loc)
 {
-  gimple region = NULL;
+  gimple_try region = NULL;
   gimple_seq new_seq;
   gimple_stmt_iterator gsi;
 
@@ -1014,6 +1015,8 @@ honor_protect_cleanup_actions (struct leh_state *outer_state,
   bool finally_may_fallthru;
   gimple_seq finally;
   gimple x;
+  gimple_eh_must_not_throw eh_mnt;
+  gimple_try try_stmt;
   gimple_eh_else eh_else;
 
   /* First check for nothing to do.  */
@@ -1056,10 +1059,10 @@ honor_protect_cleanup_actions (struct leh_state *outer_state,
     }
 
   /* Wrap the block with protect_cleanup_actions as the action.  */
-  x = gimple_build_eh_must_not_throw (protect_cleanup_actions);
-  x = gimple_build_try (finally, gimple_seq_alloc_with_stmt (x),
-			GIMPLE_TRY_CATCH);
-  finally = lower_eh_must_not_throw (outer_state, x);
+  eh_mnt = gimple_build_eh_must_not_throw (protect_cleanup_actions);
+  try_stmt = gimple_build_try (finally, gimple_seq_alloc_with_stmt (eh_mnt),
+			       GIMPLE_TRY_CATCH);
+  finally = lower_eh_must_not_throw (outer_state, try_stmt);
 
   /* Drop all of this into the exception sequence.  */
   emit_post_landing_pad (&eh_seq, tf->region);
@@ -1667,7 +1670,7 @@ cleanup_is_dead_in (eh_region reg)
    arrange for the FINALLY block to be executed on all exits.  */
 
 static gimple_seq
-lower_try_finally (struct leh_state *state, gimple tp)
+lower_try_finally (struct leh_state *state, gimple_try tp)
 {
   struct leh_tf_state this_tf;
   struct leh_state this_state;
@@ -1774,7 +1777,7 @@ lower_try_finally (struct leh_state *state, gimple tp)
    exception region trees that records all the magic.  */
 
 static gimple_seq
-lower_catch (struct leh_state *state, gimple tp)
+lower_catch (struct leh_state *state, gimple_try tp)
 {
   eh_region try_region = NULL;
   struct leh_state this_state = *state;
@@ -1846,7 +1849,7 @@ lower_catch (struct leh_state *state, gimple tp)
    region trees that record all the magic.  */
 
 static gimple_seq
-lower_eh_filter (struct leh_state *state, gimple tp)
+lower_eh_filter (struct leh_state *state, gimple_try tp)
 {
   struct leh_state this_state = *state;
   eh_region this_region = NULL;
@@ -1891,7 +1894,7 @@ lower_eh_filter (struct leh_state *state, gimple tp)
    plus the exception region trees that record all the magic.  */
 
 static gimple_seq
-lower_eh_must_not_throw (struct leh_state *state, gimple tp)
+lower_eh_must_not_throw (struct leh_state *state, gimple_try tp)
 {
   struct leh_state this_state = *state;
 
@@ -1924,7 +1927,7 @@ lower_eh_must_not_throw (struct leh_state *state, gimple tp)
    except that we only execute the cleanup block for exception edges.  */
 
 static gimple_seq
-lower_cleanup (struct leh_state *state, gimple tp)
+lower_cleanup (struct leh_state *state, gimple_try tp)
 {
   struct leh_state this_state = *state;
   eh_region this_region = NULL;
@@ -2079,36 +2082,39 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi)
       break;
 
     case GIMPLE_TRY:
-      if (gimple_try_kind (stmt) == GIMPLE_TRY_FINALLY)
-	replace = lower_try_finally (state, stmt);
-      else
-	{
-	  x = gimple_seq_first_stmt (gimple_try_cleanup (stmt));
-	  if (!x)
-	    {
-	      replace = gimple_try_eval (stmt);
-	      lower_eh_constructs_1 (state, &replace);
-	    }
-	  else
-	    switch (gimple_code (x))
+      {
+	gimple_try try_stmt = stmt->as_a_gimple_try ();
+	if (gimple_try_kind (try_stmt) == GIMPLE_TRY_FINALLY)
+	  replace = lower_try_finally (state, try_stmt);
+	else
+	  {
+	    x = gimple_seq_first_stmt (gimple_try_cleanup (try_stmt));
+	    if (!x)
 	      {
+		replace = gimple_try_eval (try_stmt);
+		lower_eh_constructs_1 (state, &replace);
+	      }
+	    else
+	      switch (gimple_code (x))
+		{
 		case GIMPLE_CATCH:
-		    replace = lower_catch (state, stmt);
-		    break;
+		  replace = lower_catch (state, try_stmt);
+		  break;
 		case GIMPLE_EH_FILTER:
-		    replace = lower_eh_filter (state, stmt);
-		    break;
+		  replace = lower_eh_filter (state, try_stmt);
+		  break;
 		case GIMPLE_EH_MUST_NOT_THROW:
-		    replace = lower_eh_must_not_throw (state, stmt);
-		    break;
+		  replace = lower_eh_must_not_throw (state, try_stmt);
+		  break;
 		case GIMPLE_EH_ELSE:
-		    /* This code is only valid with GIMPLE_TRY_FINALLY.  */
-		    gcc_unreachable ();
+		  /* This code is only valid with GIMPLE_TRY_FINALLY.  */
+		  gcc_unreachable ();
 		default:
-		    replace = lower_cleanup (state, stmt);
-		    break;
-	      }
-	}
+		  replace = lower_cleanup (state, try_stmt);
+		  break;
+		}
+	  }
+      }
 
       /* Remove the old stmt and insert the transformed sequence
 	 instead. */
-- 
1.8.5.3

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

* [PATCH 36/89] Introduce gimple_omp_continue
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (66 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 79/89] Concretize gimple_call_nothrow_p David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 17:42   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 26/89] Introduce gimple_eh_filter David Malcolm
                   ` (23 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_continue): New typedef.
	(const_gimple_omp_continue): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_continue): New.
	(gimple_build_omp_continue): Return a gimple_omp_continue rather
	than a plain gimple.
	(gimple_omp_continue_control_def): Require a
	const_gimple_omp_continue rather than a plain const_gimple.
	(gimple_omp_continue_control_use): Likewise.
	(gimple_omp_continue_control_def_ptr): Require a gimple_omp_continue
	rather than a plain gimple.
	(gimple_omp_continue_set_control_def): Likewise.
	(gimple_omp_continue_control_use_ptr): Likewise.
	(gimple_omp_continue_set_control_use): Likewise.

	* gimple-pretty-print.c (dump_gimple_omp_continue): Require a
	gimple_omp_continue rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_continue
	within GIMPLE_OMP_CONTINUE case of switch statement.

	* gimple-walk.c (walk_gimple_op): Likewise, adding a new local.

	* gimple.c (gimple_build_omp_continue): Return a
	gimple_omp_continue rather than a plain gimple.

	* omp-low.c (gimple_build_cond_empty): Return a gimple_cond
	rather than a plain gimple.
	(expand_omp_for_generic): Split local "stmt" into "assign_stmt",
	"cont_stmt", "cond_stmt", "call_stmt" of types gimple_assign,
	gimple_omp_continue, gimple_cond, gimple_call respectively.
	(expand_omp_for_static_nochunk): Likewise, splitting into two
	"cond_stmt" decls. "assign_stmt", "cont_stmt"
	(expand_omp_for_static_chunk): Likewise, splitting into
	"cond_stmt", "assign_stmt", "cont_stmt".
	(expand_omp_sections): Strengthen local "cont" from gimple to
	gimple_omp_continue.
---
 gcc/coretypes.h           |   4 ++
 gcc/gimple-pretty-print.c |   6 +-
 gcc/gimple-walk.c         |  19 +++---
 gcc/gimple.c              |   5 +-
 gcc/gimple.h              |  44 ++++++--------
 gcc/omp-low.c             | 144 ++++++++++++++++++++++++----------------------
 6 files changed, 115 insertions(+), 107 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 34c160e..e2ad76e 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -155,6 +155,10 @@ typedef struct gimple_statement_omp_atomic_store *gimple_omp_atomic_store;
 typedef const struct gimple_statement_omp_atomic_store *
   const_gimple_omp_atomic_store;
 
+struct gimple_statement_omp_continue;
+typedef struct gimple_statement_omp_continue *gimple_omp_continue;
+typedef const struct gimple_statement_omp_continue *const_gimple_omp_continue;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 5cbda7d..3de01d0 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1227,7 +1227,8 @@ dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_continue (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_continue (pretty_printer *buffer, gimple_omp_continue gs,
+			  int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2165,7 +2166,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_CONTINUE:
-      dump_gimple_omp_continue (buffer, gs, spc, flags);
+      dump_gimple_omp_continue (buffer, gs->as_a_gimple_omp_continue (), spc,
+				flags);
       break;
 
     case GIMPLE_OMP_SINGLE:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index f15d1f3..f286748 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -298,15 +298,18 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_CONTINUE:
-      ret = walk_tree (gimple_omp_continue_control_def_ptr (stmt),
-	  	       callback_op, wi, pset);
-      if (ret)
-	return ret;
+      {
+	gimple_omp_continue cont_stmt = stmt->as_a_gimple_omp_continue ();
+	ret = walk_tree (gimple_omp_continue_control_def_ptr (cont_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
 
-      ret = walk_tree (gimple_omp_continue_control_use_ptr (stmt),
-	  	       callback_op, wi, pset);
-      if (ret)
-	return ret;
+	ret = walk_tree (gimple_omp_continue_control_use_ptr (cont_stmt),
+			 callback_op, wi, pset);
+	if (ret)
+	  return ret;
+      }
       break;
 
     case GIMPLE_OMP_CRITICAL:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index c45cc48..a0fa31e 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -958,10 +958,11 @@ gimple_build_omp_taskgroup (gimple_seq body)
    CONTROL_DEF is the definition of the control variable.
    CONTROL_USE is the use of the control variable.  */
 
-gimple
+gimple_omp_continue
 gimple_build_omp_continue (tree control_def, tree control_use)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_CONTINUE, 0);
+  gimple_omp_continue p =
+    gimple_alloc (GIMPLE_OMP_CONTINUE, 0)->as_a_gimple_omp_continue ();
   gimple_omp_continue_set_control_def (p, control_def);
   gimple_omp_continue_set_control_use (p, control_use);
   return p;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index b74ff4b..5a3626e 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -348,6 +348,12 @@ public:
     return as_a <gimple_statement_omp_atomic_store> (this);
   }
 
+  inline gimple_omp_continue
+  as_a_gimple_omp_continue ()
+  {
+    return as_a <gimple_statement_omp_continue> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1583,7 +1589,7 @@ gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
 gimple gimple_build_omp_section (gimple_seq);
 gimple gimple_build_omp_master (gimple_seq);
 gimple gimple_build_omp_taskgroup (gimple_seq);
-gimple gimple_build_omp_continue (tree, tree);
+gimple_omp_continue gimple_build_omp_continue (tree, tree);
 gimple gimple_build_omp_ordered (gimple_seq);
 gimple gimple_build_omp_return (bool);
 gimple gimple_build_omp_sections (gimple_seq, tree);
@@ -5649,64 +5655,52 @@ gimple_omp_atomic_load_rhs_ptr (gimple_omp_atomic_load load_stmt)
 /* Get the definition of the control variable in a GIMPLE_OMP_CONTINUE.  */
 
 static inline tree
-gimple_omp_continue_control_def (const_gimple g)
+gimple_omp_continue_control_def (const_gimple_omp_continue cont_stmt)
 {
-  const gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <const gimple_statement_omp_continue> (g);
-  return omp_continue_stmt->control_def;
+  return cont_stmt->control_def;
 }
 
 /* The same as above, but return the address.  */
 
 static inline tree *
-gimple_omp_continue_control_def_ptr (gimple g)
+gimple_omp_continue_control_def_ptr (gimple_omp_continue cont_stmt)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue> (g);
-  return &omp_continue_stmt->control_def;
+  return &cont_stmt->control_def;
 }
 
 /* Set the definition of the control variable in a GIMPLE_OMP_CONTINUE.  */
 
 static inline void
-gimple_omp_continue_set_control_def (gimple g, tree def)
+gimple_omp_continue_set_control_def (gimple_omp_continue cont_stmt, tree def)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue> (g);
-  omp_continue_stmt->control_def = def;
+  cont_stmt->control_def = def;
 }
 
 
 /* Get the use of the control variable in a GIMPLE_OMP_CONTINUE.  */
 
 static inline tree
-gimple_omp_continue_control_use (const_gimple g)
+gimple_omp_continue_control_use (const_gimple_omp_continue cont_stmt)
 {
-  const gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <const gimple_statement_omp_continue> (g);
-  return omp_continue_stmt->control_use;
+  return cont_stmt->control_use;
 }
 
 
 /* The same as above, but return the address.  */
 
 static inline tree *
-gimple_omp_continue_control_use_ptr (gimple g)
+gimple_omp_continue_control_use_ptr (gimple_omp_continue cont_stmt)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue> (g);
-  return &omp_continue_stmt->control_use;
+  return &cont_stmt->control_use;
 }
 
 
 /* Set the use of the control variable in a GIMPLE_OMP_CONTINUE.  */
 
 static inline void
-gimple_omp_continue_set_control_use (gimple g, tree use)
+gimple_omp_continue_set_control_use (gimple_omp_continue cont_stmt, tree use)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue> (g);
-  omp_continue_stmt->control_use = use;
+  cont_stmt->control_use = use;
 }
 
 /* Return a pointer to the body for the GIMPLE_TRANSACTION statement
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 22ea34f..1cd4731 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4132,7 +4132,7 @@ lower_send_shared_vars (gimple_seq *ilist, gimple_seq *olist, omp_context *ctx)
 /* A convenience function to build an empty GIMPLE_COND with just the
    condition.  */
 
-static gimple
+static gimple_cond
 gimple_build_cond_empty (tree cond)
 {
   enum tree_code pred_code;
@@ -5342,7 +5342,7 @@ expand_omp_for_generic (struct omp_region *region,
   basic_block entry_bb, cont_bb, exit_bb, l0_bb, l1_bb, collapse_bb;
   basic_block l2_bb = NULL, l3_bb = NULL;
   gimple_stmt_iterator gsi;
-  gimple stmt;
+  gimple_assign assign_stmt;
   bool in_combined_parallel = is_combined_parallel (region);
   bool broken_loop = region->cont == NULL;
   edge e, ne;
@@ -5557,8 +5557,8 @@ expand_omp_for_generic (struct omp_region *region,
 				DECL_P (startvar)
 				&& TREE_ADDRESSABLE (startvar),
 				NULL_TREE, false, GSI_CONTINUE_LINKING);
-  stmt = gimple_build_assign (startvar, t);
-  gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+  assign_stmt = gimple_build_assign (startvar, t);
+  gsi_insert_after (&gsi, assign_stmt, GSI_CONTINUE_LINKING);
 
   t = iend0;
   if (bias)
@@ -5570,8 +5570,8 @@ expand_omp_for_generic (struct omp_region *region,
 				   false, GSI_CONTINUE_LINKING);
   if (endvar)
     {
-      stmt = gimple_build_assign (endvar, iend);
-      gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+      assign_stmt = gimple_build_assign (endvar, iend);
+      gsi_insert_after (&gsi, assign_stmt, GSI_CONTINUE_LINKING);
     }
   if (fd->collapse > 1)
     expand_omp_for_init_vars (fd, &gsi, counts, inner_stmt, startvar);
@@ -5581,10 +5581,11 @@ expand_omp_for_generic (struct omp_region *region,
       /* Code to control the increment and predicate for the sequential
 	 loop goes in the CONT_BB.  */
       gsi = gsi_last_bb (cont_bb);
-      stmt = gsi_stmt (gsi);
-      gcc_assert (gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
-      vmain = gimple_omp_continue_control_use (stmt);
-      vback = gimple_omp_continue_control_def (stmt);
+      gimple_omp_continue cont_stmt =
+	gsi_stmt (gsi)->as_a_gimple_omp_continue ();
+      gcc_assert (gimple_code (cont_stmt) == GIMPLE_OMP_CONTINUE);
+      vmain = gimple_omp_continue_control_use (cont_stmt);
+      vback = gimple_omp_continue_control_def (cont_stmt);
 
       if (!gimple_omp_for_combined_p (fd->for_stmt))
 	{
@@ -5596,14 +5597,14 @@ expand_omp_for_generic (struct omp_region *region,
 					DECL_P (vback)
 					&& TREE_ADDRESSABLE (vback),
 					NULL_TREE, true, GSI_SAME_STMT);
-	  stmt = gimple_build_assign (vback, t);
-	  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+	  assign_stmt = gimple_build_assign (vback, t);
+	  gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
 
 	  t = build2 (fd->loop.cond_code, boolean_type_node,
 		      DECL_P (vback) && TREE_ADDRESSABLE (vback) ? t : vback,
 		      iend);
-	  stmt = gimple_build_cond_empty (t);
-	  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+	  gimple_cond cond_stmt = gimple_build_cond_empty (t);
+	  gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
 	}
 
       /* Remove GIMPLE_OMP_CONTINUE.  */
@@ -5623,8 +5624,8 @@ expand_omp_for_generic (struct omp_region *region,
       if (TREE_TYPE (t) != boolean_type_node)
 	t = fold_build2 (NE_EXPR, boolean_type_node,
 			 t, build_int_cst (TREE_TYPE (t), 0));
-      stmt = gimple_build_cond_empty (t);
-      gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+      gimple_cond cond_stmt = gimple_build_cond_empty (t);
+      gsi_insert_after (&gsi, cond_stmt, GSI_CONTINUE_LINKING);
     }
 
   /* Add the loop cleanup function.  */
@@ -5635,10 +5636,10 @@ expand_omp_for_generic (struct omp_region *region,
     t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_CANCEL);
   else
     t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END);
-  stmt = gimple_build_call (t, 0);
+  gimple_call call_stmt = gimple_build_call (t, 0);
   if (gimple_omp_return_lhs (gsi_stmt (gsi)))
-    gimple_call_set_lhs (stmt, gimple_omp_return_lhs (gsi_stmt (gsi)));
-  gsi_insert_after (&gsi, stmt, GSI_SAME_STMT);
+    gimple_call_set_lhs (call_stmt, gimple_omp_return_lhs (gsi_stmt (gsi)));
+  gsi_insert_after (&gsi, call_stmt, GSI_SAME_STMT);
   gsi_remove (&gsi, true);
 
   /* Connect the new blocks.  */
@@ -5762,7 +5763,6 @@ expand_omp_for_static_nochunk (struct omp_region *region,
   basic_block body_bb, cont_bb, collapse_bb = NULL;
   basic_block fin_bb;
   gimple_stmt_iterator gsi;
-  gimple stmt;
   edge ep;
   enum built_in_function get_num_threads = BUILT_IN_OMP_GET_NUM_THREADS;
   enum built_in_function get_thread_num = BUILT_IN_OMP_GET_THREAD_NUM;
@@ -5826,18 +5826,18 @@ expand_omp_for_static_nochunk (struct omp_region *region,
       n2 = fold_convert (type, unshare_expr (fd->loop.n2));
       n2 = force_gimple_operand_gsi (&gsi, n2, true, NULL_TREE,
 				     true, GSI_SAME_STMT);
-      stmt = gimple_build_cond (fd->loop.cond_code, n1, n2,
-				NULL_TREE, NULL_TREE);
-      gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
-      if (walk_tree (gimple_cond_lhs_ptr (stmt),
+      gimple_cond cond_stmt = gimple_build_cond (fd->loop.cond_code, n1, n2,
+						 NULL_TREE, NULL_TREE);
+      gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
+      if (walk_tree (gimple_cond_lhs_ptr (cond_stmt),
 		     expand_omp_regimplify_p, NULL, NULL)
-	  || walk_tree (gimple_cond_rhs_ptr (stmt),
+	  || walk_tree (gimple_cond_rhs_ptr (cond_stmt),
 			expand_omp_regimplify_p, NULL, NULL))
 	{
-	  gsi = gsi_for_stmt (stmt);
-	  gimple_regimplify_operands (stmt, &gsi);
+	  gsi = gsi_for_stmt (cond_stmt);
+	  gimple_regimplify_operands (cond_stmt, &gsi);
 	}
-      ep = split_block (entry_bb, stmt);
+      ep = split_block (entry_bb, cond_stmt);
       ep->flags = EDGE_TRUE_VALUE;
       entry_bb = ep->dest;
       ep->probability = REG_BR_PROB_BASE - (REG_BR_PROB_BASE / 2000 - 1);
@@ -5912,20 +5912,21 @@ expand_omp_for_static_nochunk (struct omp_region *region,
   gsi_insert_before (&gsi, gimple_build_assign (tt, t), GSI_SAME_STMT);
 
   t = build2 (LT_EXPR, boolean_type_node, threadid, tt);
-  stmt = gimple_build_cond_empty (t);
-  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+  gimple_cond cond_stmt = gimple_build_cond_empty (t);
+  gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT);
 
-  second_bb = split_block (entry_bb, stmt)->dest;
+  second_bb = split_block (entry_bb, cond_stmt)->dest;
   gsi = gsi_last_bb (second_bb);
   gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_FOR);
 
   gsi_insert_before (&gsi, gimple_build_assign (tt, build_int_cst (itype, 0)),
 		     GSI_SAME_STMT);
-  stmt = gimple_build_assign_with_ops (PLUS_EXPR, q, q,
-				       build_int_cst (itype, 1));
-  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+  gimple_assign assign_stmt =
+    gimple_build_assign_with_ops (PLUS_EXPR, q, q,
+				  build_int_cst (itype, 1));
+  gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
 
-  third_bb = split_block (second_bb, stmt)->dest;
+  third_bb = split_block (second_bb, assign_stmt)->dest;
   gsi = gsi_last_bb (third_bb);
   gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_FOR);
 
@@ -5972,8 +5973,8 @@ expand_omp_for_static_nochunk (struct omp_region *region,
 				DECL_P (startvar)
 				&& TREE_ADDRESSABLE (startvar),
 				NULL_TREE, false, GSI_CONTINUE_LINKING);
-  stmt = gimple_build_assign (startvar, t);
-  gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+  assign_stmt = gimple_build_assign (startvar, t);
+  gsi_insert_after (&gsi, assign_stmt, GSI_CONTINUE_LINKING);
 
   t = fold_convert (itype, e0);
   t = fold_build2 (MULT_EXPR, itype, t, step);
@@ -5986,8 +5987,8 @@ expand_omp_for_static_nochunk (struct omp_region *region,
 				false, GSI_CONTINUE_LINKING);
   if (endvar)
     {
-      stmt = gimple_build_assign (endvar, e);
-      gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+      assign_stmt = gimple_build_assign (endvar, e);
+      gsi_insert_after (&gsi, assign_stmt, GSI_CONTINUE_LINKING);
     }
   if (fd->collapse > 1)
     expand_omp_for_init_vars (fd, &gsi, counts, inner_stmt, startvar);
@@ -5997,10 +5998,11 @@ expand_omp_for_static_nochunk (struct omp_region *region,
       /* The code controlling the sequential loop replaces the
 	 GIMPLE_OMP_CONTINUE.  */
       gsi = gsi_last_bb (cont_bb);
-      stmt = gsi_stmt (gsi);
-      gcc_assert (gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
-      vmain = gimple_omp_continue_control_use (stmt);
-      vback = gimple_omp_continue_control_def (stmt);
+      gimple_omp_continue cont_stmt =
+	gsi_stmt (gsi)->as_a_gimple_omp_continue ();
+      gcc_assert (gimple_code (cont_stmt) == GIMPLE_OMP_CONTINUE);
+      vmain = gimple_omp_continue_control_use (cont_stmt);
+      vback = gimple_omp_continue_control_def (cont_stmt);
 
       if (!gimple_omp_for_combined_p (fd->for_stmt))
 	{
@@ -6012,8 +6014,8 @@ expand_omp_for_static_nochunk (struct omp_region *region,
 					DECL_P (vback)
 					&& TREE_ADDRESSABLE (vback),
 					NULL_TREE, true, GSI_SAME_STMT);
-	  stmt = gimple_build_assign (vback, t);
-	  gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+	  assign_stmt = gimple_build_assign (vback, t);
+	  gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
 
 	  t = build2 (fd->loop.cond_code, boolean_type_node,
 		      DECL_P (vback) && TREE_ADDRESSABLE (vback)
@@ -6133,7 +6135,6 @@ expand_omp_for_static_chunk (struct omp_region *region,
   basic_block entry_bb, exit_bb, body_bb, seq_start_bb, iter_part_bb;
   basic_block trip_update_bb = NULL, cont_bb, collapse_bb = NULL, fin_bb;
   gimple_stmt_iterator si;
-  gimple stmt;
   edge se;
   enum built_in_function get_num_threads = BUILT_IN_OMP_GET_NUM_THREADS;
   enum built_in_function get_thread_num = BUILT_IN_OMP_GET_THREAD_NUM;
@@ -6201,18 +6202,18 @@ expand_omp_for_static_chunk (struct omp_region *region,
       n2 = fold_convert (type, unshare_expr (fd->loop.n2));
       n2 = force_gimple_operand_gsi (&si, n2, true, NULL_TREE,
 				     true, GSI_SAME_STMT);
-      stmt = gimple_build_cond (fd->loop.cond_code, n1, n2,
-				NULL_TREE, NULL_TREE);
-      gsi_insert_before (&si, stmt, GSI_SAME_STMT);
-      if (walk_tree (gimple_cond_lhs_ptr (stmt),
+      gimple_cond cond_stmt = gimple_build_cond (fd->loop.cond_code, n1, n2,
+						 NULL_TREE, NULL_TREE);
+      gsi_insert_before (&si, cond_stmt, GSI_SAME_STMT);
+      if (walk_tree (gimple_cond_lhs_ptr (cond_stmt),
 		     expand_omp_regimplify_p, NULL, NULL)
-	  || walk_tree (gimple_cond_rhs_ptr (stmt),
+	  || walk_tree (gimple_cond_rhs_ptr (cond_stmt),
 			expand_omp_regimplify_p, NULL, NULL))
 	{
-	  si = gsi_for_stmt (stmt);
-	  gimple_regimplify_operands (stmt, &si);
+	  si = gsi_for_stmt (cond_stmt);
+	  gimple_regimplify_operands (cond_stmt, &si);
 	}
-      se = split_block (entry_bb, stmt);
+      se = split_block (entry_bb, cond_stmt);
       se->flags = EDGE_TRUE_VALUE;
       entry_bb = se->dest;
       se->probability = REG_BR_PROB_BASE - (REG_BR_PROB_BASE / 2000 - 1);
@@ -6294,8 +6295,9 @@ expand_omp_for_static_chunk (struct omp_region *region,
       trip_back = trip_var;
     }
 
-  stmt = gimple_build_assign (trip_init, build_int_cst (itype, 0));
-  gsi_insert_before (&si, stmt, GSI_SAME_STMT);
+  gimple_assign assign_stmt = gimple_build_assign (trip_init,
+						   build_int_cst (itype, 0));
+  gsi_insert_before (&si, assign_stmt, GSI_SAME_STMT);
 
   t = fold_build2 (MULT_EXPR, itype, threadid, fd->chunk_size);
   t = fold_build2 (MULT_EXPR, itype, t, step);
@@ -6357,8 +6359,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
 				DECL_P (startvar)
 				&& TREE_ADDRESSABLE (startvar),
 				NULL_TREE, false, GSI_CONTINUE_LINKING);
-  stmt = gimple_build_assign (startvar, t);
-  gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING);
+  assign_stmt = gimple_build_assign (startvar, t);
+  gsi_insert_after (&si, assign_stmt, GSI_CONTINUE_LINKING);
 
   t = fold_convert (itype, e0);
   t = fold_build2 (MULT_EXPR, itype, t, step);
@@ -6371,8 +6373,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
 				false, GSI_CONTINUE_LINKING);
   if (endvar)
     {
-      stmt = gimple_build_assign (endvar, e);
-      gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING);
+      assign_stmt = gimple_build_assign (endvar, e);
+      gsi_insert_after (&si, assign_stmt, GSI_CONTINUE_LINKING);
     }
   if (fd->collapse > 1)
     expand_omp_for_init_vars (fd, &si, counts, inner_stmt, startvar);
@@ -6382,10 +6384,11 @@ expand_omp_for_static_chunk (struct omp_region *region,
       /* The code controlling the sequential loop goes in CONT_BB,
 	 replacing the GIMPLE_OMP_CONTINUE.  */
       si = gsi_last_bb (cont_bb);
-      stmt = gsi_stmt (si);
-      gcc_assert (gimple_code (stmt) == GIMPLE_OMP_CONTINUE);
-      v_main = gimple_omp_continue_control_use (stmt);
-      v_back = gimple_omp_continue_control_def (stmt);
+      gimple_omp_continue cont_stmt =
+	gsi_stmt (si)->as_a_gimple_omp_continue ();
+      gcc_assert (gimple_code (cont_stmt) == GIMPLE_OMP_CONTINUE);
+      v_main = gimple_omp_continue_control_use (cont_stmt);
+      v_back = gimple_omp_continue_control_def (cont_stmt);
 
       if (!gimple_omp_for_combined_p (fd->for_stmt))
 	{
@@ -6396,8 +6399,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
 	  if (DECL_P (v_back) && TREE_ADDRESSABLE (v_back))
 	    t = force_gimple_operand_gsi (&si, t, true, NULL_TREE,
 					  true, GSI_SAME_STMT);
-	  stmt = gimple_build_assign (v_back, t);
-	  gsi_insert_before (&si, stmt, GSI_SAME_STMT);
+	  assign_stmt = gimple_build_assign (v_back, t);
+	  gsi_insert_before (&si, assign_stmt, GSI_SAME_STMT);
 
 	  t = build2 (fd->loop.cond_code, boolean_type_node,
 		      DECL_P (v_back) && TREE_ADDRESSABLE (v_back)
@@ -6416,8 +6419,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
 
       t = build_int_cst (itype, 1);
       t = build2 (PLUS_EXPR, itype, trip_main, t);
-      stmt = gimple_build_assign (trip_back, t);
-      gsi_insert_after (&si, stmt, GSI_CONTINUE_LINKING);
+      assign_stmt = gimple_build_assign (trip_back, t);
+      gsi_insert_after (&si, assign_stmt, GSI_CONTINUE_LINKING);
     }
 
   /* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing.  */
@@ -6957,7 +6960,8 @@ expand_omp_sections (struct omp_region *region)
   unsigned len;
   basic_block entry_bb, l0_bb, l1_bb, l2_bb, default_bb;
   gimple_stmt_iterator si, switch_si;
-  gimple sections_stmt, stmt, cont;
+  gimple sections_stmt, stmt;
+  gimple_omp_continue cont;
   edge_iterator ei;
   edge e;
   struct omp_region *inner;
@@ -7038,7 +7042,7 @@ expand_omp_sections (struct omp_region *region)
   gcc_assert (gimple_code (gsi_stmt (switch_si)) == GIMPLE_OMP_SECTIONS_SWITCH);
   if (exit_reachable)
     {
-      cont = last_stmt (l1_bb);
+      cont = last_stmt (l1_bb)->as_a_gimple_omp_continue ();
       gcc_assert (gimple_code (cont) == GIMPLE_OMP_CONTINUE);
       vmain = gimple_omp_continue_control_use (cont);
       vnext = gimple_omp_continue_control_def (cont);
-- 
1.8.5.3

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

* [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (61 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 42/89] Introduce gimple_omp_single David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 20:06   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 24/89] Introduce gimple_transaction David Malcolm
                   ` (28 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
	Strengthen local "psi" to be a gimple_phi_iterator and "phi" to
	a gimple_phi.

	* graphite-sese-to-poly.c (phi_arg_in_outermost_loop): Require
	a gimple_phi rathen than a plain gimple.
	(remove_simple_copy_phi): Require a gimple_phi_iterator;
	strengthen local "phi" to be a gimple_phi and "stmt" to be a
	gimple_assign.
	(remove_invariant_phi): Likewise.
	(simple_copy_phi_p): Require a gimple_phi.
	(reduction_phi_p): Require a gimple_phi_iterator; strengthen
	local "phi" to be a gimple_phi.
	(add_condition_to_pbb): Require a gimple_cond rather than a
	plain gimple.
	(add_conditions_to_domain): Add checked cast to gimple_cond
	within GIMPLE_COND case of switch statement.
	(single_pred_cond_non_loop_exit): Return a gimple_cond rather
	than a plain gimple, via a checked cast.
	(sese_dom_walker::before_dom_children): Strengthen local "stmt"
	from gimple to gimple_cond.
	(gsi_for_phi_node): Require a gimple_phi, and return a
	gimple_phi_iterator.
	(insert_out_of_ssa_copy): Strengthen local "stmt" from gimple to
	gimple_assign.
	(rewrite_reductions_out_of_ssa): Strengthen "psi" to be a
	gimple_phi_iterator, and "phi" to be a gimple_phi.
	(phi_contains_arg): Require a gimple_phi.
	(follow_ssa_with_commutative_ops): Strengthen return type from
	gimple to gimple_phi, by converting a check for code GIMPLE_PHI to
	a dyn_cast_gimple_phi, and strengthening local "res" from gimple
	to gimple_phi.
	(detect_commutative_reduction_arg): Strengthen return type from
	gimple to gimple_phi, and strengthen local "phi" to be a
	gimple_phi.
	(detect_commutative_reduction_assign): Strengthen return type from
	gimple to gimple_phi, and strengthen local "res" to be a
	gimple_phi.
	(follow_inital_value_to_phi): Strengthen return type from
	gimple to gimple_phi.  Replace check for code GIMPLE_PHI with
	a dyn_cast_gimple_phi.
	(detect_commutative_reduction): Strengthen return type and locals
	"loop_phi", "phi", "close_phi" from gimple to gimple_phi,
	introducing a checked cast of "stmt" in region guarded by
	scalar_close_phi_node_p (stmt).
	(translate_scalar_reduction_to_array_for_stmt): Require param
	"loop_phi" to be a gimple_phi.  Strengthen local "assign" from
	gimple to gimple_assign.
	(remove_phi): Require a gimple_phi.
	(close_phi_written_to_memory): Likewise.
	(translate_scalar_reduction_to_array): We expect the first element
	in each vector to be an arbitrary statement, but all of the
	subsequent elements to be phi nodes.  Hence the decls of gimple
	locals "loop_phi" and "close_phi" are replaced with decls of gimple
	"loop_stmt" and "close_stmt", with decls of the more-strongly typed
	gimple_phi "loop_phi" and "close_phi" occurring lower down, within
	the region where we're dealing with i > 0 and hence where we can
	safely assign them using the checked cast as_a_gimple_phi.
	This allows many of the strengthenings from gimple to gimple_phi
	above.  We eliminate the local "stmt", since we can simply use
	"loop_stmt".
	(rewrite_commutative_reductions_out_of_ssa_close_phi): Strengthen
	param "close_phi" from gimple to gimple_phi, and local "gsi" from
	gimple_stmt_iterator to gimple_phi_iterator, converting uses of
	gsi_stmt to gsi.phi for type-safety.
	(scop_ivs_can_be_represented): Strengthen local "gsi" from
	gimple_stmt_iterator to gimple_phi_iterator, and "phi" from gimple
	to gimple_phi.
---
 gcc/graphite-scop-detection.c |   4 +-
 gcc/graphite-sese-to-poly.c   | 125 ++++++++++++++++++++++--------------------
 2 files changed, 68 insertions(+), 61 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index e50cc5b..af04dd0 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1316,14 +1316,14 @@ canonicalize_loop_closed_ssa (loop_p loop)
     }
   else
     {
-      gimple_stmt_iterator psi;
+      gimple_phi_iterator psi;
       basic_block close = split_edge (e);
 
       e = single_succ_edge (close);
 
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
 	{
-	  gimple phi = gsi_stmt (psi);
+	  gimple_phi phi = psi.phi ();
 	  unsigned i;
 
 	  for (i = 0; i < gimple_phi_num_args (phi); i++)
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index d4a1bb2..8dca109 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -81,7 +81,7 @@ tree_int_to_gmp (tree t, mpz_t res)
    loop.  */
 
 static size_t
-phi_arg_in_outermost_loop (gimple phi)
+phi_arg_in_outermost_loop (gimple_phi phi)
 {
   loop_p loop = gimple_bb (phi)->loop_father;
   size_t i, res = 0;
@@ -100,13 +100,13 @@ phi_arg_in_outermost_loop (gimple phi)
    PSI by inserting on the loop ENTRY edge assignment "RES = INIT".  */
 
 static void
-remove_simple_copy_phi (gimple_stmt_iterator *psi)
+remove_simple_copy_phi (gimple_phi_iterator *psi)
 {
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   tree res = gimple_phi_result (phi);
   size_t entry = phi_arg_in_outermost_loop (phi);
   tree init = gimple_phi_arg_def (phi, entry);
-  gimple stmt = gimple_build_assign (res, init);
+  gimple_assign stmt = gimple_build_assign (res, init);
   edge e = gimple_phi_arg_edge (phi, entry);
 
   remove_phi_node (psi, false);
@@ -117,16 +117,16 @@ remove_simple_copy_phi (gimple_stmt_iterator *psi)
    loop ENTRY edge the assignment RES = INIT.  */
 
 static void
-remove_invariant_phi (sese region, gimple_stmt_iterator *psi)
+remove_invariant_phi (sese region, gimple_phi_iterator *psi)
 {
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   loop_p loop = loop_containing_stmt (phi);
   tree res = gimple_phi_result (phi);
   tree scev = scalar_evolution_in_region (region, loop, res);
   size_t entry = phi_arg_in_outermost_loop (phi);
   edge e = gimple_phi_arg_edge (phi, entry);
   tree var;
-  gimple stmt;
+  gimple_assign stmt;
   gimple_seq stmts = NULL;
 
   if (tree_contains_chrecs (scev, NULL))
@@ -145,7 +145,7 @@ remove_invariant_phi (sese region, gimple_stmt_iterator *psi)
 /* Returns true when the phi node at PSI is of the form "a = phi (a, x)".  */
 
 static inline bool
-simple_copy_phi_p (gimple phi)
+simple_copy_phi_p (gimple_phi phi)
 {
   tree res;
 
@@ -162,10 +162,10 @@ simple_copy_phi_p (gimple phi)
    be considered.  */
 
 static bool
-reduction_phi_p (sese region, gimple_stmt_iterator *psi)
+reduction_phi_p (sese region, gimple_phi_iterator *psi)
 {
   loop_p loop;
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   tree res = gimple_phi_result (phi);
 
   loop = loop_containing_stmt (phi);
@@ -1119,7 +1119,7 @@ create_pw_aff_from_tree (poly_bb_p pbb, tree t)
    inequalities.  */
 
 static void
-add_condition_to_pbb (poly_bb_p pbb, gimple stmt, enum tree_code code)
+add_condition_to_pbb (poly_bb_p pbb, gimple_cond stmt, enum tree_code code)
 {
   isl_pw_aff *lhs = create_pw_aff_from_tree (pbb, gimple_cond_lhs (stmt));
   isl_pw_aff *rhs = create_pw_aff_from_tree (pbb, gimple_cond_rhs (stmt));
@@ -1179,13 +1179,14 @@ add_conditions_to_domain (poly_bb_p pbb)
       {
       case GIMPLE_COND:
 	  {
-	    enum tree_code code = gimple_cond_code (stmt);
+	    gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	    enum tree_code code = gimple_cond_code (cond_stmt);
 
 	    /* The conditions for ELSE-branches are inverted.  */
 	    if (!GBB_CONDITION_CASES (gbb)[i])
 	      code = invert_tree_comparison (code, false);
 
-	    add_condition_to_pbb (pbb, stmt, code);
+	    add_condition_to_pbb (pbb, cond_stmt, code);
 	    break;
 	  }
 
@@ -1215,7 +1216,7 @@ add_conditions_to_constraints (scop_p scop)
    edge between BB and its predecessor is not a loop exit edge, and
    the last statement of the single predecessor is a COND_EXPR.  */
 
-static gimple
+static gimple_cond
 single_pred_cond_non_loop_exit (basic_block bb)
 {
   if (single_pred_p (bb))
@@ -1230,7 +1231,7 @@ single_pred_cond_non_loop_exit (basic_block bb)
       stmt = last_stmt (pred);
 
       if (stmt && gimple_code (stmt) == GIMPLE_COND)
-	return stmt;
+	return stmt->as_a_gimple_cond ();
     }
 
   return NULL;
@@ -1261,7 +1262,7 @@ void
 sese_dom_walker::before_dom_children (basic_block bb)
 {
   gimple_bb_p gbb;
-  gimple stmt;
+  gimple_cond stmt;
 
   if (!bb_in_sese_p (bb, m_region))
     return;
@@ -1931,10 +1932,10 @@ build_scop_drs (scop_p scop)
 
 /* Return a gsi at the position of the phi node STMT.  */
 
-static gimple_stmt_iterator
-gsi_for_phi_node (gimple stmt)
+static gimple_phi_iterator
+gsi_for_phi_node (gimple_phi stmt)
 {
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
   basic_block bb = gimple_bb (stmt);
 
   for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
@@ -2006,7 +2007,7 @@ insert_out_of_ssa_copy (scop_p scop, tree res, tree expr, gimple after_stmt)
   gimple_seq stmts;
   gimple_stmt_iterator gsi;
   tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
-  gimple stmt = gimple_build_assign (unshare_expr (res), var);
+  gimple_assign stmt = gimple_build_assign (unshare_expr (res), var);
   auto_vec<gimple, 3> x;
 
   gimple_seq_add_stmt (&stmts, stmt);
@@ -2292,14 +2293,14 @@ static void
 rewrite_reductions_out_of_ssa (scop_p scop)
 {
   basic_block bb;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
   sese region = SCOP_REGION (scop);
 
   FOR_EACH_BB_FN (bb, cfun)
     if (bb_in_sese_p (bb, region))
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi);)
 	{
-	  gimple phi = gsi_stmt (psi);
+	  gimple_phi phi = psi.phi ();
 
 	  if (virtual_operand_p (gimple_phi_result (phi)))
 	    {
@@ -2615,7 +2616,7 @@ is_reduction_operation_p (gimple stmt)
 /* Returns true when PHI contains an argument ARG.  */
 
 static bool
-phi_contains_arg (gimple phi, tree arg)
+phi_contains_arg (gimple_phi phi, tree arg)
 {
   size_t i;
 
@@ -2628,7 +2629,7 @@ phi_contains_arg (gimple phi, tree arg)
 
 /* Return a loop phi node that corresponds to a reduction containing LHS.  */
 
-static gimple
+static gimple_phi
 follow_ssa_with_commutative_ops (tree arg, tree lhs)
 {
   gimple stmt;
@@ -2642,10 +2643,10 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs)
       || gimple_code (stmt) == GIMPLE_CALL)
     return NULL;
 
-  if (gimple_code (stmt) == GIMPLE_PHI)
+  if (gimple_phi phi = stmt->dyn_cast_gimple_phi ())
     {
-      if (phi_contains_arg (stmt, lhs))
-	return stmt;
+      if (phi_contains_arg (phi, lhs))
+	return phi;
       return NULL;
     }
 
@@ -2657,7 +2658,8 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs)
 
   if (is_reduction_operation_p (stmt))
     {
-      gimple res = follow_ssa_with_commutative_ops (gimple_assign_rhs1 (stmt), lhs);
+      gimple_phi res =
+	follow_ssa_with_commutative_ops (gimple_assign_rhs1 (stmt), lhs);
 
       return res ? res :
 	follow_ssa_with_commutative_ops (gimple_assign_rhs2 (stmt), lhs);
@@ -2669,12 +2671,12 @@ follow_ssa_with_commutative_ops (tree arg, tree lhs)
 /* Detect commutative and associative scalar reductions starting at
    the STMT.  Return the phi node of the reduction cycle, or NULL.  */
 
-static gimple
+static gimple_phi
 detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg,
 				  vec<gimple> *in,
 				  vec<gimple> *out)
 {
-  gimple phi = follow_ssa_with_commutative_ops (arg, lhs);
+  gimple_phi phi = follow_ssa_with_commutative_ops (arg, lhs);
 
   if (!phi)
     return NULL;
@@ -2687,7 +2689,7 @@ detect_commutative_reduction_arg (tree lhs, gimple stmt, tree arg,
 /* Detect commutative and associative scalar reductions starting at
    STMT.  Return the phi node of the reduction cycle, or NULL.  */
 
-static gimple
+static gimple_phi
 detect_commutative_reduction_assign (gimple stmt, vec<gimple> *in,
 				     vec<gimple> *out)
 {
@@ -2700,9 +2702,10 @@ detect_commutative_reduction_assign (gimple stmt, vec<gimple> *in,
 
   if (is_reduction_operation_p (stmt))
     {
-      gimple res = detect_commutative_reduction_arg (lhs, stmt,
-						     gimple_assign_rhs1 (stmt),
-						     in, out);
+      gimple_phi res =
+	detect_commutative_reduction_arg (lhs, stmt,
+					  gimple_assign_rhs1 (stmt),
+					  in, out);
       return res ? res
 	: detect_commutative_reduction_arg (lhs, stmt,
 					    gimple_assign_rhs2 (stmt),
@@ -2714,7 +2717,7 @@ detect_commutative_reduction_assign (gimple stmt, vec<gimple> *in,
 
 /* Return a loop phi node that corresponds to a reduction containing LHS.  */
 
-static gimple
+static gimple_phi
 follow_inital_value_to_phi (tree arg, tree lhs)
 {
   gimple stmt;
@@ -2724,9 +2727,9 @@ follow_inital_value_to_phi (tree arg, tree lhs)
 
   stmt = SSA_NAME_DEF_STMT (arg);
 
-  if (gimple_code (stmt) == GIMPLE_PHI
-      && phi_contains_arg (stmt, lhs))
-    return stmt;
+  if (gimple_phi phi = stmt->dyn_cast_gimple_phi ())
+    if (phi_contains_arg (phi, lhs))
+      return phi;
 
   return NULL;
 }
@@ -2800,13 +2803,14 @@ used_outside_reduction (tree def, gimple loop_phi)
    the SCOP starting at the loop closed phi node STMT.  Return the phi
    node of the reduction cycle, or NULL.  */
 
-static gimple
+static gimple_phi
 detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
 			      vec<gimple> *out)
 {
   if (scalar_close_phi_node_p (stmt))
     {
-      gimple def, loop_phi, phi, close_phi = stmt;
+      gimple def;
+      gimple_phi loop_phi, phi, close_phi = stmt->as_a_gimple_phi ();
       tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
 
       if (TREE_CODE (arg) != SSA_NAME)
@@ -2846,10 +2850,10 @@ detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
 
 static void
 translate_scalar_reduction_to_array_for_stmt (scop_p scop, tree red,
-					      gimple stmt, gimple loop_phi)
+					      gimple stmt, gimple_phi loop_phi)
 {
   tree res = gimple_phi_result (loop_phi);
-  gimple assign = gimple_build_assign (res, unshare_expr (red));
+  gimple_assign assign = gimple_build_assign (res, unshare_expr (red));
   gimple_stmt_iterator gsi;
 
   insert_stmts (scop, assign, NULL, gsi_after_labels (gimple_bb (loop_phi)));
@@ -2864,7 +2868,7 @@ translate_scalar_reduction_to_array_for_stmt (scop_p scop, tree red,
    the PHI_RESULT.  */
 
 static void
-remove_phi (gimple phi)
+remove_phi (gimple_phi phi)
 {
   imm_use_iterator imm_iter;
   tree def;
@@ -2927,7 +2931,7 @@ dr_indices_valid_in_loop (tree ref ATTRIBUTE_UNUSED, tree *index, void *data)
    NULL_TREE.  */
 
 static tree
-close_phi_written_to_memory (gimple close_phi)
+close_phi_written_to_memory (gimple_phi close_phi)
 {
   imm_use_iterator imm_iter;
   use_operand_p use_p;
@@ -2982,30 +2986,33 @@ translate_scalar_reduction_to_array (scop_p scop,
 				     vec<gimple> in,
 				     vec<gimple> out)
 {
-  gimple loop_phi;
+  gimple loop_stmt;
   unsigned int i = out.length () - 1;
-  tree red = close_phi_written_to_memory (out[i]);
+  tree red = close_phi_written_to_memory (out[i]->as_a_gimple_phi ());
 
-  FOR_EACH_VEC_ELT (in, i, loop_phi)
+  FOR_EACH_VEC_ELT (in, i, loop_stmt)
     {
-      gimple close_phi = out[i];
+      gimple close_stmt = out[i];
 
       if (i == 0)
 	{
-	  gimple stmt = loop_phi;
-	  basic_block bb = split_reduction_stmt (scop, stmt);
+	  basic_block bb = split_reduction_stmt (scop, loop_stmt);
 	  poly_bb_p pbb = pbb_from_bb (bb);
 	  PBB_IS_REDUCTION (pbb) = true;
-	  gcc_assert (close_phi == loop_phi);
+	  gcc_assert (close_stmt == loop_stmt);
 
 	  if (!red)
 	    red = create_zero_dim_array
-	      (gimple_assign_lhs (stmt), "Commutative_Associative_Reduction");
+	      (gimple_assign_lhs (loop_stmt), "Commutative_Associative_Reduction");
 
-	  translate_scalar_reduction_to_array_for_stmt (scop, red, stmt, in[1]);
+	  translate_scalar_reduction_to_array_for_stmt (scop, red, loop_stmt,
+							in[1]->as_a_gimple_phi ());
 	  continue;
 	}
 
+      gimple_phi loop_phi = loop_stmt->as_a_gimple_phi ();
+      gimple_phi close_phi = close_stmt->as_a_gimple_phi ();
+
       if (i == in.length () - 1)
 	{
 	  insert_out_of_ssa_copy (scop, gimple_phi_result (close_phi),
@@ -3025,7 +3032,7 @@ translate_scalar_reduction_to_array (scop_p scop,
 
 static bool
 rewrite_commutative_reductions_out_of_ssa_close_phi (scop_p scop,
-						     gimple close_phi)
+						     gimple_phi close_phi)
 {
   bool res;
   auto_vec<gimple, 10> in;
@@ -3046,7 +3053,7 @@ static bool
 rewrite_commutative_reductions_out_of_ssa_loop (scop_p scop,
 						loop_p loop)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   edge exit = single_exit (loop);
   tree res;
   bool changed = false;
@@ -3055,11 +3062,11 @@ rewrite_commutative_reductions_out_of_ssa_loop (scop_p scop,
     return false;
 
   for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    if ((res = gimple_phi_result (gsi_stmt (gsi)))
+    if ((res = gimple_phi_result (gsi.phi ()))
 	&& !virtual_operand_p (res)
 	&& !scev_analyzable_p (res, SCOP_REGION (scop)))
       changed |= rewrite_commutative_reductions_out_of_ssa_close_phi
-	(scop, gsi_stmt (gsi));
+	(scop, gsi.phi ());
 
   return changed;
 }
@@ -3096,7 +3103,7 @@ static bool
 scop_ivs_can_be_represented (scop_p scop)
 {
   loop_p loop;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
   bool result = true;
 
   FOR_EACH_LOOP (loop, 0)
@@ -3107,7 +3114,7 @@ scop_ivs_can_be_represented (scop_p scop)
       for (psi = gsi_start_phis (loop->header);
 	   !gsi_end_p (psi); gsi_next (&psi))
 	{
-	  gimple phi = gsi_stmt (psi);
+	  gimple_phi phi = psi.phi ();
 	  tree res = PHI_RESULT (phi);
 	  tree type = TREE_TYPE (res);
 
-- 
1.8.5.3

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

* [PATCH 62/89] Concretize gimple_label_label
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (57 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 18/89] Concretize get_loop_exit_condition et al to working on gimple_cond David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 20:34   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 74/89] Concretize gimple_cond_set_code David Malcolm
                   ` (32 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_label_label): Require a const_gimple_label
	rather than just a const_gimple.

	* cfgexpand.c (label_rtx_for_bb): Convert local from gimple to
	gimple_label, replacing a check against GIMPLE_LABEL with a
	dyn_cast_gimple_label.
	* predict.c (tree_estimate_probability_bb): Likewise.
	* tree-cfg.c (make_edges): Likewise.
	(cleanup_dead_labels): Likewise (twice).
	(gimple_can_merge_blocks_p): Likewise.
	(gimple_block_label): Likewise.
	* tree-eh.c (unsplit_eh): Likewise.
	(cleanup_empty_eh_unsplit): Likewise.
	* tree-inline.c (mark_local_labels_stmt): Likewise.
	* tree-nested.c (convert_nl_goto_receiver): Likewise.

	* cfgexpand.c (expand_gimple_stmt_1): Add a checked cast to
	gimple_label when invoking gimple_label_label in a region where
	we've checked the code is GIMPLE_LABEL.
	* gimple-pretty-print.c (pp_cfg_jump): Likewise.
	* gimple.c (gimple_set_bb): Likewise.
	* ipa-pure-const.c (check_stmt): Likewise.
	* omp-low.c (diagnose_sb_1): Likewise.
	* tree-cfg.c (gimple_verify_flow_info): Likewise.
	* tree-cfgcleanup.c (tree_forwarder_block_p): Likewise.
	(remove_forwarder_block): Likewise.
	* tree-eh.c (collect_finally_tree): Likewise.

	* ipa-split.c (verify_non_ssa_vars): Replace a check against
	GIMPLE_LABEL with a dyn_cast_gimple_label, introducing a
	gimple_label local.
	* tree-cfg.c (gimple_can_merge_blocks_p): Likewise.
	(gimple_merge_blocks): Likewise.
	(remove_bb): Likewise.
	(stmt_starts_bb_p): Likewise.
	(gimple_verify_flow_info): Likewise.
	(move_block_to_fn): Likewise.
	* tree-cfgcleanup.c (remove_forwarder_block): Likewise.
	(remove_forwarder_block_with_phi): Likewise.
	* tree-ssa-ccp.c (optimize_unreachable): Likewise.
---
 gcc/cfgexpand.c           |  9 +++---
 gcc/gimple-pretty-print.c |  4 ++-
 gcc/gimple.c              |  2 +-
 gcc/gimple.h              |  3 +-
 gcc/ipa-pure-const.c      |  2 +-
 gcc/ipa-split.c           | 16 ++++++-----
 gcc/omp-low.c             |  4 ++-
 gcc/predict.c             |  7 +++--
 gcc/tree-cfg.c            | 72 ++++++++++++++++++++++++-----------------------
 gcc/tree-cfgcleanup.c     | 22 +++++++--------
 gcc/tree-eh.c             | 12 ++++----
 gcc/tree-inline.c         |  4 +--
 gcc/tree-nested.c         |  4 +--
 gcc/tree-ssa-ccp.c        |  4 +--
 14 files changed, 87 insertions(+), 78 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 71615a8..ed4f037 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1919,7 +1919,6 @@ label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED)
 {
   gimple_stmt_iterator gsi;
   tree lab;
-  gimple lab_stmt;
   void **elt;
 
   if (bb->flags & BB_RTL)
@@ -1933,8 +1932,10 @@ label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED)
 
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      lab_stmt = gsi_stmt (gsi);
-      if (gimple_code (lab_stmt) != GIMPLE_LABEL)
+      gimple_label lab_stmt;
+
+      lab_stmt = gsi_stmt (gsi)->dyn_cast_gimple_label ();
+      if (!lab_stmt)
 	break;
 
       lab = gimple_label_label (lab_stmt);
@@ -3141,7 +3142,7 @@ expand_gimple_stmt_1 (gimple stmt)
 	expand_computed_goto (op0);
       break;
     case GIMPLE_LABEL:
-      expand_label (gimple_label_label (stmt));
+      expand_label (gimple_label_label (stmt->as_a_gimple_label ()));
       break;
     case GIMPLE_NOP:
     case GIMPLE_PREDICT:
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index f375a61..887093f 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2354,7 +2354,9 @@ pp_cfg_jump (pretty_printer *buffer, basic_block bb)
   if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
     {
       pp_string (buffer, " (");
-      dump_generic_node (buffer, gimple_label_label (stmt), 0, 0, false);
+      dump_generic_node (buffer,
+			 gimple_label_label (stmt->as_a_gimple_label ()),
+			 0, 0, false);
       pp_right_paren (buffer);
       pp_semicolon (buffer);
     }
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 75a9f5f..5f75b6c 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1492,7 +1492,7 @@ gimple_set_bb (gimple stmt, basic_block bb)
       tree t;
       int uid;
 
-      t = gimple_label_label (stmt);
+      t = gimple_label_label (stmt->as_a_gimple_label ());
       uid = LABEL_DECL_UID (t);
       if (uid == -1)
 	{
diff --git a/gcc/gimple.h b/gcc/gimple.h
index e4aeec6..d54d011 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3477,9 +3477,8 @@ gimple_cond_set_condition (gimple_cond stmt, enum tree_code code, tree lhs,
 /* Return the LABEL_DECL node used by GIMPLE_LABEL statement GS.  */
 
 static inline tree
-gimple_label_label (const_gimple gs)
+gimple_label_label (const_gimple_label gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_LABEL);
   return gimple_op (gs, 0);
 }
 
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 133bc73..66313c8 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -688,7 +688,7 @@ check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
       check_call (local, stmt->as_a_gimple_call (), ipa);
       break;
     case GIMPLE_LABEL:
-      if (DECL_NONLOCAL (gimple_label_label (stmt)))
+      if (DECL_NONLOCAL (gimple_label_label (stmt->as_a_gimple_label ())))
 	/* Target of long jump. */
 	{
           if (dump_file)
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 0797abff..4e00e82 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -247,13 +247,15 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars,
 	      ok = false;
 	      goto done;
 	    }
-	  if (gimple_code (stmt) == GIMPLE_LABEL
-	      && test_nonssa_use (stmt, gimple_label_label (stmt),
-				  NULL_TREE, non_ssa_vars))
-	  {
-	    ok = false;
-	    goto done;
-	  }
+	  if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
+	    {
+	      if (test_nonssa_use (stmt, gimple_label_label (label_stmt),
+				   NULL_TREE, non_ssa_vars))
+		{
+		  ok = false;
+		  goto done;
+		}
+	    }
 	}
       for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index c978c56..79f725c 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10398,7 +10398,9 @@ diagnose_sb_1 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
       break;
 
     case GIMPLE_LABEL:
-      splay_tree_insert (all_labels, (splay_tree_key) gimple_label_label (stmt),
+      splay_tree_insert (all_labels,
+			 (splay_tree_key) gimple_label_label (
+					    stmt->as_a_gimple_label ()),
 			 (splay_tree_value) context);
       break;
 
diff --git a/gcc/predict.c b/gcc/predict.c
index 7b4bb12..b15de97 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2347,12 +2347,13 @@ tree_estimate_probability_bb (basic_block bb)
 	  gimple_stmt_iterator gi;
 	  for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi))
 	    {
-	      gimple stmt = gsi_stmt (gi);
+	      gimple_label label_stmt =
+		gsi_stmt (gi)->dyn_cast_gimple_label ();
 	      tree decl;
 
-	      if (gimple_code (stmt) != GIMPLE_LABEL)
+	      if (!label_stmt)
 		break;
-	      decl = gimple_label_label (stmt);
+	      decl = gimple_label_label (label_stmt);
 	      if (DECL_ARTIFICIAL (decl))
 		continue;
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index efc3367..2a54b71 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -863,10 +863,11 @@ make_edges (void)
 	{
 	  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	    {
-	      gimple label_stmt = gsi_stmt (gsi);
+	      gimple_label label_stmt =
+		gsi_stmt (gsi)->dyn_cast_gimple_label ();
 	      tree target;
 
-	      if (gimple_code (label_stmt) != GIMPLE_LABEL)
+	      if (!label_stmt)
 		break;
 
 	      target = gimple_label_label (label_stmt);
@@ -1329,12 +1330,12 @@ cleanup_dead_labels (void)
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
 	{
 	  tree label;
-	  gimple stmt = gsi_stmt (i);
+	  gimple_label label_stmt = gsi_stmt (i)->dyn_cast_gimple_label ();
 
-	  if (gimple_code (stmt) != GIMPLE_LABEL)
+	  if (!label_stmt)
 	    break;
 
-	  label = gimple_label_label (stmt);
+	  label = gimple_label_label (label_stmt);
 
 	  /* If we have not yet seen a label for the current block,
 	     remember this one and see if there are more labels.  */
@@ -1469,12 +1470,12 @@ cleanup_dead_labels (void)
       for (i = gsi_start_bb (bb); !gsi_end_p (i); )
 	{
 	  tree label;
-	  gimple stmt = gsi_stmt (i);
+	  gimple_label label_stmt = gsi_stmt (i)->dyn_cast_gimple_label ();
 
-	  if (gimple_code (stmt) != GIMPLE_LABEL)
+	  if (!label_stmt)
 	    break;
 
-	  label = gimple_label_label (stmt);
+	  label = gimple_label_label (label_stmt);
 
 	  if (label == label_for_this_bb
 	      || !DECL_ARTIFICIAL (label)
@@ -1616,19 +1617,19 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
     return false;
 
   /* Do not allow a block with only a non-local label to be merged.  */
-  if (stmt
-      && gimple_code (stmt) == GIMPLE_LABEL
-      && DECL_NONLOCAL (gimple_label_label (stmt)))
-    return false;
+  if (stmt)
+    if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
+      if (DECL_NONLOCAL (gimple_label_label (label_stmt)))
+	return false;
 
   /* Examine the labels at the beginning of B.  */
   for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       tree lab;
-      stmt = gsi_stmt (gsi);
-      if (gimple_code (stmt) != GIMPLE_LABEL)
+      gimple_label label_stmt = gsi_stmt (gsi)->dyn_cast_gimple_label ();
+      if (!label_stmt)
 	break;
-      lab = gimple_label_label (stmt);
+      lab = gimple_label_label (label_stmt);
 
       /* Do not remove user forced labels or for -O0 any user labels.  */
       if (!DECL_ARTIFICIAL (lab) && (!optimize || FORCED_LABEL (lab)))
@@ -1828,9 +1829,9 @@ gimple_merge_blocks (basic_block a, basic_block b)
   for (gsi = gsi_start_bb (b); !gsi_end_p (gsi);)
     {
       gimple stmt = gsi_stmt (gsi);
-      if (gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
 	{
-	  tree label = gimple_label_label (stmt);
+	  tree label = gimple_label_label (label_stmt);
 	  int lp_nr;
 
 	  gsi_remove (&gsi, false);
@@ -1979,9 +1980,10 @@ remove_bb (basic_block bb)
       for (i = gsi_last_bb (bb); !gsi_end_p (i);)
 	{
 	  gimple stmt = gsi_stmt (i);
-	  if (gimple_code (stmt) == GIMPLE_LABEL
-	      && (FORCED_LABEL (gimple_label_label (stmt))
-		  || DECL_NONLOCAL (gimple_label_label (stmt))))
+	  gimple_label label_stmt = stmt->dyn_cast_gimple_label ();
+	  if (label_stmt
+	      && (FORCED_LABEL (gimple_label_label (label_stmt))
+		  || DECL_NONLOCAL (gimple_label_label (label_stmt))))
 	    {
 	      basic_block new_bb;
 	      gimple_stmt_iterator new_gsi;
@@ -1989,10 +1991,10 @@ remove_bb (basic_block bb)
 	      /* A non-reachable non-local label may still be referenced.
 		 But it no longer needs to carry the extra semantics of
 		 non-locality.  */
-	      if (DECL_NONLOCAL (gimple_label_label (stmt)))
+	      if (DECL_NONLOCAL (gimple_label_label (label_stmt)))
 		{
-		  DECL_NONLOCAL (gimple_label_label (stmt)) = 0;
-		  FORCED_LABEL (gimple_label_label (stmt)) = 1;
+		  DECL_NONLOCAL (gimple_label_label (label_stmt)) = 0;
+		  FORCED_LABEL (gimple_label_label (label_stmt)) = 1;
 		}
 
 	      new_bb = bb->prev_bb;
@@ -2432,16 +2434,16 @@ stmt_starts_bb_p (gimple stmt, gimple prev_stmt)
   /* Labels start a new basic block only if the preceding statement
      wasn't a label of the same type.  This prevents the creation of
      consecutive blocks that have nothing but a single label.  */
-  if (gimple_code (stmt) == GIMPLE_LABEL)
+  if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
     {
       /* Nonlocal and computed GOTO targets always start a new block.  */
-      if (DECL_NONLOCAL (gimple_label_label (stmt))
-	  || FORCED_LABEL (gimple_label_label (stmt)))
+      if (DECL_NONLOCAL (gimple_label_label (label_stmt))
+	  || FORCED_LABEL (gimple_label_label (label_stmt)))
 	return true;
 
       if (prev_stmt && gimple_code (prev_stmt) == GIMPLE_LABEL)
 	{
-	  if (DECL_NONLOCAL (gimple_label_label (prev_stmt)))
+	  if (DECL_NONLOCAL (gimple_label_label (prev_stmt->as_a_gimple_label ())))
 	    return true;
 
 	  cfg_stats.num_merged_labels++;
@@ -5011,7 +5013,7 @@ gimple_verify_flow_info (void)
 	  if (gimple_code (stmt) != GIMPLE_LABEL)
 	    break;
 
-	  label = gimple_label_label (stmt);
+	  label = gimple_label_label (stmt->as_a_gimple_label ());
 	  if (prev_stmt && DECL_NONLOCAL (label))
 	    {
 	      error ("nonlocal label ");
@@ -5064,10 +5066,10 @@ gimple_verify_flow_info (void)
 	  if (stmt_ends_bb_p (stmt))
 	    found_ctrl_stmt = true;
 
-	  if (gimple_code (stmt) == GIMPLE_LABEL)
+	  if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
 	    {
 	      error ("label ");
-	      print_generic_expr (stderr, gimple_label_label (stmt), 0);
+	      print_generic_expr (stderr, gimple_label_label (label_stmt), 0);
 	      fprintf (stderr, " in the middle of basic block %d", bb->index);
 	      err = 1;
 	    }
@@ -5326,12 +5328,12 @@ gimple_block_label (basic_block bb)
   gimple_stmt_iterator i, s = gsi_start_bb (bb);
   bool first = true;
   tree label;
-  gimple stmt;
+  gimple_label stmt;
 
   for (i = s; !gsi_end_p (i); first = false, gsi_next (&i))
     {
-      stmt = gsi_stmt (i);
-      if (gimple_code (stmt) != GIMPLE_LABEL)
+      stmt = gsi_stmt (i)->dyn_cast_gimple_label ();
+      if (!stmt)
 	break;
       label = gimple_label_label (stmt);
       if (!DECL_NONLOCAL (label))
@@ -6628,9 +6630,9 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
       wi.info = d;
       walk_gimple_stmt (&si, move_stmt_r, move_stmt_op, &wi);
 
-      if (gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
 	{
-	  tree label = gimple_label_label (stmt);
+	  tree label = gimple_label_label (label_stmt);
 	  int uid = LABEL_DECL_UID (label);
 
 	  gcc_assert (uid > -1);
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 3c879f5..914cc71 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -289,7 +289,7 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
       switch (gimple_code (stmt))
 	{
 	case GIMPLE_LABEL:
-	  if (DECL_NONLOCAL (gimple_label_label (stmt)))
+	  if (DECL_NONLOCAL (gimple_label_label (stmt->as_a_gimple_label ())))
 	    return false;
 	  if (optimize == 0 && gimple_location (stmt) != locus)
 	    return false;
@@ -386,11 +386,11 @@ remove_forwarder_block (basic_block bb)
   /* If the destination block consists of a nonlocal label or is a
      EH landing pad, do not merge it.  */
   label = first_stmt (dest);
-  if (label
-      && gimple_code (label) == GIMPLE_LABEL
-      && (DECL_NONLOCAL (gimple_label_label (label))
-	  || EH_LANDING_PAD_NR (gimple_label_label (label)) != 0))
-    return false;
+  if (label)
+    if (gimple_label label_stmt = label->dyn_cast_gimple_label ())
+      if (DECL_NONLOCAL (gimple_label_label (label_stmt))
+	  || EH_LANDING_PAD_NR (gimple_label_label (label_stmt)) != 0)
+	return false;
 
   /* If there is an abnormal edge to basic block BB, but not into
      dest, problems might occur during removal of the phi node at out
@@ -472,7 +472,7 @@ remove_forwarder_block (basic_block bb)
       label = gsi_stmt (gsi);
       if (is_gimple_debug (label))
 	break;
-      decl = gimple_label_label (label);
+      decl = gimple_label_label (label->as_a_gimple_label ());
       if (EH_LANDING_PAD_NR (decl) != 0
 	  || DECL_NONLOCAL (decl)
 	  || FORCED_LABEL (decl)
@@ -815,10 +815,10 @@ remove_forwarder_block_with_phi (basic_block bb)
   /* If the destination block consists of a nonlocal label, do not
      merge it.  */
   label = first_stmt (dest);
-  if (label
-      && gimple_code (label) == GIMPLE_LABEL
-      && DECL_NONLOCAL (gimple_label_label (label)))
-    return false;
+  if (label)
+    if (gimple_label label_stmt = label->dyn_cast_gimple_label ())
+      if (DECL_NONLOCAL (gimple_label_label (label_stmt)))
+	return false;
 
   /* Record BB's single pred in case we need to update the father
      loop's latch information later.  */
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 928d397..412e79a 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -265,7 +265,7 @@ collect_finally_tree (gimple stmt, gimple_try region)
   switch (gimple_code (stmt))
     {
     case GIMPLE_LABEL:
-      temp.t = gimple_label_label (stmt);
+      temp.t = gimple_label_label (stmt->as_a_gimple_label ());
       record_in_finally_tree (temp, region);
       break;
 
@@ -4067,13 +4067,13 @@ unsplit_eh (eh_landing_pad lp)
      for a different region.  */
   for (gsi = gsi_start_bb (e_out->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple stmt = gsi_stmt (gsi);
+      gimple_label label_stmt = gsi_stmt (gsi)->dyn_cast_gimple_label ();
       tree lab;
       int lp_nr;
 
-      if (gimple_code (stmt) != GIMPLE_LABEL)
+      if (!label_stmt)
 	break;
-      lab = gimple_label_label (stmt);
+      lab = gimple_label_label (label_stmt);
       lp_nr = EH_LANDING_PAD_NR (lab);
       if (lp_nr && get_eh_region_from_lp_number (lp_nr) != lp->region)
 	return false;
@@ -4340,10 +4340,10 @@ cleanup_empty_eh_unsplit (basic_block bb, edge e_out, eh_landing_pad lp)
   lab = NULL;
   for (gsi = gsi_start_bb (e_out->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple stmt = gsi_stmt (gsi);
+      gimple_label stmt = gsi_stmt (gsi)->dyn_cast_gimple_label ();
       int lp_nr;
 
-      if (gimple_code (stmt) != GIMPLE_LABEL)
+      if (!stmt)
 	break;
       lab = gimple_label_label (stmt);
       lp_nr = EH_LANDING_PAD_NR (lab);
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 37d6a8b..2f675d2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4792,9 +4792,9 @@ mark_local_labels_stmt (gimple_stmt_iterator *gsip,
 		        struct walk_stmt_info *wi)
 {
   copy_body_data *id = (copy_body_data *) wi->info;
-  gimple stmt = gsi_stmt (*gsip);
+  gimple_label stmt = gsi_stmt (*gsip)->dyn_cast_gimple_label ();
 
-  if (gimple_code (stmt) == GIMPLE_LABEL)
+  if (stmt)
     {
       tree decl = gimple_label_label (stmt);
 
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index ca3e0ba..ce6f309 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1938,9 +1938,9 @@ convert_nl_goto_receiver (gimple_stmt_iterator *gsi, bool *handled_ops_p,
   tree label, new_label;
   gimple_stmt_iterator tmp_gsi;
   void **slot;
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_label stmt = gsi_stmt (*gsi)->dyn_cast_gimple_label ();
 
-  if (gimple_code (stmt) != GIMPLE_LABEL)
+  if (!stmt)
     {
       *handled_ops_p = false;
       return NULL_TREE;
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 3f3c27f..3509d31 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2519,10 +2519,10 @@ optimize_unreachable (gimple_stmt_iterator i)
       if (is_gimple_debug (stmt))
        continue;
 
-      if (gimple_code (stmt) == GIMPLE_LABEL)
+      if (gimple_label label_stmt = stmt->dyn_cast_gimple_label ())
 	{
 	  /* Verify we do not need to preserve the label.  */
-	  if (FORCED_LABEL (gimple_label_label (stmt)))
+	  if (FORCED_LABEL (gimple_label_label (label_stmt)))
 	    return false;
 
 	  continue;
-- 
1.8.5.3

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

* [PATCH 42/89] Introduce gimple_omp_single
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (60 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 32/89] Introduce gimple_try David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 17:18   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes David Malcolm
                   ` (29 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_single): New typedef.
	(const_gimple_omp_single): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_single): New.
	(gimple_build_omp_single): Return a gimple_omp_single rather than
	a plain gimple.
	(gimple_omp_single_set_clauses): Require a gimple_omp_single
	rather than a plain gimple.

	* gimple-pretty-print.c (dump_gimple_omp_single): Require a
	gimple_omp_single rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_single within
	GIMPLE_OMP_SINGLE case of switch statement.

	* gimple.c (gimple_build_omp_single): Return a gimple_omp_single
	rather than a plain gimple.

	* omp-low.c (scan_omp_single): Require a gimple_omp_single rather
	than a plain gimple.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_single within
	GIMPLE_OMP_SINGLE case of switch statement.
	(lower_omp_single_simple): Require a gimple_omp_single rather
	than a plain gimple.
	(lower_omp_single_copy): Likewise.
	(lower_omp_single): Strengthen local "single_stmt" from gimple to
	gimple_omp_single.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  6 ++++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 14 +++++++++-----
 gcc/omp-low.c             | 12 +++++++-----
 5 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 9564ab7..6d7bb0f 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -175,6 +175,10 @@ struct gimple_statement_omp_task;
 typedef struct gimple_statement_omp_task *gimple_omp_task;
 typedef const struct gimple_statement_omp_task *const_gimple_omp_task;
 
+struct gimple_statement_omp_single;
+typedef struct gimple_statement_omp_single *gimple_omp_single;
+typedef const struct gimple_statement_omp_single *const_gimple_omp_single;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d249373..d024730 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1252,7 +1252,8 @@ dump_gimple_omp_continue (pretty_printer *buffer, gimple_omp_continue gs,
 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_single (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_single (pretty_printer *buffer, gimple_omp_single gs,
+			int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2172,7 +2173,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_SINGLE:
-      dump_gimple_omp_single (buffer, gs, spc, flags);
+      dump_gimple_omp_single (buffer, gs->as_a_gimple_omp_single (), spc,
+			      flags);
       break;
 
     case GIMPLE_OMP_TARGET:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 1f58a03..ba9adb8 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1033,10 +1033,11 @@ gimple_build_omp_sections_switch (void)
    CLAUSES are any of the OMP single construct's clauses: private, firstprivate,
    copyprivate, nowait.  */
 
-gimple
+gimple_omp_single
 gimple_build_omp_single (gimple_seq body, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_SINGLE, 0);
+  gimple_omp_single p =
+    gimple_alloc (GIMPLE_OMP_SINGLE, 0)->as_a_gimple_omp_single ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_single_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6675d9b..485cec4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -378,6 +378,12 @@ public:
     return as_a <gimple_statement_omp_task> (this);
   }
 
+  inline gimple_omp_single
+  as_a_gimple_omp_single ()
+  {
+    return as_a <gimple_statement_omp_single> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1636,7 +1642,7 @@ gimple gimple_build_omp_ordered (gimple_seq);
 gimple gimple_build_omp_return (bool);
 gimple gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
-gimple gimple_build_omp_single (gimple_seq, tree);
+gimple_omp_single gimple_build_omp_single (gimple_seq, tree);
 gimple gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
 gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
@@ -5330,13 +5336,11 @@ gimple_omp_single_clauses_ptr (gimple gs)
 }
 
 
-/* Set CLAUSES to be the clauses associated with OMP_SINGLE GS.  */
+/* Set CLAUSES to be the clauses associated with OMP_SINGLE_STMT.  */
 
 static inline void
-gimple_omp_single_set_clauses (gimple gs, tree clauses)
+gimple_omp_single_set_clauses (gimple_omp_single omp_single_stmt, tree clauses)
 {
-  gimple_statement_omp_single *omp_single_stmt =
-    as_a <gimple_statement_omp_single> (gs);
   omp_single_stmt->clauses = clauses;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 990b985..f17226b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2155,7 +2155,7 @@ scan_omp_sections (gimple stmt, omp_context *outer_ctx)
 /* Scan an OpenMP single directive.  */
 
 static void
-scan_omp_single (gimple stmt, omp_context *outer_ctx)
+scan_omp_single (gimple_omp_single stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
   tree name;
@@ -2651,7 +2651,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_SINGLE:
-      scan_omp_single (stmt, ctx);
+      scan_omp_single (stmt->as_a_gimple_omp_single (), ctx);
       break;
 
     case GIMPLE_OMP_SECTION:
@@ -8522,7 +8522,7 @@ lower_omp_sections (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   to a synchronization analysis pass.  */
 
 static void
-lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p)
+lower_omp_single_simple (gimple_omp_single single_stmt, gimple_seq *pre_p)
 {
   location_t loc = gimple_location (single_stmt);
   tree tlabel = create_artificial_label (loc);
@@ -8577,7 +8577,8 @@ lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p)
   to a synchronization analysis pass.  */
 
 static void
-lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx)
+lower_omp_single_copy (gimple_omp_single single_stmt, gimple_seq *pre_p,
+		       omp_context *ctx)
 {
   tree ptr_type, t, l0, l1, l2, bfn_decl;
   gimple_seq copyin_seq;
@@ -8633,7 +8634,8 @@ static void
 lower_omp_single (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree block;
-  gimple t, single_stmt = gsi_stmt (*gsi_p);
+  gimple t;
+  gimple_omp_single single_stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_single ();
   gimple_bind bind;
   gimple_seq bind_body, bind_body_tail = NULL, dlist;
 
-- 
1.8.5.3

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

* [PATCH 18/89] Concretize get_loop_exit_condition et al to working on gimple_cond
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (56 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-04-21 17:13 ` [PATCH 62/89] Concretize gimple_label_label David Malcolm
                   ` (33 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-scalar-evolution.h (get_loop_exit_condition): Return a
	gimple_cond.
	* tree-scalar-evolution.c (get_loop_exit_condition): Likewise, also
	concretizing local "res" from gimple to gimple_cond.
	* tree-vect-loop-manip.c (slpeel_make_loop_iterate_ntimes): Convert
	locals from gimple to gimple_cond.
	(slpeel_can_duplicate_loop_p): Likewise.
	* tree-vect-loop.c (vect_get_loop_niters): Return a gimple_cond.
	(vect_analyze_loop_form): Convert local from gimple to gimple_cond.
---
 gcc/tree-scalar-evolution.c | 8 ++++----
 gcc/tree-scalar-evolution.h | 2 +-
 gcc/tree-vect-loop-manip.c  | 6 +++---
 gcc/tree-vect-loop.c        | 5 +++--
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 14dbd45..40f9901 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -868,10 +868,10 @@ add_to_evolution (unsigned loop_nb, tree chrec_before, enum tree_code code,
    guards the exit edge.  If the expression is too difficult to
    analyze, then give up.  */
 
-gimple
+gimple_cond
 get_loop_exit_condition (const struct loop *loop)
 {
-  gimple res = NULL;
+  gimple_cond res = NULL;
   edge exit_edge = single_exit (loop);
 
   if (dump_file && (dump_flags & TDF_SCEV))
@@ -882,8 +882,8 @@ get_loop_exit_condition (const struct loop *loop)
       gimple stmt;
 
       stmt = last_stmt (exit_edge->src);
-      if (gimple_code (stmt) == GIMPLE_COND)
-	res = stmt;
+      if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
+	res = cond_stmt;
     }
 
   if (dump_file && (dump_flags & TDF_SCEV))
diff --git a/gcc/tree-scalar-evolution.h b/gcc/tree-scalar-evolution.h
index 5569976..3466a75 100644
--- a/gcc/tree-scalar-evolution.h
+++ b/gcc/tree-scalar-evolution.h
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_TREE_SCALAR_EVOLUTION_H
 
 extern tree number_of_latch_executions (struct loop *);
-extern gimple get_loop_exit_condition (const struct loop *);
+extern gimple_cond get_loop_exit_condition (const struct loop *);
 
 extern void scev_initialize (void);
 extern bool scev_initialized_p (void);
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 15d9a53..b0b6bbe 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -667,8 +667,8 @@ void
 slpeel_make_loop_iterate_ntimes (struct loop *loop, tree niters)
 {
   tree indx_before_incr, indx_after_incr;
-  gimple cond_stmt;
-  gimple orig_cond;
+  gimple_cond cond_stmt;
+  gimple_cond orig_cond;
   edge exit_edge = single_exit (loop);
   gimple_stmt_iterator loop_cond_gsi;
   gimple_stmt_iterator incr_gsi;
@@ -974,7 +974,7 @@ slpeel_can_duplicate_loop_p (const struct loop *loop, const_edge e)
 {
   edge exit_e = single_exit (loop);
   edge entry_e = loop_preheader_edge (loop);
-  gimple orig_cond = get_loop_exit_condition (loop);
+  gimple_cond orig_cond = get_loop_exit_condition (loop);
   gimple_stmt_iterator loop_exit_gsi = gsi_last_bb (exit_e->src);
 
   if (loop->inner
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 220f665..3781d43 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -805,7 +805,8 @@ vect_analyze_scalar_cycles (loop_vec_info loop_vinfo)
 
    Return the loop exit condition.  */
 
-static gimple
+
+static gimple_cond
 vect_get_loop_niters (struct loop *loop, tree *number_of_iterations,
 		      tree *number_of_iterationsm1)
 {
@@ -1084,7 +1085,7 @@ loop_vec_info
 vect_analyze_loop_form (struct loop *loop)
 {
   loop_vec_info loop_vinfo;
-  gimple loop_cond;
+  gimple_cond loop_cond;
   tree number_of_iterations = NULL, number_of_iterationsm1 = NULL;
   loop_vec_info inner_loop_vinfo = NULL;
 
-- 
1.8.5.3

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

* [PATCH 79/89] Concretize gimple_call_nothrow_p
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (65 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 71/89] Concretize gimple_cond_make_{false|true} David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 18:37   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 36/89] Introduce gimple_omp_continue David Malcolm
                   ` (24 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_nothrow_p): Require a gimple_call.

	* tree-eh.c (stmt_could_throw_p): Add checked cast to gimple_call.

	* tree-vect-slp.c (vect_build_slp_tree_1): Replace call to
	is_gimple_call with dyn_cast_gimple_call, introducing a local.
---
 gcc/gimple.h        |  3 +--
 gcc/tree-eh.c       |  2 +-
 gcc/tree-vect-slp.c | 15 ++++++++-------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index f3242c4..33f1889 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3201,9 +3201,8 @@ gimple_call_set_nothrow (gimple_call s, bool nothrow_p)
 /* Return true if S is a nothrow call.  */
 
 static inline bool
-gimple_call_nothrow_p (gimple s)
+gimple_call_nothrow_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (gimple_call_flags (s) & ECF_NOTHROW) != 0;
 }
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 46dcc20..5e4eef8 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -2820,7 +2820,7 @@ stmt_could_throw_p (gimple stmt)
       return true;
 
     case GIMPLE_CALL:
-      return !gimple_call_nothrow_p (stmt);
+      return !gimple_call_nothrow_p (stmt->as_a_gimple_call ());
 
     case GIMPLE_ASSIGN:
     case GIMPLE_COND:
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 65f8b02..31d4dfb 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -505,20 +505,21 @@ vect_build_slp_tree_1 (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
             vectorization_factor = *max_nunits;
         }
 
-      if (is_gimple_call (stmt))
+      if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	{
 	  rhs_code = CALL_EXPR;
-	  if (gimple_call_internal_p (stmt)
-	      || gimple_call_tail_p (stmt)
-	      || gimple_call_noreturn_p (stmt)
-	      || !gimple_call_nothrow_p (stmt)
-	      || gimple_call_chain (stmt))
+	  if (gimple_call_internal_p (call_stmt)
+	      || gimple_call_tail_p (call_stmt)
+	      || gimple_call_noreturn_p (call_stmt)
+	      || !gimple_call_nothrow_p (call_stmt)
+	      || gimple_call_chain (call_stmt))
 	    {
 	      if (dump_enabled_p ())
 		{
 		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
 				   "Build SLP failed: unsupported call type ");
-		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+				    call_stmt, 0);
                   dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
 		}
 	      /* Fatal mismatch.  */
-- 
1.8.5.3

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

* [PATCH 24/89] Introduce gimple_transaction
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (62 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-04-21 17:13 ` [PATCH 08/89] Introduce gimple_phi and use it in various places David Malcolm
                   ` (27 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_transaction): New typedef.
	(const_gimple_transaction): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_transaction): New.
	(gimple_statement_base::dyn_cast_gimple_transaction): New.
	(gimple_build_transaction): Return a gimple_transaction rather than
	a plain gimple.
	(gimple_transaction_body_ptr): Require a gimple_transaction rather
	than a plain gimple.
	(gimple_transaction_body): Likewise.
	(gimple_transaction_label_ptr): Likewise.
	(gimple_transaction_set_body): Likewise.
	(gimple_transaction_set_label): Likewise.
	(gimple_transaction_set_subcode): Likewise.
	(gimple_transaction_label): Require a const_gimple_transaction rather
	than a plain const_gimple.
	(gimple_transaction_subcode): Likewise.

	* gimple-low.c (lower_stmt): Add checked cast to gimple_transaction
	within GIMPLE_TRANSACTION case of switch statement.

	* gimple-pretty-print.c (dump_gimple_transaction): Require a
	gimple_transaction rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_transaction within
	GIMPLE_TRANSACTION case of switch statement.
	* gimple-streamer-in.c (input_gimple_stmt): Likewise.
	* gimple-streamer-out.c (output_gimple_stmt): Likewise.
	* gimple-walk.c (walk_gimple_op): Likewise.
	(walk_gimple_stmt): Likewise.

	* gimple.c (gimple_build_transaction): Return a gimple_transaction
	rather than a plain gimple.
	(gimple_copy): Add checked casts to gimple_transaction within
	GIMPLE_TRANSACTION case of switch statement.

	* gimplify.c (gimplify_transaction): Split local "g" into "body_stmt"
	and "trans_stmt", strengthening the type of the latter from gimple to
	gimple_transaction.

	* omp-low.c (lower_omp_1): Add checked cast to gimple_transaction
	within GIMPLE_TRANSACTION case of switch statement.

	* trans-mem.c (diagnose_tm_1): Add checked cast within
	GIMPLE_TRANSACTION case of switch statement, introducing a new
	local "trans_stmt".  Use it in place of "stmt".
	(examine_call_tm): Convert local from gimple to gimple_transaction.
	(tm_region::get_transaction_stmt): New method.
	(tm_region::transaction_stmt): Add clarification of type to the comment.
	(tm_region_init_0): Require a gimple_transaction rather than a
	plain gimple.
	(tm_region_init): Convert a check against GIMPLE_TRANSACTION to a
	dyn_cast_gimple_transaction and new local.
	(transaction_subcode_ior): Add a new local, using the new
	get_transaction_stmt method to perform a checked cast.
	(propagate_tm_flags_out): Likewise.
	(expand_transaction): Add a checked cast using the new
	get_transaction_stmt method.
	(generate_tm_state): Likewise.
	(execute_tm_mark): Likewise.
	(ipa_tm_diagnose_transaction): Likewise.

	* tree-cfg.c (verify_gimple_transaction): Require a
	gimple_transaction rather than a plain gimple.
	(make_edges): Add checked cast within GIMPLE_TRANSACTION case of
	switch statement
	(cleanup_dead_labels): Likewise.
	(verify_gimple_stmt): Likewise.
	(verify_gimple_in_seq_2): Likewise.
	(verify_gimple_in_seq_2): Likewise.
	(gimple_redirect_edge_and_branch): Add checked cast.

	* tree-inline.c (remap_gimple_stmt): Add checked cast within
	GIMPLE_TRANSACTION case of switch statement, introducing a new
	local "old_trans_stmt".  Use it in place of "stmt".  Add new
	local "new_trans_stmt", using it to initialize "copy", and for
	type-safe operations as a transaction.
	(estimate_num_insns): Add checked cast within GIMPLE_TRANSACTION
	case of switch statement.
---
 gcc/coretypes.h           |  4 +++
 gcc/gimple-low.c          |  4 ++-
 gcc/gimple-pretty-print.c |  6 +++--
 gcc/gimple-streamer-in.c  |  3 ++-
 gcc/gimple-streamer-out.c |  7 +++--
 gcc/gimple-walk.c         |  8 +++---
 gcc/gimple.c              | 11 +++++---
 gcc/gimple.h              | 58 ++++++++++++++++++++++-------------------
 gcc/gimplify.c            | 13 +++++-----
 gcc/omp-low.c             |  4 ++-
 gcc/trans-mem.c           | 66 +++++++++++++++++++++++++++++++++--------------
 gcc/tree-cfg.c            | 19 ++++++++------
 gcc/tree-inline.c         | 19 +++++++++++---
 13 files changed, 143 insertions(+), 79 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 7c869e9..284fcb6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -101,6 +101,10 @@ struct gimple_statement_call;
 typedef struct gimple_statement_call *gimple_call;
 typedef const struct gimple_statement_call *const_gimple_call;
 
+struct gimple_statement_transaction;
+typedef struct gimple_statement_transaction *gimple_transaction;
+typedef const struct gimple_statement_transaction *const_gimple_transaction;
+
 struct gimple_statement_return;
 typedef struct gimple_statement_return *gimple_return;
 typedef const struct gimple_statement_return *const_gimple_return;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 98e001d..5f19f6e 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -363,7 +363,9 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
       return;
 
     case GIMPLE_TRANSACTION:
-      lower_sequence (gimple_transaction_body_ptr (stmt), data);
+      lower_sequence (gimple_transaction_body_ptr (
+			stmt->as_a_gimple_transaction ()),
+		      data);
       break;
 
     default:
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index da27f21..dfb6459 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1493,7 +1493,8 @@ dump_gimple_omp_return (pretty_printer *buffer, gimple gs, int spc, int flags)
 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_transaction (pretty_printer *buffer, gimple_transaction gs,
+			 int spc, int flags)
 {
   unsigned subcode = gimple_transaction_subcode (gs);
 
@@ -2237,7 +2238,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_TRANSACTION:
-      dump_gimple_transaction (buffer, gs, spc, flags);
+      dump_gimple_transaction (buffer, gs->as_a_gimple_transaction (), spc,
+			       flags);
       break;
 
     default:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 25d871c..0e94369 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -200,7 +200,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_TRANSACTION:
-      gimple_transaction_set_label (stmt, stream_read_tree (ib, data_in));
+      gimple_transaction_set_label (stmt->as_a_gimple_transaction (),
+				    stream_read_tree (ib, data_in));
       break;
 
     default:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 7aafba1..b3c3b25 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -177,8 +177,11 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_TRANSACTION:
-      gcc_assert (gimple_transaction_body (stmt) == NULL);
-      stream_write_tree (ob, gimple_transaction_label (stmt), true);
+      {
+	gimple_transaction trans_stmt = stmt->as_a_gimple_transaction ();
+	gcc_assert (gimple_transaction_body (trans_stmt) == NULL);
+	stream_write_tree (ob, gimple_transaction_label (trans_stmt), true);
+      }
       break;
 
     default:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index f71b0db..2d987c6 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -438,8 +438,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_TRANSACTION:
-      ret = walk_tree (gimple_transaction_label_ptr (stmt), callback_op,
-		       wi, pset);
+      ret = walk_tree (gimple_transaction_label_ptr (
+			 stmt->as_a_gimple_transaction ()),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
@@ -618,7 +619,8 @@ walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt,
       break;
 
     case GIMPLE_TRANSACTION:
-      ret = walk_gimple_seq_mod (gimple_transaction_body_ptr (stmt),
+      ret = walk_gimple_seq_mod (gimple_transaction_body_ptr (
+				   stmt->as_a_gimple_transaction ()),
 			     callback_stmt, callback_op, wi);
       if (ret)
 	return wi->callback_result;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index e037c05..7ee7da1 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1100,10 +1100,11 @@ gimple_build_omp_atomic_store (tree val)
 
 /* Build a GIMPLE_TRANSACTION statement.  */
 
-gimple
+gimple_transaction
 gimple_build_transaction (gimple_seq body, tree label)
 {
-  gimple p = gimple_alloc (GIMPLE_TRANSACTION, 0);
+  gimple_transaction p =
+    gimple_alloc (GIMPLE_TRANSACTION, 0)->as_a_gimple_transaction ();
   gimple_transaction_set_body (p, body);
   gimple_transaction_set_label (p, label);
   return p;
@@ -1746,8 +1747,10 @@ gimple_copy (gimple stmt)
 	  break;
 
 	case GIMPLE_TRANSACTION:
-	  new_seq = gimple_seq_copy (gimple_transaction_body (stmt));
-	  gimple_transaction_set_body (copy, new_seq);
+	  new_seq = gimple_seq_copy (gimple_transaction_body (
+				       stmt->as_a_gimple_transaction ()));
+	  gimple_transaction_set_body (copy->as_a_gimple_transaction (),
+				       new_seq);
 	  break;
 
 	case GIMPLE_WITH_CLEANUP_EXPR:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 944e473..7cb778d 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -264,6 +264,12 @@ public:
     return as_a <gimple_statement_call> (this);
   }
 
+  inline gimple_transaction
+  as_a_gimple_transaction ()
+  {
+    return as_a <gimple_statement_transaction> (this);
+  }
+
   inline gimple_return
   as_a_gimple_return ()
   {
@@ -344,6 +350,12 @@ public:
     return dyn_cast <gimple_statement_call> (this);
   }
 
+  inline gimple_transaction
+  dyn_cast_gimple_transaction ()
+  {
+    return dyn_cast <gimple_statement_transaction> (this);
+  }
+
   inline gimple_return
   dyn_cast_gimple_return ()
   {
@@ -1521,7 +1533,7 @@ gimple gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
 gimple gimple_build_omp_atomic_load (tree, tree);
 gimple gimple_build_omp_atomic_store (tree);
-gimple gimple_build_transaction (gimple_seq, tree);
+gimple_transaction gimple_build_transaction (gimple_seq, tree);
 gimple 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);
@@ -5674,78 +5686,70 @@ gimple_omp_continue_set_control_use (gimple g, tree use)
   omp_continue_stmt->control_use = use;
 }
 
-/* Return a pointer to the body for the GIMPLE_TRANSACTION statement GS.  */
+/* Return a pointer to the body for the GIMPLE_TRANSACTION statement
+   TRANSACTION_STMT.  */
 
 static inline gimple_seq *
-gimple_transaction_body_ptr (gimple gs)
+gimple_transaction_body_ptr (gimple_transaction transaction_stmt)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction> (gs);
   return &transaction_stmt->body;
 }
 
-/* Return the body for the GIMPLE_TRANSACTION statement GS.  */
+/* Return the body for the GIMPLE_TRANSACTION statement TRANSACTION_STMT.  */
 
 static inline gimple_seq
-gimple_transaction_body (gimple gs)
+gimple_transaction_body (gimple_transaction transaction_stmt)
 {
-  return *gimple_transaction_body_ptr (gs);
+  return *gimple_transaction_body_ptr (transaction_stmt);
 }
 
 /* Return the label associated with a GIMPLE_TRANSACTION.  */
 
 static inline tree
-gimple_transaction_label (const_gimple gs)
+gimple_transaction_label (const_gimple_transaction transaction_stmt)
 {
-  const gimple_statement_transaction *transaction_stmt =
-    as_a <const gimple_statement_transaction> (gs);
   return transaction_stmt->label;
 }
 
 static inline tree *
-gimple_transaction_label_ptr (gimple gs)
+gimple_transaction_label_ptr (gimple_transaction transaction_stmt)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction> (gs);
   return &transaction_stmt->label;
 }
 
 /* Return the subcode associated with a GIMPLE_TRANSACTION.  */
 
 static inline unsigned int
-gimple_transaction_subcode (const_gimple gs)
+gimple_transaction_subcode (const_gimple_transaction transaction_stmt)
 {
-  GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
-  return gs->subcode;
+  return transaction_stmt->subcode;
 }
 
-/* Set BODY to be the body for the GIMPLE_TRANSACTION statement GS.  */
+/* Set BODY to be the body for the GIMPLE_TRANSACTION statement
+   TRANSACTION_STMT.  */
 
 static inline void
-gimple_transaction_set_body (gimple gs, gimple_seq body)
+gimple_transaction_set_body (gimple_transaction transaction_stmt,
+			     gimple_seq body)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction> (gs);
   transaction_stmt->body = body;
 }
 
 /* Set the label associated with a GIMPLE_TRANSACTION.  */
 
 static inline void
-gimple_transaction_set_label (gimple gs, tree label)
+gimple_transaction_set_label (gimple_transaction transaction_stmt, tree label)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction> (gs);
   transaction_stmt->label = label;
 }
 
 /* Set the subcode associated with a GIMPLE_TRANSACTION.  */
 
 static inline void
-gimple_transaction_set_subcode (gimple gs, unsigned int subcode)
+gimple_transaction_set_subcode (gimple_transaction transaction_stmt,
+				unsigned int subcode)
 {
-  GIMPLE_CHECK (gs, GIMPLE_TRANSACTION);
-  gs->subcode = subcode;
+  transaction_stmt->subcode = subcode;
 }
 
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e0444ca..520e71e 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7150,7 +7150,8 @@ static enum gimplify_status
 gimplify_transaction (tree *expr_p, gimple_seq *pre_p)
 {
   tree expr = *expr_p, temp, tbody = TRANSACTION_EXPR_BODY (expr);
-  gimple g;
+  gimple body_stmt;
+  gimple_transaction trans_stmt;
   gimple_seq body = NULL;
   int subcode = 0;
 
@@ -7167,17 +7168,17 @@ gimplify_transaction (tree *expr_p, gimple_seq *pre_p)
   push_gimplify_context ();
   temp = voidify_wrapper_expr (*expr_p, NULL);
 
-  g = gimplify_and_return_first (TRANSACTION_EXPR_BODY (expr), &body);
-  pop_gimplify_context (g);
+  body_stmt = gimplify_and_return_first (TRANSACTION_EXPR_BODY (expr), &body);
+  pop_gimplify_context (body_stmt);
 
-  g = gimple_build_transaction (body, NULL);
+  trans_stmt = gimple_build_transaction (body, NULL);
   if (TRANSACTION_EXPR_OUTER (expr))
     subcode = GTMA_IS_OUTER;
   else if (TRANSACTION_EXPR_RELAXED (expr))
     subcode = GTMA_IS_RELAXED;
-  gimple_transaction_set_subcode (g, subcode);
+  gimple_transaction_set_subcode (trans_stmt, subcode);
 
-  gimplify_seq_add_stmt (pre_p, g);
+  gimplify_seq_add_stmt (pre_p, trans_stmt);
 
   if (temp)
     {
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index af50d89..b1eb22d 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10012,7 +10012,9 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
       lower_omp (gimple_try_cleanup_ptr (stmt), ctx);
       break;
     case GIMPLE_TRANSACTION:
-      lower_omp (gimple_transaction_body_ptr (stmt), ctx);
+      lower_omp (gimple_transaction_body_ptr (
+                   stmt->as_a_gimple_transaction ()),
+		 ctx);
       break;
     case GIMPLE_BIND:
       lower_omp (gimple_bind_body_ptr (stmt->as_a_gimple_bind ()), ctx);
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 1d992f6..7911ad6 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -763,9 +763,10 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 
     case GIMPLE_TRANSACTION:
       {
+	gimple_transaction trans_stmt = stmt->as_a_gimple_transaction ();
 	unsigned char inner_flags = DIAG_TM_SAFE;
 
-	if (gimple_transaction_subcode (stmt) & GTMA_IS_RELAXED)
+	if (gimple_transaction_subcode (trans_stmt) & GTMA_IS_RELAXED)
 	  {
 	    if (d->block_flags & DIAG_TM_SAFE)
 	      error_at (gimple_location (stmt),
@@ -775,7 +776,7 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 			"relaxed transaction in %<transaction_safe%> function");
 	    inner_flags = DIAG_TM_RELAXED;
 	  }
-	else if (gimple_transaction_subcode (stmt) & GTMA_IS_OUTER)
+	else if (gimple_transaction_subcode (trans_stmt) & GTMA_IS_OUTER)
 	  {
 	    if (d->block_flags)
 	      error_at (gimple_location (stmt),
@@ -791,7 +792,7 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 	  }
 
 	*handled_ops_p = true;
-	if (gimple_transaction_body (stmt))
+	if (gimple_transaction_body (trans_stmt))
 	  {
 	    struct walk_stmt_info wi_inner;
 	    struct diagnose_tm d_inner;
@@ -804,7 +805,7 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
 	    memset (&wi_inner, 0, sizeof (wi_inner));
 	    wi_inner.info = &d_inner;
 
-	    walk_gimple_seq (gimple_transaction_body (stmt),
+	    walk_gimple_seq (gimple_transaction_body (trans_stmt),
 			     diagnose_tm_1, diagnose_tm_1_op, &wi_inner);
 	  }
       }
@@ -1606,7 +1607,8 @@ examine_call_tm (unsigned *state, gimple_stmt_iterator *gsi)
 static void
 lower_transaction (gimple_stmt_iterator *gsi, struct walk_stmt_info *wi)
 {
-  gimple g, stmt = gsi_stmt (*gsi);
+  gimple g;
+  gimple_transaction stmt = gsi_stmt (*gsi)->as_a_gimple_transaction ();
   unsigned int *outer_state = (unsigned int *) wi->info;
   unsigned int this_state = 0;
   struct walk_stmt_info this_wi;
@@ -1804,6 +1806,22 @@ make_pass_lower_tm (gcc::context *ctxt)
 
 struct tm_region
 {
+public:
+
+  /* The field "transaction_stmt" is initially a gimple_transaction,
+     but eventually gets lowered to a gimple_call (to BUILT_IN_TM_START).
+
+     Helper method to get it as a gimple_transaction, with code-checking
+     in a checked-build.  */
+
+  gimple_transaction
+  get_transaction_stmt () const
+  {
+    return transaction_stmt->as_a_gimple_transaction ();
+  }
+
+public:
+
   /* Link to the next unnested transaction.  */
   struct tm_region *next;
 
@@ -1815,7 +1833,8 @@ struct tm_region
 
   /* The GIMPLE_TRANSACTION statement beginning this transaction.
      After TM_MARK, this gets replaced by a call to
-     BUILT_IN_TM_START.  */
+     BUILT_IN_TM_START.
+     Hence this will be either a gimple_transaction or a gimple_call.  */
   gimple transaction_stmt;
 
   /* After TM_MARK expands the GIMPLE_TRANSACTION into a call to
@@ -1858,7 +1877,8 @@ static bitmap_obstack tm_obstack;
    GIMPLE_TRANSACTION statement in a tree of tm_region elements.  */
 
 static struct tm_region *
-tm_region_init_0 (struct tm_region *outer, basic_block bb, gimple stmt)
+tm_region_init_0 (struct tm_region *outer, basic_block bb,
+		  gimple_transaction stmt)
 {
   struct tm_region *region;
 
@@ -1973,8 +1993,9 @@ tm_region_init (struct tm_region *region)
       /* Check for the last statement in the block beginning a new region.  */
       g = last_stmt (bb);
       old_region = region;
-      if (g && gimple_code (g) == GIMPLE_TRANSACTION)
-	region = tm_region_init_0 (region, bb, g);
+      if (g)
+	if (gimple_transaction trans_stmt = g->dyn_cast_gimple_transaction ())
+	  region = tm_region_init_0 (region, bb, trans_stmt);
 
       /* Process subsequent blocks.  */
       FOR_EACH_EDGE (e, ei, bb->succs)
@@ -2085,8 +2106,9 @@ transaction_subcode_ior (struct tm_region *region, unsigned flags)
 {
   if (region && region->transaction_stmt)
     {
-      flags |= gimple_transaction_subcode (region->transaction_stmt);
-      gimple_transaction_set_subcode (region->transaction_stmt, flags);
+      gimple_transaction transaction_stmt = region->get_transaction_stmt ();
+      flags |= gimple_transaction_subcode (transaction_stmt);
+      gimple_transaction_set_subcode (transaction_stmt, flags);
     }
 }
 
@@ -2710,7 +2732,7 @@ expand_transaction (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
 
   /* ??? There are plenty of bits here we're not computing.  */
   {
-    int subcode = gimple_transaction_subcode (region->transaction_stmt);
+    int subcode = gimple_transaction_subcode (region->get_transaction_stmt ());
     int flags = 0;
     if (subcode & GTMA_DOES_GO_IRREVOCABLE)
       flags |= PR_DOESGOIRREVOCABLE;
@@ -2921,8 +2943,8 @@ generate_tm_state (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
   // again as we process blocks.
   if (region->exit_blocks)
     {
-      unsigned int subcode
-	= gimple_transaction_subcode (region->transaction_stmt);
+      gimple_transaction transaction_stmt = region->get_transaction_stmt ();
+      unsigned int subcode = gimple_transaction_subcode (transaction_stmt);
 
       if (subcode & GTMA_DOES_GO_IRREVOCABLE)
 	subcode &= (GTMA_DECLARATION_MASK | GTMA_DOES_GO_IRREVOCABLE
@@ -2930,7 +2952,7 @@ generate_tm_state (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
 		    | GTMA_HAS_NO_INSTRUMENTATION);
       else
 	subcode &= GTMA_DECLARATION_MASK;
-      gimple_transaction_set_subcode (region->transaction_stmt, subcode);
+      gimple_transaction_set_subcode (transaction_stmt, subcode);
     }
 
   return NULL;
@@ -2946,11 +2968,13 @@ propagate_tm_flags_out (struct tm_region *region)
 
   if (region->outer && region->outer->transaction_stmt)
     {
-      unsigned s = gimple_transaction_subcode (region->transaction_stmt);
+      unsigned s =
+	gimple_transaction_subcode (region->get_transaction_stmt ());
       s &= (GTMA_HAVE_ABORT | GTMA_HAVE_LOAD | GTMA_HAVE_STORE
             | GTMA_MAY_ENTER_IRREVOCABLE);
-      s |= gimple_transaction_subcode (region->outer->transaction_stmt);
-      gimple_transaction_set_subcode (region->outer->transaction_stmt, s);
+      s |= gimple_transaction_subcode (region->outer->get_transaction_stmt ());
+      gimple_transaction_set_subcode (region->outer->get_transaction_stmt (),
+				      s);
     }
 
   propagate_tm_flags_out (region->next);
@@ -2985,7 +3009,8 @@ execute_tm_mark (void)
 	{
 	  if (r->transaction_stmt)
 	    {
-	      unsigned sub = gimple_transaction_subcode (r->transaction_stmt);
+	      unsigned sub =
+		gimple_transaction_subcode (r->get_transaction_stmt ());
 
 	      /* If we're sure to go irrevocable, there won't be
 		 anything to expand, since the run-time will go
@@ -4693,7 +4718,8 @@ ipa_tm_diagnose_transaction (struct cgraph_node *node,
   struct tm_region *r;
 
   for (r = all_tm_regions; r ; r = r->next)
-    if (gimple_transaction_subcode (r->transaction_stmt) & GTMA_IS_RELAXED)
+    if (gimple_transaction_subcode (r->get_transaction_stmt ())
+	& GTMA_IS_RELAXED)
       {
 	/* Atomic transactions can be nested inside relaxed.  */
 	if (r->inner)
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 6c0f157..a2557e4 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -161,7 +161,7 @@ static inline bool stmt_starts_bb_p (gimple, gimple);
 static int gimple_verify_flow_info (void);
 static void gimple_make_forwarder_block (edge);
 static gimple first_non_label_stmt (basic_block);
-static bool verify_gimple_transaction (gimple);
+static bool verify_gimple_transaction (gimple_transaction);
 
 /* Flowgraph optimization and cleanup.  */
 static void gimple_merge_blocks (basic_block, basic_block);
@@ -813,7 +813,8 @@ make_edges (void)
 
 	    case GIMPLE_TRANSACTION:
 	      {
-		tree abort_label = gimple_transaction_label (last);
+		tree abort_label = gimple_transaction_label (
+				      last->as_a_gimple_transaction ());
 		if (abort_label)
 		  make_edge (bb, label_to_block (abort_label), EDGE_TM_ABORT);
 		fallthru = true;
@@ -1429,12 +1430,13 @@ cleanup_dead_labels (void)
 
 	case GIMPLE_TRANSACTION:
 	  {
-	    tree label = gimple_transaction_label (stmt);
+	    gimple_transaction trans_stmt = stmt->as_a_gimple_transaction ();
+	    tree label = gimple_transaction_label (trans_stmt);
 	    if (label)
 	      {
 		tree new_label = main_block_label (label);
 		if (new_label != label)
-		  gimple_transaction_set_label (stmt, new_label);
+		  gimple_transaction_set_label (trans_stmt, new_label);
 	      }
 	  }
 	  break;
@@ -4442,7 +4444,7 @@ verify_gimple_stmt (gimple stmt)
       return false;
 
     case GIMPLE_TRANSACTION:
-      return verify_gimple_transaction (stmt);
+      return verify_gimple_transaction (stmt->as_a_gimple_transaction ());
 
     /* Tuples that do not have tree operands.  */
     case GIMPLE_NOP:
@@ -4571,7 +4573,7 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
 	  break;
 
 	case GIMPLE_TRANSACTION:
-	  err |= verify_gimple_transaction (stmt);
+	  err |= verify_gimple_transaction (stmt->as_a_gimple_transaction ());
 	  break;
 
 	default:
@@ -4591,7 +4593,7 @@ verify_gimple_in_seq_2 (gimple_seq stmts)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_transaction (gimple stmt)
+verify_gimple_transaction (gimple_transaction stmt)
 {
   tree lab = gimple_transaction_label (stmt);
   if (lab != NULL && TREE_CODE (lab) != LABEL_DECL)
@@ -5509,7 +5511,8 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
       /* The ABORT edge has a stored label associated with it, otherwise
 	 the edges are simply redirectable.  */
       if (e->flags == 0)
-	gimple_transaction_set_label (stmt, gimple_block_label (dest));
+	gimple_transaction_set_label (stmt->as_a_gimple_transaction (),
+				      gimple_block_label (dest));
       break;
 
     default:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 3c935b8..69d5953 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1413,9 +1413,19 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 	  break;
 
 	case GIMPLE_TRANSACTION:
-	  s1 = remap_gimple_seq (gimple_transaction_body (stmt), id);
-	  copy = gimple_build_transaction (s1, gimple_transaction_label (stmt));
-	  gimple_transaction_set_subcode (copy, gimple_transaction_subcode (stmt));
+	  {
+	    gimple_transaction old_trans_stmt =
+	      stmt->as_a_gimple_transaction ();
+	    gimple_transaction new_trans_stmt;
+	    s1 = remap_gimple_seq (gimple_transaction_body (old_trans_stmt),
+				   id);
+	    copy = new_trans_stmt =
+	      gimple_build_transaction (s1,
+					gimple_transaction_label (old_trans_stmt));
+	    gimple_transaction_set_subcode (
+              new_trans_stmt,
+	      gimple_transaction_subcode (old_trans_stmt));
+	  }
 	  break;
 
 	default:
@@ -3964,7 +3974,8 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
 
     case GIMPLE_TRANSACTION:
       return (weights->tm_cost
-	      + estimate_num_insns_seq (gimple_transaction_body (stmt),
+	      + estimate_num_insns_seq (gimple_transaction_body (
+					  stmt->as_a_gimple_transaction ()),
 					weights));
 
     default:
-- 
1.8.5.3

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

* [PATCH 08/89] Introduce gimple_phi and use it in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (63 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 24/89] Introduce gimple_transaction David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-09 18:29   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 71/89] Concretize gimple_cond_make_{false|true} David Malcolm
                   ` (26 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_phi): New typedef.
	(const_gimple_phi): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_phi): New.
	(gimple_statement_base::dyn_cast_gimple_phi): New.

	* gdbhooks.py (build_pretty_printer): Add gimple_phi and its
	variants, using the gimple printer.

	* gimple.h (gimple_vec): Eliminate thie typedef in the hope of using
	vecs of more concrete gimple subclasses as appropriate; also the
	comment is about to become misleading.

	* gimple.h (gimple_phi_capacity): Use const_gimple_phi typedef
	rather than spelling out the full type.
	(gimple_phi_num_args): Likewise.
	(gimple_phi_result): Likewise.
	(gimple_phi_result_ptr): Use gimple_phi typedef.
	(gimple_phi_set_result): Likewise.
	(gimple_phi_arg): Likewise.
	(gimple_phi_set_arg): Likewise.
	* tree-phinodes.c (allocate_phi_node): Likewise.
	(resize_phi_node): Likewise.
	(reserve_phi_args_for_new_edge): Likewise.
	(remove_phi_arg_num): Likewise.

	* gimple-pretty-print.c (dump_gimple_phi): Require a gimple_phi
	rather than just a gimple.
	* tree-into-ssa.c (mark_phi_for_rewrite): Likewise.

	* tree-phinodes.c (make_phi_node): Return a gimple_phi rather than
	just a gimple.
	(create_phi_node): Likewise.
	* tree-phinodes.h (create_phi_node): Likewise.

	* trans-mem.c (struct struct tm_log_entry): Replace use of
	now-removed gimple_vec with a plain vec<gimple>.

	* tree-into-ssa.c (phis_to_rewrite): Strengthen from a
	vec<gimple_vec> to a vec< vec<gimple_phi> >.

	* tree-into-ssa.c (insert_phi_nodes_for): Update local to be a
	gimple_phi.
	* tree-into-ssa.c (rewrite_update_phi_arguments): Strengthen local
	"phis" from a gimple_vec to a vec<gimple_phi>, and local "phi" to
	a gimple_phi.
	* tree-into-ssa.c (delete_update_ssa): Strengthen local
	"phis" from a gimple_vec to a vec<gimple_phi>.

	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
	gimple_phi in regions where a stmt is known to have code
	GIMPLE_PHI.
	* tree-into-ssa.c (mark_use_interesting): Likewise.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gdbhooks.py           |  4 +++-
 gcc/gimple-pretty-print.c |  6 +++---
 gcc/gimple.h              | 30 +++++++++++++++++++-----------
 gcc/trans-mem.c           |  2 +-
 gcc/tree-into-ssa.c       | 16 ++++++++--------
 gcc/tree-phinodes.c       | 26 +++++++++++++-------------
 gcc/tree-phinodes.h       |  2 +-
 8 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index a9df731..e199b0c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -93,6 +93,10 @@ struct gimple_statement_bind;
 typedef struct gimple_statement_bind *gimple_bind;
 typedef const struct gimple_statement_bind *const_gimple_bind;
 
+struct gimple_statement_phi;
+typedef struct gimple_statement_phi *gimple_phi;
+typedef const struct gimple_statement_phi *const_gimple_phi;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index b7d6015..d842388 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -468,7 +468,9 @@ def build_pretty_printer():
                               'gimple_assign', 'const_gimple_assign',
                               'gimple_statement_assign *',
                               'gimple_bind', 'const_gimple_bind',
-                              'gimple_statement_bind *'],
+                              'gimple_statement_bind *',
+                              'gimple_phi', 'const_gimple_phi',
+                              'gimple_statement_phi *'],
 
                              'gimple',
                              GimplePrinter)
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index cda33b3..c0f6ba9 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1792,7 +1792,7 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
    pretty printer.  If COMMENT is true, print this after #.  */
 
 static void
-dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, bool comment,
+dump_gimple_phi (pretty_printer *buffer, gimple_phi phi, int spc, bool comment,
 		 int flags)
 {
   size_t i;
@@ -2135,7 +2135,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_PHI:
-      dump_gimple_phi (buffer, gs, spc, false, flags);
+      dump_gimple_phi (buffer, gs->as_a_gimple_phi (), spc, false, flags);
       break;
 
     case GIMPLE_OMP_PARALLEL:
@@ -2311,7 +2311,7 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
       if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
         {
           INDENT (indent);
-	  dump_gimple_phi (buffer, phi, indent, true, flags);
+	  dump_gimple_phi (buffer, phi->as_a_gimple_phi (), indent, true, flags);
           pp_newline (buffer);
         }
     }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 962e956..a8a8d72 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -24,10 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 
 typedef gimple gimple_seq_node;
 
-/* For each block, the PHI nodes that need to be rewritten are stored into
-   these vectors.  */
-typedef vec<gimple> gimple_vec;
-
 enum gimple_code {
 #define DEFGSCODE(SYM, STRING, STRUCT)	SYM,
 #include "gimple.def"
@@ -250,6 +246,12 @@ public:
     return as_a <gimple_statement_bind> (this);
   }
 
+  inline gimple_phi
+  as_a_gimple_phi ()
+  {
+    return as_a <gimple_statement_phi> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -294,6 +296,12 @@ public:
     return dyn_cast <gimple_statement_bind> (this);
   }
 
+  inline gimple_phi
+  dyn_cast_gimple_phi ()
+  {
+    return dyn_cast <gimple_statement_phi> (this);
+  }
+
 };
 
 
@@ -3945,7 +3953,7 @@ gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
 static inline unsigned
 gimple_phi_capacity (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
+  const_gimple_phi phi_stmt =
     as_a <const gimple_statement_phi> (gs);
   return phi_stmt->capacity;
 }
@@ -3958,7 +3966,7 @@ gimple_phi_capacity (const_gimple gs)
 static inline unsigned
 gimple_phi_num_args (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
+  const_gimple_phi phi_stmt =
     as_a <const gimple_statement_phi> (gs);
   return phi_stmt->nargs;
 }
@@ -3969,7 +3977,7 @@ gimple_phi_num_args (const_gimple gs)
 static inline tree
 gimple_phi_result (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
+  const_gimple_phi phi_stmt =
     as_a <const gimple_statement_phi> (gs);
   return phi_stmt->result;
 }
@@ -3979,7 +3987,7 @@ gimple_phi_result (const_gimple gs)
 static inline tree *
 gimple_phi_result_ptr (gimple gs)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs);
+  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
   return &phi_stmt->result;
 }
 
@@ -3988,7 +3996,7 @@ gimple_phi_result_ptr (gimple gs)
 static inline void
 gimple_phi_set_result (gimple gs, tree result)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs);
+  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
   phi_stmt->result = result;
   if (result && TREE_CODE (result) == SSA_NAME)
     SSA_NAME_DEF_STMT (result) = gs;
@@ -4001,7 +4009,7 @@ gimple_phi_set_result (gimple gs, tree result)
 static inline struct phi_arg_d *
 gimple_phi_arg (gimple gs, unsigned index)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs);
+  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
   gcc_gimple_checking_assert (index <= phi_stmt->capacity);
   return &(phi_stmt->args[index]);
 }
@@ -4012,7 +4020,7 @@ gimple_phi_arg (gimple gs, unsigned index)
 static inline void
 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi> (gs);
+  gimple_phi phi_stmt = as_a <gimple_statement_phi> (gs);
   gcc_gimple_checking_assert (index <= phi_stmt->nargs);
   phi_stmt->args[index] = *phiarg;
 }
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index fe6dc28..f3300c3 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -928,7 +928,7 @@ typedef struct tm_log_entry
   /* Entry block for the transaction this address occurs in.  */
   basic_block entry_block;
   /* Dominating statements the store occurs in.  */
-  gimple_vec stmts;
+  vec<gimple> stmts;
   /* Initially, while we are building the log, we place a nonzero
      value here to mean that this address *will* be saved with a
      save/restore sequence.  Later, when generating the save sequence
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 3ca2bd1..f12a246 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -118,7 +118,7 @@ static bitmap names_to_release;
 /* vec of vec of PHIs to rewrite in a basic block.  Element I corresponds
    the to basic block with index I.  Allocated once per compilation, *not*
    released between different functions.  */
-static vec<gimple_vec> phis_to_rewrite;
+static vec< vec<gimple_phi> > phis_to_rewrite;
 
 /* The bitmap of non-NULL elements of PHIS_TO_REWRITE.  */
 static bitmap blocks_with_phis_to_rewrite;
@@ -949,9 +949,9 @@ find_def_blocks_for (tree var)
 /* Marks phi node PHI in basic block BB for rewrite.  */
 
 static void
-mark_phi_for_rewrite (basic_block bb, gimple phi)
+mark_phi_for_rewrite (basic_block bb, gimple_phi phi)
 {
-  gimple_vec phis;
+  vec<gimple_phi> phis;
   unsigned n, idx = bb->index;
 
   if (rewrite_uses_p (phi))
@@ -990,7 +990,7 @@ insert_phi_nodes_for (tree var, bitmap phi_insertion_points, bool update_p)
 {
   unsigned bb_index;
   edge e;
-  gimple phi;
+  gimple_phi phi;
   basic_block bb;
   bitmap_iterator bi;
   struct def_blocks_d *def_map = find_def_blocks_for (var);
@@ -1990,8 +1990,8 @@ rewrite_update_phi_arguments (basic_block bb)
 
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
-      gimple phi;
-      gimple_vec phis;
+      gimple_phi phi;
+      vec<gimple_phi> phis;
 
       if (!bitmap_bit_p (blocks_with_phis_to_rewrite, e->dest->index))
 	continue;
@@ -2456,7 +2456,7 @@ mark_use_interesting (tree var, gimple stmt, basic_block bb, bool insert_phi_p)
   mark_block_for_update (bb);
 
   if (gimple_code (stmt) == GIMPLE_PHI)
-    mark_phi_for_rewrite (def_bb, stmt);
+    mark_phi_for_rewrite (def_bb, stmt->as_a_gimple_phi ());
   else
     {
       set_rewrite_uses (stmt, true);
@@ -2816,7 +2816,7 @@ delete_update_ssa (void)
   if (blocks_with_phis_to_rewrite)
     EXECUTE_IF_SET_IN_BITMAP (blocks_with_phis_to_rewrite, 0, i, bi)
       {
-	gimple_vec phis = phis_to_rewrite[i];
+	vec<gimple_phi> phis = phis_to_rewrite[i];
 	phis.release ();
 	phis_to_rewrite[i].create (0);
       }
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 9dff6ad..26f5793 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -97,10 +97,10 @@ phinodes_print_statistics (void)
    happens to contain a PHI node with LEN arguments or more, return
    that one.  */
 
-static inline gimple_statement_phi *
+static inline gimple_phi
 allocate_phi_node (size_t len)
 {
-  gimple_statement_phi *phi;
+  gimple_phi phi;
   size_t bucket = NUM_BUCKETS - 2;
   size_t size = sizeof (struct gimple_statement_phi)
 	        + (len - 1) * sizeof (struct phi_arg_d);
@@ -123,7 +123,7 @@ allocate_phi_node (size_t len)
     }
   else
     {
-      phi = static_cast <gimple_statement_phi *> (
+      phi = static_cast <gimple_phi> (
 	ggc_internal_alloc_stat (size MEM_STAT_INFO));
       if (GATHER_STATISTICS)
 	{
@@ -173,10 +173,10 @@ ideal_phi_node_len (int len)
 
 /* Return a PHI node with LEN argument slots for variable VAR.  */
 
-static gimple
+static gimple_phi
 make_phi_node (tree var, int len)
 {
-  gimple_statement_phi *phi;
+  gimple_phi phi;
   int capacity, i;
 
   capacity = ideal_phi_node_len (len);
@@ -241,11 +241,11 @@ release_phi_node (gimple phi)
 /* Resize an existing PHI node.  The only way is up.  Return the
    possibly relocated phi.  */
 
-static gimple_statement_phi *
-resize_phi_node (gimple_statement_phi *phi, size_t len)
+static gimple_phi
+resize_phi_node (gimple_phi phi, size_t len)
 {
   size_t old_size, i;
-  gimple_statement_phi *new_phi;
+  gimple_phi new_phi;
 
   gcc_assert (len > gimple_phi_capacity (phi));
 
@@ -296,12 +296,12 @@ reserve_phi_args_for_new_edge (basic_block bb)
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple_statement_phi *stmt =
+      gimple_phi stmt =
 	as_a <gimple_statement_phi> (gsi_stmt (gsi));
 
       if (len > gimple_phi_capacity (stmt))
 	{
-	  gimple_statement_phi *new_phi = resize_phi_node (stmt, cap);
+	  gimple_phi new_phi = resize_phi_node (stmt, cap);
 
 	  /* The result of the PHI is defined by this PHI node.  */
 	  SSA_NAME_DEF_STMT (gimple_phi_result (new_phi)) = new_phi;
@@ -347,10 +347,10 @@ add_phi_node_to_bb (gimple phi, basic_block bb)
 
 /* Create a new PHI node for variable VAR at basic block BB.  */
 
-gimple
+gimple_phi
 create_phi_node (tree var, basic_block bb)
 {
-  gimple phi = make_phi_node (var, EDGE_COUNT (bb->preds));
+  gimple_phi phi = make_phi_node (var, EDGE_COUNT (bb->preds));
 
   add_phi_node_to_bb (phi, bb);
   return phi;
@@ -397,7 +397,7 @@ add_phi_arg (gimple phi, tree def, edge e, source_location locus)
    is consistent with how we remove an edge from the edge vector.  */
 
 static void
-remove_phi_arg_num (gimple_statement_phi *phi, int i)
+remove_phi_arg_num (gimple_phi phi, int i)
 {
   int num_elem = gimple_phi_num_args (phi);
 
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index 1e5df83..0159d5d 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -24,7 +24,7 @@ extern void phinodes_print_statistics (void);
 extern void release_phi_node (gimple);
 extern void reserve_phi_args_for_new_edge (basic_block);
 extern void add_phi_node_to_bb (gimple phi, basic_block bb);
-extern gimple create_phi_node (tree, basic_block);
+extern gimple_phi create_phi_node (tree, basic_block);
 extern void add_phi_arg (gimple, tree, edge, source_location);
 extern void remove_phi_args (edge);
 extern void remove_phi_node (gimple_stmt_iterator *, bool);
-- 
1.8.5.3

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

* [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (64 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 08/89] Introduce gimple_phi and use it in various places David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-04-22 15:58   ` Trevor Saunders
  2014-05-12 19:56   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 79/89] Concretize gimple_call_nothrow_p David Malcolm
                   ` (25 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_make_false): Require a gimple_cond.
	(gimple_cond_make_true): Likewise.

	* tree-cfg.c (fold_cond_expr_cond): Add a checked cast to
	gimple_cond within region guarded by check for GIMPLE_COND.
	* tree-ssa-ccp.c (ccp_fold_stmt): Likewise.

	* tree-loop-distribution.c (generate_loops_for_partition): Replace
	a check for GIMPLE_COND with a dyn_cast_gimple_cond.
	* tree-ssa-ccp.c (optimize_unreachable): Likewise.
	* tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise.
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
	Likewise.

	* tree-vrp.c (fold_predicate_in): Add a checked cast to
	gimple_cond.  We must be dealing with a GIMPLE_COND since logic
	at top of the function ensures we only act on GIMPLE_ASSIGN and
	GIMPLE_COND statements, and we're now within a "not a GIMPLE_ASSIGN"
	clause.

	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Add
	checked cast of elt->stmt to gimple_cond.  The existing code requires
	this to be a GIMPLE_COND, though it's not clear to me how this
	requirement is enforced.
	(remove_redundant_iv_tests): Likewise.
	(try_unroll_loop_completely): Likewise, for the last_stmt of the
	preceding bb along edge_to_cancel.
	* tree-ssa-reassoc.c (maybe_optimize_range_tests): Likewise, for the
	last_stmt of bb.
---
 gcc/gimple.h                 |  4 ++--
 gcc/tree-cfg.c               | 11 +++++++----
 gcc/tree-loop-distribution.c |  4 ++--
 gcc/tree-ssa-ccp.c           | 13 +++++++------
 gcc/tree-ssa-loop-ivcanon.c  | 17 +++++++++--------
 gcc/tree-ssa-loop-niter.c    | 10 +++++++---
 gcc/tree-ssa-pre.c           | 15 ++++++++-------
 gcc/tree-ssa-reassoc.c       | 15 ++++++++-------
 gcc/tree-vrp.c               |  5 +++--
 9 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 395c432..ed99d02 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3399,7 +3399,7 @@ gimple_cond_false_label (const_gimple gs)
 /* Set the conditional COND_STMT to be of the form 'if (1 == 0)'.  */
 
 static inline void
-gimple_cond_make_false (gimple gs)
+gimple_cond_make_false (gimple_cond gs)
 {
   gimple_cond_set_lhs (gs, boolean_true_node);
   gimple_cond_set_rhs (gs, boolean_false_node);
@@ -3410,7 +3410,7 @@ gimple_cond_make_false (gimple gs)
 /* Set the conditional COND_STMT to be of the form 'if (1 == 1)'.  */
 
 static inline void
-gimple_cond_make_true (gimple gs)
+gimple_cond_make_true (gimple_cond gs)
 {
   gimple_cond_set_lhs (gs, boolean_true_node);
   gimple_cond_set_rhs (gs, boolean_true_node);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 68093de..1000bbb 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -548,13 +548,16 @@ fold_cond_expr_cond (void)
 
       if (stmt && gimple_code (stmt) == GIMPLE_COND)
 	{
+	  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
 	  location_t loc = gimple_location (stmt);
 	  tree cond;
 	  bool zerop, onep;
 
 	  fold_defer_overflow_warnings ();
-	  cond = fold_binary_loc (loc, gimple_cond_code (stmt), boolean_type_node,
-			      gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
+	  cond = fold_binary_loc (loc, gimple_cond_code (cond_stmt),
+				  boolean_type_node,
+				  gimple_cond_lhs (cond_stmt),
+				  gimple_cond_rhs (cond_stmt));
 	  if (cond)
 	    {
 	      zerop = integer_zerop (cond);
@@ -567,9 +570,9 @@ fold_cond_expr_cond (void)
 					  stmt,
 					  WARN_STRICT_OVERFLOW_CONDITIONAL);
 	  if (zerop)
-	    gimple_cond_make_false (stmt);
+	    gimple_cond_make_false (cond_stmt);
 	  else if (onep)
-	    gimple_cond_make_true (stmt);
+	    gimple_cond_make_true (cond_stmt);
 	}
     }
 }
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 8ce25f5..2d25277 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -680,9 +680,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 	    {
 	      /* Choose an arbitrary path through the empty CFG part
 		 that this unnecessary control stmt controls.  */
-	      if (gimple_code (stmt) == GIMPLE_COND)
+	      if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
 		{
-		  gimple_cond_make_false (stmt);
+		  gimple_cond_make_false (cond_stmt);
 		  update_stmt (stmt);
 		}
 	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 3509d31..cc8c78b 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2006,6 +2006,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
     {
     case GIMPLE_COND:
       {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
 	prop_value_t val;
 	/* Statement evaluation will handle type mismatches in constants
 	   more gracefully than the final propagation.  This allows us to
@@ -2025,9 +2026,9 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
 	  }
 
 	if (integer_zerop (val.value))
-	  gimple_cond_make_false (stmt);
+	  gimple_cond_make_false (cond_stmt);
 	else
-	  gimple_cond_make_true (stmt);
+	  gimple_cond_make_true (cond_stmt);
 
 	return true;
       }
@@ -2543,15 +2544,15 @@ optimize_unreachable (gimple_stmt_iterator i)
 	continue;
 
       stmt = gsi_stmt (gsi);
-      if (gimple_code (stmt) == GIMPLE_COND)
+      if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
 	{
 	  if (e->flags & EDGE_TRUE_VALUE)
-	    gimple_cond_make_false (stmt);
+	    gimple_cond_make_false (cond_stmt);
 	  else if (e->flags & EDGE_FALSE_VALUE)
-	    gimple_cond_make_true (stmt);
+	    gimple_cond_make_true (cond_stmt);
 	  else
 	    gcc_unreachable ();
-	  update_stmt (stmt);
+	  update_stmt (cond_stmt);
 	}
       else
 	{
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 6049f81..52f8e85 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -520,11 +520,12 @@ remove_exits_and_undefined_stmts (struct loop *loop, unsigned int npeeled)
 	  if (!loop_exit_edge_p (loop, exit_edge))
 	    exit_edge = EDGE_SUCC (bb, 1);
 	  gcc_checking_assert (loop_exit_edge_p (loop, exit_edge));
+	  gimple_cond cond_stmt = elt->stmt->as_a_gimple_cond ();
 	  if (exit_edge->flags & EDGE_TRUE_VALUE)
-	    gimple_cond_make_true (elt->stmt);
+	    gimple_cond_make_true (cond_stmt);
 	  else
-	    gimple_cond_make_false (elt->stmt);
-	  update_stmt (elt->stmt);
+	    gimple_cond_make_false (cond_stmt);
+	  update_stmt (cond_stmt);
 	  changed = true;
 	}
     }
@@ -573,11 +574,12 @@ remove_redundant_iv_tests (struct loop *loop)
 	      fprintf (dump_file, "Removed pointless exit: ");
 	      print_gimple_stmt (dump_file, elt->stmt, 0, 0);
 	    }
+	  gimple_cond cond_stmt = elt->stmt->as_a_gimple_cond ();
 	  if (exit_edge->flags & EDGE_TRUE_VALUE)
-	    gimple_cond_make_false (elt->stmt);
+	    gimple_cond_make_false (cond_stmt);
 	  else
-	    gimple_cond_make_true (elt->stmt);
-	  update_stmt (elt->stmt);
+	    gimple_cond_make_true (cond_stmt);
+	  update_stmt (cond_stmt);
 	  changed = true;
 	}
     }
@@ -657,7 +659,6 @@ try_unroll_loop_completely (struct loop *loop,
 			    location_t locus)
 {
   unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
-  gimple cond;
   struct loop_size size;
   bool n_unroll_found = false;
   edge edge_to_cancel = NULL;
@@ -854,7 +855,7 @@ try_unroll_loop_completely (struct loop *loop,
   /* Remove the conditional from the last copy of the loop.  */
   if (edge_to_cancel)
     {
-      cond = last_stmt (edge_to_cancel->src);
+      gimple_cond cond = last_stmt (edge_to_cancel->src)->as_a_gimple_cond ();
       if (edge_to_cancel->flags & EDGE_TRUE_VALUE)
 	gimple_cond_make_false (cond);
       else
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 1d0ed34..5709ddd 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1922,7 +1922,8 @@ number_of_iterations_exit (struct loop *loop, edge exit,
 			   struct tree_niter_desc *niter,
 			   bool warn, bool every_iteration)
 {
-  gimple stmt;
+  gimple last;
+  gimple_cond stmt;
   tree type;
   tree op0, op1;
   enum tree_code code;
@@ -1935,8 +1936,11 @@ number_of_iterations_exit (struct loop *loop, edge exit,
     return false;
 
   niter->assumptions = boolean_false_node;
-  stmt = last_stmt (exit->src);
-  if (!stmt || gimple_code (stmt) != GIMPLE_COND)
+  last = last_stmt (exit->src);
+  if (!last)
+    return false;
+  stmt = last->dyn_cast_gimple_cond ();
+  if (!stmt)
     return false;
 
   /* We want the condition for staying inside loop.  */
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index f081349..b8047a4 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -4315,25 +4315,26 @@ eliminate_dom_walker::before_dom_children (basic_block b)
 	}
       /* Visit COND_EXPRs and fold the comparison with the
 	 available value-numbers.  */
-      else if (gimple_code (stmt) == GIMPLE_COND)
+      else if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
 	{
-	  tree op0 = gimple_cond_lhs (stmt);
-	  tree op1 = gimple_cond_rhs (stmt);
+	  tree op0 = gimple_cond_lhs (cond_stmt);
+	  tree op1 = gimple_cond_rhs (cond_stmt);
 	  tree result;
 
 	  if (TREE_CODE (op0) == SSA_NAME)
 	    op0 = VN_INFO (op0)->valnum;
 	  if (TREE_CODE (op1) == SSA_NAME)
 	    op1 = VN_INFO (op1)->valnum;
-	  result = fold_binary (gimple_cond_code (stmt), boolean_type_node,
+	  result = fold_binary (gimple_cond_code (cond_stmt),
+				boolean_type_node,
 				op0, op1);
 	  if (result && TREE_CODE (result) == INTEGER_CST)
 	    {
 	      if (integer_zerop (result))
-		gimple_cond_make_false (stmt);
+		gimple_cond_make_false (cond_stmt);
 	      else
-		gimple_cond_make_true (stmt);
-	      update_stmt (stmt);
+		gimple_cond_make_true (cond_stmt);
+	      update_stmt (cond_stmt);
 	      el_todo = TODO_cleanup_cfg;
 	    }
 	}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 932d82b..47b7e8c 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3009,18 +3009,19 @@ maybe_optimize_range_tests (gimple stmt)
 	      && bbinfo[idx].op == NULL_TREE
 	      && ops[bbinfo[idx].first_idx]->op != NULL_TREE)
 	    {
-	      stmt = last_stmt (bb);
+	      gimple_cond cond_stmt = last_stmt (bb)->as_a_gimple_cond ();
 	      if (integer_zerop (ops[bbinfo[idx].first_idx]->op))
-		gimple_cond_make_false (stmt);
+		gimple_cond_make_false (cond_stmt);
 	      else if (integer_onep (ops[bbinfo[idx].first_idx]->op))
-		gimple_cond_make_true (stmt);
+		gimple_cond_make_true (cond_stmt);
 	      else
 		{
-		  gimple_cond_set_code (stmt, NE_EXPR);
-		  gimple_cond_set_lhs (stmt, ops[bbinfo[idx].first_idx]->op);
-		  gimple_cond_set_rhs (stmt, boolean_false_node);
+		  gimple_cond_set_code (cond_stmt, NE_EXPR);
+		  gimple_cond_set_lhs (cond_stmt,
+				       ops[bbinfo[idx].first_idx]->op);
+		  gimple_cond_set_rhs (cond_stmt, boolean_false_node);
 		}
-	      update_stmt (stmt);
+	      update_stmt (cond_stmt);
 	    }
 	  if (bb == first_bb)
 	    break;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 902b879..62ec9f5 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -9517,10 +9517,11 @@ fold_predicate_in (gimple_stmt_iterator *si)
       else
 	{
 	  gcc_assert (gimple_code (stmt) == GIMPLE_COND);
+	  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
 	  if (integer_zerop (val))
-	    gimple_cond_make_false (stmt);
+	    gimple_cond_make_false (cond_stmt);
 	  else if (integer_onep (val))
-	    gimple_cond_make_true (stmt);
+	    gimple_cond_make_true (cond_stmt);
 	  else
 	    gcc_unreachable ();
 	}
-- 
1.8.5.3

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

* [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (55 preceding siblings ...)
  2014-04-21 17:12 ` [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 17:23   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 18/89] Concretize get_loop_exit_condition et al to working on gimple_cond David Malcolm
                   ` (34 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.c (gimple_call_copy_skip_args): Require a gimple_call.
	* gimple.h (gimple_call_copy_skip_args): Likewise.
---
 gcc/gimple.c | 2 +-
 gcc/gimple.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 6de651d..75a9f5f 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2044,7 +2044,7 @@ canonicalize_cond_expr_cond (tree t)
    the positions marked by the set ARGS_TO_SKIP.  */
 
 gimple_call
-gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip)
+gimple_call_copy_skip_args (gimple_call stmt, bitmap args_to_skip)
 {
   int i;
   int nargs = gimple_call_num_args (stmt);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 49385bd..cf21083 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1696,7 +1696,7 @@ bool gimple_assign_rhs_could_trap_p (gimple);
 extern void dump_gimple_statistics (void);
 unsigned get_gimple_rhs_num_ops (enum tree_code);
 extern tree canonicalize_cond_expr_cond (tree);
-gimple_call gimple_call_copy_skip_args (gimple, bitmap);
+gimple_call gimple_call_copy_skip_args (gimple_call, bitmap);
 extern bool gimple_compare_field_offset (tree, tree);
 extern tree gimple_unsigned_type (tree);
 extern tree gimple_signed_type (tree);
-- 
1.8.5.3

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

* [PATCH 74/89] Concretize gimple_cond_set_code
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (58 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 62/89] Concretize gimple_label_label David Malcolm
@ 2014-04-21 17:13 ` David Malcolm
  2014-05-12 19:22   ` Jeff Law
  2014-04-21 17:13 ` [PATCH 32/89] Introduce gimple_try David Malcolm
                   ` (31 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_set_code): Require a gimple_cond.

	* tree-complex.c (expand_complex_comparison): Add a checked cast to
	gimple_cond within "case GIMPLE_COND".

	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond"
	to a gimple_cond, adding a checked cast.  The existing code requires
	that the last statement before the exit edge have code GIMPLE_COND,
	though it's not clear to me where this is verified.

	* tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast
	to gimple_cond on "use->stmt".

	* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert
	local "exit_if" to gimple_cond, adding a checked cast.  It's not
	clear to me exactly where the GIMPLE_COND-ness of this is
	established, but the existing code requires it.
	(canonicalize_loop_ivs): Similarly for "stmt".

	* tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace
	a check against GIMPLE_COND with a dyn_cast_gimple_cond.
---
 gcc/gimple.h                | 3 +--
 gcc/tree-complex.c          | 9 ++++++---
 gcc/tree-ssa-loop-ivcanon.c | 4 ++--
 gcc/tree-ssa-loop-ivopts.c  | 7 ++++---
 gcc/tree-ssa-loop-manip.c   | 8 ++++----
 gcc/tree-ssa-propagate.c    | 8 ++++----
 6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 9e60c4f..bb8c3c1 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3286,9 +3286,8 @@ gimple_cond_code (const_gimple gs)
 /* Set CODE to be the predicate code for the conditional statement GS.  */
 
 static inline void
-gimple_cond_set_code (gimple gs, enum tree_code code)
+gimple_cond_set_code (gimple_cond gs, enum tree_code code)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   gs->subcode = code;
 }
 
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index fb2db1a..425fcbe 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -1406,9 +1406,12 @@ expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
       break;
 
     case GIMPLE_COND:
-      gimple_cond_set_code (stmt, EQ_EXPR);
-      gimple_cond_set_lhs (stmt, cc);
-      gimple_cond_set_rhs (stmt, boolean_true_node);
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	gimple_cond_set_code (cond_stmt, EQ_EXPR);
+	gimple_cond_set_lhs (cond_stmt, cc);
+	gimple_cond_set_rhs (cond_stmt, boolean_true_node);
+      }
       break;
 
     default:
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index cbef59b..c0087e3 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -88,7 +88,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter)
 {
   edge in;
   tree type, var;
-  gimple cond;
+  gimple_cond cond;
   gimple_stmt_iterator incr_at;
   enum tree_code cmp;
 
@@ -99,7 +99,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter)
       fprintf (dump_file, " iterations.\n");
     }
 
-  cond = last_stmt (exit->src);
+  cond = last_stmt (exit->src)->as_a_gimple_cond ();
   in = EDGE_SUCC (exit->src, 0);
   if (in == exit)
     in = EDGE_SUCC (exit->src, 1);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index eba5b0f..2be1a6d 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -6477,9 +6477,10 @@ rewrite_use_compare (struct ivopts_data *data,
 		loop_preheader_edge (data->current_loop),
 		stmts);
 
-      gimple_cond_set_lhs (use->stmt, var);
-      gimple_cond_set_code (use->stmt, compare);
-      gimple_cond_set_rhs (use->stmt, op);
+      gimple_cond cond_stmt = use->stmt->as_a_gimple_cond ();
+      gimple_cond_set_lhs (cond_stmt, var);
+      gimple_cond_set_code (cond_stmt, compare);
+      gimple_cond_set_rhs (cond_stmt, op);
       return;
     }
 
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index d74250f..fe63700 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -1031,7 +1031,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
 				transform_callback transform,
 				void *data)
 {
-  gimple exit_if;
+  gimple_cond exit_if;
   tree ctr_before, ctr_after;
   tree enter_main_cond, exit_base, exit_step, exit_bound;
   enum tree_code exit_cmp;
@@ -1228,7 +1228,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   /* Finally create the new counter for number of iterations and add the new
      exit instruction.  */
   bsi = gsi_last_nondebug_bb (exit_bb);
-  exit_if = gsi_stmt (bsi);
+  exit_if = gsi_stmt (bsi)->as_a_gimple_cond ();
   create_iv (exit_base, exit_step, NULL_TREE, loop,
 	     &bsi, false, &ctr_before, &ctr_after);
   gimple_cond_set_code (exit_if, exit_cmp);
@@ -1339,7 +1339,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   tree type, var_before;
   gimple_stmt_iterator gsi;
   gimple_phi_iterator psi;
-  gimple stmt;
+  gimple_cond stmt;
   edge exit = single_dom_exit (loop);
   gimple_seq stmts;
   enum machine_mode mode;
@@ -1390,7 +1390,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
 
   rewrite_all_phi_nodes_with_iv (loop, var_before);
 
-  stmt = last_stmt (exit->src);
+  stmt = last_stmt (exit->src)->as_a_gimple_cond ();
   /* Make the loop exit if the control condition is not satisfied.  */
   if (exit->flags & EDGE_TRUE_VALUE)
     {
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index dd8fad4..522eecd 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1431,14 +1431,14 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
       propagate_tree_value (&expr, val);
       gimple_assign_set_rhs_from_tree (gsi, expr);
     }
-  else if (gimple_code (stmt) == GIMPLE_COND)
+  else if (gimple_cond cond_stmt = stmt->dyn_cast_gimple_cond ())
     {
       tree lhs = NULL_TREE;
       tree rhs = build_zero_cst (TREE_TYPE (val));
       propagate_tree_value (&lhs, val);
-      gimple_cond_set_code (stmt, NE_EXPR);
-      gimple_cond_set_lhs (stmt, lhs);
-      gimple_cond_set_rhs (stmt, rhs);
+      gimple_cond_set_code (cond_stmt, NE_EXPR);
+      gimple_cond_set_lhs (cond_stmt, lhs);
+      gimple_cond_set_rhs (cond_stmt, rhs);
     }
   else if (is_gimple_call (stmt)
            && gimple_call_lhs (stmt) != NULL_TREE)
-- 
1.8.5.3

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

* [PATCH 38/89] Introduce gimple_omp_for
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (73 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs} David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-12 17:38   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 81/89] Concretize gimple_call_set_fn David Malcolm
                   ` (16 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_for): New.
	(const_gimple_omp_for): New.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_for): New.
	(gimple_statement_base::dyn_cast_gimple_omp_for): New.
	(gimple_build_omp_for): Return a gimple_omp_for rather than a
	plain gimple.
	(gimple_omp_for_set_kind): Require a gimple_omp_for rather than a
	plain gimple.
	(gimple_omp_for_set_combined_p): Likewise.
	(gimple_omp_for_set_combined_into_p): Likewise.

	* gimple-pretty-print.c (dump_gimple_omp_for): Require a
	gimple_omp_for rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_for in
	GIMPLE_OMP_FOR case of switch statement.

	* gimple.c (gimple_build_omp_for): Return a gimple_omp_for rather
	than a plain gimple.
	(gimple_copy): Add a checked cast to gimple_omp_for and a new local.

	* gimplify.c (gimplify_omp_for): Strengthen local "gfor" from
	gimple to gimple_omp_for.

	* omp-low.c (omp_for_data::for_stmt): Strengthen field from gimple
	to gimple_omp_for.
	(extract_omp_for_data): Require a gimple_omp_for rather than a
	plain gimple.
	(workshare_safe_to_combine_p): Add a checked cast to
	gimple_omp_for.
	(get_ws_args_for): Convert check of code against GIMPLE_OMP_FOR
	with a dyn_cast_gimple_omp_for and a new local.
	(scan_omp_parallel): Add a checked cast to gimple_omp_for and a
	new local.
	(scan_omp_for): Require a gimple_omp_for rather than a plain
	gimple.
	(scan_omp_1_stmt): Add a checked cast to gimple_omp_for in
	GIMPLE_OMP_FOR case of switch statement.
	(expand_omp_for): Add a checked cast to gimple_omp_for.
	(lower_omp_for): Strengthen local "stmt" from gimple to
	gimple_omp_for.

	* tree-nested.c (walk_gimple_omp_for): Require a gimple_omp_for
	rather than a plain gimple.
	(convert_nonlocal_reference_stmt): Add a checked cast to
	gimple_omp_for in GIMPLE_OMP_FOR case of switch statement.
	(convert_local_reference_stmt): Likewise.

	* tree-parloops.c (create_parallel_loop): Strengthen local
	"for_stmt" from gimple to gimple_omp_for.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  4 ++--
 gcc/gimple.c              |  8 +++-----
 gcc/gimple.h              | 22 +++++++++++++++-------
 gcc/gimplify.c            |  2 +-
 gcc/omp-low.c             | 26 +++++++++++++-------------
 gcc/tree-nested.c         |  8 +++++---
 gcc/tree-parloops.c       |  3 ++-
 8 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index f527da6..0a797a3 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -163,6 +163,10 @@ struct gimple_statement_omp_critical;
 typedef struct gimple_statement_omp_critical *gimple_omp_critical;
 typedef const struct gimple_statement_omp_critical *const_gimple_omp_critical;
 
+struct gimple_statement_omp_for;
+typedef struct gimple_statement_omp_for *gimple_omp_for;
+typedef const struct gimple_statement_omp_for *const_gimple_omp_for;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 8248c67..1b70885 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1107,7 +1107,7 @@ dump_gimple_debug (pretty_printer *buffer, gimple_debug gs, int spc, int flags)
 
 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER.  */
 static void
-dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_for (pretty_printer *buffer, gimple_omp_for gs, int spc, int flags)
 {
   size_t i;
 
@@ -2162,7 +2162,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_FOR:
-      dump_gimple_omp_for (buffer, gs, spc, flags);
+      dump_gimple_omp_for (buffer, gs->as_a_gimple_omp_for (), spc, flags);
       break;
 
     case GIMPLE_OMP_CONTINUE:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 3b40884..7f25207 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -836,12 +836,11 @@ gimple_build_omp_critical (gimple_seq body, tree name)
    COLLAPSE is the collapse count.
    PRE_BODY is the sequence of statements that are loop invariant.  */
 
-gimple
+gimple_omp_for
 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
 		      gimple_seq pre_body)
 {
-  gimple_statement_omp_for *p =
-    as_a <gimple_statement_omp_for> (gimple_alloc (GIMPLE_OMP_FOR, 0));
+  gimple_omp_for p = gimple_alloc (GIMPLE_OMP_FOR, 0)->as_a_gimple_omp_for ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_for_set_clauses (p, clauses);
@@ -1689,8 +1688,7 @@ gimple_copy (gimple stmt)
 	  t = unshare_expr (gimple_omp_for_clauses (stmt));
 	  gimple_omp_for_set_clauses (copy, t);
 	  {
-	    gimple_statement_omp_for *omp_for_copy =
-	      as_a <gimple_statement_omp_for> (copy);
+	    gimple_omp_for omp_for_copy = copy->as_a_gimple_omp_for ();
 	    omp_for_copy->iter =
 	      static_cast <struct gimple_omp_for_iter *> (
 		  ggc_internal_vec_alloc_stat (sizeof (struct gimple_omp_for_iter),
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 525fb7b..d5e9af8 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -360,6 +360,12 @@ public:
     return as_a <gimple_statement_omp_critical> (this);
   }
 
+  inline gimple_omp_for
+  as_a_gimple_omp_for ()
+  {
+    return as_a <gimple_statement_omp_for> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -452,6 +458,11 @@ public:
     return dyn_cast <gimple_statement_omp_critical> (this);
   }
 
+  inline gimple_omp_for
+  dyn_cast_gimple_omp_for ()
+  {
+    return dyn_cast <gimple_statement_omp_for> (this);
+  }
 };
 
 
@@ -1595,7 +1606,7 @@ gimple_debug gimple_build_debug_source_bind_stat (tree, tree, gimple MEM_STAT_DE
 #define gimple_build_debug_source_bind(var,val,stmt)			\
   gimple_build_debug_source_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
 gimple_omp_critical gimple_build_omp_critical (gimple_seq, tree);
-gimple gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
+gimple_omp_for gimple_build_omp_for (gimple_seq, int, tree, size_t, gimple_seq);
 gimple gimple_build_omp_parallel (gimple_seq, tree, tree, tree);
 gimple gimple_build_omp_task (gimple_seq, tree, tree, tree, tree, tree, tree);
 gimple gimple_build_omp_section (gimple_seq);
@@ -4613,9 +4624,8 @@ gimple_omp_for_kind (const_gimple g)
 /* Set the OMP for kind.  */
 
 static inline void
-gimple_omp_for_set_kind (gimple g, int kind)
+gimple_omp_for_set_kind (gimple_omp_for g, int kind)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   g->subcode = (g->subcode & ~GF_OMP_FOR_KIND_MASK)
 		      | (kind & GF_OMP_FOR_KIND_MASK);
 }
@@ -4636,9 +4646,8 @@ gimple_omp_for_combined_p (const_gimple g)
    value of COMBINED_P.  */
 
 static inline void
-gimple_omp_for_set_combined_p (gimple g, bool combined_p)
+gimple_omp_for_set_combined_p (gimple_omp_for g, bool combined_p)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   if (combined_p)
     g->subcode |= GF_OMP_FOR_COMBINED;
   else
@@ -4661,9 +4670,8 @@ gimple_omp_for_combined_into_p (const_gimple g)
    value of COMBINED_P.  */
 
 static inline void
-gimple_omp_for_set_combined_into_p (gimple g, bool combined_p)
+gimple_omp_for_set_combined_into_p (gimple_omp_for g, bool combined_p)
 {
-  GIMPLE_CHECK (g, GIMPLE_OMP_FOR);
   if (combined_p)
     g->subcode |= GF_OMP_FOR_COMBINED_INTO;
   else
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 27058a8..763b3c0 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6572,7 +6572,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
   tree for_stmt, orig_for_stmt, decl, var, t;
   enum gimplify_status ret = GS_ALL_DONE;
   enum gimplify_status tret;
-  gimple gfor;
+  gimple_omp_for gfor;
   gimple_seq for_body, for_pre_body;
   int i;
   bool simd;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index c2ab88a..8a3b2a1 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -190,7 +190,7 @@ struct omp_for_data
 {
   struct omp_for_data_loop loop;
   tree chunk_size;
-  gimple for_stmt;
+  gimple_omp_for for_stmt;
   tree pre, iter_type;
   int collapse;
   bool have_nowait, have_ordered;
@@ -289,7 +289,7 @@ is_combined_parallel (struct omp_region *region)
    them into *FD.  */
 
 static void
-extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd,
+extract_omp_for_data (gimple_omp_for for_stmt, struct omp_for_data *fd,
 		      struct omp_for_data_loop *loops)
 {
   tree t, var, *collapse_iter, *collapse_count;
@@ -632,7 +632,7 @@ workshare_safe_to_combine_p (basic_block ws_entry_bb)
 
   gcc_assert (gimple_code (ws_stmt) == GIMPLE_OMP_FOR);
 
-  extract_omp_for_data (ws_stmt, &fd, NULL);
+  extract_omp_for_data (ws_stmt->as_a_gimple_omp_for (), &fd, NULL);
 
   if (fd.collapse > 1 && TREE_CODE (fd.loop.n2) != INTEGER_CST)
     return false;
@@ -665,16 +665,16 @@ get_ws_args_for (gimple par_stmt, gimple ws_stmt)
   location_t loc = gimple_location (ws_stmt);
   vec<tree, va_gc> *ws_args;
 
-  if (gimple_code (ws_stmt) == GIMPLE_OMP_FOR)
+  if (gimple_omp_for for_stmt = ws_stmt->dyn_cast_gimple_omp_for ())
     {
       struct omp_for_data fd;
       tree n1, n2;
 
-      extract_omp_for_data (ws_stmt, &fd, NULL);
+      extract_omp_for_data (for_stmt, &fd, NULL);
       n1 = fd.loop.n1;
       n2 = fd.loop.n2;
 
-      if (gimple_omp_for_combined_into_p (ws_stmt))
+      if (gimple_omp_for_combined_into_p (for_stmt))
 	{
 	  tree innerc
 	    = find_omp_clause (gimple_omp_parallel_clauses (par_stmt),
@@ -1972,16 +1972,15 @@ scan_omp_parallel (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 
   if (gimple_omp_parallel_combined_p (stmt))
     {
-      gimple for_stmt;
       struct walk_stmt_info wi;
 
       memset (&wi, 0, sizeof (wi));
       wi.val_only = true;
       walk_gimple_seq (gimple_omp_body (stmt),
 		       find_combined_for, NULL, &wi);
-      for_stmt = (gimple) wi.info;
-      if (for_stmt)
+      if (wi.info)
 	{
+	  gimple_omp_for for_stmt = ((gimple) wi.info)->as_a_gimple_omp_for ();
 	  struct omp_for_data fd;
 	  extract_omp_for_data (for_stmt, &fd, NULL);
 	  /* We need two temporaries with fd.loop.v type (istart/iend)
@@ -2121,7 +2120,7 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
 /* Scan an OpenMP loop directive.  */
 
 static void
-scan_omp_for (gimple stmt, omp_context *outer_ctx)
+scan_omp_for (gimple_omp_for stmt, omp_context *outer_ctx)
 {
   omp_context *ctx;
   size_t i;
@@ -2644,7 +2643,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_FOR:
-      scan_omp_for (stmt, ctx);
+      scan_omp_for (stmt->as_a_gimple_omp_for (), ctx);
       break;
 
     case GIMPLE_OMP_SECTIONS:
@@ -6871,7 +6870,8 @@ expand_omp_for (struct omp_region *region, gimple inner_stmt)
     = (struct omp_for_data_loop *)
       alloca (gimple_omp_for_collapse (last_stmt (region->entry))
 	      * sizeof (struct omp_for_data_loop));
-  extract_omp_for_data (last_stmt (region->entry), &fd, loops);
+  extract_omp_for_data (last_stmt (region->entry)->as_a_gimple_omp_for (),
+			&fd, loops);
   region->sched_kind = fd.sched_kind;
 
   gcc_assert (EDGE_COUNT (region->entry->succs) == 2);
@@ -8946,7 +8946,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
   tree *rhs_p, block;
   struct omp_for_data fd, *fdp = NULL;
-  gimple stmt = gsi_stmt (*gsi_p);
+  gimple_omp_for stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_for ();
   gimple_bind new_stmt;
   gimple_seq omp_for_body, body, dlist;
   size_t i;
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 4009311..ca3e0ba 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -618,7 +618,7 @@ walk_function (walk_stmt_fn callback_stmt, walk_tree_fn callback_op,
 /* Invoke CALLBACK on a GIMPLE_OMP_FOR's init, cond, incr and pre-body.  */
 
 static void
-walk_gimple_omp_for (gimple for_stmt,
+walk_gimple_omp_for (gimple_omp_for for_stmt,
     		     walk_stmt_fn callback_stmt, walk_tree_fn callback_op,
     		     struct nesting_info *info)
 {
@@ -1280,7 +1280,8 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
     case GIMPLE_OMP_FOR:
       save_suppress = info->suppress_expansion;
       convert_nonlocal_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
-      walk_gimple_omp_for (stmt, convert_nonlocal_reference_stmt,
+      walk_gimple_omp_for (stmt->as_a_gimple_omp_for (),
+			   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));
@@ -1741,7 +1742,8 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
     case GIMPLE_OMP_FOR:
       save_suppress = info->suppress_expansion;
       convert_local_omp_clauses (gimple_omp_for_clauses_ptr (stmt), wi);
-      walk_gimple_omp_for (stmt, convert_local_reference_stmt,
+      walk_gimple_omp_for (stmt->as_a_gimple_omp_for (),
+			   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));
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index dea9606..84fd451 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1619,7 +1619,8 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   gimple_stmt_iterator gsi;
   basic_block bb, paral_bb, for_bb, ex_bb;
   tree t, param;
-  gimple stmt, for_stmt, phi, cond_stmt;
+  gimple stmt, phi, cond_stmt;
+  gimple_omp_for for_stmt;
   tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
   edge exit, nexit, guard, end, e;
 
-- 
1.8.5.3

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

* [PATCH 26/89] Introduce gimple_eh_filter
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (67 preceding siblings ...)
  2014-04-21 17:13 ` [PATCH 36/89] Introduce gimple_omp_continue David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-04-22 12:15   ` Trevor Saunders
  2014-04-21 17:14 ` [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set David Malcolm
                   ` (22 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_eh_filter): New typedef.
	(const_gimple_eh_filter): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_eh_filter): New.
	(gimple_build_eh_filter): Return a gimple_eh_filter rather than a
	plain gimple.

	* gimple-pretty-print.c (dump_gimple_eh_filter): Require a
	gimple_eh_filter rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_eh_filter within
	GIMPLE_EH_FILTER case of switch statement.

	* gimple.c (gimple_build_eh_filter): Return a gimple_eh_filter
	rather than a plain gimple.
---
 gcc/coretypes.h           | 4 ++++
 gcc/gimple-pretty-print.c | 5 +++--
 gcc/gimple.c              | 5 +++--
 gcc/gimple.h              | 8 +++++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 1dd36fb..592b9e5 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -117,6 +117,10 @@ struct gimple_statement_catch;
 typedef struct gimple_statement_catch *gimple_catch;
 typedef const struct gimple_statement_catch *const_gimple_catch;
 
+struct gimple_statement_eh_filter;
+typedef struct gimple_statement_eh_filter *gimple_eh_filter;
+typedef const struct gimple_statement_eh_filter *const_gimple_eh_filter;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index ec16f13..37f28d9 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -994,7 +994,8 @@ dump_gimple_catch (pretty_printer *buffer, gimple_catch gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_eh_filter (pretty_printer *buffer, gimple_eh_filter gs, int spc,
+		       int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
@@ -2204,7 +2205,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_EH_FILTER:
-      dump_gimple_eh_filter (buffer, gs, spc, flags);
+      dump_gimple_eh_filter (buffer, gs->as_a_gimple_eh_filter (), spc, flags);
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 4bc844b..42eef46 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -626,10 +626,11 @@ gimple_build_catch (tree types, gimple_seq handler)
    TYPES are the filter's types.
    FAILURE is the filter's failure action.  */
 
-gimple
+gimple_eh_filter
 gimple_build_eh_filter (tree types, gimple_seq failure)
 {
-  gimple p = gimple_alloc (GIMPLE_EH_FILTER, 0);
+  gimple_eh_filter p =
+    gimple_alloc (GIMPLE_EH_FILTER, 0)->as_a_gimple_eh_filter ();
   gimple_eh_filter_set_types (p, types);
   if (failure)
     gimple_eh_filter_set_failure (p, failure);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index e12e066..38b257c 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -294,6 +294,12 @@ public:
     return as_a <gimple_statement_catch> (this);
   }
 
+  inline gimple_eh_filter
+  as_a_gimple_eh_filter ()
+  {
+    return as_a <gimple_statement_eh_filter> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1512,7 +1518,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *);
 gimple_catch gimple_build_catch (tree, gimple_seq);
-gimple gimple_build_eh_filter (tree, gimple_seq);
+gimple_eh_filter gimple_build_eh_filter (tree, gimple_seq);
 gimple gimple_build_eh_must_not_throw (tree);
 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
 gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
-- 
1.8.5.3

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

* [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (75 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 81/89] Concretize gimple_call_set_fn David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-09 18:31   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places David Malcolm
                   ` (14 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-propagate.h (typedef ssa_prop_visit_phi_fn): Strengthen
	type of parameter from gimple to gimple_phi.

	* tree-complex.c (complex_visit_phi): Update signature of callback
	implementation accordingly.
	* tree-ssa-ccp.c (ccp_visit_phi_node): Likewise.
	* tree-ssa-copy.c (copy_prop_visit_phi_node): Likewise.
	* tree-vrp.c (vrp_visit_phi_node): Likewise.

	* tree-ssa-propagate.c (simulate_stmt): Add a checked cast to
	gimple_phi when invoking the ssa_prop_visit_phi callback.
---
 gcc/tree-complex.c       | 2 +-
 gcc/tree-ssa-ccp.c       | 2 +-
 gcc/tree-ssa-copy.c      | 2 +-
 gcc/tree-ssa-propagate.c | 2 +-
 gcc/tree-ssa-propagate.h | 2 +-
 gcc/tree-vrp.c           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 5b54721..8b335cc 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -401,7 +401,7 @@ complex_visit_stmt (gimple stmt, edge *taken_edge_p ATTRIBUTE_UNUSED,
 /* Evaluate a PHI node against the complex lattice defined above.  */
 
 static enum ssa_prop_result
-complex_visit_phi (gimple phi)
+complex_visit_phi (gimple_phi phi)
 {
   complex_lattice_t new_l, old_l;
   unsigned int ver;
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index eeefeaf..41debfb 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1003,7 +1003,7 @@ ccp_lattice_meet (prop_value_t *val1, prop_value_t *val2)
    of the PHI node that are incoming via executable edges.  */
 
 static enum ssa_prop_result
-ccp_visit_phi_node (gimple phi)
+ccp_visit_phi_node (gimple_phi phi)
 {
   unsigned i;
   prop_value_t *old_val, new_val;
diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c
index 02f4743..0892126 100644
--- a/gcc/tree-ssa-copy.c
+++ b/gcc/tree-ssa-copy.c
@@ -342,7 +342,7 @@ copy_prop_visit_stmt (gimple stmt, edge *taken_edge_p, tree *result_p)
    set it to be the value of the LHS of PHI.  */
 
 static enum ssa_prop_result
-copy_prop_visit_phi_node (gimple phi)
+copy_prop_visit_phi_node (gimple_phi phi)
 {
   enum ssa_prop_result retval;
   unsigned i;
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 840d7e7..6965fb2 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -322,7 +322,7 @@ simulate_stmt (gimple stmt)
 
   if (gimple_code (stmt) == GIMPLE_PHI)
     {
-      val = ssa_prop_visit_phi (stmt);
+      val = ssa_prop_visit_phi (stmt->as_a_gimple_phi ());
       output_name = gimple_phi_result (stmt);
     }
   else
diff --git a/gcc/tree-ssa-propagate.h b/gcc/tree-ssa-propagate.h
index 2d8d876..1e1a3a1 100644
--- a/gcc/tree-ssa-propagate.h
+++ b/gcc/tree-ssa-propagate.h
@@ -63,7 +63,7 @@ enum ssa_prop_result {
 
 /* Call-back functions used by the value propagation engine.  */
 typedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (gimple, edge *, tree *);
-typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gimple);
+typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gimple_phi);
 typedef bool (*ssa_prop_fold_stmt_fn) (gimple_stmt_iterator *gsi);
 typedef tree (*ssa_prop_get_value_fn) (tree);
 
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index b784282..a19bbcd 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -8337,7 +8337,7 @@ vrp_meet (value_range_t *vr0, value_range_t *vr1)
    value ranges, set a new range for the LHS of PHI.  */
 
 static enum ssa_prop_result
-vrp_visit_phi_node (gimple phi)
+vrp_visit_phi_node (gimple_phi phi)
 {
   size_t i;
   tree lhs = PHI_RESULT (phi);
-- 
1.8.5.3

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

* [PATCH 81/89] Concretize gimple_call_set_fn
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (74 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 38/89] Introduce gimple_omp_for David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-12 18:04   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi David Malcolm
                   ` (15 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_set_fn): Require a gimple_call.

	* trans-mem.c (dump_tm_memopt_transform): Likewise.
	(tm_memopt_transform_blocks): Add checked casts to gimple_call in
	suites guarded by is_tm_simple_{load|store}, which enforce that
	the statement must be a GIMPLE_CALL; use this when invoking
	dump_tm_memopt_transform.
---
 gcc/gimple.h    |  3 +--
 gcc/trans-mem.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 33f1889..fb7b5d3 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -2957,9 +2957,8 @@ gimple_call_fn_ptr (const_gimple gs)
 /* Set FN to be the function called by call statement GS.  */
 
 static inline void
-gimple_call_set_fn (gimple gs, tree fn)
+gimple_call_set_fn (gimple_call gs, tree fn)
 {
-  GIMPLE_CHECK (gs, GIMPLE_CALL);
   gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
   gimple_set_op (gs, 1, fn);
 }
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 8ec892c..febc817 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -3800,7 +3800,7 @@ dump_tm_memopt_transform (gimple stmt)
 
 static void
 tm_memopt_transform_stmt (unsigned int offset,
-			  gimple stmt,
+			  gimple_call stmt,
 			  gimple_stmt_iterator *gsi)
 {
   tree fn = gimple_call_fn (stmt);
@@ -3836,28 +3836,30 @@ tm_memopt_transform_blocks (vec<basic_block> blocks)
 
 	  if (is_tm_simple_load (stmt))
 	    {
+	      gimple_call call_stmt = stmt->as_a_gimple_call ();
 	      loc = tm_memopt_value_number (stmt, NO_INSERT);
 	      if (store_avail && bitmap_bit_p (store_avail, loc))
-		tm_memopt_transform_stmt (TRANSFORM_RAW, stmt, &gsi);
+		tm_memopt_transform_stmt (TRANSFORM_RAW, call_stmt, &gsi);
 	      else if (store_antic && bitmap_bit_p (store_antic, loc))
 		{
-		  tm_memopt_transform_stmt (TRANSFORM_RFW, stmt, &gsi);
+		  tm_memopt_transform_stmt (TRANSFORM_RFW, call_stmt, &gsi);
 		  bitmap_set_bit (store_avail, loc);
 		}
 	      else if (read_avail && bitmap_bit_p (read_avail, loc))
-		tm_memopt_transform_stmt (TRANSFORM_RAR, stmt, &gsi);
+		tm_memopt_transform_stmt (TRANSFORM_RAR, call_stmt, &gsi);
 	      else
 		bitmap_set_bit (read_avail, loc);
 	    }
 	  else if (is_tm_simple_store (stmt))
 	    {
+	      gimple_call call_stmt = stmt->as_a_gimple_call ();
 	      loc = tm_memopt_value_number (stmt, NO_INSERT);
 	      if (store_avail && bitmap_bit_p (store_avail, loc))
-		tm_memopt_transform_stmt (TRANSFORM_WAW, stmt, &gsi);
+		tm_memopt_transform_stmt (TRANSFORM_WAW, call_stmt, &gsi);
 	      else
 		{
 		  if (read_avail && bitmap_bit_p (read_avail, loc))
-		    tm_memopt_transform_stmt (TRANSFORM_WAR, stmt, &gsi);
+		    tm_memopt_transform_stmt (TRANSFORM_WAR, call_stmt, &gsi);
 		  bitmap_set_bit (store_avail, loc);
 		}
 	    }
-- 
1.8.5.3

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

* [PATCH 55/89] Use gimple_call for callgraph edges
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (71 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 09/89] Introduce gimple_phi_iterator David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-12 20:03   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs} David Malcolm
                   ` (18 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* cgraph.h (cgraph_edge::call_stmt): Strengthen field from plain
	gimple to a gimple_call.
	(cgraph_create_edge): Require a gimple_call rather than a plain
	gimple.
	(cgraph_create_indirect_edge): Likewise.
	(cgraph_set_call_stmt): Likewise.
	(cgraph_clone_edge): Likewise.
	(cgraph_set_call_stmt_including_clones): Likewise.
	(cgraph_create_edge_including_clones): Likewise.

	* cgraph.c (cgraph_set_call_stmt): Require a gimple_call rather
	than a plain gimple.
	(cgraph_create_edge_1): Likewise.
	(cgraph_create_edge): Likewise.
	(cgraph_create_indirect_edge): Likewise.
	(cgraph_redirect_edge_call_stmt_to_callee): Strengthen decl
	of "new_stmt" from gimple to gimple_call.
	(cgraph_update_edges_for_call_stmt_node): Add checked casts to
	gimple_call.

	* cgraphbuild.c (build_cgraph_edges): Replace is_gimple_call
	with dyn_cast_gimple_call and new local "call_stmt".
	(rebuild_cgraph_edges): Likewise.

	* cgraphclones.c (cgraph_clone_edge): Require a gimple_call
	rather than a plain gimple.
	(cgraph_set_call_stmt_including_clones): Likewise.
	(cgraph_create_edge_including_clones): Likewise.

	* lto-streamer-in.c (fixup_call_stmt_edges_1): Add checked casts
	to gimple_call.

	* omp-low.c (simd_clone_adjust): Strengthen local "call" from
	gimple to gimple_call.

	* trans-mem.c (ipa_tm_insert_irr_call): Likewise for "g".
	(ipa_tm_insert_gettmclone_call): Likewise; also strengthen "g2"
	to gimple_assign.

	* tree-emutls.c (gen_emutls_addr): Strengthen local "x" from
	gimple to gimple_call.

	* tree-inline.c (copy_bb): Replace is_gimple_call with
	dyn_cast_gimple_call and new local "call_stmt".

	* value-prof.c (gimple_ic): Require and return a gimple_call,
	rather than a plain gimple.
	* value-prof.h (gimple_ic): Likewise.

Conflicts:
	gcc/cgraph.c
---
 gcc/cgraph.c          | 18 ++++++++++--------
 gcc/cgraph.h          | 17 ++++++++++-------
 gcc/cgraphbuild.c     | 24 ++++++++++++------------
 gcc/cgraphclones.c    |  6 +++---
 gcc/lto-streamer-in.c |  4 ++--
 gcc/omp-low.c         |  2 +-
 gcc/trans-mem.c       |  5 +++--
 gcc/tree-emutls.c     |  2 +-
 gcc/tree-inline.c     | 15 ++++++++-------
 gcc/value-prof.c      |  8 ++++----
 gcc/value-prof.h      |  3 ++-
 11 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 3652796..a98b716 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -787,7 +787,7 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt)
    edge, then update all components.  */
 
 void
-cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt,
+cgraph_set_call_stmt (struct cgraph_edge *e, gimple_call new_stmt,
 		      bool update_speculative)
 {
   tree decl;
@@ -840,7 +840,7 @@ cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt,
 
 static struct cgraph_edge *
 cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee,
-		       gimple call_stmt, gcov_type count, int freq,
+		       gimple_call call_stmt, gcov_type count, int freq,
 		       bool indir_unknown_callee)
 {
   struct cgraph_edge *edge;
@@ -912,7 +912,7 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee,
 
 struct cgraph_edge *
 cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee,
-		    gimple call_stmt, gcov_type count, int freq)
+		    gimple_call call_stmt, gcov_type count, int freq)
 {
   struct cgraph_edge *edge = cgraph_create_edge_1 (caller, callee, call_stmt,
 						   count, freq, false);
@@ -948,7 +948,7 @@ cgraph_allocate_init_indirect_info (void)
    PARAM_INDEX. */
 
 struct cgraph_edge *
-cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt,
+cgraph_create_indirect_edge (struct cgraph_node *caller, gimple_call call_stmt,
 			     int ecf_flags,
 			     gcov_type count, int freq)
 {
@@ -1341,7 +1341,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
   if (e->speculative)
     {
       struct cgraph_edge *e2;
-      gimple new_stmt;
+      gimple_call new_stmt;
       struct ipa_ref *ref;
 
       cgraph_speculative_call_info (e, e, e2, ref);
@@ -1547,7 +1547,7 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node,
 		  if (callee->decl == new_call
 		      || callee->former_clone_of == new_call)
 		    {
-		      cgraph_set_call_stmt (e, new_stmt);
+		      cgraph_set_call_stmt (e, new_stmt->as_a_gimple_call ());
 		      return;
 		    }
 		  callee = callee->clone_of;
@@ -1576,13 +1576,15 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node,
       if (new_call)
 	{
 	  ne = cgraph_create_edge (node, cgraph_get_create_node (new_call),
-				   new_stmt, count, frequency);
+				   new_stmt->as_a_gimple_call (), count,
+				   frequency);
 	  gcc_assert (ne->inline_failed);
 	}
     }
   /* We only updated the call stmt; update pointer in cgraph edge..  */
   else if (old_stmt != new_stmt)
-    cgraph_set_call_stmt (cgraph_edge (node, old_stmt), new_stmt);
+    cgraph_set_call_stmt (cgraph_edge (node, old_stmt),
+			  new_stmt->as_a_gimple_call ());
 }
 
 /* Update or remove the corresponding cgraph edge if a GIMPLE_CALL
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 59d9ce6..93e1302 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -579,7 +579,7 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgrap
   struct cgraph_edge *next_caller;
   struct cgraph_edge *prev_callee;
   struct cgraph_edge *next_callee;
-  gimple call_stmt;
+  gimple_call call_stmt;
   /* Additional information about an indirect call.  Not cleared when an edge
      becomes direct.  */
   struct cgraph_indirect_call_info *indirect_info;
@@ -764,8 +764,9 @@ void release_function_body (tree);
 void cgraph_node_remove_callees (struct cgraph_node *node);
 struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
 					struct cgraph_node *,
-					gimple, gcov_type, int);
-struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple,
+					gimple_call, gcov_type, int);
+struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *,
+						 gimple_call,
 						 int, gcov_type, int);
 struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void);
 struct cgraph_node * cgraph_create_node (tree);
@@ -776,7 +777,8 @@ struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, H
 				       HOST_WIDE_INT, tree, tree);
 struct cgraph_node *cgraph_node_for_asm (tree);
 struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple);
-void cgraph_set_call_stmt (struct cgraph_edge *, gimple, bool update_speculative = true);
+void cgraph_set_call_stmt (struct cgraph_edge *, gimple_call,
+			   bool update_speculative = true);
 void cgraph_update_edges_for_call_stmt (gimple, tree, gimple);
 struct cgraph_local_info *cgraph_local_info (tree);
 struct cgraph_global_info *cgraph_global_info (tree);
@@ -886,7 +888,7 @@ bool expand_thunk (struct cgraph_node *, bool);
 /* In cgraphclones.c  */
 
 struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *,
-					struct cgraph_node *, gimple,
+					struct cgraph_node *, gimple_call,
 					unsigned, gcov_type, int, bool);
 struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type,
 					int, bool, vec<cgraph_edge_p>,
@@ -899,11 +901,12 @@ struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node,
 						  const char *clone_name);
 struct cgraph_node *cgraph_find_replacement_node (struct cgraph_node *);
 bool cgraph_remove_node_and_inline_clones (struct cgraph_node *, struct cgraph_node *);
-void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple, gimple,
+void cgraph_set_call_stmt_including_clones (struct cgraph_node *, gimple,
+					    gimple_call,
 					    bool update_speculative = true);
 void cgraph_create_edge_including_clones (struct cgraph_node *,
 					  struct cgraph_node *,
-					  gimple, gimple, gcov_type, int,
+					  gimple, gimple_call, gcov_type, int,
 					  cgraph_inline_failed_t);
 void cgraph_materialize_all_clones (void);
 struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *,
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 411214a..49f52e2 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -327,19 +327,19 @@ build_cgraph_edges (void)
 	  if (is_gimple_debug (stmt))
 	    continue;
 
-	  if (is_gimple_call (stmt))
+	  if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	    {
 	      int freq = compute_call_stmt_bb_frequency (current_function_decl,
 							 bb);
-	      decl = gimple_call_fndecl (stmt);
+	      decl = gimple_call_fndecl (call_stmt);
 	      if (decl)
 		cgraph_create_edge (node, cgraph_get_create_node (decl),
-				    stmt, bb->count, freq);
-	      else if (gimple_call_internal_p (stmt))
+				    call_stmt, bb->count, freq);
+	      else if (gimple_call_internal_p (call_stmt))
 		;
 	      else
-		cgraph_create_indirect_edge (node, stmt,
-					     gimple_call_flags (stmt),
+		cgraph_create_indirect_edge (node, call_stmt,
+					     gimple_call_flags (call_stmt),
 					     bb->count, freq);
 	    }
 	  ipa_record_stmt_references (node, stmt);
@@ -459,19 +459,19 @@ rebuild_cgraph_edges (void)
 	  gimple stmt = gsi_stmt (gsi);
 	  tree decl;
 
-	  if (is_gimple_call (stmt))
+	  if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	    {
 	      int freq = compute_call_stmt_bb_frequency (current_function_decl,
 							 bb);
-	      decl = gimple_call_fndecl (stmt);
+	      decl = gimple_call_fndecl (call_stmt);
 	      if (decl)
-		cgraph_create_edge (node, cgraph_get_create_node (decl), stmt,
+		cgraph_create_edge (node, cgraph_get_create_node (decl), call_stmt,
 				    bb->count, freq);
-	      else if (gimple_call_internal_p (stmt))
+	      else if (gimple_call_internal_p (call_stmt))
 		;
 	      else
-		cgraph_create_indirect_edge (node, stmt,
-					     gimple_call_flags (stmt),
+		cgraph_create_indirect_edge (node, call_stmt,
+					     gimple_call_flags (call_stmt),
 					     bb->count, freq);
 	    }
 	  ipa_record_stmt_references (node, stmt);
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index b2eb8ab..ab761e9 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -105,7 +105,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Create clone of E in the node N represented by CALL_EXPR the callgraph.  */
 struct cgraph_edge *
 cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
-		   gimple call_stmt, unsigned stmt_uid, gcov_type count_scale,
+		   gimple_call call_stmt, unsigned stmt_uid, gcov_type count_scale,
 		   int freq_scale, bool update_original)
 {
   struct cgraph_edge *new_edge;
@@ -611,7 +611,7 @@ cgraph_find_replacement_node (struct cgraph_node *node)
 
 void
 cgraph_set_call_stmt_including_clones (struct cgraph_node *orig,
-				       gimple old_stmt, gimple new_stmt,
+				       gimple old_stmt, gimple_call new_stmt,
 				       bool update_speculative)
 {
   struct cgraph_node *node;
@@ -668,7 +668,7 @@ void
 cgraph_create_edge_including_clones (struct cgraph_node *orig,
 				     struct cgraph_node *callee,
 				     gimple old_stmt,
-				     gimple stmt, gcov_type count,
+				     gimple_call stmt, gcov_type count,
 				     int freq,
 				     cgraph_inline_failed_t reason)
 {
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index 3238ab8..455a8cb 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -782,7 +782,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts,
     {
       if (gimple_stmt_max_uid (fn) < cedge->lto_stmt_uid)
         fatal_error ("Cgraph edge statement index out of range");
-      cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1];
+      cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]->as_a_gimple_call ();
       if (!cedge->call_stmt)
         fatal_error ("Cgraph edge statement index not found");
     }
@@ -790,7 +790,7 @@ fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts,
     {
       if (gimple_stmt_max_uid (fn) < cedge->lto_stmt_uid)
         fatal_error ("Cgraph edge statement index out of range");
-      cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1];
+      cedge->call_stmt = stmts[cedge->lto_stmt_uid - 1]->as_a_gimple_call ();
       if (!cedge->call_stmt)
         fatal_error ("Cgraph edge statement index not found");
     }
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 396ddb0..c978c56 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11622,7 +11622,7 @@ simd_clone_adjust (struct cgraph_node *node)
 	    tree fn = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED);
 	    gimple_seq seq = NULL;
 	    bool need_cvt = false;
-	    gimple call
+	    gimple_call call
 	      = gimple_build_call (fn, 2, def, size_int (alignment));
 	    g = call;
 	    if (!useless_type_conversion_p (TREE_TYPE (orig_arg),
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 62d9b78..f3b9a8d 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -4990,7 +4990,7 @@ ipa_tm_insert_irr_call (struct cgraph_node *node, struct tm_region *region,
 			basic_block bb)
 {
   gimple_stmt_iterator gsi;
-  gimple g;
+  gimple_call g;
 
   transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE);
 
@@ -5017,7 +5017,8 @@ ipa_tm_insert_gettmclone_call (struct cgraph_node *node,
 			       gimple_stmt_iterator *gsi, gimple stmt)
 {
   tree gettm_fn, ret, old_fn, callfn;
-  gimple g, g2;
+  gimple_call g;
+  gimple_assign g2;
   bool safe;
 
   old_fn = gimple_call_fn (stmt);
diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
index 3391cc3..993eaf7 100644
--- a/gcc/tree-emutls.c
+++ b/gcc/tree-emutls.c
@@ -437,7 +437,7 @@ gen_emutls_addr (tree decl, struct lower_emutls_data *d)
     {
       varpool_node *cvar;
       tree cdecl;
-      gimple x;
+      gimple_call x;
 
       cvar = control_vars[index];
       cdecl = cvar->decl;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index cdc2ff2..37d6a8b 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1764,7 +1764,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 
 	  /* We're duplicating a CALL_EXPR.  Find any corresponding
 	     callgraph edges and update or duplicate them.  */
-	  if (is_gimple_call (stmt))
+	  if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
 	    {
 	      struct cgraph_edge *edge;
 
@@ -1777,7 +1777,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 		      int edge_freq = edge->frequency;
 		      int new_freq;
 		      struct cgraph_edge *old_edge = edge;
-		      edge = cgraph_clone_edge (edge, id->dst_node, stmt,
+		      edge = cgraph_clone_edge (edge, id->dst_node, call_stmt,
 					        gimple_uid (stmt),
 					        REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
 					        true);
@@ -1796,7 +1796,8 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 
 			  gcc_assert (!edge->indirect_unknown_callee);
 			  cgraph_speculative_call_info (old_edge, direct, indirect, ref);
-			  indirect = cgraph_clone_edge (indirect, id->dst_node, stmt,
+			  indirect = cgraph_clone_edge (indirect, id->dst_node,
+							call_stmt,
 							gimple_uid (stmt),
 							REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
 							true);
@@ -1835,14 +1836,14 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 
 		case CB_CGE_MOVE_CLONES:
 		  cgraph_set_call_stmt_including_clones (id->dst_node,
-							 orig_stmt, stmt);
+							 orig_stmt, call_stmt);
 		  edge = cgraph_edge (id->dst_node, stmt);
 		  break;
 
 		case CB_CGE_MOVE:
 		  edge = cgraph_edge (id->dst_node, orig_stmt);
 		  if (edge)
-		    cgraph_set_call_stmt (edge, stmt);
+		    cgraph_set_call_stmt (edge, call_stmt);
 		  break;
 
 		default:
@@ -1871,12 +1872,12 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
 			      || !id->dst_node->definition);
 		  if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)
 		    cgraph_create_edge_including_clones
-		      (id->dst_node, dest, orig_stmt, stmt, bb->count,
+		      (id->dst_node, dest, orig_stmt, call_stmt, bb->count,
 		       compute_call_stmt_bb_frequency (id->dst_node->decl,
 		       				       copy_basic_block),
 		       CIF_ORIGINALLY_INDIRECT_CALL);
 		  else
-		    cgraph_create_edge (id->dst_node, dest, stmt,
+		    cgraph_create_edge (id->dst_node, dest, call_stmt,
 					bb->count,
 					compute_call_stmt_bb_frequency
 					  (id->dst_node->decl,
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 055d221..d5a30b8 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1320,11 +1320,11 @@ check_ic_target (gimple_call call_stmt, struct cgraph_node *target)
     old call
  */
 
-gimple
-gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
+gimple_call
+gimple_ic (gimple_call icall_stmt, struct cgraph_node *direct_call,
 	   int prob, gcov_type count, gcov_type all)
 {
-  gimple dcall_stmt;
+  gimple_call dcall_stmt;
   gimple_assign load_stmt;
   gimple_cond cond_stmt;
   tree tmp0, tmp1, tmp;
@@ -1357,7 +1357,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
   gimple_set_vdef (icall_stmt, NULL_TREE);
   gimple_set_vuse (icall_stmt, NULL_TREE);
   update_stmt (icall_stmt);
-  dcall_stmt = gimple_copy (icall_stmt);
+  dcall_stmt = gimple_copy (icall_stmt)->as_a_gimple_call ();
   gimple_call_set_fndecl (dcall_stmt, direct_call->decl);
   dflags = flags_from_decl_or_type (direct_call->decl);
   if ((dflags & ECF_NORETURN) != 0)
diff --git a/gcc/value-prof.h b/gcc/value-prof.h
index 9d2c351..9324add 100644
--- a/gcc/value-prof.h
+++ b/gcc/value-prof.h
@@ -88,7 +88,8 @@ void gimple_move_stmt_histograms (struct function *, gimple, gimple);
 void verify_histograms (void);
 void free_histograms (void);
 void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *);
-gimple gimple_ic (gimple, struct cgraph_node *, int, gcov_type, gcov_type);
+gimple_call gimple_ic (gimple_call, struct cgraph_node *, int, gcov_type,
+		       gcov_type);
 
 
 /* In tree-profile.c.  */
-- 
1.8.5.3

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

* [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (68 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 26/89] Introduce gimple_eh_filter David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-12 17:25   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 27/89] Introduce gimple_eh_must_not_throw David Malcolm
                   ` (21 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_use_set): Require a gimple_call.
	(gimple_call_clobber_set): Likewise.
---
 gcc/gimple.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3c54119..e4aeec6 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3236,23 +3236,21 @@ gimple_call_copy_flags (gimple dest_call, gimple orig_call)
 
 
 /* Return a pointer to the points-to solution for the set of call-used
-   variables of the call CALL.  */
+   variables of the call CALL_STMT.  */
 
 static inline struct pt_solution *
-gimple_call_use_set (gimple call)
+gimple_call_use_set (gimple_call call_stmt)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call> (call);
   return &call_stmt->call_used;
 }
 
 
 /* Return a pointer to the points-to solution for the set of call-used
-   variables of the call CALL.  */
+   variables of the call CALL_STMT.  */
 
 static inline struct pt_solution *
-gimple_call_clobber_set (gimple call)
+gimple_call_clobber_set (gimple_call call_stmt)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call> (call);
   return &call_stmt->call_clobbered;
 }
 
-- 
1.8.5.3

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

* [PATCH 27/89] Introduce gimple_eh_must_not_throw
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (69 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-04-21 17:14 ` [PATCH 09/89] Introduce gimple_phi_iterator David Malcolm
                   ` (20 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_eh_must_not_throw): New typedef.
	(const_gimple_eh_must_not_throw): New typedef.

	* gimple-pretty-print.c (dump_gimple_eh_must_not_throw): Require
	a gimple_eh_must_not_throw rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_eh_must_not_throw
	within GIMPLE_EH_MUST_NOT_THROW case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Likewise.

	* gimple-streamer-out.c (output_gimple_stmt): Likewise.

	* gimple.c (gimple_build_eh_must_not_throw): Return a
	gimple_eh_must_not_throw rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_eh_must_not_throw):
	New.
	(gimple_build_eh_must_not_throw): Return a gimple_eh_must_not_throw
	rather than a plain gimple.
	(gimple_eh_must_not_throw_fndecl): Require a
	gimple_eh_must_not_throw rather than a plain gimple.
	(gimple_eh_must_not_throw_set_fndecl): Likewise.

	* tree-eh.c (lower_eh_must_not_throw): Add checked cast.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  8 +++++---
 gcc/gimple-streamer-in.c  |  4 +++-
 gcc/gimple-streamer-out.c |  5 ++++-
 gcc/gimple.c              |  6 ++++--
 gcc/gimple.h              | 15 ++++++++++-----
 gcc/tree-eh.c             |  3 ++-
 7 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 592b9e5..512967c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -121,6 +121,10 @@ struct gimple_statement_eh_filter;
 typedef struct gimple_statement_eh_filter *gimple_eh_filter;
 typedef const struct gimple_statement_eh_filter *const_gimple_eh_filter;
 
+struct gimple_statement_eh_mnt;
+typedef struct gimple_statement_eh_mnt *gimple_eh_must_not_throw;
+typedef const struct gimple_statement_eh_mnt *const_gimple_eh_must_not_throw;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 37f28d9..027bb94 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1011,8 +1011,8 @@ dump_gimple_eh_filter (pretty_printer *buffer, gimple_eh_filter gs, int spc,
 /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple.  */
 
 static void
-dump_gimple_eh_must_not_throw (pretty_printer *buffer, gimple gs,
-			       int spc, int flags)
+dump_gimple_eh_must_not_throw (pretty_printer *buffer,
+			       gimple_eh_must_not_throw gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
@@ -2209,7 +2209,9 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      dump_gimple_eh_must_not_throw (buffer, gs, spc, flags);
+      dump_gimple_eh_must_not_throw (buffer,
+				     gs->as_a_gimple_eh_must_not_throw (),
+				     spc, flags);
       break;
 
     case GIMPLE_EH_ELSE:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 0e94369..949e9af 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -127,7 +127,9 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      gimple_eh_must_not_throw_set_fndecl (stmt, stream_read_tree (ib, data_in));
+      gimple_eh_must_not_throw_set_fndecl (
+	stmt->as_a_gimple_eh_must_not_throw (),
+	stream_read_tree (ib, data_in));
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index b3c3b25..52130ac 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -101,7 +101,10 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      stream_write_tree (ob, gimple_eh_must_not_throw_fndecl (stmt), true);
+      stream_write_tree (ob,
+			 gimple_eh_must_not_throw_fndecl (
+			   stmt->as_a_gimple_eh_must_not_throw ()),
+			 true);
       break;
 
     case GIMPLE_EH_DISPATCH:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 42eef46..b487e46 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -640,10 +640,12 @@ gimple_build_eh_filter (tree types, gimple_seq failure)
 
 /* Build a GIMPLE_EH_MUST_NOT_THROW statement.  */
 
-gimple
+gimple_eh_must_not_throw
 gimple_build_eh_must_not_throw (tree decl)
 {
-  gimple p = gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0);
+  gimple_eh_must_not_throw p =
+    gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0)
+      ->as_a_gimple_eh_must_not_throw ();
 
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
   gcc_assert (flags_from_decl_or_type (decl) & ECF_NORETURN);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 38b257c..47377e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -300,6 +300,12 @@ public:
     return as_a <gimple_statement_eh_filter> (this);
   }
 
+  inline gimple_eh_must_not_throw
+  as_a_gimple_eh_must_not_throw ()
+  {
+    return as_a <gimple_statement_eh_mnt> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1519,7 +1525,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
 				 vec<tree, va_gc> *);
 gimple_catch gimple_build_catch (tree, gimple_seq);
 gimple_eh_filter gimple_build_eh_filter (tree, gimple_seq);
-gimple gimple_build_eh_must_not_throw (tree);
+gimple_eh_must_not_throw gimple_build_eh_must_not_throw (tree);
 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
 gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
@@ -3811,18 +3817,17 @@ gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
 /* Get the function decl to be called by the MUST_NOT_THROW region.  */
 
 static inline tree
-gimple_eh_must_not_throw_fndecl (gimple gs)
+gimple_eh_must_not_throw_fndecl (gimple_eh_must_not_throw eh_mnt_stmt)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_mnt> (gs);
   return eh_mnt_stmt->fndecl;
 }
 
 /* Set the function decl to be called by GS to DECL.  */
 
 static inline void
-gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
+gimple_eh_must_not_throw_set_fndecl (gimple_eh_must_not_throw eh_mnt_stmt,
+				     tree decl)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_mnt> (gs);
   eh_mnt_stmt->fndecl = decl;
 }
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 940b565..5a8f9e1 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1888,7 +1888,8 @@ lower_eh_must_not_throw (struct leh_state *state, gimple tp)
 
       this_region = gen_eh_region_must_not_throw (state->cur_region);
       this_region->u.must_not_throw.failure_decl
-	= gimple_eh_must_not_throw_fndecl (inner);
+	= gimple_eh_must_not_throw_fndecl (
+	    inner->as_a_gimple_eh_must_not_throw ());
       this_region->u.must_not_throw.failure_loc
 	= LOCATION_LOCUS (gimple_location (tp));
 
-- 
1.8.5.3

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

* [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs}
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (72 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 55/89] Use gimple_call for callgraph edges David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-12 19:24   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 38/89] Introduce gimple_omp_for David Malcolm
                   ` (17 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_cond_set_lhs): Require a gimple_cond.
	(gimple_cond_set_rhs): Likewise.

	* tree-parloops.c (transform_to_exit_first_loop): Convert locals
	"cond_stmt" and "cond_nit" to gimple_cond, adding checked casts,
	since the existing code assumes that code is GIMPLE_COND.  Convert
	"stmt" to a gimple_assign.
	(create_parallel_loop): Likewise for "cond_stmt".

	* tree-ssa-loop-im.c (rewrite_bittest): Replace check for code
	GIMPLE_COND with a dyn_cast, adding new local "cond_stmt".
---
 gcc/gimple.h           |  6 ++----
 gcc/tree-parloops.c    | 12 +++++++-----
 gcc/tree-ssa-loop-im.c | 19 ++++++++++++-------
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index bb8c3c1..a8da0c4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3315,9 +3315,8 @@ gimple_cond_lhs_ptr (const_gimple gs)
    conditional statement GS.  */
 
 static inline void
-gimple_cond_set_lhs (gimple gs, tree lhs)
+gimple_cond_set_lhs (gimple_cond gs, tree lhs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   gimple_set_op (gs, 0, lhs);
 }
 
@@ -3346,9 +3345,8 @@ gimple_cond_rhs_ptr (const_gimple gs)
    conditional statement GS.  */
 
 static inline void
-gimple_cond_set_rhs (gimple gs, tree rhs)
+gimple_cond_set_rhs (gimple_cond gs, tree rhs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   gimple_set_op (gs, 1, rhs);
 }
 
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 94af311..521e050 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1513,14 +1513,15 @@ transform_to_exit_first_loop (struct loop *loop,
   edge exit = single_dom_exit (loop), hpred;
   tree control, control_name, res, t;
   gimple_phi phi, nphi;
-  gimple cond_stmt, stmt, cond_nit;
+  gimple_assign stmt;
+  gimple_cond cond_stmt, cond_nit;
   tree nit_1;
 
   split_block_after_labels (loop->header);
   orig_header = single_succ (loop->header);
   hpred = single_succ_edge (loop->header);
 
-  cond_stmt = last_stmt (exit->src);
+  cond_stmt = last_stmt (exit->src)->as_a_gimple_cond ();
   control = gimple_cond_lhs (cond_stmt);
   gcc_assert (gimple_cond_rhs (cond_stmt) == nit);
 
@@ -1600,7 +1601,7 @@ transform_to_exit_first_loop (struct loop *loop,
   /* Initialize the control variable to number of iterations
      according to the rhs of the exit condition.  */
   gimple_stmt_iterator gsi = gsi_after_labels (ex_bb);
-  cond_nit = last_stmt (exit->src);
+  cond_nit = last_stmt (exit->src)->as_a_gimple_cond ();
   nit_1 =  gimple_cond_rhs (cond_nit);
   nit_1 = force_gimple_operand_gsi (&gsi,
 				  fold_convert (TREE_TYPE (control_name), nit_1),
@@ -1624,7 +1625,8 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   tree t, param;
   gimple_omp_parallel omp_par_stmt;
   gimple omp_return_stmt1, omp_return_stmt2;
-  gimple phi, cond_stmt;
+  gimple phi;
+  gimple_cond cond_stmt;
   gimple_omp_for for_stmt;
   gimple_omp_continue omp_cont_stmt;
   tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
@@ -1668,7 +1670,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
 
   /* Extract data for GIMPLE_OMP_FOR.  */
   gcc_assert (loop->header == single_dom_exit (loop)->src);
-  cond_stmt = last_stmt (loop->header);
+  cond_stmt = last_stmt (loop->header)->as_a_gimple_cond ();
 
   cvar = gimple_cond_lhs (cond_stmt);
   cvar_base = SSA_NAME_VAR (cvar);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index f1a1b3d..3a0b518 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -901,6 +901,7 @@ rewrite_bittest (gimple_stmt_iterator *bsi)
   gimple stmt1;
   gimple_assign stmt2;
   gimple use_stmt;
+  gimple_cond cond_stmt;
   tree lhs, name, t, a, b;
   use_operand_p use;
 
@@ -909,13 +910,15 @@ rewrite_bittest (gimple_stmt_iterator *bsi)
 
   /* Verify that the single use of lhs is a comparison against zero.  */
   if (TREE_CODE (lhs) != SSA_NAME
-      || !single_imm_use (lhs, &use, &use_stmt)
-      || gimple_code (use_stmt) != GIMPLE_COND)
+      || !single_imm_use (lhs, &use, &use_stmt))
     return stmt;
-  if (gimple_cond_lhs (use_stmt) != lhs
-      || (gimple_cond_code (use_stmt) != NE_EXPR
-	  && gimple_cond_code (use_stmt) != EQ_EXPR)
-      || !integer_zerop (gimple_cond_rhs (use_stmt)))
+  cond_stmt = use_stmt->dyn_cast_gimple_cond ();
+  if (!cond_stmt)
+    return stmt;
+  if (gimple_cond_lhs (cond_stmt) != lhs
+      || (gimple_cond_code (cond_stmt) != NE_EXPR
+	  && gimple_cond_code (cond_stmt) != EQ_EXPR)
+      || !integer_zerop (gimple_cond_rhs (cond_stmt)))
     return stmt;
 
   /* Get at the operands of the shift.  The rhs is TMP1 & 1.  */
@@ -963,7 +966,9 @@ rewrite_bittest (gimple_stmt_iterator *bsi)
       /* Replace the SSA_NAME we compare against zero.  Adjust
 	 the type of zero accordingly.  */
       SET_USE (use, name);
-      gimple_cond_set_rhs (use_stmt, build_int_cst_type (TREE_TYPE (name), 0));
+      gimple_cond_set_rhs (cond_stmt,
+			   build_int_cst_type (TREE_TYPE (name),
+					       0));
 
       /* Don't use gsi_replace here, none of the new assignments sets
 	 the variable originally set in stmt.  Move bsi to stmt1, and
-- 
1.8.5.3

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

* [PATCH 33/89] Use more concrete types for various gimple statements
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (77 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-04-21 20:20   ` Bill Schmidt
  2014-05-12 17:11   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 12/89] tree-predcom.c: use gimple_phi in various places David Malcolm
                   ` (12 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* cgraphunit.c (thunk_adjust): Strengthen local "stmt" from gimple
	to gimple_assign.

	* gimple-ssa-isolate-paths.c
	(insert_trap_and_remove_trailing_statements): Strengthen local
	"new_stmt" from gimple to gimple_call.

	* gimple-ssa-strength-reduction.c (replace_mult_candidate):
	Strengthen local "copy_stmt" from gimple to gimple_assign.
	(create_add_on_incoming_edge): Likewise, for "new_stmt".
	(insert_initializers): Likewise, for "init_stmt".
	(introduce_cast_before_cand): Likewise, for "cast_stmt".
	(replace_one_candidate): Likewise, for "copy_stmt" and
	"cast_stmt".

	* gimplify.c (build_stack_save_restore): Require gimple_calls
	rather than plain gimples.
	(gimplify_bind_expr): Strengthen locals "stack_save" and
	"stack_restore" from gimple to gimple_call.  Strengthen "gs"
	to gimple_try.
	(gimplify_switch_expr): Strengthen local "gimple_switch" from
	gimple to gimple_switch, and "new_default" to gimple_label.
	(gimplify_cond_expr): Strengthen local "gimple_cond" from gimple
	to gimple_cond.
	(gimplify_init_constructor): Strengthen local "init" from gimple
	to gimple_assign.
	(gimplify_cleanup_point_expr): Strengthen local "gtry" from gimple
	to gimple_try.
	(gimple_push_cleanup): Strengthen locals "ffalse" and "ftrue" from
	gimple to gimple_assign.

	* tree-eh.c (do_goto_redirection): Strengthen local to gimple_goto.
	(emit_post_landing_pad): Strengthen local to gimple_label.

	* tree-outof-ssa.c (insert_backedge_copies): Strengthen local
	"stmt" from gimple to gimple_assign.

	* tree-parloops.c (take_address_of): Likewise.

	* tree-predcom.c (replace_ref_with): Likewise, for "new_stmt".
	(initialize_root_vars_lm): Likewise, for "init_stmt".
	(reassociate_to_the_same_stmt): Likewise, for "new_stmt" and "tmp_stmt".

	* tree-profile.c (gimple_gen_edge_profiler): Likewise, for "stmt1",
	"stmt2", "stmt3".
	(gimple_gen_ic_profiler): Likewise.
	(gimple_gen_ic_func_profiler): Strengthen local "stmt1" from
	gimple to gimple_call, and "stmt2" to gimple_assign.

	* tree-scalar-evolution.c (scev_const_prop): Strengthen local
	"ass" from gimple to gimple_assign.

	* tree-sra.c (build_ref_for_offset): Likewise for "stmt".
	(generate_subtree_copies): Likewise; also strengthen "ds" to
	gimple_debug.
	(init_subtree_with_zero): Likewise.
	(sra_modify_expr): Likewise.
	(load_assign_lhs_subreplacements): Likewise.
	(sra_modify_assign): Strengthen "ds" to gimple_debug.
	(sra_ipa_reset_debug_stmts): Likewise for "def_temp".

	* tree-ssa-ccp.c (insert_clobber_before_stack_restore):
	Strengthen local "clobber_stmt" from gimple to gimple_assign.

	* tree-ssa-dce.c (remove_dead_stmt): Strengthen "note" to
	gimple_debug.

	* tree-ssa-dom.c (record_equivalences_from_stmt): Strengthen
	local "new_stmt" from gimple to gimple_assign.
	(optimize_stmt): Likewise.

	* tree-ssa-forwprop.c (simplify_bitwise_binary): Likewise for
	4 declarations of "newop".
	(simplify_rotate): Likewise for "g".

	* tree-ssa-loop-im.c (rewrite_reciprocal): Likewise for 3 locals.
	(rewrite_bittest): Likewise for "stmt" and "stmt2".
	(move_computations_dom_walker::before_dom_children): Likewise for
	"new_stmt".
	(execute_sm): Likewise for "load" and "store".

	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts):
	Strengthen local "stmt" from gimple to gimple_call.
	(unloop_loops): Likewise.

	* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Strengthen
	local "ass" from gimple to gimple_assign.
	(remove_unused_ivs): Strengthen "def_temp" to gimple_debug.

	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Strengthen local "stmt"
	from gimple to gimple_assign.

	* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Strengthen local
	"prefetch" from gimple to gimple_call.

	* tree-ssa-math-opts.c (insert_reciprocals): Strengthen local
	"new_stmt" from gimple to gimple_assign.
	(powi_as_mults_1): Likewise for "mult_stmt".
	(powi_as_mults): Likewise for "div_stmt".
	(build_and_insert_binop): Likewise for "stmt".
	(build_and_insert_cast): Likewise.
	(execute_cse_sincos): Likewise for "stmt" and various decls of
	"new_stmt".
	(execute_optimize_bswap): Likewise for two decls of "convert_stmt".
	(convert_mult_to_fma): Likewise for "fma_stmt".

	* tree-ssa-phiopt.c (conditional_replacement): Likewise for "new_stmt".
	(abs_replacement): Likewise.

	* tree-ssa-phiprop.c (phiprop_insert_phi): Likewise for "tmp".

	* tree-ssa-pre.c (create_expression_by_pieces): Likewise for "newstmt".
	(eliminate_insert): Likewise for "tem".

	* tree-ssa-propagate.c (update_gimple_call): Strengthen locals
	"new_stmt" and "stmt" from gimple to gimple_call.
	(update_call_from_tree): Likewise for "new_stmt".
	(substitute_and_fold): Strengthen local "new_stmt" from gimple to
	gimple_assign.

	* tree-ssa-reassoc.c (build_and_add_sum): Likewise for "sum".
	(update_ops): Likewise for "g".
	(maybe_optimize_range_tests): Likewise.
	(rewrite_expr_tree_parallel): Require a gimple_assign rather than
	a plain gimple.
	(reassociate_bb): Add a checked cast to gimple_assign.

	* tree-ssa.c (insert_debug_temp_for_var_def): Strengthen local
	"def_temp" from gimple to gimple_debug.

	* tree-switch-conversion.c (emit_case_bit_tests): Strengthen local
	"shift_stmt" from gimple to gimple_assign.

	* tree-tailcall.c (adjust_return_value_with_ops): Likewise for
	"stmt".
	(update_accumulator_with_ops): Likewise.

	* tree-vect-data-refs.c (bump_vector_ptr): Likewise for
	"incr_stmt".

	* tree-vect-stmts.c (vectorizable_condition): Likewise for
	"new_stmt".

	* tree-vrp.c (build_assert_expr_for): Likewise for "assertion".
	(simplify_truth_ops_using_ranges): Likewise for "newop".
	(simplify_float_conversion_using_ranges): Likewise for "conv".

	* ubsan.c (instrument_member_call): Strengthen local "g" from
	gimple to gimple_call.
	(instrument_mem_ref): Likewise.

	* value-prof.c (gimple_divmod_fixed_value): Require a
	gimple_assign rather than a plain gimple; strengthen types of locals.
	(gimple_mod_pow2): Likewise.
	(gimple_mod_subtract): Likewise.
	(gimple_divmod_fixed_value_transform): Strengthen local
	"stmt" from gimple to gimple_assign.
	(gimple_mod_pow2_value_transform): Likewise.
	(gimple_mod_subtract_transform): Likewise.
	(gimple_ic): Strengthen types of locals.
---
 gcc/cgraphunit.c                    |  2 +-
 gcc/gimple-ssa-isolate-paths.c      |  2 +-
 gcc/gimple-ssa-strength-reduction.c | 17 +++++++------
 gcc/gimplify.c                      | 22 ++++++++---------
 gcc/tree-eh.c                       |  4 +--
 gcc/tree-outof-ssa.c                |  3 ++-
 gcc/tree-parloops.c                 |  2 +-
 gcc/tree-predcom.c                  |  6 ++---
 gcc/tree-profile.c                  |  7 +++---
 gcc/tree-scalar-evolution.c         |  2 +-
 gcc/tree-sra.c                      | 35 ++++++++++++++------------
 gcc/tree-ssa-ccp.c                  |  3 ++-
 gcc/tree-ssa-dce.c                  |  2 +-
 gcc/tree-ssa-dom.c                  |  4 +--
 gcc/tree-ssa-forwprop.c             | 10 ++++----
 gcc/tree-ssa-loop-im.c              | 17 +++++++------
 gcc/tree-ssa-loop-ivcanon.c         |  4 +--
 gcc/tree-ssa-loop-ivopts.c          |  5 ++--
 gcc/tree-ssa-loop-manip.c           |  2 +-
 gcc/tree-ssa-loop-prefetch.c        |  2 +-
 gcc/tree-ssa-math-opts.c            | 27 +++++++++++---------
 gcc/tree-ssa-phiopt.c               |  6 +++--
 gcc/tree-ssa-phiprop.c              |  2 +-
 gcc/tree-ssa-pre.c                  |  9 ++++---
 gcc/tree-ssa-propagate.c            |  6 ++---
 gcc/tree-ssa-reassoc.c              | 14 ++++++-----
 gcc/tree-ssa.c                      |  2 +-
 gcc/tree-switch-conversion.c        |  2 +-
 gcc/tree-tailcall.c                 |  4 +--
 gcc/tree-vect-data-refs.c           |  2 +-
 gcc/tree-vect-stmts.c               |  2 +-
 gcc/tree-vrp.c                      |  7 +++---
 gcc/ubsan.c                         |  5 ++--
 gcc/value-prof.c                    | 49 +++++++++++++++++++++----------------
 34 files changed, 158 insertions(+), 130 deletions(-)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index dea6335..289b959 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1360,7 +1360,7 @@ thunk_adjust (gimple_stmt_iterator * bsi,
 	      tree ptr, bool this_adjusting,
 	      HOST_WIDE_INT fixed_offset, tree virtual_offset)
 {
-  gimple stmt;
+  gimple_assign stmt;
   tree ret;
 
   if (this_adjusting
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 4e2b8a8..62298f6 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -94,7 +94,7 @@ insert_trap_and_remove_trailing_statements (gimple_stmt_iterator *si_p, tree op)
       update_stmt (stmt);
     }
 
-  gimple new_stmt
+  gimple_call new_stmt
     = gimple_build_call (builtin_decl_explicit (BUILT_IN_TRAP), 0);
   gimple_seq seq = NULL;
   gimple_seq_add_stmt (&seq, new_stmt);
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 9320b51..35e15e0 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2058,7 +2058,7 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, double_int bump)
       if (bump.is_zero ())
 	{
 	  tree lhs = gimple_assign_lhs (c->cand_stmt);
-	  gimple copy_stmt = gimple_build_assign (lhs, basis_name);
+	  gimple_assign copy_stmt = gimple_build_assign (lhs, basis_name);
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
 	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, copy_stmt, false);
@@ -2159,7 +2159,7 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
   basic_block insert_bb;
   gimple_stmt_iterator gsi;
   tree lhs, basis_type;
-  gimple new_stmt;
+  gimple_assign new_stmt;
 
   /* If the add candidate along this incoming edge has the same
      index as C's hidden basis, the hidden basis represents this
@@ -3118,7 +3118,7 @@ insert_initializers (slsr_cand_t c)
     {
       basic_block bb;
       slsr_cand_t where = NULL;
-      gimple init_stmt;
+      gimple_assign init_stmt;
       tree stride_type, new_name, incr_tree;
       double_int incr = incr_vec[i].incr;
 
@@ -3256,7 +3256,7 @@ static tree
 introduce_cast_before_cand (slsr_cand_t c, tree to_type, tree from_expr)
 {
   tree cast_lhs;
-  gimple cast_stmt;
+  gimple_assign cast_stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
 
   cast_lhs = make_temp_ssa_name (to_type, NULL, "slsr");
@@ -3418,7 +3418,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
       
       if (types_compatible_p (lhs_type, basis_type))
 	{
-	  gimple copy_stmt = gimple_build_assign (lhs, basis_name);
+	  gimple_assign copy_stmt = gimple_build_assign (lhs, basis_name);
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
 	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, copy_stmt, false);
@@ -3430,9 +3430,10 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
       else
 	{
 	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
-	  gimple cast_stmt = gimple_build_assign_with_ops (NOP_EXPR, lhs,
-							   basis_name,
-							   NULL_TREE);
+	  gimple_assign cast_stmt =
+	    gimple_build_assign_with_ops (NOP_EXPR, lhs,
+					  basis_name,
+					  NULL_TREE);
 	  gimple_set_location (cast_stmt, gimple_location (c->cand_stmt));
 	  gsi_replace (&gsi, cast_stmt, false);
 	  c->cand_stmt = cast_stmt;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 520e71e..f8c3aff 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1003,7 +1003,7 @@ voidify_wrapper_expr (tree wrapper, tree temp)
    a temporary through which they communicate.  */
 
 static void
-build_stack_save_restore (gimple *save, gimple *restore)
+build_stack_save_restore (gimple_call *save, gimple_call *restore)
 {
   tree tmp_var;
 
@@ -1026,7 +1026,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
   tree t;
   gimple_bind gimple_bind;
   gimple_seq body, cleanup;
-  gimple stack_save;
+  gimple_call stack_save;
 
   tree temp = voidify_wrapper_expr (bind_expr, NULL);
 
@@ -1083,7 +1083,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
   stack_save = NULL;
   if (gimplify_ctxp->save_stack)
     {
-      gimple stack_restore;
+      gimple_call stack_restore;
 
       /* Save stack on entry and restore it on exit.  Add a try_finally
 	 block to achieve this.  */
@@ -1115,7 +1115,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
 
   if (cleanup)
     {
-      gimple gs;
+      gimple_try gs;
       gimple_seq new_body;
 
       new_body = NULL;
@@ -1446,7 +1446,7 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
       vec<tree> labels;
       vec<tree> saved_labels;
       tree default_case = NULL_TREE;
-      gimple gimple_switch;
+      gimple_switch gimple_switch;
 
       /* If someone can be bothered to fill in the labels, they can
 	 be bothered to null out the body too.  */
@@ -1466,7 +1466,7 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
 
       if (!default_case)
 	{
-	  gimple new_default;
+	  gimple_label new_default;
 
 	  default_case
 	    = build_case_label (NULL_TREE, NULL_TREE,
@@ -2898,7 +2898,7 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
   enum gimplify_status ret;
   tree label_true, label_false, label_cont;
   bool have_then_clause_p, have_else_clause_p;
-  gimple gimple_cond;
+  gimple_cond gimple_cond;
   enum tree_code pred_code;
   gimple_seq seq = NULL;
 
@@ -4002,7 +4002,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	{
 	  tree lhs = TREE_OPERAND (*expr_p, 0);
 	  tree rhs = TREE_OPERAND (*expr_p, 1);
-	  gimple init = gimple_build_assign (lhs, rhs);
+	  gimple_assign init = gimple_build_assign (lhs, rhs);
 	  gimplify_seq_add_stmt (pre_p, init);
 	  *expr_p = NULL;
 	}
@@ -5151,7 +5151,7 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p)
 	    }
 	  else
 	    {
-	      gimple_statement_try *gtry;
+	      gimple_try gtry;
 	      gimple_seq seq;
 	      enum gimple_try_flags kind;
 
@@ -5223,8 +5223,8 @@ gimple_push_cleanup (tree var, tree cleanup, bool eh_only, gimple_seq *pre_p)
 	   val
       */
       tree flag = create_tmp_var (boolean_type_node, "cleanup");
-      gimple ffalse = gimple_build_assign (flag, boolean_false_node);
-      gimple ftrue = gimple_build_assign (flag, boolean_true_node);
+      gimple_assign ffalse = gimple_build_assign (flag, boolean_false_node);
+      gimple_assign ftrue = gimple_build_assign (flag, boolean_true_node);
 
       cleanup = build3 (COND_EXPR, void_type_node, flag, cleanup, NULL);
       gimplify_stmt (&cleanup, &cleanup_stmts);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index ca8d4aa..70a284b 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -793,7 +793,7 @@ static void
 do_goto_redirection (struct goto_queue_node *q, tree finlab, gimple_seq mod,
 		     struct leh_tf_state *tf)
 {
-  gimple x;
+  gimple_goto x;
 
   gcc_assert (q->is_label);
 
@@ -813,7 +813,7 @@ static void
 emit_post_landing_pad (gimple_seq *seq, eh_region region)
 {
   eh_landing_pad lp = region->landing_pads;
-  gimple x;
+  gimple_label x;
 
   if (lp == NULL)
     lp = gen_eh_landing_pad (region);
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 7f87ffc..026b048 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -1130,7 +1130,8 @@ insert_backedge_copies (void)
 		      || trivially_conflicts_p (bb, result, arg)))
 		{
 		  tree name;
-		  gimple stmt, last = NULL;
+		  gimple_assign stmt;
+		  gimple last = NULL;
 		  gimple_stmt_iterator gsi2;
 
 		  gsi2 = gsi_last_bb (gimple_phi_arg_edge (phi, i)->src);
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index a142e96..dea9606 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -492,7 +492,7 @@ take_address_of (tree obj, tree type, edge entry,
   int_tree_map **dslot;
   struct int_tree_map ielt, *nielt;
   tree *var_p, name, addr;
-  gimple stmt;
+  gimple_assign stmt;
   gimple_seq stmts;
 
   /* Since the address of OBJ is invariant, the trees may be shared.
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index e95af52..9a5f317 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1293,7 +1293,7 @@ static void
 replace_ref_with (gimple stmt, tree new_tree, bool set, bool in_lhs)
 {
   tree val;
-  gimple new_stmt;
+  gimple_assign new_stmt;
   gimple_stmt_iterator bsi, psi;
 
   if (gimple_code (stmt) == GIMPLE_PHI)
@@ -1562,7 +1562,7 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written,
     }
   else
     {
-      gimple init_stmt = gimple_build_assign (var, init);
+      gimple_assign init_stmt = gimple_build_assign (var, init);
       gsi_insert_on_edge_immediate (entry, init_stmt);
     }
 }
@@ -2129,7 +2129,7 @@ static gimple
 reassociate_to_the_same_stmt (tree name1, tree name2)
 {
   gimple stmt1, stmt2, root1, root2, s1, s2;
-  gimple new_stmt, tmp_stmt;
+  gimple_assign new_stmt, tmp_stmt;
   tree new_name, tmp_name, var, r1, r2;
   unsigned dist1, dist2;
   enum tree_code code;
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index e79fedc..1a887a0 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -287,7 +287,7 @@ void
 gimple_gen_edge_profiler (int edgeno, edge e)
 {
   tree ref, one, gcov_type_tmp_var;
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1, stmt2, stmt3;
 
   ref = tree_coverage_counter_ref (GCOV_COUNTER_ARCS, edgeno);
   one = build_int_cst (gcov_type_node, 1);
@@ -395,7 +395,7 @@ void
 gimple_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
 {
   tree tmp1;
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1, stmt2, stmt3;
   gimple stmt = value->hvalue.stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
   tree ref_ptr = tree_coverage_counter_addr (tag, base);
@@ -431,7 +431,8 @@ gimple_gen_ic_func_profiler (void)
 {
   struct cgraph_node * c_node = cgraph_get_node (current_function_decl);
   gimple_stmt_iterator gsi;
-  gimple stmt1, stmt2;
+  gimple_call stmt1;
+  gimple_assign stmt2;
   tree tree_uid, cur_func, void0;
 
   if (cgraph_only_called_directly_p (c_node))
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 40f9901..998c06c 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -3349,7 +3349,7 @@ scev_const_prop (void)
   basic_block bb;
   tree name, type, ev;
   gimple_phi phi;
-  gimple ass;
+  gimple_assign ass;
   struct loop *loop, *ex_loop;
   bitmap ssa_names_to_remove = NULL;
   unsigned i;
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 60728aa..52198a8 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1530,7 +1530,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset,
      offset such as array[var_index].  */
   if (!base)
     {
-      gimple stmt;
+      gimple_assign stmt;
       tree tmp, addr;
 
       gcc_checking_assert (gsi);
@@ -2612,7 +2612,7 @@ generate_subtree_copies (struct access *access, tree agg,
 	      || access->offset + access->size > start_offset))
 	{
 	  tree expr, repl = get_access_replacement (access);
-	  gimple stmt;
+	  gimple_assign stmt;
 
 	  expr = build_ref_for_model (loc, agg, access->offset - top_offset,
 				      access, gsi, insert_after);
@@ -2650,7 +2650,7 @@ generate_subtree_copies (struct access *access, tree agg,
 	       && (chunk_size == 0
 		   || access->offset + access->size > start_offset))
 	{
-	  gimple ds;
+	  gimple_debug ds;
 	  tree drhs = build_debug_ref_for_model (loc, agg,
 						 access->offset - top_offset,
 						 access);
@@ -2686,7 +2686,7 @@ init_subtree_with_zero (struct access *access, gimple_stmt_iterator *gsi,
 
   if (access->grp_to_be_replaced)
     {
-      gimple stmt;
+      gimple_assign stmt;
 
       stmt = gimple_build_assign (get_access_replacement (access),
 				  build_zero_cst (access->type));
@@ -2699,9 +2699,10 @@ init_subtree_with_zero (struct access *access, gimple_stmt_iterator *gsi,
     }
   else if (access->grp_to_be_debug_replaced)
     {
-      gimple ds = gimple_build_debug_bind (get_access_replacement (access),
-					   build_zero_cst (access->type),
-					   gsi_stmt (*gsi));
+      gimple_debug ds =
+	gimple_build_debug_bind (get_access_replacement (access),
+				 build_zero_cst (access->type),
+				 gsi_stmt (*gsi));
       if (insert_after)
 	gsi_insert_after (gsi, ds, GSI_NEW_STMT);
       else
@@ -2788,7 +2789,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write)
 
 	  if (write)
 	    {
-	      gimple stmt;
+	      gimple_assign stmt;
 
 	      if (access->grp_partial_lhs)
 		ref = force_gimple_operand_gsi (gsi, ref, true, NULL_TREE,
@@ -2799,7 +2800,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write)
 	    }
 	  else
 	    {
-	      gimple stmt;
+	      gimple_assign stmt;
 
 	      if (access->grp_partial_lhs)
 		repl = force_gimple_operand_gsi (gsi, repl, true, NULL_TREE,
@@ -2815,9 +2816,10 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write)
     }
   else if (write && access->grp_to_be_debug_replaced)
     {
-      gimple ds = gimple_build_debug_bind (get_access_replacement (access),
-					   NULL_TREE,
-					   gsi_stmt (*gsi));
+      gimple_debug ds =
+	gimple_build_debug_bind (get_access_replacement (access),
+				 NULL_TREE,
+				 gsi_stmt (*gsi));
       gsi_insert_after (gsi, ds, GSI_NEW_STMT);
     }
 
@@ -2900,7 +2902,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc,
       if (lacc->grp_to_be_replaced)
 	{
 	  struct access *racc;
-	  gimple stmt;
+	  gimple_assign stmt;
 	  tree rhs;
 
 	  racc = find_access_in_subtree (top_racc, offset, lacc->size);
@@ -2947,7 +2949,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc,
 							      old_gsi);
 	  if (lacc && lacc->grp_to_be_debug_replaced)
 	    {
-	      gimple ds;
+	      gimple_debug ds;
 	      tree drhs;
 	      struct access *racc = find_access_in_subtree (top_racc, offset,
 							    lacc->size);
@@ -3189,7 +3191,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
 	    drhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
 				    TREE_TYPE (dlhs), drhs);
 	}
-      gimple ds = gimple_build_debug_bind (dlhs, drhs, *stmt);
+      gimple_debug ds = gimple_build_debug_bind (dlhs, drhs, *stmt);
       gsi_insert_before (gsi, ds, GSI_SAME_STMT);
     }
 
@@ -4693,7 +4695,8 @@ sra_ipa_reset_debug_stmts (ipa_parm_adjustment_vec adjustments)
     {
       struct ipa_parm_adjustment *adj;
       imm_use_iterator ui;
-      gimple stmt, def_temp;
+      gimple stmt;
+      gimple_debug def_temp;
       tree name, vexpr, copy = NULL_TREE;
       use_operand_p use_p;
 
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index d10f9ba..3f3c27f 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1847,7 +1847,8 @@ static void
 insert_clobber_before_stack_restore (tree saved_val, tree var,
 				     gimple_htab *visited)
 {
-  gimple stmt, clobber_stmt;
+  gimple stmt;
+  gimple_assign clobber_stmt;
   tree clobber;
   imm_use_iterator iter;
   gimple_stmt_iterator i;
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 1f885c6..294fc33 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1121,7 +1121,7 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb)
 	  && !DECL_HAS_VALUE_EXPR_P (lhs))
 	{
 	  tree rhs = gimple_assign_rhs1 (stmt);
-	  gimple note
+	  gimple_debug note
 	    = gimple_build_debug_bind (lhs, unshare_expr (rhs), stmt);
 	  gsi_insert_after (i, note, GSI_SAME_STMT);
 	}
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index b483289..4ecab6a 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -2191,7 +2191,7 @@ record_equivalences_from_stmt (gimple stmt, int may_optimize_p)
       && !is_gimple_reg (lhs))
     {
       tree rhs = gimple_assign_rhs1 (stmt);
-      gimple new_stmt;
+      gimple_assign new_stmt;
 
       /* Build a new statement with the RHS and LHS exchanged.  */
       if (TREE_CODE (rhs) == SSA_NAME)
@@ -2423,7 +2423,7 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
 	  tree lhs = gimple_assign_lhs (stmt);
 	  tree rhs = gimple_assign_rhs1 (stmt);
 	  tree cached_lhs;
-	  gimple new_stmt;
+	  gimple_assign new_stmt;
 	  if (TREE_CODE (rhs) == SSA_NAME)
 	    {
 	      tree tem = SSA_NAME_VALUE (rhs);
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 87e44b7..c46d2e4 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1962,7 +1962,7 @@ simplify_bitwise_binary (gimple_stmt_iterator *gsi)
       && INTEGRAL_TYPE_P (TREE_TYPE (def1_arg1))
       && int_fits_type_p (arg2, TREE_TYPE (def1_arg1)))
     {
-      gimple newop;
+      gimple_assign newop;
       tree tem = make_ssa_name (TREE_TYPE (def1_arg1), NULL);
       newop =
         gimple_build_assign_with_ops (code, tem, def1_arg1,
@@ -1985,7 +1985,7 @@ simplify_bitwise_binary (gimple_stmt_iterator *gsi)
       && types_compatible_p (TREE_TYPE (def1_arg1), TREE_TYPE (def2_arg1))
       && hoist_conversion_for_bitop_p (TREE_TYPE (arg1), TREE_TYPE (def1_arg1)))
     {
-      gimple newop;
+      gimple_assign newop;
       tree tem = make_ssa_name (TREE_TYPE (def1_arg1), NULL);
       newop = gimple_build_assign_with_ops (code, tem, def1_arg1, def2_arg1);
       gimple_set_location (newop, gimple_location (stmt));
@@ -2027,7 +2027,7 @@ simplify_bitwise_binary (gimple_stmt_iterator *gsi)
 	}
       else
 	{
-	  gimple newop;
+	  gimple_assign newop;
 	  tree tem;
 	  tem = make_ssa_name (TREE_TYPE (arg2), NULL);
 	  newop = gimple_build_assign_with_ops (code, tem, a, c);
@@ -2051,7 +2051,7 @@ simplify_bitwise_binary (gimple_stmt_iterator *gsi)
       tree cst = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg2),
 			      arg2, def1_arg2);
       tree tem;
-      gimple newop;
+      gimple_assign newop;
       if (integer_zerop (cst))
 	{
 	  gimple_assign_set_rhs1 (stmt, def1_arg1);
@@ -2259,7 +2259,7 @@ simplify_rotate (gimple_stmt_iterator *gsi)
   tree lhs;
   int i;
   bool swapped_p = false;
-  gimple g;
+  gimple_assign g;
 
   arg[0] = gimple_assign_rhs1 (stmt);
   arg[1] = gimple_assign_rhs2 (stmt);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index aa51afb..00e6e16 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -862,12 +862,12 @@ nonpure_call_p (gimple stmt)
 static gimple
 rewrite_reciprocal (gimple_stmt_iterator *bsi)
 {
-  gimple stmt, stmt1, stmt2;
+  gimple_assign stmt, stmt1, stmt2;
   tree name, lhs, type;
   tree real_one;
   gimple_stmt_iterator gsi;
 
-  stmt = gsi_stmt (*bsi);
+  stmt = gsi_stmt (*bsi)->as_a_gimple_assign ();
   lhs = gimple_assign_lhs (stmt);
   type = TREE_TYPE (lhs);
 
@@ -897,11 +897,14 @@ rewrite_reciprocal (gimple_stmt_iterator *bsi)
 static gimple
 rewrite_bittest (gimple_stmt_iterator *bsi)
 {
-  gimple stmt, use_stmt, stmt1, stmt2;
+  gimple_assign stmt;
+  gimple stmt1;
+  gimple_assign stmt2;
+  gimple use_stmt;
   tree lhs, name, t, a, b;
   use_operand_p use;
 
-  stmt = gsi_stmt (*bsi);
+  stmt = gsi_stmt (*bsi)->as_a_gimple_assign ();
   lhs = gimple_assign_lhs (stmt);
 
   /* Verify that the single use of lhs is a comparison against zero.  */
@@ -1154,7 +1157,7 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
 
   for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); )
     {
-      gimple new_stmt;
+      gimple_assign new_stmt;
       stmt = gsi_stmt (bsi);
 
       lim_data = get_lim_data (stmt);
@@ -1930,7 +1933,7 @@ execute_sm (struct loop *loop, vec<edge> exits, mem_ref_p ref)
 {
   tree tmp_var, store_flag = NULL_TREE;
   unsigned i;
-  gimple load;
+  gimple_assign load;
   struct fmt_data fmt_data;
   edge ex;
   struct lim_aux_data *lim_data;
@@ -1987,7 +1990,7 @@ execute_sm (struct loop *loop, vec<edge> exits, mem_ref_p ref)
   FOR_EACH_VEC_ELT (exits, i, ex)
     if (!multi_threaded_model_p)
       {
-	gimple store;
+	gimple_assign store;
 	store = gimple_build_assign (unshare_expr (ref->mem.ref), tmp_var);
 	gsi_insert_on_edge (ex, store);
       }
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index b475b06..6049f81 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -493,7 +493,7 @@ remove_exits_and_undefined_stmts (struct loop *loop, unsigned int npeeled)
 	  && elt->bound.ult (double_int::from_uhwi (npeeled)))
 	{
 	  gimple_stmt_iterator gsi = gsi_for_stmt (elt->stmt);
-	  gimple stmt = gimple_build_call
+	  gimple_call stmt = gimple_build_call
 	      (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
 
 	  gimple_set_location (stmt, gimple_location (elt->stmt));
@@ -612,7 +612,7 @@ unloop_loops (bitmap loop_closed_ssa_invalidated,
       edge latch_edge = loop_latch_edge (loop);
       int flags = latch_edge->flags;
       location_t locus = latch_edge->goto_locus;
-      gimple stmt;
+      gimple_call stmt;
       gimple_stmt_iterator gsi;
 
       remove_exits_and_undefined_stmts (loop, n_unroll);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 24f296a..eba5b0f 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -6225,7 +6225,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
 {
   tree comp;
   tree op, tgt;
-  gimple ass;
+  gimple_assign ass;
   gimple_stmt_iterator bsi;
 
   /* An important special case -- if we are asked to express value of
@@ -6642,7 +6642,8 @@ remove_unused_ivs (struct ivopts_data *data)
 		    DECL_MODE (vexpr) = DECL_MODE (SSA_NAME_VAR (def));
 		  else
 		    DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (vexpr));
-		  gimple def_temp = gimple_build_debug_bind (vexpr, comp, NULL);
+		  gimple_debug def_temp =
+		    gimple_build_debug_bind (vexpr, comp, NULL);
 		  gimple_stmt_iterator gsi;
 
 		  if (gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI)
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index dbcc4ce..235b6fc 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -1264,7 +1264,7 @@ rewrite_phi_with_iv (loop_p loop,
 		     tree main_iv)
 {
   affine_iv iv;
-  gimple stmt;
+  gimple_assign stmt;
   gimple_phi phi = psi->phi ();
   tree atype, mtype, val, res = PHI_RESULT (phi);
 
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index be34d05..c7d163f 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -1127,7 +1127,7 @@ issue_prefetch_ref (struct mem_ref *ref, unsigned unroll_factor, unsigned ahead)
 {
   HOST_WIDE_INT delta;
   tree addr, addr_base, write_p, local, forward;
-  gimple prefetch;
+  gimple_call prefetch;
   gimple_stmt_iterator bsi;
   unsigned n_prefetches, ap;
   bool nontemporal = ref->reuse_distance >= L2_CACHE_SIZE_BYTES;
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index c9e5674..8102768 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -354,7 +354,7 @@ insert_reciprocals (gimple_stmt_iterator *def_gsi, struct occurrence *occ,
 		    tree def, tree recip_def, int threshold)
 {
   tree type;
-  gimple new_stmt;
+  gimple_assign new_stmt;
   gimple_stmt_iterator gsi;
   struct occurrence *occ_child;
 
@@ -979,7 +979,7 @@ powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
 {
   tree op0, op1, ssa_target;
   unsigned HOST_WIDE_INT digit;
-  gimple mult_stmt;
+  gimple_assign mult_stmt;
 
   if (n < POWI_TABLE_SIZE && cache[n])
     return cache[n];
@@ -1019,7 +1019,7 @@ powi_as_mults (gimple_stmt_iterator *gsi, location_t loc,
 	       tree arg0, HOST_WIDE_INT n)
 {
   tree cache[POWI_TABLE_SIZE], result, type = TREE_TYPE (arg0);
-  gimple div_stmt;
+  gimple_assign div_stmt;
   tree target;
 
   if (n == 0)
@@ -1095,7 +1095,7 @@ build_and_insert_binop (gimple_stmt_iterator *gsi, location_t loc,
 			tree arg0, tree arg1)
 {
   tree result = make_temp_ssa_name (TREE_TYPE (arg0), NULL, name);
-  gimple stmt = gimple_build_assign_with_ops (code, result, arg0, arg1);
+  gimple_assign stmt = gimple_build_assign_with_ops (code, result, arg0, arg1);
   gimple_set_location (stmt, loc);
   gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
   return result;
@@ -1125,7 +1125,8 @@ build_and_insert_cast (gimple_stmt_iterator *gsi, location_t loc,
 		       tree type, tree val)
 {
   tree result = make_ssa_name (type, NULL);
-  gimple stmt = gimple_build_assign_with_ops (NOP_EXPR, result, val, NULL_TREE);
+  gimple_assign stmt =
+    gimple_build_assign_with_ops (NOP_EXPR, result, val, NULL_TREE);
   gimple_set_location (stmt, loc);
   gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
   return result;
@@ -1468,7 +1469,8 @@ execute_cse_sincos (void)
 		  if (result)
 		    {
 		      tree lhs = gimple_get_lhs (stmt);
-		      gimple new_stmt = gimple_build_assign (lhs, result);
+		      gimple_assign new_stmt =
+			gimple_build_assign (lhs, result);
 		      gimple_set_location (new_stmt, loc);
 		      unlink_stmt_vdef (stmt);
 		      gsi_replace (&gsi, new_stmt, true);
@@ -1486,7 +1488,7 @@ execute_cse_sincos (void)
 		  if (real_minus_onep (arg0))
 		    {
                       tree t0, t1, cond, one, minus_one;
-		      gimple stmt;
+		      gimple_assign stmt;
 
 		      t0 = TREE_TYPE (arg0);
 		      t1 = TREE_TYPE (arg1);
@@ -1520,7 +1522,7 @@ execute_cse_sincos (void)
 		  if (result)
 		    {
 		      tree lhs = gimple_get_lhs (stmt);
-		      gimple new_stmt = gimple_build_assign (lhs, result);
+		      gimple_assign new_stmt = gimple_build_assign (lhs, result);
 		      gimple_set_location (new_stmt, loc);
 		      unlink_stmt_vdef (stmt);
 		      gsi_replace (&gsi, new_stmt, true);
@@ -1538,7 +1540,7 @@ execute_cse_sincos (void)
 		  if (result)
 		    {
 		      tree lhs = gimple_get_lhs (stmt);
-		      gimple new_stmt = gimple_build_assign (lhs, result);
+		      gimple_assign new_stmt = gimple_build_assign (lhs, result);
 		      gimple_set_location (new_stmt, loc);
 		      unlink_stmt_vdef (stmt);
 		      gsi_replace (&gsi, new_stmt, true);
@@ -2021,7 +2023,7 @@ execute_optimize_bswap (void)
 	  /* Convert the src expression if necessary.  */
 	  if (!useless_type_conversion_p (TREE_TYPE (bswap_tmp), bswap_type))
 	    {
-	      gimple convert_stmt;
+	      gimple_assign convert_stmt;
 	      bswap_tmp = make_temp_ssa_name (bswap_type, NULL, "bswapsrc");
 	      convert_stmt = gimple_build_assign_with_ops
 		  		(NOP_EXPR, bswap_tmp, bswap_src, NULL);
@@ -2035,7 +2037,7 @@ execute_optimize_bswap (void)
 	  /* Convert the result if necessary.  */
 	  if (!useless_type_conversion_p (TREE_TYPE (bswap_tmp), bswap_type))
 	    {
-	      gimple convert_stmt;
+	      gimple_assign convert_stmt;
 	      bswap_tmp = make_temp_ssa_name (bswap_type, NULL, "bswapdst");
 	      convert_stmt = gimple_build_assign_with_ops
 			(NOP_EXPR, gimple_assign_lhs (stmt), bswap_tmp, NULL);
@@ -2587,7 +2589,8 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2)
 {
   tree mul_result = gimple_get_lhs (mul_stmt);
   tree type = TREE_TYPE (mul_result);
-  gimple use_stmt, neguse_stmt, fma_stmt;
+  gimple use_stmt, neguse_stmt;
+  gimple_assign fma_stmt;
   use_operand_p use_p;
   imm_use_iterator imm_iter;
 
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 9828f18..b8ed719 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -593,7 +593,8 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb,
 			 tree arg0, tree arg1)
 {
   tree result;
-  gimple stmt, new_stmt;
+  gimple stmt;
+  gimple_assign new_stmt;
   tree cond;
   gimple_stmt_iterator gsi;
   edge true_edge, false_edge;
@@ -1201,7 +1202,8 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb,
 		 gimple phi, tree arg0, tree arg1)
 {
   tree result;
-  gimple new_stmt, cond;
+  gimple_assign new_stmt;
+  gimple cond;
   gimple_stmt_iterator gsi;
   edge true_edge, false_edge;
   gimple assign;
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index 33ac8c8..73792bb 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -166,7 +166,7 @@ phiprop_insert_phi (basic_block bb, gimple_phi phi, gimple use_stmt,
   FOR_EACH_EDGE (e, ei, bb->preds)
     {
       tree old_arg, new_var;
-      gimple tmp;
+      gimple_assign tmp;
       source_location locus;
 
       old_arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index e7b3ca2..c7d19cd 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2861,7 +2861,7 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
   gimple_stmt_iterator gsi;
   tree exprtype = type ? type : get_expr_type (expr);
   pre_expr nameexpr;
-  gimple newstmt;
+  gimple_assign newstmt;
 
   switch (expr->kind)
     {
@@ -4035,9 +4035,10 @@ eliminate_insert (gimple_stmt_iterator *gsi, tree val)
     return NULL_TREE;
 
   tree res = make_temp_ssa_name (TREE_TYPE (val), NULL, "pretmp");
-  gimple tem = gimple_build_assign (res,
-				    fold_build1 (TREE_CODE (expr),
-						 TREE_TYPE (expr), leader));
+  gimple_assign tem =
+    gimple_build_assign (res,
+			 fold_build1 (TREE_CODE (expr),
+				      TREE_TYPE (expr), leader));
   gsi_insert_before (gsi, tem, GSI_SAME_STMT);
   VN_INFO_GET (res)->valnum = val;
 
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 6965fb2..a2afcdd 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -727,7 +727,7 @@ bool
 update_gimple_call (gimple_stmt_iterator *si_p, tree fn, int nargs, ...)
 {
   va_list ap;
-  gimple new_stmt, stmt = gsi_stmt (*si_p);
+  gimple_call new_stmt, stmt = gsi_stmt (*si_p)->as_a_gimple_call ();
 
   gcc_assert (is_gimple_call (stmt));
   va_start (ap, nargs);
@@ -761,7 +761,7 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
       unsigned i;
       unsigned nargs = call_expr_nargs (expr);
       vec<tree> args = vNULL;
-      gimple new_stmt;
+      gimple_call new_stmt;
 
       if (nargs > 0)
         {
@@ -1086,7 +1086,7 @@ substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
 	  }
 	else if (gimple_code (def_stmt) == GIMPLE_PHI)
 	  {
-	    gimple new_stmt = gimple_build_assign (name, val);
+	    gimple_assign new_stmt = gimple_build_assign (name, val);
 	    gimple_stmt_iterator gsi2;
 	    gsi2 = gsi_after_labels (gimple_bb (def_stmt));
 	    gsi_insert_before (&gsi2, new_stmt, GSI_SAME_STMT);
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index c8421b7..932d82b 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1287,7 +1287,7 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode)
   gimple op1def = NULL, op2def = NULL;
   gimple_stmt_iterator gsi;
   tree op;
-  gimple sum;
+  gimple_assign sum;
 
   /* Create the addition statement.  */
   op = make_ssa_name (type, NULL);
@@ -2675,8 +2675,9 @@ update_ops (tree var, enum tree_code code, vec<operand_entry_t> ops,
     {
       gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
       var = make_ssa_name (TREE_TYPE (var), NULL);
-      gimple g = gimple_build_assign_with_ops (gimple_assign_rhs_code (stmt),
-					       var, rhs[2], rhs[3]);
+      gimple_assign g =
+	gimple_build_assign_with_ops (gimple_assign_rhs_code (stmt),
+				      var, rhs[2], rhs[3]);
       gimple_set_uid (g, gimple_uid (stmt));
       gimple_set_visited (g, true);
       gsi_insert_before (&gsi, g, GSI_SAME_STMT);
@@ -2974,7 +2975,7 @@ maybe_optimize_range_tests (gimple stmt)
 		      tree new_lhs = make_ssa_name (TREE_TYPE (lhs), NULL);
 		      enum tree_code rhs_code
 			= gimple_assign_rhs_code (cast_stmt);
-		      gimple g;
+		      gimple_assign g;
 		      if (is_gimple_min_invariant (new_op))
 			{
 			  new_op = fold_convert (TREE_TYPE (lhs), new_op);
@@ -3361,7 +3362,7 @@ get_reassociation_width (int ops_num, enum tree_code opc,
    parallel.  */
 
 static void
-rewrite_expr_tree_parallel (gimple stmt, int width,
+rewrite_expr_tree_parallel (gimple_assign stmt, int width,
 			    vec<operand_entry_t> ops)
 {
   enum tree_code opcode = gimple_assign_rhs_code (stmt);
@@ -4503,7 +4504,8 @@ reassociate_bb (basic_block bb)
 
 		  if (width > 1
 		      && ops.length () > 3)
-		    rewrite_expr_tree_parallel (stmt, width, ops);
+		    rewrite_expr_tree_parallel (stmt->as_a_gimple_assign (),
+						width, ops);
 		  else
                     {
                       /* When there are three operands left, we want
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 7d0e844..bbf042c 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -477,7 +477,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
 	;
       else
 	{
-	  gimple def_temp;
+	  gimple_debug def_temp;
 	  tree vexpr = make_node (DEBUG_EXPR_DECL);
 
 	  def_temp = gimple_build_debug_bind (vexpr,
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index de3045a..e84d0b5 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -321,7 +321,7 @@ emit_case_bit_tests (gimple_switch swtch, tree index_expr,
   unsigned int branch_num = gimple_switch_num_labels (swtch);
 
   gimple_stmt_iterator gsi;
-  gimple shift_stmt;
+  gimple_assign shift_stmt;
 
   tree idx, tmp, csui;
   tree word_type_node = lang_hooks.types.type_for_mode (word_mode, 1);
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index e89f9ba..25644ad 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -633,7 +633,7 @@ adjust_return_value_with_ops (enum tree_code code, const char *label,
 
   tree ret_type = TREE_TYPE (DECL_RESULT (current_function_decl));
   tree result = make_temp_ssa_name (ret_type, NULL, label);
-  gimple stmt;
+  gimple_assign stmt;
 
   if (POINTER_TYPE_P (ret_type))
     {
@@ -670,7 +670,7 @@ static tree
 update_accumulator_with_ops (enum tree_code code, tree acc, tree op1,
 			     gimple_stmt_iterator gsi)
 {
-  gimple stmt;
+  gimple_assign stmt;
   tree var = copy_ssa_name (acc, NULL);
   if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1)))
     stmt = gimple_build_assign_with_ops (code, var, acc, op1);
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index fe8cd9d..fb4f800 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4282,7 +4282,7 @@ bump_vector_ptr (tree dataref_ptr, gimple ptr_incr, gimple_stmt_iterator *gsi,
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
   tree update = TYPE_SIZE_UNIT (vectype);
-  gimple incr_stmt;
+  gimple_assign incr_stmt;
   ssa_op_iter iter;
   use_operand_p use_p;
   tree new_dataref_ptr;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index a166d1e..70428d9 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -6791,7 +6791,7 @@ vectorizable_condition (gimple stmt, gimple_stmt_iterator *gsi,
   /* Handle cond expr.  */
   for (j = 0; j < ncopies; j++)
     {
-      gimple new_stmt = NULL;
+      gimple_assign new_stmt = NULL;
       if (j == 0)
 	{
           if (slp_node)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index a19bbcd..902b879 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4484,7 +4484,7 @@ static gimple
 build_assert_expr_for (tree cond, tree v)
 {
   tree a;
-  gimple assertion;
+  gimple_assign assertion;
 
   gcc_assert (TREE_CODE (v) == SSA_NAME
 	      && COMPARISON_CLASS_P (cond));
@@ -8575,7 +8575,8 @@ simplify_truth_ops_using_ranges (gimple_stmt_iterator *gsi, gimple stmt)
   else if (need_conversion)
     {
       tree tem = make_ssa_name (TREE_TYPE (op0), NULL);
-      gimple newop = gimple_build_assign_with_ops (BIT_XOR_EXPR, tem, op0, op1);
+      gimple_assign newop =
+	gimple_build_assign_with_ops (BIT_XOR_EXPR, tem, op0, op1);
       gsi_insert_before (gsi, newop, GSI_SAME_STMT);
       gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, tem, NULL_TREE);
     }
@@ -9249,7 +9250,7 @@ simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi, gimple stmt)
   enum machine_mode fltmode = TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt)));
   enum machine_mode mode;
   tree tem;
-  gimple conv;
+  gimple_assign conv;
 
   /* We can only handle constant ranges.  */
   if (vr->type != VR_RANGE
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index ac40c85..7d801da 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -615,7 +615,8 @@ instrument_member_call (gimple_stmt_iterator *iter)
 {
   tree this_parm = gimple_call_arg (gsi_stmt (*iter), 0);
   tree kind = build_int_cst (unsigned_char_type_node, UBSAN_MEMBER_CALL);
-  gimple g = gimple_build_call_internal (IFN_UBSAN_NULL, 2, this_parm, kind);
+  gimple_call g =
+    gimple_build_call_internal (IFN_UBSAN_NULL, 2, this_parm, kind);
   gimple_set_location (g, gimple_location (gsi_stmt (*iter)));
   gsi_insert_before (iter, g, GSI_SAME_STMT);
 }
@@ -630,7 +631,7 @@ instrument_mem_ref (tree t, gimple_stmt_iterator *iter, bool is_lhs)
   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_TYPE (t))))
     ikind = UBSAN_MEMBER_ACCESS;
   tree kind = build_int_cst (unsigned_char_type_node, ikind);
-  gimple g = gimple_build_call_internal (IFN_UBSAN_NULL, 2, t, kind);
+  gimple_call g = gimple_build_call_internal (IFN_UBSAN_NULL, 2, t, kind);
   gimple_set_location (g, gimple_location (gsi_stmt (*iter)));
   gsi_insert_before (iter, g, GSI_SAME_STMT);
 }
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index eabd84c..055d221 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -125,10 +125,11 @@ along with GCC; see the file COPYING3.  If not see
      and gimple_value_profile_transformations table-driven, perhaps...
 */
 
-static tree gimple_divmod_fixed_value (gimple, tree, int, gcov_type, gcov_type);
-static tree gimple_mod_pow2 (gimple, int, gcov_type, gcov_type);
-static tree gimple_mod_subtract (gimple, int, int, int, gcov_type, gcov_type,
-				 gcov_type);
+static tree gimple_divmod_fixed_value (gimple_assign, tree, int, gcov_type,
+				       gcov_type);
+static tree gimple_mod_pow2 (gimple_assign, int, gcov_type, gcov_type);
+static tree gimple_mod_subtract (gimple_assign, int, int, int, gcov_type,
+				 gcov_type, gcov_type);
 static bool gimple_divmod_fixed_value_transform (gimple_stmt_iterator *);
 static bool gimple_mod_pow2_value_transform (gimple_stmt_iterator *);
 static bool gimple_mod_subtract_transform (gimple_stmt_iterator *);
@@ -705,10 +706,11 @@ gimple_value_profile_transformations (void)
    alter the original STMT.  */
 
 static tree
-gimple_divmod_fixed_value (gimple stmt, tree value, int prob, gcov_type count,
-			   gcov_type all)
+gimple_divmod_fixed_value (gimple_assign stmt, tree value, int prob,
+			   gcov_type count, gcov_type all)
 {
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1, stmt2;
+  gimple_cond stmt3;
   tree tmp0, tmp1, tmp2;
   gimple bb1end, bb2end, bb3end;
   basic_block bb, bb2, bb3, bb4;
@@ -792,10 +794,10 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
   gcov_type val, count, all;
   tree result, value, tree_val;
   gcov_type prob;
-  gimple stmt;
+  gimple_assign stmt;
 
-  stmt = gsi_stmt (*si);
-  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+  stmt = gsi_stmt (*si)->dyn_cast_gimple_assign ();
+  if (!stmt)
     return false;
 
   if (!INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt))))
@@ -860,9 +862,10 @@ gimple_divmod_fixed_value_transform (gimple_stmt_iterator *si)
    within roundoff error).  This generates the result into a temp and returns
    the temp; it does not replace or alter the original STMT.  */
 static tree
-gimple_mod_pow2 (gimple stmt, int prob, gcov_type count, gcov_type all)
+gimple_mod_pow2 (gimple_assign stmt, int prob, gcov_type count, gcov_type all)
 {
-  gimple stmt1, stmt2, stmt3, stmt4;
+  gimple_assign stmt1, stmt2, stmt3;
+  gimple_cond stmt4;
   tree tmp2, tmp3;
   gimple bb1end, bb2end, bb3end;
   basic_block bb, bb2, bb3, bb4;
@@ -946,10 +949,10 @@ gimple_mod_pow2_value_transform (gimple_stmt_iterator *si)
   gcov_type count, wrong_values, all;
   tree lhs_type, result, value;
   gcov_type prob;
-  gimple stmt;
+  gimple_assign stmt;
 
-  stmt = gsi_stmt (*si);
-  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+  stmt = gsi_stmt (*si)->dyn_cast_gimple_assign ();
+  if (!stmt)
     return false;
 
   lhs_type = TREE_TYPE (gimple_assign_lhs (stmt));
@@ -1012,10 +1015,12 @@ gimple_mod_pow2_value_transform (gimple_stmt_iterator *si)
 /* FIXME: Generalize the interface to handle NCOUNTS > 1.  */
 
 static tree
-gimple_mod_subtract (gimple stmt, int prob1, int prob2, int ncounts,
+gimple_mod_subtract (gimple_assign stmt, int prob1, int prob2, int ncounts,
 		     gcov_type count1, gcov_type count2, gcov_type all)
 {
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1;
+  gimple stmt2;
+  gimple_cond stmt3;
   tree tmp1;
   gimple bb1end, bb2end = NULL, bb3end;
   basic_block bb, bb2, bb3, bb4;
@@ -1118,10 +1123,10 @@ gimple_mod_subtract_transform (gimple_stmt_iterator *si)
   gcov_type prob1, prob2;
   unsigned int i, steps;
   gcov_type count1, count2;
-  gimple stmt;
+  gimple_assign stmt;
 
-  stmt = gsi_stmt (*si);
-  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+  stmt = gsi_stmt (*si)->dyn_cast_gimple_assign ();
+  if (!stmt)
     return false;
 
   lhs_type = TREE_TYPE (gimple_assign_lhs (stmt));
@@ -1319,7 +1324,9 @@ gimple
 gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
 	   int prob, gcov_type count, gcov_type all)
 {
-  gimple dcall_stmt, load_stmt, cond_stmt;
+  gimple dcall_stmt;
+  gimple_assign load_stmt;
+  gimple_cond cond_stmt;
   tree tmp0, tmp1, tmp;
   basic_block cond_bb, dcall_bb, icall_bb, join_bb = NULL;
   tree optype = build_pointer_type (void_type_node);
-- 
1.8.5.3

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

* [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (76 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-09 18:32   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 33/89] Use more concrete types for various gimple statements David Malcolm
                   ` (13 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-loop-manip.c (add_exit_phi): Convert local "phi" to be a
	gimple_phi.
	(split_loop_exit_edge): Likewise for "phi" and "new_phi".
---
 gcc/tree-ssa-loop-manip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 5b78ca4..dbcc4ce 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -276,7 +276,7 @@ compute_live_loop_exits (bitmap live_exits, bitmap use_blocks,
 static void
 add_exit_phi (basic_block exit, tree var)
 {
-  gimple phi;
+  gimple_phi phi;
   edge e;
   edge_iterator ei;
 
@@ -627,7 +627,7 @@ split_loop_exit_edge (edge exit)
 {
   basic_block dest = exit->dest;
   basic_block bb = split_edge (exit);
-  gimple phi, new_phi;
+  gimple_phi phi, new_phi;
   tree new_name, name;
   use_operand_p op_p;
   gimple_phi_iterator psi;
-- 
1.8.5.3

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

* [PATCH 09/89] Introduce gimple_phi_iterator
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (70 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 27/89] Introduce gimple_eh_must_not_throw David Malcolm
@ 2014-04-21 17:14 ` David Malcolm
  2014-05-09 18:51   ` Jeff Law
  2014-04-21 17:14 ` [PATCH 55/89] Use gimple_call for callgraph edges David Malcolm
                   ` (19 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple-iterator.h (struct gimple_phi_iterator): New subclass of
	gimple_stmt_iterator with identical layout, but adding...
	(gimple_phi_iterator::phi): ...new method, equivalent to
	gsi_stmt (), but casting the underlying gimple to gimple_phi,
	checking that code == GIMPLE_PHI in a checked build.
	(gsi_start_phis): Return a gimple_phi_iterator, rather than just a
	gimple_stmt_iterator.

	* tree-if-conv.c (bb_with_exit_edge_p): Require a gimple_phi rather
	than just a gimple.
	(if_convertible_phi_p): Likewise.
	* tree-phinodes.h (add_phi_node_to_bb): Likewise.
	* tree-ssa-phiprop.c (propagate_with_phi): Likewise.

	* tree-ssa-uninit.c (warn_uninitialized_phi): Require a gimple_phi
	and a vec<gimple_phi> *, rather than just a gimple and vec<gimple> *.
	(find_uninit_use): Likewise; add checked cast to gimple_phi when
	adding to worklist.
	(execute_late_warn_uninitialized): Strengthen types of various locals,
	"worklist" from vec<gimple> to vec<gimple_phi>, "gsi" to a
	gimple_phi_iterator, and "phi" and "cur_phi" to a gimple_phi.

	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Require a
	gimple_phi_iterator * rather than a gimple_stmt_iterator *;
	use it to strengthen local from a gimple to a gimple_phi.

	* cfgloop.c (find_subloop_latch_edge_by_ivs): Convert local from a
	gimple_stmt_iterator to a gimple_phi_iterator.  Use the iterator's
	"phi" method rather than gsi_stmt.  Use this checked cast to convert
	the type of related local from a plain gimple to a gimple_phi.
	* gimple-pretty-print.c (dump_phi_nodes): Likewise.
	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behaviour):
	Likewise.
	* sese.c (sese_add_exit_phis_edge): Likewise.
	* tree-cfg.c (reinstall_phi_args): Likewise.
	(gimple_make_forwarder_block): Likewise.
	(add_phi_args_after_copy_edge): Likewise.
	(gimple_lv_adjust_loop_header_phi): Likewise.
	* tree-cfgcleanup.c (phi_alternatives_equal): Likewise.
	(remove_forwarder_block_with_phi): Likewise.
	(merge_phi_nodes): Likewise.
	* tree-complex.c (update_phi_components): Likewise.
	* tree-if-conv.c (if_convertible_loop_p_1): Likewise.
	* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
	(copy_phis_for_bb): Likewise.
	* tree-into-ssa.c (rewrite_add_phi_arguments): Likewise.
	* tree-outof-ssa.c (eliminate_build): Likewise.
	(eliminate_useless_phis): Likewise.
	(rewrite_trees): Likewise.
	(insert_backedge_copies): Likewise.
	* tree-phinodes.c (reserve_phi_args_for_new_edge): Likewise.
	(remove_phi_args): Likewise.
	(remove_phi_nodes): Likewise.
	* tree-predcom.c (find_looparound_phi): Likewise.
	(eliminate_temp_copies): Likewise.
	* tree-scalar-evolution.c (loop_closed_phi_def): Likewise.
	(scev_const_prop): Likewise; also, add checked cast to phi.
	* tree-ssa-coalesce.c (coalesce_partitions): Likewise.
	* tree-ssa-dce.c (remove_dead_phis): Likewise.
	(forward_edge_to_pdom): Likewise.
	* tree-ssa-dom.c (record_equivalences_from_phis): Likewise.
	(cprop_into_successor_phis): Likewise.
	(propagate_rhs_into_lhs): Likewise.
	(eliminate_degenerate_phis_1): Likewise.
	* tree-ssa-ifcombine.c (same_phi_args_p): Likewise.
	* tree-ssa-live.c (calculate_live_on_exit): Likewise.
	(verify_live_on_entry): Likewise.
	* tree-ssa-loop-im.c
	(move_computations_dom_walker::before_dom_children): Likewise.
	* tree-ssa-loop-ivopts.c (find_bivs): Likewise.
	(mark_bivs): Likewise.
	(find_interesting_uses_outside): Likewise.
	(determine_set_costs): Likewise.
	* tree-ssa-loop-manip.c (split_loop_exit_edge): Likewise.
	(tree_transform_and_unroll_loop): Likewise.
	(rewrite_all_phi_nodes_with_iv): Likewise.
	(canonicalize_loop_ivs): Likewise.
	* tree-ssa-loop-niter.c (determine_value_range): Likewise.
	* tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise.
	* tree-ssa-phiprop.c (tree_ssa_phiprop): Likewise.
	* tree-ssa-reassoc.c (suitable_cond_bb): Likewise.
	* tree-ssa-tail-merge.c (same_phi_alternatives_1): Likewise.
	(vop_phi): Likewise.
	* tree-ssa-threadedge.c (record_temporary_equivalences_from_phis):
	Likewise.
	* tree-ssa-threadupdate.c (copy_phi_arg_into_existing_phi): Likewise.
	(copy_phi_args): Likewise.
	(phi_args_equal_on_edges): Likewise.
	* tree-ssa.c (ssa_redirect_edge): Likewise.
	(flush_pending_stmts): Likewise.
	* tree-switch-conversion.c (check_final_bb): Likewise.
	(gather_default_values): Likewise.
	(build_constructors): Likewise.
	(fix_phi_nodes): Likewise.
	* tree-tailcall.c (propagate_through_phis): Likewise.
	(add_successor_phi_arg): Likewise.
	* tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard1):
	Likewise.
	(slpeel_update_phi_nodes_for_guard2): Likewise.
	(slpeel_tree_peel_loop_to_edge): Likewise.
	(vect_can_advance_ivs_p): Likewise.
	(vect_update_ivs_after_vectorizer): Likewise.
	* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Likewise.
	* tree-vrp.c (find_assert_locations): Likewise.
	* value-prof.c (gimple_ic): Likewise.

	* omp-low.c (expand_parallel_call): Convert local to a gimple_phi.
---
 gcc/cfgloop.c                  |  6 +++---
 gcc/gimple-iterator.c          | 12 ++++++++++--
 gcc/gimple-iterator.h          | 11 ++++++++++-
 gcc/gimple-pretty-print.c      |  4 ++--
 gcc/gimple-ssa-isolate-paths.c |  4 ++--
 gcc/omp-low.c                  |  2 +-
 gcc/sese.c                     |  2 +-
 gcc/tree-cfg.c                 | 26 +++++++++++++-------------
 gcc/tree-cfgcleanup.c          | 12 ++++++------
 gcc/tree-complex.c             |  4 ++--
 gcc/tree-if-conv.c             |  6 +++---
 gcc/tree-inline.c              | 14 +++++++-------
 gcc/tree-into-ssa.c            |  6 +++---
 gcc/tree-outof-ssa.c           | 16 ++++++++--------
 gcc/tree-phinodes.c            | 13 ++++++-------
 gcc/tree-phinodes.h            |  2 +-
 gcc/tree-predcom.c             | 14 ++++++++------
 gcc/tree-scalar-evolution.c    | 17 +++++++++--------
 gcc/tree-ssa-coalesce.c        |  4 ++--
 gcc/tree-ssa-dce.c             | 10 +++++-----
 gcc/tree-ssa-dom.c             | 17 +++++++++--------
 gcc/tree-ssa-ifcombine.c       |  6 +++---
 gcc/tree-ssa-live.c            |  8 ++++----
 gcc/tree-ssa-loop-im.c         |  4 ++--
 gcc/tree-ssa-loop-ivopts.c     | 20 ++++++++++----------
 gcc/tree-ssa-loop-manip.c      | 24 +++++++++++++-----------
 gcc/tree-ssa-loop-niter.c      |  4 ++--
 gcc/tree-ssa-phiopt.c          |  4 ++--
 gcc/tree-ssa-phiprop.c         |  6 +++---
 gcc/tree-ssa-reassoc.c         |  4 ++--
 gcc/tree-ssa-tail-merge.c      |  8 ++++----
 gcc/tree-ssa-threadedge.c      |  4 ++--
 gcc/tree-ssa-threadupdate.c    | 16 ++++++++--------
 gcc/tree-ssa-uninit.c          | 16 ++++++++--------
 gcc/tree-ssa.c                 | 12 ++++++------
 gcc/tree-switch-conversion.c   | 16 ++++++++--------
 gcc/tree-tailcall.c            |  8 ++++----
 gcc/tree-vect-loop-manip.c     | 34 +++++++++++++++++-----------------
 gcc/tree-vect-loop.c           |  4 ++--
 gcc/tree-vrp.c                 |  4 ++--
 gcc/value-prof.c               |  4 ++--
 41 files changed, 215 insertions(+), 193 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 70744d8..4391dd9 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -577,8 +577,8 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec<edge> la
 {
   edge e, latch = latches[0];
   unsigned i;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree lop;
   basic_block bb;
 
@@ -596,7 +596,7 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec<edge> la
      a subloop.  */
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       lop = PHI_ARG_DEF_FROM_EDGE (phi, latch);
 
       /* Ignore the values that are not changed inside the subloop.  */
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index 1cfeb73..95fbad3 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -874,9 +874,17 @@ gsi_commit_one_edge_insert (edge e, basic_block *new_bb)
 
 /* Returns iterator at the start of the list of phi nodes of BB.  */
 
-gimple_stmt_iterator
+gimple_phi_iterator
 gsi_start_phis (basic_block bb)
 {
   gimple_seq *pseq = phi_nodes_ptr (bb);
-  return gsi_start_1 (pseq);
+
+  /* Adapted from gsi_start_1. */
+  gimple_phi_iterator i;
+
+  i.ptr = gimple_seq_first (*pseq);
+  i.seq = pseq;
+  i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
+
+  return i;
 }
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index c35dc81..735b6a0 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -34,6 +34,15 @@ struct gimple_stmt_iterator
   gimple_seq *seq;
   basic_block bb;
 };
+
+/* Iterator over GIMPLE_PHI statements.  */
+struct gimple_phi_iterator : public gimple_stmt_iterator
+{
+  gimple_phi phi () const
+  {
+    return as_a <gimple_statement_phi> (ptr);
+  }
+};
  
 enum gsi_iterator_update
 {
@@ -79,7 +88,7 @@ extern basic_block gsi_insert_on_edge_immediate (edge, gimple);
 extern basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
 extern void gsi_commit_edge_inserts (void);
 extern void gsi_commit_one_edge_insert (edge, basic_block *);
-extern gimple_stmt_iterator gsi_start_phis (basic_block);
+extern gimple_phi_iterator gsi_start_phis (basic_block);
 
 /* Return a new iterator pointing to GIMPLE_SEQ's first statement.  */
 
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index c0f6ba9..bf5f286 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2303,11 +2303,11 @@ dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
 static void
 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
 {
-  gimple_stmt_iterator i;
+  gimple_phi_iterator i;
 
   for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
     {
-      gimple phi = gsi_stmt (i);
+      gimple_phi phi = i.phi ();
       if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
         {
           INDENT (indent);
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 56fcfc8..4e2b8a8 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -217,7 +217,7 @@ find_implicit_erroneous_behaviour (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator si;
+      gimple_phi_iterator si;
 
       /* Out of an abundance of caution, do not isolate paths to a
 	 block where the block has any abnormal outgoing edges.
@@ -236,7 +236,7 @@ find_implicit_erroneous_behaviour (void)
 	 cases.   */
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
 	{
-	  gimple phi = gsi_stmt (si);
+	  gimple_phi phi = si.phi ();
 	  tree lhs = gimple_phi_result (phi);
 
 	  /* If the result is not a pointer, then there is no need to
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 59e632f..cbf13d2 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4280,7 +4280,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb,
 
 	  if (gimple_in_ssa_p (cfun))
 	    {
-	      gimple phi = create_phi_node (tmp_join, bb);
+	      gimple_phi phi = create_phi_node (tmp_join, bb);
 	      add_phi_arg (phi, tmp_then, e_then, UNKNOWN_LOCATION);
 	      add_phi_arg (phi, tmp_else, e_else, UNKNOWN_LOCATION);
 	    }
diff --git a/gcc/sese.c b/gcc/sese.c
index 342c5e8..eb34c41 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -346,7 +346,7 @@ free_sese (sese region)
 static void
 sese_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e)
 {
-  gimple phi = create_phi_node (NULL_TREE, exit);
+  gimple_phi phi = create_phi_node (NULL_TREE, exit);
   create_new_def_for (use, phi, gimple_phi_result_ptr (phi));
   add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION);
   add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index f42d10b..53c4808 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2554,7 +2554,7 @@ reinstall_phi_args (edge new_edge, edge old_edge)
   edge_var_map_vector *v;
   edge_var_map *vm;
   int i;
-  gimple_stmt_iterator phis;
+  gimple_phi_iterator phis;
 
   v = redirect_edge_var_map_vector (old_edge);
   if (!v)
@@ -2564,7 +2564,7 @@ reinstall_phi_args (edge new_edge, edge old_edge)
        v->iterate (i, &vm) && !gsi_end_p (phis);
        i++, gsi_next (&phis))
     {
-      gimple phi = gsi_stmt (phis);
+      gimple_phi phi = phis.phi ();
       tree result = redirect_edge_var_map_result (vm);
       tree arg = redirect_edge_var_map_def (vm);
 
@@ -5272,7 +5272,7 @@ gimple_make_forwarder_block (edge fallthru)
   edge_iterator ei;
   basic_block dummy, bb;
   tree var;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   dummy = fallthru->src;
   bb = fallthru->dest;
@@ -5284,9 +5284,9 @@ gimple_make_forwarder_block (edge fallthru)
      start of BB.  */
   for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi, new_phi;
+      gimple_phi phi, new_phi;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       var = gimple_phi_result (phi);
       new_phi = create_phi_node (var, bb);
       gimple_phi_set_result (phi, copy_ssa_name (var, phi));
@@ -5753,9 +5753,9 @@ add_phi_args_after_copy_edge (edge e_copy)
   basic_block bb, bb_copy = e_copy->src, dest;
   edge e;
   edge_iterator ei;
-  gimple phi, phi_copy;
+  gimple_phi phi, phi_copy;
   tree def;
-  gimple_stmt_iterator psi, psi_copy;
+  gimple_phi_iterator psi, psi_copy;
 
   if (gimple_seq_empty_p (phi_nodes (e_copy->dest)))
     return;
@@ -5788,8 +5788,8 @@ add_phi_args_after_copy_edge (edge e_copy)
        !gsi_end_p (psi);
        gsi_next (&psi), gsi_next (&psi_copy))
     {
-      phi = gsi_stmt (psi);
-      phi_copy = gsi_stmt (psi_copy);
+      phi = psi.phi ();
+      phi_copy = psi_copy.phi ();
       def = PHI_ARG_DEF_FROM_EDGE (phi, e);
       add_phi_arg (phi_copy, def, e_copy,
 		   gimple_phi_arg_location_from_edge (phi, e));
@@ -7903,8 +7903,8 @@ static void
 gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second,
 				  basic_block new_head, edge e)
 {
-  gimple phi1, phi2;
-  gimple_stmt_iterator psi1, psi2;
+  gimple_phi phi1, phi2;
+  gimple_phi_iterator psi1, psi2;
   tree def;
   edge e2 = find_edge (new_head, second);
 
@@ -7920,8 +7920,8 @@ gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second,
        !gsi_end_p (psi2) && !gsi_end_p (psi1);
        gsi_next (&psi2),  gsi_next (&psi1))
     {
-      phi1 = gsi_stmt (psi1);
-      phi2 = gsi_stmt (psi2);
+      phi1 = psi1.phi ();
+      phi2 = psi2.phi ();
       def = PHI_ARG_DEF (phi2, e2->dest_idx);
       add_phi_arg (phi1, def, e, gimple_phi_arg_location_from_edge (phi2, e2));
     }
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 08401dd..64aeb6a 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -347,11 +347,11 @@ phi_alternatives_equal (basic_block dest, edge e1, edge e2)
 {
   int n1 = e1->dest_idx;
   int n2 = e2->dest_idx;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree val1 = gimple_phi_arg_def (phi, n1);
       tree val2 = gimple_phi_arg_def (phi, n2);
 
@@ -830,7 +830,7 @@ remove_forwarder_block_with_phi (basic_block bb)
   while (EDGE_COUNT (bb->preds) > 0)
     {
       edge e = EDGE_PRED (bb, 0), s;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       s = find_edge (e->src, dest);
       if (s)
@@ -862,7 +862,7 @@ remove_forwarder_block_with_phi (basic_block bb)
 	   !gsi_end_p (gsi);
 	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree def = gimple_phi_arg_def (phi, succ->dest_idx);
 	  source_location locus = gimple_phi_arg_location_from_edge (phi, succ);
 
@@ -984,7 +984,7 @@ merge_phi_nodes (void)
 	}
       else
 	{
-	  gimple_stmt_iterator gsi;
+	  gimple_phi_iterator gsi;
 	  unsigned int dest_idx = single_succ_edge (bb)->dest_idx;
 
 	  /* BB dominates DEST.  There may be many users of the PHI
@@ -995,7 +995,7 @@ merge_phi_nodes (void)
 	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      tree result = gimple_phi_result (phi);
 	      use_operand_p imm_use;
 	      gimple use_stmt;
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 4a657c0..5b54721 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -724,11 +724,11 @@ update_parameter_components (void)
 static void
 update_phi_components (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       if (is_complex_reg (gimple_phi_result (phi)))
 	{
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 0dc340f..6fe69ae 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -485,7 +485,7 @@ bb_with_exit_edge_p (struct loop *loop, basic_block bb)
    - there is a virtual PHI in a BB other than the loop->header.  */
 
 static bool
-if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi,
+if_convertible_phi_p (struct loop *loop, basic_block bb, gimple_phi phi,
 		      bool any_mask_load_store)
 {
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1251,10 +1251,10 @@ if_convertible_loop_p_1 (struct loop *loop,
   for (i = 0; i < loop->num_nodes; i++)
     {
       basic_block bb = ifc_bbs[i];
-      gimple_stmt_iterator itr;
+      gimple_phi_iterator itr;
 
       for (itr = gsi_start_phis (bb); !gsi_end_p (itr); gsi_next (&itr))
-	if (!if_convertible_phi_p (loop, bb, gsi_stmt (itr),
+	if (!if_convertible_phi_p (loop, bb, itr.phi (),
 				   *any_mask_load_store))
 	  return false;
     }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 4d3c2ff..9cea36c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1923,8 +1923,8 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
     if (!e->dest->aux
 	|| ((basic_block)e->dest->aux)->index == ENTRY_BLOCK)
       {
-	gimple phi;
-	gimple_stmt_iterator si;
+	gimple_phi phi;
+	gimple_phi_iterator si;
 
 	if (!nonlocal_goto)
 	  gcc_assert (e->flags & EDGE_EH);
@@ -1936,7 +1936,7 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
 	  {
 	    edge re;
 
-	    phi = gsi_stmt (si);
+	    phi = si.phi ();
 
 	    /* For abnormal goto/call edges the receiver can be the
 	       ENTRY_BLOCK.  Do not assert this cannot happen.  */
@@ -2089,17 +2089,17 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
 {
   basic_block const new_bb = (basic_block) bb->aux;
   edge_iterator ei;
-  gimple phi;
-  gimple_stmt_iterator si;
+  gimple_phi phi;
+  gimple_phi_iterator si;
   edge new_edge;
   bool inserted = false;
 
   for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
     {
       tree res, new_res;
-      gimple new_phi;
+      gimple_phi new_phi;
 
-      phi = gsi_stmt (si);
+      phi = si.phi ();
       res = PHI_RESULT (phi);
       new_res = res;
       if (!virtual_operand_p (res))
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index f12a246..dfe9108 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1394,8 +1394,8 @@ rewrite_add_phi_arguments (basic_block bb)
 
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
-      gimple phi;
-      gimple_stmt_iterator gsi;
+      gimple_phi phi;
+      gimple_phi_iterator gsi;
 
       for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi);
 	   gsi_next (&gsi))
@@ -1403,7 +1403,7 @@ rewrite_add_phi_arguments (basic_block bb)
 	  tree currdef, res;
 	  location_t loc;
 
-	  phi = gsi_stmt (gsi);
+	  phi = gsi.phi ();
 	  res = gimple_phi_result (phi);
 	  currdef = get_reaching_def (SSA_NAME_VAR (res));
 	  /* Virtual operand PHI args do not need a location.  */
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index d5a635b..7f87ffc 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -581,13 +581,13 @@ eliminate_build (elim_graph g)
 {
   tree Ti;
   int p0, pi;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   clear_elim_graph (g);
 
   for (gsi = gsi_start_phis (g->e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       source_location locus;
 
       p0 = var_to_partition (g->map, gimple_phi_result (phi));
@@ -832,14 +832,14 @@ static void
 eliminate_useless_phis (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   tree result;
 
   FOR_EACH_BB_FN (bb, cfun)
     {
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
         {
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  result = gimple_phi_result (phi);
 	  if (virtual_operand_p (result))
 	    {
@@ -895,10 +895,10 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
      create incorrect code.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree T0 = var_to_partition_to_var (map, gimple_phi_result (phi));
 	  if (T0 == NULL_TREE)
 	    {
@@ -1097,7 +1097,7 @@ static void
 insert_backedge_copies (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   mark_dfs_back_edges ();
 
@@ -1108,7 +1108,7 @@ insert_backedge_copies (void)
 
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree result = gimple_phi_result (phi);
 	  size_t i;
 
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 26f5793..222b4ed 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -292,12 +292,11 @@ reserve_phi_args_for_new_edge (basic_block bb)
 {
   size_t len = EDGE_COUNT (bb->preds);
   size_t cap = ideal_phi_node_len (len + 4);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple_phi stmt =
-	as_a <gimple_statement_phi> (gsi_stmt (gsi));
+      gimple_phi stmt = gsi.phi ();
 
       if (len > gimple_phi_capacity (stmt))
 	{
@@ -328,7 +327,7 @@ reserve_phi_args_for_new_edge (basic_block bb)
 /* Adds PHI to BB.  */
 
 void
-add_phi_node_to_bb (gimple phi, basic_block bb)
+add_phi_node_to_bb (gimple_phi phi, basic_block bb)
 {
   gimple_seq seq = phi_nodes (bb);
   /* Add the new PHI node to the list of PHI nodes for block BB.  */
@@ -433,10 +432,10 @@ remove_phi_arg_num (gimple_phi phi, int i)
 void
 remove_phi_args (edge e)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    remove_phi_arg_num (as_a <gimple_statement_phi> (gsi_stmt (gsi)),
+    remove_phi_arg_num (gsi.phi (),
 			e->dest_idx);
 }
 
@@ -468,7 +467,7 @@ remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p)
 void
 remove_phi_nodes (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
     remove_phi_node (&gsi, true);
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index 0159d5d..fe8b32d 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 extern void phinodes_print_statistics (void);
 extern void release_phi_node (gimple);
 extern void reserve_phi_args_for_new_edge (basic_block);
-extern void add_phi_node_to_bb (gimple phi, basic_block bb);
+extern void add_phi_node_to_bb (gimple_phi phi, basic_block bb);
 extern gimple_phi create_phi_node (tree, basic_block);
 extern void add_phi_arg (gimple, tree, edge, source_location);
 extern void remove_phi_args (edge);
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 730bad4..e859959 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1116,10 +1116,11 @@ static gimple
 find_looparound_phi (struct loop *loop, dref ref, dref root)
 {
   tree name, init, init_ref;
-  gimple phi = NULL, init_stmt;
+  gimple_phi phi = NULL;
+  gimple init_stmt;
   edge latch = loop_latch_edge (loop);
   struct data_reference init_dr;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   if (is_gimple_assign (ref->stmt))
     {
@@ -1135,7 +1136,7 @@ find_looparound_phi (struct loop *loop, dref ref, dref root)
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, latch) == name)
 	break;
     }
@@ -1887,14 +1888,15 @@ static void
 eliminate_temp_copies (struct loop *loop, bitmap tmp_vars)
 {
   edge e;
-  gimple phi, stmt;
+  gimple_phi phi;
+  gimple stmt;
   tree name, use, var;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   e = loop_latch_edge (loop);
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       name = PHI_RESULT (phi);
       var = SSA_NAME_VAR (name);
       if (!var || !bitmap_bit_p (tmp_vars, DECL_UID (var)))
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index f1ddc24..fd51156 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -2239,8 +2239,8 @@ loop_closed_phi_def (tree var)
 {
   struct loop *loop;
   edge exit;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
 
   if (var == NULL_TREE
       || TREE_CODE (var) != SSA_NAME)
@@ -2253,7 +2253,7 @@ loop_closed_phi_def (tree var)
 
   for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, exit) == var)
 	return PHI_RESULT (phi);
     }
@@ -3342,11 +3342,12 @@ scev_const_prop (void)
 {
   basic_block bb;
   tree name, type, ev;
-  gimple phi, ass;
+  gimple_phi phi;
+  gimple ass;
   struct loop *loop, *ex_loop;
   bitmap ssa_names_to_remove = NULL;
   unsigned i;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   if (number_of_loops (cfun) <= 1)
     return 0;
@@ -3357,7 +3358,7 @@ scev_const_prop (void)
 
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
 	{
-	  phi = gsi_stmt (psi);
+	  phi = psi.phi ();
 	  name = PHI_RESULT (phi);
 
 	  if (virtual_operand_p (name))
@@ -3395,7 +3396,7 @@ scev_const_prop (void)
 	{
 	  gimple_stmt_iterator psi;
 	  name = ssa_name (i);
-	  phi = SSA_NAME_DEF_STMT (name);
+	  phi = SSA_NAME_DEF_STMT (name)->as_a_gimple_phi ();
 
 	  gcc_assert (gimple_code (phi) == GIMPLE_PHI);
 	  psi = gsi_for_stmt (phi);
@@ -3433,7 +3434,7 @@ scev_const_prop (void)
 
       for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); )
 	{
-	  phi = gsi_stmt (psi);
+	  phi = psi.phi ();
 	  rslt = PHI_RESULT (phi);
 	  def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
 	  if (virtual_operand_p (def))
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index 9a1ac67..c42a8eb 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -1188,11 +1188,11 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
       FOR_EACH_EDGE (e, ei, bb->preds)
 	if (e->flags & EDGE_ABNORMAL)
 	  {
-	    gimple_stmt_iterator gsi;
+	    gimple_phi_iterator gsi;
 	    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 		 gsi_next (&gsi))
 	      {
-		gimple phi = gsi_stmt (gsi);
+		gimple_phi phi = gsi.phi ();
 		tree res = PHI_RESULT (phi);
 	        tree arg = PHI_ARG_DEF (phi, e->dest_idx);
 		int v1 = SSA_NAME_VERSION (res);
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 13a71ce..c5a530b 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -929,13 +929,13 @@ static bool
 remove_dead_phis (basic_block bb)
 {
   bool something_changed = false;
-  gimple phi;
-  gimple_stmt_iterator gsi;
+  gimple_phi phi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);)
     {
       stats.total_phis++;
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
 
       /* We do not track necessity of virtual PHI nodes.  Instead do
          very simple dead PHI removal here.  */
@@ -987,7 +987,7 @@ remove_dead_phis (basic_block bb)
 static edge
 forward_edge_to_pdom (edge e, basic_block post_dom_bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   edge e2 = NULL;
   edge_iterator ei;
 
@@ -1011,7 +1011,7 @@ forward_edge_to_pdom (edge e, basic_block post_dom_bb)
 	  break;
       for (gsi = gsi_start_phis (post_dom_bb); !gsi_end_p (gsi);)
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree op;
 	  source_location locus;
 
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 24099cc..b483289 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1190,11 +1190,11 @@ dom_opt_dom_walker::thread_across_edge (edge e)
 static void
 record_equivalences_from_phis (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       tree lhs = gimple_phi_result (phi);
       tree rhs = NULL;
@@ -1714,7 +1714,7 @@ cprop_into_successor_phis (basic_block bb)
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
       int indx;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       /* If this is an abnormal edge, then we do not want to copy propagate
 	 into the PHI alternative associated with this edge.  */
@@ -1753,7 +1753,7 @@ cprop_into_successor_phis (basic_block bb)
 	  tree new_val;
 	  use_operand_p orig_p;
 	  tree orig_val;
-          gimple phi = gsi_stmt (gsi);
+          gimple_phi phi = gsi.phi ();
 
 	  /* The alternative may be associated with a constant, so verify
 	     it is an SSA_NAME before doing anything with it.  */
@@ -2866,7 +2866,8 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
 		  edge te = find_taken_edge (bb, val);
 		  edge_iterator ei;
 		  edge e;
-		  gimple_stmt_iterator gsi, psi;
+		  gimple_stmt_iterator gsi;
+		  gimple_phi_iterator psi;
 
 		  /* Remove all outgoing edges except TE.  */
 		  for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei));)
@@ -2879,7 +2880,7 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
                                !gsi_end_p (psi);
                                gsi_next (&psi))
                             {
-                              gimple phi = gsi_stmt (psi);
+                              gimple_phi phi = psi.phi ();
 
 			      tree result = gimple_phi_result (phi);
 			      int version = SSA_NAME_VERSION (result);
@@ -2989,12 +2990,12 @@ eliminate_const_or_copy (gimple stmt, bitmap interesting_names)
 static void
 eliminate_degenerate_phis_1 (basic_block bb, bitmap interesting_names)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   basic_block son;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       eliminate_const_or_copy (phi, interesting_names);
     }
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index 1a060b5..756bda2 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -154,12 +154,12 @@ same_phi_args_p (basic_block bb1, basic_block bb2, basic_block dest)
 {
   edge e1 = find_edge (bb1, dest);
   edge e2 = find_edge (bb2, dest);
-  gimple_stmt_iterator gsi;
-  gimple phi;
+  gimple_phi_iterator gsi;
+  gimple_phi phi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       if (!operand_equal_p (PHI_ARG_DEF_FROM_EDGE (phi, e1),
 			    PHI_ARG_DEF_FROM_EDGE (phi, e2), 0))
         return false;
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 3cd3613..2c431e7 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1156,13 +1156,13 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
   /* Set all the live-on-exit bits for uses in PHIs.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       size_t i;
 
       /* Mark the PHI arguments which are live on exit to the pred block.  */
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  for (i = 0; i < gimple_phi_num_args (phi); i++)
 	    {
 	      tree t = PHI_ARG_DEF (phi, i);
@@ -1435,12 +1435,12 @@ verify_live_on_entry (tree_live_info_p live)
 		   if it occurs in a PHI argument of the block.  */
 		size_t z;
 		bool ok = false;
-		gimple_stmt_iterator gsi;
+		gimple_phi_iterator gsi;
 		for (gsi = gsi_start_phis (e->dest);
 		     !gsi_end_p (gsi) && !ok;
 		     gsi_next (&gsi))
 		  {
-		    gimple phi = gsi_stmt (gsi);
+		    gimple_phi phi = gsi.phi ();
 		    for (z = 0; z < gimple_phi_num_args (phi); z++)
 		      if (var == gimple_phi_arg_def (phi, z))
 			{
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index c75f257..aa51afb 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1251,11 +1251,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
 	{
 	  /* The new VUSE is the one from the virtual PHI in the loop
 	     header or the one already present.  */
-	  gimple_stmt_iterator gsi2;
+	  gimple_phi_iterator gsi2;
 	  for (gsi2 = gsi_start_phis (e->dest);
 	       !gsi_end_p (gsi2); gsi_next (&gsi2))
 	    {
-	      gimple phi = gsi_stmt (gsi2);
+	      gimple_phi phi = gsi2.phi ();
 	      if (virtual_operand_p (gimple_phi_result (phi)))
 		{
 		  gimple_set_vuse (stmt, PHI_ARG_DEF_FROM_EDGE (phi, e));
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 14ba20f..ea18311 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1033,11 +1033,11 @@ find_bivs (struct ivopts_data *data)
   tree step, type, base;
   bool found = false;
   struct loop *loop = data->current_loop;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
 
       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (PHI_RESULT (phi)))
 	continue;
@@ -1079,11 +1079,11 @@ mark_bivs (struct ivopts_data *data)
   struct iv *iv, *incr_iv;
   struct loop *loop = data->current_loop;
   basic_block incr_bb;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
 
       iv = get_iv (data, PHI_RESULT (phi));
       if (!iv)
@@ -1964,13 +1964,13 @@ find_interesting_uses_stmt (struct ivopts_data *data, gimple stmt)
 static void
 find_interesting_uses_outside (struct ivopts_data *data, edge exit)
 {
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree def;
 
   for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
       if (!virtual_operand_p (def))
         find_interesting_uses_op (data, def);
@@ -5177,8 +5177,8 @@ static void
 determine_set_costs (struct ivopts_data *data)
 {
   unsigned j, n;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree op;
   struct loop *loop = data->current_loop;
   bitmap_iterator bi;
@@ -5195,7 +5195,7 @@ determine_set_costs (struct ivopts_data *data)
   n = 0;
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       op = PHI_RESULT (phi);
 
       if (virtual_operand_p (op))
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 9dcbc53..5b78ca4 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -630,12 +630,12 @@ split_loop_exit_edge (edge exit)
   gimple phi, new_phi;
   tree new_name, name;
   use_operand_p op_p;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
   source_location locus;
 
   for (psi = gsi_start_phis (dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, single_succ_edge (bb));
       locus = gimple_phi_arg_location_from_edge (phi, single_succ_edge (bb));
 
@@ -1034,8 +1034,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   tree ctr_before, ctr_after;
   tree enter_main_cond, exit_base, exit_step, exit_bound;
   enum tree_code exit_cmp;
-  gimple phi_old_loop, phi_new_loop, phi_rest;
-  gimple_stmt_iterator psi_old_loop, psi_new_loop;
+  gimple_phi phi_old_loop, phi_new_loop, phi_rest;
+  gimple_phi_iterator psi_old_loop, psi_new_loop;
   tree init, next, new_init;
   struct loop *new_loop;
   basic_block rest, exit_bb;
@@ -1142,8 +1142,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
        !gsi_end_p (psi_old_loop);
        gsi_next (&psi_old_loop), gsi_next (&psi_new_loop))
     {
-      phi_old_loop = gsi_stmt (psi_old_loop);
-      phi_new_loop = gsi_stmt (psi_new_loop);
+      phi_old_loop = psi_old_loop.phi ();
+      phi_new_loop = psi_new_loop.phi ();
 
       init = PHI_ARG_DEF_FROM_EDGE (phi_old_loop, old_entry);
       op = PHI_ARG_DEF_PTR_FROM_EDGE (phi_new_loop, new_entry);
@@ -1259,12 +1259,13 @@ tree_unroll_loop (struct loop *loop, unsigned factor,
 
 static void
 rewrite_phi_with_iv (loop_p loop,
-		     gimple_stmt_iterator *psi,
+		     gimple_phi_iterator *psi,
 		     gimple_stmt_iterator *gsi,
 		     tree main_iv)
 {
   affine_iv iv;
-  gimple stmt, phi = gsi_stmt (*psi);
+  gimple stmt;
+  gimple_phi phi = psi->phi ();
   tree atype, mtype, val, res = PHI_RESULT (phi);
 
   if (virtual_operand_p (res) || res == main_iv)
@@ -1302,7 +1303,7 @@ rewrite_all_phi_nodes_with_iv (loop_p loop, tree main_iv)
 {
   unsigned i;
   basic_block *bbs = get_loop_body_in_dom_order (loop);
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (i = 0; i < loop->num_nodes; i++)
     {
@@ -1335,7 +1336,8 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
   unsigned original_precision = precision;
   tree type, var_before;
-  gimple_stmt_iterator gsi, psi;
+  gimple_stmt_iterator gsi;
+  gimple_phi_iterator psi;
   gimple stmt;
   edge exit = single_dom_exit (loop);
   gimple_seq stmts;
@@ -1345,7 +1347,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   for (psi = gsi_start_phis (loop->header);
        !gsi_end_p (psi); gsi_next (&psi))
     {
-      gimple phi = gsi_stmt (psi);
+      gimple_phi phi = psi.phi ();
       tree res = PHI_RESULT (phi);
       bool uns;
 
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 7628363..76113dd 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -149,7 +149,7 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off,
   if (TREE_CODE (var) == SSA_NAME && INTEGRAL_TYPE_P (type))
     {
       edge e = loop_preheader_edge (loop);
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       /* Either for VAR itself...  */
       rtype = get_range_info (var, &minv, &maxv);
@@ -157,7 +157,7 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off,
 	 PHI argument from the loop preheader edge.  */
       for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  double_int minc, maxc;
 	  if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var
 	      && (get_range_info (gimple_phi_result (phi), &minc, &maxc)
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 95cf4d4..da1cd37 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -2044,14 +2044,14 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1,
 {
   int param_align = PARAM_VALUE (PARAM_L1_CACHE_LINE_SIZE);
   unsigned param_align_bits = (unsigned) (param_align * BITS_PER_UNIT);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Walk the phis in bb3 looking for an opportunity.  We are looking
      for phis of two SSA names, one each of which is defined in bb1 and
      bb2.  */
   for (gsi = gsi_start_phis (bb3); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi_stmt = gsi_stmt (gsi);
+      gimple_phi phi_stmt = gsi.phi ();
       gimple def1, def2, defswap;
       tree arg1, arg2, ref1, ref2, field1, field2, fieldswap;
       tree tree_offset1, tree_offset2, tree_size2, next;
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index 4d66c12..f3dc67f 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -247,7 +247,7 @@ phiprop_insert_phi (basic_block bb, gimple phi, gimple use_stmt,
    with aliasing issues as we are moving memory reads.  */
 
 static bool
-propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn,
+propagate_with_phi (basic_block bb, gimple_phi phi, struct phiprop_d *phivn,
 		    size_t n)
 {
   tree ptr = PHI_RESULT (phi);
@@ -381,7 +381,7 @@ tree_ssa_phiprop (void)
   struct phiprop_d *phivn;
   bool did_something = false;
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   unsigned i;
   size_t n;
 
@@ -396,7 +396,7 @@ tree_ssa_phiprop (void)
 				  single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
   FOR_EACH_VEC_ELT (bbs, i, bb)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n);
+      did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n);
 
   if (did_something)
     gsi_commit_edge_inserts ();
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index e9e29e5..c8421b7 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2462,7 +2462,7 @@ suitable_cond_bb (basic_block bb, basic_block test_bb, basic_block *other_bb,
   edge_iterator ei, ei2;
   edge e, e2;
   gimple stmt;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   bool other_edge_seen = false;
   bool is_cond;
 
@@ -2524,7 +2524,7 @@ suitable_cond_bb (basic_block bb, basic_block test_bb, basic_block *other_bb,
   e2 = find_edge (test_bb, *other_bb);
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       /* If both BB and TEST_BB end with GIMPLE_COND, all PHI arguments
 	 corresponding to BB and TEST_BB predecessor must be the same.  */
       if (!operand_equal_p (gimple_phi_arg_def (phi, e->dest_idx),
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index f6b1ba0..93096cc 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1284,11 +1284,11 @@ static bool
 same_phi_alternatives_1 (basic_block dest, edge e1, edge e2)
 {
   int n1 = e1->dest_idx, n2 = e2->dest_idx;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree lhs = gimple_phi_result (phi);
       tree val1 = gimple_phi_arg_def (phi, n1);
       tree val2 = gimple_phi_arg_def (phi, n2);
@@ -1469,10 +1469,10 @@ static gimple
 vop_phi (basic_block bb)
 {
   gimple stmt;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      stmt = gsi_stmt (gsi);
+      stmt = gsi.phi ();
       if (! virtual_operand_p (gimple_phi_result (stmt)))
 	continue;
       return stmt;
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index ce1dee5..a332456 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -203,14 +203,14 @@ record_temporary_equivalences_from_phis (edge e, vec<tree> *stack,
 					 bool backedge_seen,
 					 bitmap src_map, bitmap dst_map)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Each PHI creates a temporary equivalence, record them.
      These are context sensitive equivalences and will be removed
      later.  */
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree src = PHI_ARG_DEF_FROM_EDGE (phi, e);
       tree dst = gimple_phi_result (phi);
 
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index f458d6a..7fd92ce 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -388,13 +388,13 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
   int tgt_idx = tgt_e->dest_idx;
 
   /* Iterate over each PHI in e->dest.  */
-  for (gimple_stmt_iterator gsi = gsi_start_phis (src_e->dest),
-			    gsi2 = gsi_start_phis (tgt_e->dest);
+  for (gimple_phi_iterator gsi = gsi_start_phis (src_e->dest),
+			   gsi2 = gsi_start_phis (tgt_e->dest);
        !gsi_end_p (gsi);
        gsi_next (&gsi), gsi_next (&gsi2))
     {
-      gimple src_phi = gsi_stmt (gsi);
-      gimple dest_phi = gsi_stmt (gsi2);
+      gimple_phi src_phi = gsi.phi ();
+      gimple_phi dest_phi = gsi2.phi ();
       tree val = gimple_phi_arg_def (src_phi, src_idx);
       source_location locus = gimple_phi_arg_location (src_phi, src_idx);
 
@@ -408,12 +408,12 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
 static void
 copy_phi_args (basic_block bb, edge src_e, edge tgt_e)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int src_indx = src_e->dest_idx;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       source_location locus = gimple_phi_arg_location (phi, src_indx);
       add_phi_arg (phi, gimple_phi_arg_def (phi, src_indx), tgt_e, locus);
     }
@@ -1390,13 +1390,13 @@ fail:
 static bool
 phi_args_equal_on_edges (edge e1, edge e2)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int indx1 = e1->dest_idx;
   int indx2 = e2->dest_idx;
 
   for (gsi = gsi_start_phis (e1->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       if (!operand_equal_p (gimple_phi_arg_def (phi, indx1),
 			    gimple_phi_arg_def (phi, indx2), 0))
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index eee83f7..43be808 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -2170,8 +2170,8 @@ is_use_properly_guarded (gimple use_stmt,
    if the new phi is already in the worklist.  */
 
 static gimple
-find_uninit_use (gimple phi, unsigned uninit_opnds,
-                 vec<gimple> *worklist,
+find_uninit_use (gimple_phi phi, unsigned uninit_opnds,
+                 vec<gimple_phi> *worklist,
 		 pointer_set_t *added_to_worklist)
 {
   tree phi_result;
@@ -2225,7 +2225,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds,
               print_gimple_stmt (dump_file, use_stmt, 0, 0);
             }
 
-          worklist->safe_push (use_stmt);
+          worklist->safe_push (use_stmt->as_a_gimple_phi ());
           pointer_set_insert (possibly_undefined_names, phi_result);
         }
     }
@@ -2242,7 +2242,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds,
    a pointer set tracking if the new phi is added to the worklist or not.  */
 
 static void
-warn_uninitialized_phi (gimple phi, vec<gimple> *worklist,
+warn_uninitialized_phi (gimple_phi phi, vec<gimple_phi> *worklist,
                         pointer_set_t *added_to_worklist)
 {
   unsigned uninit_opnds;
@@ -2289,8 +2289,8 @@ static unsigned int
 execute_late_warn_uninitialized (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
-  vec<gimple> worklist = vNULL;
+  gimple_phi_iterator gsi;
+  vec<gimple_phi> worklist = vNULL;
   pointer_set_t *added_to_worklist;
 
   calculate_dominance_info (CDI_DOMINATORS);
@@ -2309,7 +2309,7 @@ execute_late_warn_uninitialized (void)
   FOR_EACH_BB_FN (bb, cfun)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
-        gimple phi = gsi_stmt (gsi);
+        gimple_phi phi = gsi.phi ();
         size_t n, i;
 
         n = gimple_phi_num_args (phi);
@@ -2338,7 +2338,7 @@ execute_late_warn_uninitialized (void)
 
   while (worklist.length () != 0)
     {
-      gimple cur_phi = 0;
+      gimple_phi cur_phi = 0;
       cur_phi = worklist.pop ();
       warn_uninitialized_phi (cur_phi, &worklist, added_to_worklist);
     }
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 20f061f..2927e0b 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -189,8 +189,8 @@ redirect_edge_var_map_destroy (void)
 edge
 ssa_redirect_edge (edge e, basic_block dest)
 {
-  gimple_stmt_iterator gsi;
-  gimple phi;
+  gimple_phi_iterator gsi;
+  gimple_phi phi;
 
   redirect_edge_var_map_clear (e);
 
@@ -200,7 +200,7 @@ ssa_redirect_edge (edge e, basic_block dest)
       tree def;
       source_location locus ;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       def = gimple_phi_arg_def (phi, e->dest_idx);
       locus = gimple_phi_arg_location (phi, e->dest_idx);
 
@@ -222,11 +222,11 @@ ssa_redirect_edge (edge e, basic_block dest)
 void
 flush_pending_stmts (edge e)
 {
-  gimple phi;
+  gimple_phi phi;
   edge_var_map_vector *v;
   edge_var_map *vm;
   int i;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   v = redirect_edge_var_map_vector (e);
   if (!v)
@@ -238,7 +238,7 @@ flush_pending_stmts (edge e)
     {
       tree def;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       def = redirect_edge_var_map_def (vm);
       add_phi_arg (phi, def, e, redirect_edge_var_map_location (vm));
     }
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index e88f710..86e7840 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -749,12 +749,12 @@ check_all_empty_except_final (struct switch_conv_info *info)
 static bool
 check_final_bb (struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   info->phi_count = 0;
   for (gsi = gsi_start_phis (info->final_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       unsigned int i;
 
       info->phi_count++;
@@ -830,7 +830,7 @@ free_temp_arrays (struct switch_conv_info *info)
 static void
 gather_default_values (tree default_case, struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   basic_block bb = label_to_block (CASE_LABEL (default_case));
   edge e;
   int i = 0;
@@ -844,7 +844,7 @@ gather_default_values (tree default_case, struct switch_conv_info *info)
 
   for (gsi = gsi_start_phis (info->final_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree val = PHI_ARG_DEF_FROM_EDGE (phi, e);
       gcc_assert (val);
       info->default_values[i++] = val;
@@ -867,7 +867,7 @@ build_constructors (gimple_switch swtch, struct switch_conv_info *info)
       basic_block bb = label_to_block (CASE_LABEL (cs));
       edge e;
       tree high;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       int j;
 
       if (bb == info->final_bb)
@@ -901,7 +901,7 @@ build_constructors (gimple_switch swtch, struct switch_conv_info *info)
       for (gsi = gsi_start_phis (info->final_bb);
 	   !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree val = PHI_ARG_DEF_FROM_EDGE (phi, e);
 	  tree low = CASE_LOW (cs);
 	  pos = CASE_LOW (cs);
@@ -1178,13 +1178,13 @@ static void
 fix_phi_nodes (edge e1f, edge e2f, basic_block bbf,
 	       struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int i;
 
   for (gsi = gsi_start_phis (bbf), i = 0;
        !gsi_end_p (gsi); gsi_next (&gsi), i++)
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       add_phi_arg (phi, info->target_inbound_names[i], e1f, UNKNOWN_LOCATION);
       add_phi_arg (phi, info->target_outbound_names[i], e2f, UNKNOWN_LOCATION);
     }
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index a436be7..4c85f3d 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -378,11 +378,11 @@ static tree
 propagate_through_phis (tree var, edge e)
 {
   basic_block dest = e->dest;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var)
         return PHI_RESULT (phi);
     }
@@ -610,10 +610,10 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
 static void
 add_successor_phi_arg (edge e, tree var, tree phi_arg)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    if (PHI_RESULT (gsi_stmt (gsi)) == var)
+    if (PHI_RESULT (gsi.phi ()) == var)
       break;
 
   gcc_assert (!gsi_end_p (gsi));
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 77d945e..15d9a53 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -391,8 +391,8 @@ static void
 slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
                                     bool is_new_loop, basic_block *new_exit_bb)
 {
-  gimple orig_phi, new_phi;
-  gimple update_phi, update_phi2;
+  gimple_phi orig_phi, new_phi;
+  gimple_phi update_phi, update_phi2;
   tree guard_arg, loop_arg;
   basic_block new_merge_bb = guard_edge->dest;
   edge e = EDGE_SUCC (new_merge_bb, 0);
@@ -400,7 +400,7 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
   basic_block orig_bb = loop->header;
   edge new_exit_e;
   tree current_new_name;
-  gimple_stmt_iterator gsi_orig, gsi_update;
+  gimple_phi_iterator gsi_orig, gsi_update;
 
   /* Create new bb between loop and new_merge_bb.  */
   *new_exit_bb = split_edge (single_exit (loop));
@@ -414,8 +414,8 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
     {
       source_location loop_locus, guard_locus;
       tree new_res;
-      orig_phi = gsi_stmt (gsi_orig);
-      update_phi = gsi_stmt (gsi_update);
+      orig_phi = gsi_orig.phi ();
+      update_phi = gsi_update.phi ();
 
       /** 1. Handle new-merge-point phis  **/
 
@@ -531,8 +531,8 @@ static void
 slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
                                     bool is_new_loop, basic_block *new_exit_bb)
 {
-  gimple orig_phi, new_phi;
-  gimple update_phi, update_phi2;
+  gimple_phi orig_phi, new_phi;
+  gimple_phi update_phi, update_phi2;
   tree guard_arg, loop_arg;
   basic_block new_merge_bb = guard_edge->dest;
   edge e = EDGE_SUCC (new_merge_bb, 0);
@@ -541,7 +541,7 @@ slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
   tree orig_def, orig_def_new_name;
   tree new_name, new_name2;
   tree arg;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Create new bb between loop and new_merge_bb.  */
   *new_exit_bb = split_edge (single_exit (loop));
@@ -551,7 +551,7 @@ slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
   for (gsi = gsi_start_phis (update_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       tree new_res;
-      update_phi = gsi_stmt (gsi);
+      update_phi = gsi.phi ();
       orig_phi = update_phi;
       orig_def = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
       /* This loop-closed-phi actually doesn't represent a use
@@ -1173,7 +1173,7 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
   basic_block bb_before_first_loop;
   basic_block bb_between_loops;
   basic_block new_exit_bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   edge exit_e = single_exit (loop);
   source_location loop_loc;
   /* There are many aspects to how likely the first loop is going to be executed.
@@ -1205,7 +1205,7 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
     if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
       {
-	gimple phi = gsi_stmt (gsi);
+	gimple_phi phi = gsi.phi ();
 	for (gsi = gsi_start_phis (exit_e->dest);
 	     !gsi_end_p (gsi); gsi_next (&gsi))
 	  if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
@@ -1529,7 +1529,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block bb = loop->header;
   gimple phi;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Analyze phi functions of the loop header.  */
 
@@ -1539,7 +1539,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
     {
       tree evolution_part;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       if (dump_enabled_p ())
 	{
           dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
@@ -1638,8 +1638,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
 {
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block exit_bb = single_exit (loop)->dest;
-  gimple phi, phi1;
-  gimple_stmt_iterator gsi, gsi1;
+  gimple_phi phi, phi1;
+  gimple_phi_iterator gsi, gsi1;
   basic_block update_bb = update_e->dest;
 
   gcc_checking_assert (vect_can_advance_ivs_p (loop_vinfo));
@@ -1658,8 +1658,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
       gimple_stmt_iterator last_gsi;
       stmt_vec_info stmt_info;
 
-      phi = gsi_stmt (gsi);
-      phi1 = gsi_stmt (gsi1);
+      phi = gsi.phi ();
+      phi1 = gsi1.phi ();
       if (dump_enabled_p ())
         {
           dump_printf_loc (MSG_NOTE, vect_location,
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index df6ab6f..220f665 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -622,7 +622,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
   basic_block bb = loop->header;
   tree init, step;
   auto_vec<gimple, 64> worklist;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   bool double_reduc;
 
   if (dump_enabled_p ())
@@ -634,7 +634,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
      changed.  */
   for (gsi = gsi_start_phis  (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree access_fn = NULL;
       tree def = PHI_RESULT (phi);
       stmt_vec_info stmt_vinfo = vinfo_for_stmt (phi);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 8c6d110..b784282 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5959,10 +5959,10 @@ find_assert_locations (void)
     {
       i = loop->latch->index;
       unsigned int j = single_succ_edge (loop->latch)->dest_idx;
-      for (gimple_stmt_iterator gsi = gsi_start_phis (loop->header);
+      for (gimple_phi_iterator gsi = gsi_start_phis (loop->header);
 	   !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  if (virtual_operand_p (gimple_phi_result (phi)))
 	    continue;
 	  tree arg = gimple_phi_arg_def (phi, j);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 2890093..555f3a4 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1328,7 +1328,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
   int lp_nr, dflags;
   edge e_eh, e;
   edge_iterator ei;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   cond_bb = gimple_bb (icall_stmt);
   gsi = gsi_for_stmt (icall_stmt);
@@ -1441,7 +1441,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
 	for (psi = gsi_start_phis (e_eh->dest);
 	     !gsi_end_p (psi); gsi_next (&psi))
 	  {
-	    gimple phi = gsi_stmt (psi);
+	    gimple_phi phi = psi.phi ();
 	    SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e),
 		     PHI_ARG_DEF_FROM_EDGE (phi, e_eh));
 	  }
-- 
1.8.5.3

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

* [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call.
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (80 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 17:35   ` Jeff Law
  2014-05-12 17:49   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi David Malcolm
                   ` (9 subsequent siblings)
  91 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_call_return_slot_opt_p): Require a gimple_call
	rather than a plain gimple.

	* gimple-walk.c (walk_stmt_load_store_addr_ops): Convert usage of
	is_gimple_call to dyn_cast_gimple_call, introducing a new local
	"call_stmt".

	* trans-mem.c (expand_call_tm): Split local "stmt", strengthening
	from plain gimple to a gimple_call, and introducing new local
	gimple_assign "assign_stmt".

	* tree-inline.c (expand_call_inline):  Convert check of code against
	GIMPLE_CALL to dyn_cast_gimple_call, introducing a new local
	"call_stmt".
---
 gcc/gimple-walk.c | 26 +++++++++++++-------------
 gcc/gimple.h      |  3 +--
 gcc/trans-mem.c   | 11 ++++++-----
 gcc/tree-inline.c |  6 ++++--
 4 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 63200a2..cdb5516 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -758,11 +758,11 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	    }
 	}
     }
-  else if (is_gimple_call (stmt))
+  else if (gimple_call call_stmt = stmt->dyn_cast_gimple_call ())
     {
       if (visit_store)
 	{
-	  tree arg = gimple_call_lhs (stmt);
+	  tree arg = gimple_call_lhs (call_stmt);
 	  if (arg)
 	    {
 	      tree lhs = get_base_loadstore (arg);
@@ -771,9 +771,9 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	    }
 	}
       if (visit_load || visit_addr)
-	for (i = 0; i < gimple_call_num_args (stmt); ++i)
+	for (i = 0; i < gimple_call_num_args (call_stmt); ++i)
 	  {
-	    tree arg = gimple_call_arg (stmt, i);
+	    tree arg = gimple_call_arg (call_stmt, i);
 	    if (visit_addr
 		&& TREE_CODE (arg) == ADDR_EXPR)
 	      ret |= visit_addr (stmt, TREE_OPERAND (arg, 0), arg, data);
@@ -785,16 +785,16 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	      }
 	  }
       if (visit_addr
-	  && gimple_call_chain (stmt)
-	  && TREE_CODE (gimple_call_chain (stmt)) == ADDR_EXPR)
-	ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (stmt), 0),
-			   gimple_call_chain (stmt), data);
+	  && gimple_call_chain (call_stmt)
+	  && TREE_CODE (gimple_call_chain (call_stmt)) == ADDR_EXPR)
+	ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (call_stmt), 0),
+			   gimple_call_chain (call_stmt), data);
       if (visit_addr
-	  && gimple_call_return_slot_opt_p (stmt)
-	  && gimple_call_lhs (stmt) != NULL_TREE
-	  && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt))))
-	ret |= visit_addr (stmt, gimple_call_lhs (stmt),
-			   gimple_call_lhs (stmt), data);
+	  && gimple_call_return_slot_opt_p (call_stmt)
+	  && gimple_call_lhs (call_stmt) != NULL_TREE
+	  && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call_stmt))))
+	ret |= visit_addr (stmt, gimple_call_lhs (call_stmt),
+			   gimple_call_lhs (call_stmt), data);
     }
   else if (gimple_asm asm_stmt = stmt->dyn_cast_gimple_asm ())
     {
diff --git a/gcc/gimple.h b/gcc/gimple.h
index c48b3d5..49385bd 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3119,9 +3119,8 @@ gimple_call_set_return_slot_opt (gimple_call s, bool return_slot_opt_p)
 /* Return true if S is marked for return slot optimization.  */
 
 static inline bool
-gimple_call_return_slot_opt_p (gimple s)
+gimple_call_return_slot_opt_p (gimple_call s)
 {
-  GIMPLE_CHECK (s, GIMPLE_CALL);
   return (s->subcode & GF_CALL_RETURN_SLOT_OPT) != 0;
 }
 
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 7911ad6..62d9b78 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -2362,7 +2362,7 @@ static bool
 expand_call_tm (struct tm_region *region,
 		gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_call stmt = gsi_stmt (*gsi)->as_a_gimple_call ();
   tree lhs = gimple_call_lhs (stmt);
   tree fn_decl;
   struct cgraph_node *node;
@@ -2449,6 +2449,7 @@ expand_call_tm (struct tm_region *region,
       tree tmp = create_tmp_reg (TREE_TYPE (lhs), NULL);
       location_t loc = gimple_location (stmt);
       edge fallthru_edge = NULL;
+      gimple_assign assign_stmt;
 
       /* Remember if the call was going to throw.  */
       if (stmt_can_throw_internal (stmt))
@@ -2467,15 +2468,15 @@ expand_call_tm (struct tm_region *region,
 
       gimple_call_set_lhs (stmt, tmp);
       update_stmt (stmt);
-      stmt = gimple_build_assign (lhs, tmp);
-      gimple_set_location (stmt, loc);
+      assign_stmt = gimple_build_assign (lhs, tmp);
+      gimple_set_location (assign_stmt, loc);
 
       /* We cannot throw in the middle of a BB.  If the call was going
 	 to throw, place the instrumentation on the fallthru edge, so
 	 the call remains the last statement in the block.  */
       if (fallthru_edge)
 	{
-	  gimple_seq fallthru_seq = gimple_seq_alloc_with_stmt (stmt);
+	  gimple_seq fallthru_seq = gimple_seq_alloc_with_stmt (assign_stmt);
 	  gimple_stmt_iterator fallthru_gsi = gsi_start (fallthru_seq);
 	  expand_assign_tm (region, &fallthru_gsi);
 	  gsi_insert_seq_on_edge (fallthru_edge, fallthru_seq);
@@ -2483,7 +2484,7 @@ expand_call_tm (struct tm_region *region,
 	}
       else
 	{
-	  gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
+	  gsi_insert_after (gsi, assign_stmt, GSI_CONTINUE_LINKING);
 	  expand_assign_tm (region, gsi);
 	}
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 291dbf7..cdc2ff2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4123,6 +4123,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
   gimple_stmt_iterator gsi, stmt_gsi;
   bool successfully_inlined = FALSE;
   bool purge_dead_abnormal_edges;
+  gimple_call call_stmt;
 
   /* Set input_location here so we get the right instantiation context
      if we call instantiate_decl from inlinable_function_p.  */
@@ -4131,7 +4132,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
   input_location = gimple_location (stmt);
 
   /* From here on, we're only interested in CALL_EXPRs.  */
-  if (gimple_code (stmt) != GIMPLE_CALL)
+  call_stmt = stmt->dyn_cast_gimple_call ();
+  if (!call_stmt)
     goto egress;
 
   cg_edge = cgraph_edge (id->dst_node, stmt);
@@ -4341,7 +4343,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
       if (DECL_P (modify_dest))
 	TREE_NO_WARNING (modify_dest) = 1;
 
-      if (gimple_call_return_slot_opt_p (stmt))
+      if (gimple_call_return_slot_opt_p (call_stmt))
 	{
 	  return_slot = modify_dest;
 	  modify_dest = NULL;
-- 
1.8.5.3

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

* [PATCH 68/89] Concretize three gimple_return_ accessors
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (83 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 44/89] Introduce gimple_omp_teams David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 19:59   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call David Malcolm
                   ` (6 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

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

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

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

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

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

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

* [PATCH 44/89] Introduce gimple_omp_teams
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (82 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 17:19   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 68/89] Concretize three gimple_return_ accessors David Malcolm
                   ` (7 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_teams): New typedef.
	(const_gimple_omp_teams): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_teams): New.
	(gimple_build_omp_teams): Return a gimple_omp_teams rather than a
	plain gimple.
	(gimple_omp_teams_set_clauses): Require a gimple_omp_teams rather
	than a plain gimple.

	* gimple-pretty-print.c (dump_gimple_omp_teams): Require a
	gimple_omp_teams rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_teams within
	GIMPLE_OMP_TEAMS case of switch statement.

	* gimple.c (gimple_build_omp_teams): Return a gimple_omp_teams
	rather than a plain gimple.

	* omp-low.c (scan_omp_teams): Likewise.
	(scan_omp_1_stmt): Add checked cast to gimple_omp_teams within
	GIMPLE_OMP_TEAMS case of switch statement.
	(lower_omp_teams): Strengthen local "teams_stmt" from gimple to
	gimple_omp_teams.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  6 ++++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 14 +++++++++-----
 gcc/omp-low.c             |  6 +++---
 5 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 1ac8765..529dc96 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -183,6 +183,10 @@ struct gimple_statement_omp_target;
 typedef struct gimple_statement_omp_target *gimple_omp_target;
 typedef const struct gimple_statement_omp_target *const_gimple_omp_target;
 
+struct gimple_statement_omp_teams;
+typedef struct gimple_statement_omp_teams *gimple_omp_teams;
+typedef const struct gimple_statement_omp_teams *const_gimple_omp_teams;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index a5d8706..3787136 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1333,7 +1333,8 @@ dump_gimple_omp_target (pretty_printer *buffer, gimple_omp_target gs,
 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_teams (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_omp_teams (pretty_printer *buffer, gimple_omp_teams gs, int spc,
+		       int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2184,7 +2185,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_TEAMS:
-      dump_gimple_omp_teams (buffer, gs, spc, flags);
+      dump_gimple_omp_teams (buffer, gs->as_a_gimple_omp_teams (), spc,
+			     flags);
       break;
 
     case GIMPLE_OMP_RETURN:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 2ba7c5b..310839f 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1070,10 +1070,11 @@ gimple_build_omp_target (gimple_seq body, int kind, tree clauses)
    BODY is the sequence of statements that will be executed.
    CLAUSES are any of the OMP teams construct's clauses.  */
 
-gimple
+gimple_omp_teams
 gimple_build_omp_teams (gimple_seq body, tree clauses)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_TEAMS, 0);
+  gimple_omp_teams p =
+    gimple_alloc (GIMPLE_OMP_TEAMS, 0)->as_a_gimple_omp_teams ();
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_teams_set_clauses (p, clauses);
diff --git a/gcc/gimple.h b/gcc/gimple.h
index d791a28..0a06620 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -390,6 +390,12 @@ public:
     return as_a <gimple_statement_omp_target> (this);
   }
 
+  inline gimple_omp_teams
+  as_a_gimple_omp_teams ()
+  {
+    return as_a <gimple_statement_omp_teams> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1650,7 +1656,7 @@ gimple gimple_build_omp_sections (gimple_seq, tree);
 gimple gimple_build_omp_sections_switch (void);
 gimple_omp_single gimple_build_omp_single (gimple_seq, tree);
 gimple_omp_target gimple_build_omp_target (gimple_seq, int, tree);
-gimple gimple_build_omp_teams (gimple_seq, tree);
+gimple_omp_teams gimple_build_omp_teams (gimple_seq, tree);
 gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
 gimple_omp_atomic_store gimple_build_omp_atomic_store (tree);
 gimple_transaction gimple_build_transaction (gimple_seq, tree);
@@ -5482,13 +5488,11 @@ gimple_omp_teams_clauses_ptr (gimple gs)
 }
 
 
-/* Set CLAUSES to be the clauses associated with OMP_TEAMS GS.  */
+/* Set CLAUSES to be the clauses associated with OMP_TEAMS_STMT.  */
 
 static inline void
-gimple_omp_teams_set_clauses (gimple gs, tree clauses)
+gimple_omp_teams_set_clauses (gimple_omp_teams omp_teams_stmt, tree clauses)
 {
-  gimple_statement_omp_teams *omp_teams_stmt =
-    as_a <gimple_statement_omp_teams> (gs);
   omp_teams_stmt->clauses = clauses;
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 9809cf4..680c21f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2228,7 +2228,7 @@ scan_omp_target (gimple_omp_target stmt, omp_context *outer_ctx)
 /* Scan an OpenMP teams directive.  */
 
 static void
-scan_omp_teams (gimple stmt, omp_context *outer_ctx)
+scan_omp_teams (gimple_omp_teams stmt, omp_context *outer_ctx)
 {
   omp_context *ctx = new_omp_context (stmt, outer_ctx);
   scan_sharing_clauses (gimple_omp_teams_clauses (stmt), ctx);
@@ -2668,7 +2668,7 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       break;
 
     case GIMPLE_OMP_TEAMS:
-      scan_omp_teams (stmt, ctx);
+      scan_omp_teams (stmt->as_a_gimple_omp_teams (), ctx);
       break;
 
     case GIMPLE_BIND:
@@ -9899,7 +9899,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 static void
 lower_omp_teams (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 {
-  gimple teams_stmt = gsi_stmt (*gsi_p);
+  gimple_omp_teams teams_stmt = gsi_stmt (*gsi_p)->as_a_gimple_omp_teams ();
   push_gimplify_context ();
 
   tree block = make_node (BLOCK);
-- 
1.8.5.3

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

* [PATCH 12/89] tree-predcom.c: use gimple_phi in various places
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (78 preceding siblings ...)
  2014-04-21 17:14 ` [PATCH 33/89] Use more concrete types for various gimple statements David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-09 18:31   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi David Malcolm
                   ` (11 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-predcom.c (find_looparound_phi): Return a gimple_phi rather
	than just a gimple.
	(insert_looparound_copy): Require a gimple_phi rather than just a
	gimple.
	(add_looparound_copies): Convert local "phi" to be a gimple_phi.
	(initialize_root_vars): Likewise.
	(initialize_root_vars_lm): Likewise.
---
 gcc/tree-predcom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index e859959..e95af52 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1112,7 +1112,7 @@ valid_initializer_p (struct data_reference *ref,
    iteration), returns the phi node.  Otherwise, NULL_TREE is returned.  ROOT
    is the root of the current chain.  */
 
-static gimple
+static gimple_phi
 find_looparound_phi (struct loop *loop, dref ref, dref root)
 {
   tree name, init, init_ref;
@@ -1174,7 +1174,7 @@ find_looparound_phi (struct loop *loop, dref ref, dref root)
 /* Adds a reference for the looparound copy of REF in PHI to CHAIN.  */
 
 static void
-insert_looparound_copy (chain_p chain, dref ref, gimple phi)
+insert_looparound_copy (chain_p chain, dref ref, gimple_phi phi)
 {
   dref nw = XCNEW (struct dref_d), aref;
   unsigned i;
@@ -1205,7 +1205,7 @@ add_looparound_copies (struct loop *loop, chain_p chain)
 {
   unsigned i;
   dref ref, root = get_chain_root (chain);
-  gimple phi;
+  gimple_phi phi;
 
   FOR_EACH_VEC_ELT (chain->refs, i, ref)
     {
@@ -1457,7 +1457,7 @@ initialize_root_vars (struct loop *loop, chain_p chain, bitmap tmp_vars)
   dref root = get_chain_root (chain);
   bool reuse_first = !chain->has_max_use_after;
   tree ref, init, var, next;
-  gimple phi;
+  gimple_phi phi;
   gimple_seq stmts;
   edge entry = loop_preheader_edge (loop), latch = loop_latch_edge (loop);
 
@@ -1531,7 +1531,7 @@ initialize_root_vars_lm (struct loop *loop, dref root, bool written,
   unsigned i;
   tree ref = DR_REF (root->ref), init, var, next;
   gimple_seq stmts;
-  gimple phi;
+  gimple_phi phi;
   edge entry = loop_preheader_edge (loop), latch = loop_latch_edge (loop);
 
   /* Find the initializer for the variable, and check that it cannot
-- 
1.8.5.3

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

* [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (81 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-09 18:32   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 44/89] Introduce gimple_omp_teams David Malcolm
                   ` (8 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-ssa-phiprop.c (phiprop_insert_phi): Strengthen types of
	parameter "phi" and local "new_phi" from gimple to gimple_phi.
---
 gcc/tree-ssa-phiprop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index f3dc67f..33ac8c8 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -139,11 +139,11 @@ phivn_valid_p (struct phiprop_d *phivn, tree name, basic_block bb)
    BB with the virtual operands from USE_STMT.  */
 
 static tree
-phiprop_insert_phi (basic_block bb, gimple phi, gimple use_stmt,
+phiprop_insert_phi (basic_block bb, gimple_phi phi, gimple use_stmt,
 		    struct phiprop_d *phivn, size_t n)
 {
   tree res;
-  gimple new_phi;
+  gimple_phi new_phi;
   edge_iterator ei;
   edge e;
 
-- 
1.8.5.3

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

* [PATCH 35/89] Introduce gimple_omp_atomic_store
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (86 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 23/89] Introduce gimple_asm David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 17:16   ` Jeff Law
  2014-04-21 17:29 ` [PATCH 30/89] Introduce gimple_eh_dispatch David Malcolm
                   ` (3 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_omp_atomic_store): New typedef.
	(const_gimple_omp_atomic_store): New typedef.

	* gimple-pretty-print.c (dump_gimple_omp_atomic_store): Require
	a gimple_omp_atomic_store rather than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_omp_atomic_store
	within GIMPLE_OMP_ATOMIC_STORE case of switch statement.
	* gimple-walk.c (walk_gimple_op): Likewise.

	* gimple.c (gimple_build_omp_atomic_store): Return a
	gimple_omp_atomic_store rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_omp_atomic_store):
	New.
	(gimple_build_omp_atomic_store): Return a gimple_omp_atomic_store
	rather than a plain gimple.
	(gimple_omp_atomic_store_set_val): Require a gimple_omp_atomic_store
	rather than a plain gimple.
	(gimple_omp_atomic_store_val_ptr): Likewise.
	(gimple_omp_atomic_store_val): Require a
	const_gimple_omp_atomic_store rather than a plain const_gimple.

	* gimplify.c (gimplify_omp_atomic): Strengthen locals "loadstmt" and
	"storestmt" from gimple to gimple_omp_atomic_load loadstmt and
	gimple_omp_atomic_store storestmt respectively.

	* omp-low.c (expand_omp_atomic): Strengthen local "store" from
	gimple to gimple_omp_atomic_store.
---
 gcc/coretypes.h           |  5 +++++
 gcc/gimple-pretty-print.c |  8 +++++---
 gcc/gimple-walk.c         |  5 +++--
 gcc/gimple.c              |  5 +++--
 gcc/gimple.h              | 26 +++++++++++++-------------
 gcc/gimplify.c            |  3 ++-
 gcc/omp-low.c             |  3 ++-
 7 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2fb510f..34c160e 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -150,6 +150,11 @@ typedef struct gimple_statement_omp_atomic_load *gimple_omp_atomic_load;
 typedef const struct gimple_statement_omp_atomic_load *
   const_gimple_omp_atomic_load;
 
+struct gimple_statement_omp_atomic_store;
+typedef struct gimple_statement_omp_atomic_store *gimple_omp_atomic_store;
+typedef const struct gimple_statement_omp_atomic_store *
+  const_gimple_omp_atomic_store;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index bf0d73c..5cbda7d 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1994,8 +1994,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, gimple_omp_atomic_load gs,
    in dumpfile.h).  */
 
 static void
-dump_gimple_omp_atomic_store (pretty_printer *buffer, gimple gs, int spc,
-                             int flags)
+dump_gimple_omp_atomic_store (pretty_printer *buffer,
+			      gimple_omp_atomic_store gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2155,7 +2155,9 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
-      dump_gimple_omp_atomic_store (buffer, gs, spc, flags);
+      dump_gimple_omp_atomic_store (buffer,
+				    gs->as_a_gimple_omp_atomic_store (),
+				    spc, flags);
       break;
 
     case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index bbfc20b..f15d1f3 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -434,8 +434,9 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
-      ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op,
-		       wi, pset);
+      ret = walk_tree (gimple_omp_atomic_store_val_ptr (
+		         stmt->as_a_gimple_omp_atomic_store ()),
+		       callback_op, wi, pset);
       if (ret)
 	return ret;
       break;
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 797726b..c45cc48 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1093,10 +1093,11 @@ gimple_build_omp_atomic_load (tree lhs, tree rhs)
 
    VAL is the value we are storing.  */
 
-gimple
+gimple_omp_atomic_store
 gimple_build_omp_atomic_store (tree val)
 {
-  gimple p = gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0);
+  gimple_omp_atomic_store p =
+    gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0)->as_a_gimple_omp_atomic_store ();
   gimple_omp_atomic_store_set_val (p, val);
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f255ff0..b74ff4b 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -342,6 +342,12 @@ public:
     return as_a <gimple_statement_omp_atomic_load> (this);
   }
 
+  inline gimple_omp_atomic_store
+  as_a_gimple_omp_atomic_store ()
+  {
+    return as_a <gimple_statement_omp_atomic_store> (this);
+  }
+
   /* Dynamic casting methods, where the cast returns NULL if the
      stmt is not of the required kind.
 
@@ -1586,7 +1592,7 @@ gimple gimple_build_omp_single (gimple_seq, tree);
 gimple gimple_build_omp_target (gimple_seq, int, tree);
 gimple gimple_build_omp_teams (gimple_seq, tree);
 gimple_omp_atomic_load gimple_build_omp_atomic_load (tree, tree);
-gimple gimple_build_omp_atomic_store (tree);
+gimple_omp_atomic_store gimple_build_omp_atomic_store (tree);
 gimple_transaction gimple_build_transaction (gimple_seq, tree);
 gimple gimple_build_predict (enum br_predictor, enum prediction);
 extern void gimple_seq_add_stmt (gimple_seq *, gimple);
@@ -5562,33 +5568,27 @@ gimple_omp_for_cond (const_gimple gs, size_t i)
 /* Set the value being stored in an atomic store.  */
 
 static inline void
-gimple_omp_atomic_store_set_val (gimple g, tree val)
+gimple_omp_atomic_store_set_val (gimple_omp_atomic_store store_stmt, tree val)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store> (g);
-  omp_atomic_store_stmt->val = val;
+  store_stmt->val = val;
 }
 
 
 /* Return the value being stored in an atomic store.  */
 
 static inline tree
-gimple_omp_atomic_store_val (const_gimple g)
+gimple_omp_atomic_store_val (const_gimple_omp_atomic_store store_stmt)
 {
-  const gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <const gimple_statement_omp_atomic_store> (g);
-  return omp_atomic_store_stmt->val;
+  return store_stmt->val;
 }
 
 
 /* Return a pointer to the value being stored in an atomic store.  */
 
 static inline tree *
-gimple_omp_atomic_store_val_ptr (gimple g)
+gimple_omp_atomic_store_val_ptr (gimple_omp_atomic_store store_stmt)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store> (g);
-  return &omp_atomic_store_stmt->val;
+  return &store_stmt->val;
 }
 
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f8c3aff..27058a8 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -7099,7 +7099,8 @@ gimplify_omp_atomic (tree *expr_p, gimple_seq *pre_p)
 	     ? NULL : TREE_OPERAND (*expr_p, 1);
   tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (addr)));
   tree tmp_load;
-  gimple loadstmt, storestmt;
+  gimple_omp_atomic_load loadstmt;
+  gimple_omp_atomic_store storestmt;
 
   tmp_load = create_tmp_reg (type, NULL);
   if (rhs && goa_stabilize_expr (&rhs, pre_p, addr, tmp_load) < 0)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index edcd0ec..22ea34f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -7734,7 +7734,8 @@ expand_omp_atomic (struct omp_region *region)
   basic_block load_bb = region->entry, store_bb = region->exit;
   gimple_omp_atomic_load load =
     last_stmt (load_bb)->as_a_gimple_omp_atomic_load ();
-  gimple store = last_stmt (store_bb);
+  gimple_omp_atomic_store store =
+    last_stmt (store_bb)->as_a_gimple_omp_atomic_store ();
   tree loaded_val = gimple_omp_atomic_load_lhs (load);
   tree addr = gimple_omp_atomic_load_rhs (load);
   tree stored_val = gimple_omp_atomic_store_val (store);
-- 
1.8.5.3

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

* [PATCH 23/89] Introduce gimple_asm
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (85 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-04-21 17:15 ` [PATCH 35/89] Introduce gimple_omp_atomic_store David Malcolm
                   ` (4 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_asm): New typedef.
	(const_gimple_asm): New typedef.

	* gimple.h (gimple_statement_base::as_a_gimple_asm): New.
	gimple_statement_base::dyn_cast_gimple_asm): New.
	(gimple_build_asm_vec): Return a gimple_asm rather than
	just a gimple.
	(gimple_asm_clobbers_memory_p): Require a const_gimple_asm rather
	than just a const_gimple.
	(gimple_asm_ninputs): Likewise.
	(gimple_asm_noutputs): Likewise.
	(gimple_asm_nclobbers): Likewise.
	(gimple_asm_nlabels): Likewise.
	(gimple_asm_input_op): Likewise.
	(gimple_asm_input_op_ptr): Likewise.
	(gimple_asm_output_op): Likewise.
	(gimple_asm_output_op_ptr): Likewise.
	(gimple_asm_clobber_op): Likewise.
	(gimple_asm_label_op): Likewise.
	(gimple_asm_string): Likewise.
	(gimple_asm_volatile_p): Likewise.
	(gimple_asm_input_p): Likewise.
	(gimple_asm_set_input_op): Require a gimple_asm rather than a plain
	gimple.
	(gimple_asm_set_output_op): Likewise.
	(gimple_asm_set_clobber_op): Likewise.
	(gimple_asm_set_label_op): Likewise.
	(gimple_asm_set_volatile): Likewise.
	(gimple_asm_set_input): Likewise.

	* cfgexpand.c (expand_asm_stmt): Require a gimple_asm rather than
	a plain gimple.
	(expand_gimple_stmt_1): Add checked cast to gimple_asm within
	GIMPLE_ASM case of switch statement.

	* gimple-fold.c (fold_stmt_1): Add new local from checked cast to
	gimple_asm within case GIMPLE_ASM.

	* gimple-pretty-print.c (dump_gimple_asm): Require a gimple_asm rather
	than a plain gimple.
	(pp_gimple_stmt_1): Add checked cast to gimple_asm within
	GIMPLE_ASM case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Rework existing checked
	cast to gimple_asm; add a new one.

	* gimple-streamer-out.c (output_gimple_stmt): Add new local from
	checked cast to gimple_asm within case GIMPLE_ASM.

	* gimple-walk.c (walk_gimple_asm): Require a gimple_asm rather than
	a plain gimple.
	(walk_gimple_op): Add checked cast to gimple_asm within GIMPLE_ASM
	case of switch statement.
	(walk_stmt_load_store_addr_ops): Use dyn_cast_gimple_asm in place
	of a code check against GIMPLE_ASM to introduce a new gimple_asm
	local.

	* gimple.c (gimple_build_asm_1): Return a gimple_asm rather than
	a plain gimple.
	(gimple_build_asm_vec): Likewise.
	(gimple_has_side_effects): Add a checked cast to gimple_asm.
	(gimple_could_trap_p_1): Likewise.
	(gimple_call_builtin_p): Require a const_gimple_asm rather then
	a const_gimple.

	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
	and a new local of type gimple_asm within GIMPLE_ASM case.

	* gimplify.c (gimplify_asm_expr): Convert a local from gimple to
	gimple_asm.

	* ipa-pure-const.c (check_stmt): Add checked casts within
	GIMPLE_ASM case.

	* ssa-iterators.h (op_iter_init): Likewise.

	* tree-cfg.c (make_goto_expr_edges): Convert a local from gimple to
	gimple_asm.
	(cleanup_dead_labels): Add a checked cast and a new local of type
	gimple_asm within GIMPLE_ASM case.
	(gimple_redirect_edge_and_branch): Likewise.
	(is_ctrl_altering_stmt): Add a checked cast.
	(need_fake_edge_p): Replace a code check against GIMPLE_ASM with a
	dyn_cast_gimple_asm.

	* tree-complex.c (expand_complex_comparison): Convert a local from
	gimple to gimple_asm.

	* tree-data-ref.c (get_references_in_stmt): Add a checked cast to
	gimple_asm.

	* tree-eh.c (stmt_could_throw_p): Likewise.

	* tree-inline.c (estimate_num_insns): Likewise.

	* tree-sra.c (scan_function): Add a checked cast and a new local
	of type gimple_asm within GIMPLE_ASM case.
	(sra_modify_function_body): Likewise.
	(ipa_sra_modify_function_body): Likewise.

	* tree-ssa-coalesce.c (create_outofssa_var_map): Likewise.

	* tree-ssa-dce.c (propagate_necessity): Replace a code check
	against GIMPLE_ASM with a dyn_cast_gimple_asm.

	* tree-ssa-operands.c (maybe_add_call_vops): Require a gimple_asm
	rather than a plain gimple.
	(parse_ssa_operands): Add a checked cast to gimple_asm.

	* tree-ssa-structalias.c (find_func_aliases): Add a checked cast
	and a new local of type gimple_asm within clause guarded by
	code check.

	* tree-ssa-threadedge.c
	(record_temporary_equivalences_from_stmts_at_dest): Add a checked
	cast to gimple_asm.

	* tree-ssa.c (execute_update_addresses_taken): Add checked casts
	and new locals of type gimple_asm within clauses guarded by code
	check.
---
 gcc/cfgexpand.c            |   4 +-
 gcc/coretypes.h            |   4 ++
 gcc/gimple-fold.c          |  11 +--
 gcc/gimple-pretty-print.c  |   4 +-
 gcc/gimple-streamer-in.c   |   7 +-
 gcc/gimple-streamer-out.c  |  15 +++--
 gcc/gimple-walk.c          |  16 ++---
 gcc/gimple.c               |  14 ++--
 gcc/gimple.h               | 164 +++++++++++++++++++++------------------------
 gcc/gimplify-me.c          |   9 +--
 gcc/gimplify.c             |   2 +-
 gcc/ipa-pure-const.c       |   4 +-
 gcc/ssa-iterators.h        |   2 +-
 gcc/tree-cfg.c             |  20 +++---
 gcc/tree-complex.c         |   2 +-
 gcc/tree-data-ref.c        |   3 +-
 gcc/tree-eh.c              |   2 +-
 gcc/tree-inline.c          |   3 +-
 gcc/tree-sra.c             |  77 +++++++++++----------
 gcc/tree-ssa-coalesce.c    |   9 +--
 gcc/tree-ssa-dce.c         |   6 +-
 gcc/tree-ssa-operands.c    |   4 +-
 gcc/tree-ssa-structalias.c |   9 +--
 gcc/tree-ssa-threadedge.c  |   3 +-
 gcc/tree-ssa.c             |  18 ++---
 25 files changed, 214 insertions(+), 198 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 175a9f4..71615a8 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2865,7 +2865,7 @@ expand_asm_operands (tree string, tree outputs, tree inputs,
 
 
 static void
-expand_asm_stmt (gimple stmt)
+expand_asm_stmt (gimple_asm stmt)
 {
   int noutputs;
   tree outputs, tail, t;
@@ -3150,7 +3150,7 @@ expand_gimple_stmt_1 (gimple stmt)
       expand_case (stmt->as_a_gimple_switch ());
       break;
     case GIMPLE_ASM:
-      expand_asm_stmt (stmt);
+      expand_asm_stmt (stmt->as_a_gimple_asm ());
       break;
     case GIMPLE_CALL:
       expand_call_stmt (stmt->as_a_gimple_call ());
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 1d04d07..7c869e9 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -93,6 +93,10 @@ struct gimple_statement_assign;
 typedef struct gimple_statement_assign *gimple_assign;
 typedef const struct gimple_statement_assign *const_gimple_assign;
 
+struct gimple_statement_asm;
+typedef struct gimple_statement_asm *gimple_asm;
+typedef const struct gimple_statement_asm *const_gimple_asm;
+
 struct gimple_statement_call;
 typedef struct gimple_statement_call *gimple_call;
 typedef const struct gimple_statement_call *const_gimple_call;
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index aa62bef..2d317b0 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1304,17 +1304,18 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace)
     case GIMPLE_ASM:
       /* Fold *& in asm operands.  */
       {
+	gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
 	size_t noutputs;
 	const char **oconstraints;
 	const char *constraint;
 	bool allows_mem, allows_reg;
 
-	noutputs = gimple_asm_noutputs (stmt);
+	noutputs = gimple_asm_noutputs (asm_stmt);
 	oconstraints = XALLOCAVEC (const char *, noutputs);
 
-	for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
+	for (i = 0; i < gimple_asm_noutputs (asm_stmt); ++i)
 	  {
-	    tree link = gimple_asm_output_op (stmt, i);
+	    tree link = gimple_asm_output_op (asm_stmt, i);
 	    tree op = TREE_VALUE (link);
 	    oconstraints[i]
 	      = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
@@ -1325,9 +1326,9 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace)
 		changed = true;
 	      }
 	  }
-	for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+	for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 	  {
-	    tree link = gimple_asm_input_op (stmt, i);
+	    tree link = gimple_asm_input_op (asm_stmt, i);
 	    tree op = TREE_VALUE (link);
 	    constraint
 	      = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 6ee6ce9..da27f21 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1580,7 +1580,7 @@ dump_gimple_transaction (pretty_printer *buffer, gimple gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_asm (pretty_printer *buffer, gimple_asm gs, int spc, int flags)
 {
   unsigned int i, n, f, fields;
 
@@ -2091,7 +2091,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
   switch (gimple_code (gs))
     {
     case GIMPLE_ASM:
-      dump_gimple_asm (buffer, gs, spc, flags);
+      dump_gimple_asm (buffer, gs->as_a_gimple_asm (), spc, flags);
       break;
 
     case GIMPLE_ASSIGN:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 2d5885f..25d871c 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -137,7 +137,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
     case GIMPLE_ASM:
       {
 	/* FIXME lto.  Move most of this into a new gimple_asm_set_string().  */
-	gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (stmt);
+	gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
 	tree str;
 	asm_stmt->ni = streamer_read_uhwi (ib);
 	asm_stmt->no = streamer_read_uhwi (ib);
@@ -218,11 +218,12 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
     }
   else if (code == GIMPLE_ASM)
     {
+      gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
       unsigned i;
 
-      for (i = 0; i < gimple_asm_noutputs (stmt); i++)
+      for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++)
 	{
-	  tree op = TREE_VALUE (gimple_asm_output_op (stmt, i));
+	  tree op = TREE_VALUE (gimple_asm_output_op (asm_stmt, i));
 	  if (TREE_CODE (op) == SSA_NAME)
 	    SSA_NAME_DEF_STMT (op) = stmt;
 	}
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 85a7966..7aafba1 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -109,12 +109,15 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_ASM:
-      streamer_write_uhwi (ob, gimple_asm_ninputs (stmt));
-      streamer_write_uhwi (ob, gimple_asm_noutputs (stmt));
-      streamer_write_uhwi (ob, gimple_asm_nclobbers (stmt));
-      streamer_write_uhwi (ob, gimple_asm_nlabels (stmt));
-      streamer_write_string (ob, ob->main_stream, gimple_asm_string (stmt),
-			     true);
+      {
+	gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+	streamer_write_uhwi (ob, gimple_asm_ninputs (asm_stmt));
+	streamer_write_uhwi (ob, gimple_asm_noutputs (asm_stmt));
+	streamer_write_uhwi (ob, gimple_asm_nclobbers (asm_stmt));
+	streamer_write_uhwi (ob, gimple_asm_nlabels (asm_stmt));
+	streamer_write_string (ob, ob->main_stream,
+			       gimple_asm_string (asm_stmt), true);
+      }
       /* Fallthru  */
 
     case GIMPLE_ASSIGN:
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 0bb86db..f71b0db 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -94,7 +94,7 @@ walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt,
 /* Helper function for walk_gimple_stmt.  Walk operands of a GIMPLE_ASM.  */
 
 static tree
-walk_gimple_asm (gimple stmt, walk_tree_fn callback_op,
+walk_gimple_asm (gimple_asm stmt, walk_tree_fn callback_op,
 		 struct walk_stmt_info *wi)
 {
   tree ret, op;
@@ -292,7 +292,7 @@ walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
       break;
 
     case GIMPLE_ASM:
-      ret = walk_gimple_asm (stmt, callback_op, wi);
+      ret = walk_gimple_asm (stmt->as_a_gimple_asm (), callback_op, wi);
       if (ret)
 	return ret;
       break;
@@ -779,18 +779,18 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	ret |= visit_addr (stmt, gimple_call_lhs (stmt),
 			   gimple_call_lhs (stmt), data);
     }
-  else if (gimple_code (stmt) == GIMPLE_ASM)
+  else if (gimple_asm asm_stmt = stmt->dyn_cast_gimple_asm ())
     {
       unsigned noutputs;
       const char *constraint;
       const char **oconstraints;
       bool allows_mem, allows_reg, is_inout;
-      noutputs = gimple_asm_noutputs (stmt);
+      noutputs = gimple_asm_noutputs (asm_stmt);
       oconstraints = XALLOCAVEC (const char *, noutputs);
       if (visit_store || visit_addr)
-	for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
+	for (i = 0; i < gimple_asm_noutputs (asm_stmt); ++i)
 	  {
-	    tree link = gimple_asm_output_op (stmt, i);
+	    tree link = gimple_asm_output_op (asm_stmt, i);
 	    tree op = get_base_loadstore (TREE_VALUE (link));
 	    if (op && visit_store)
 	      ret |= visit_store (stmt, op, TREE_VALUE (link), data);
@@ -806,9 +806,9 @@ walk_stmt_load_store_addr_ops (gimple stmt, void *data,
 	      }
 	  }
       if (visit_load || visit_addr)
-	for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+	for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 	  {
-	    tree link = gimple_asm_input_op (stmt, i);
+	    tree link = gimple_asm_input_op (asm_stmt, i);
 	    tree op = TREE_VALUE (link);
 	    if (visit_addr
 		&& TREE_CODE (op) == ADDR_EXPR)
diff --git a/gcc/gimple.c b/gcc/gimple.c
index b73fc74..e037c05 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -538,11 +538,11 @@ gimple_build_bind (tree vars, gimple_seq body, tree block)
    NCLOBBERS is the number of clobbered registers.
    */
 
-static inline gimple
+static inline gimple_asm
 gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs,
                     unsigned nclobbers, unsigned nlabels)
 {
-  gimple_statement_asm *p;
+  gimple_asm p;
   int size = strlen (string);
 
   /* ASMs with labels cannot have outputs.  This should have been
@@ -576,12 +576,12 @@ gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs,
    CLOBBERS is a vector of the clobbered register parameters.
    LABELS is a vector of destination labels.  */
 
-gimple
+gimple_asm
 gimple_build_asm_vec (const char *string, vec<tree, va_gc> *inputs,
                       vec<tree, va_gc> *outputs, vec<tree, va_gc> *clobbers,
 		      vec<tree, va_gc> *labels)
 {
-  gimple p;
+  gimple_asm p;
   unsigned i;
 
   p = gimple_build_asm_1 (string,
@@ -1802,7 +1802,7 @@ gimple_has_side_effects (const_gimple s)
     return true;
 
   if (gimple_code (s) == GIMPLE_ASM
-      && gimple_asm_volatile_p (s))
+      && gimple_asm_volatile_p (s->as_a_gimple_asm ()))
     return true;
 
   if (is_gimple_call (s))
@@ -1843,7 +1843,7 @@ gimple_could_trap_p_1 (gimple s, bool include_mem, bool include_stores)
   switch (gimple_code (s))
     {
     case GIMPLE_ASM:
-      return gimple_asm_volatile_p (s);
+      return gimple_asm_volatile_p (s->as_a_gimple_asm ());
 
     case GIMPLE_CALL:
       t = gimple_call_fndecl (s);
@@ -2457,7 +2457,7 @@ gimple_call_builtin_p (const_gimple stmt, enum built_in_function code)
    GIMPLE_ASM.  */
 
 bool
-gimple_asm_clobbers_memory_p (const_gimple stmt)
+gimple_asm_clobbers_memory_p (const_gimple_asm stmt)
 {
   unsigned i;
 
diff --git a/gcc/gimple.h b/gcc/gimple.h
index a4c7b30..944e473 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -246,6 +246,18 @@ public:
     return as_a <gimple_statement_assign> (this);
   }
 
+  inline gimple_asm
+  as_a_gimple_asm ()
+  {
+    return as_a <gimple_statement_asm> (this);
+  }
+
+  inline const_gimple_asm
+  as_a_gimple_asm () const
+  {
+    return as_a <const gimple_statement_asm> (this);
+  }
+
   inline gimple_call
   as_a_gimple_call ()
   {
@@ -320,6 +332,12 @@ public:
     return dyn_cast <gimple_statement_assign> (this);
   }
 
+  inline gimple_asm
+  dyn_cast_gimple_asm ()
+  {
+    return dyn_cast <gimple_statement_asm> (this);
+  }
+
   inline gimple_call
   dyn_cast_gimple_call ()
   {
@@ -1466,9 +1484,9 @@ gimple_label gimple_build_label (tree label);
 gimple_goto gimple_build_goto (tree dest);
 gimple gimple_build_nop (void);
 gimple_bind gimple_build_bind (tree, gimple_seq, tree);
-gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
-			     vec<tree, va_gc> *, vec<tree, va_gc> *,
-			     vec<tree, va_gc> *);
+gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
+				 vec<tree, va_gc> *, vec<tree, va_gc> *,
+				 vec<tree, va_gc> *);
 gimple gimple_build_catch (tree, gimple_seq);
 gimple gimple_build_eh_filter (tree, gimple_seq);
 gimple gimple_build_eh_must_not_throw (tree);
@@ -1544,7 +1562,7 @@ extern bool gimple_builtin_call_types_compatible_p (const_gimple, tree);
 extern bool gimple_call_builtin_p (const_gimple);
 extern bool gimple_call_builtin_p (const_gimple, enum built_in_class);
 extern bool gimple_call_builtin_p (const_gimple, enum built_in_function);
-extern bool gimple_asm_clobbers_memory_p (const_gimple);
+extern bool gimple_asm_clobbers_memory_p (const_gimple_asm);
 extern void dump_decl_set (FILE *, bitmap);
 extern bool nonfreeing_call_p (gimple);
 extern bool infer_nonnull_range (gimple, tree, bool, bool);
@@ -3450,218 +3468,188 @@ gimple_bind_set_block (gimple_bind bind_stmt, tree block)
 }
 
 
-/* Return the number of input operands for GIMPLE_ASM GS.  */
+/* Return the number of input operands for GIMPLE_ASM ASM_STMT.  */
 
 static inline unsigned
-gimple_asm_ninputs (const_gimple gs)
+gimple_asm_ninputs (const_gimple_asm asm_stmt)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   return asm_stmt->ni;
 }
 
 
-/* Return the number of output operands for GIMPLE_ASM GS.  */
+/* Return the number of output operands for GIMPLE_ASM ASM_STMT.  */
 
 static inline unsigned
-gimple_asm_noutputs (const_gimple gs)
+gimple_asm_noutputs (const_gimple_asm asm_stmt)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   return asm_stmt->no;
 }
 
 
-/* Return the number of clobber operands for GIMPLE_ASM GS.  */
+/* Return the number of clobber operands for GIMPLE_ASM ASM_STMT.  */
 
 static inline unsigned
-gimple_asm_nclobbers (const_gimple gs)
+gimple_asm_nclobbers (const_gimple_asm asm_stmt)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   return asm_stmt->nc;
 }
 
-/* Return the number of label operands for GIMPLE_ASM GS.  */
+/* Return the number of label operands for GIMPLE_ASM ASM_STMT.  */
 
 static inline unsigned
-gimple_asm_nlabels (const_gimple gs)
+gimple_asm_nlabels (const_gimple_asm asm_stmt)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   return asm_stmt->nl;
 }
 
-/* Return input operand INDEX of GIMPLE_ASM GS.  */
+/* Return input operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree
-gimple_asm_input_op (const_gimple gs, unsigned index)
+gimple_asm_input_op (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni);
-  return gimple_op (gs, index + asm_stmt->no);
+  return gimple_op (asm_stmt, index + asm_stmt->no);
 }
 
-/* Return a pointer to input operand INDEX of GIMPLE_ASM GS.  */
+/* Return a pointer to input operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree *
-gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
+gimple_asm_input_op_ptr (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni);
-  return gimple_op_ptr (gs, index + asm_stmt->no);
+  return gimple_op_ptr (asm_stmt, index + asm_stmt->no);
 }
 
 
-/* Set IN_OP to be input operand INDEX in GIMPLE_ASM GS.  */
+/* Set IN_OP to be input operand INDEX in GIMPLE_ASM ASM_STMT.  */
 
 static inline void
-gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
+gimple_asm_set_input_op (gimple_asm asm_stmt, unsigned index, tree in_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni
 			      && TREE_CODE (in_op) == TREE_LIST);
-  gimple_set_op (gs, index + asm_stmt->no, in_op);
+  gimple_set_op (asm_stmt, index + asm_stmt->no, in_op);
 }
 
 
-/* Return output operand INDEX of GIMPLE_ASM GS.  */
+/* Return output operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree
-gimple_asm_output_op (const_gimple gs, unsigned index)
+gimple_asm_output_op (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no);
-  return gimple_op (gs, index);
+  return gimple_op (asm_stmt, index);
 }
 
-/* Return a pointer to output operand INDEX of GIMPLE_ASM GS.  */
+/* Return a pointer to output operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree *
-gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
+gimple_asm_output_op_ptr (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no);
-  return gimple_op_ptr (gs, index);
+  return gimple_op_ptr (asm_stmt, index);
 }
 
 
-/* Set OUT_OP to be output operand INDEX in GIMPLE_ASM GS.  */
+/* Set OUT_OP to be output operand INDEX in GIMPLE_ASM ASM_STMT.  */
 
 static inline void
-gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
+gimple_asm_set_output_op (gimple_asm asm_stmt, unsigned index, tree out_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no
 			      && TREE_CODE (out_op) == TREE_LIST);
-  gimple_set_op (gs, index, out_op);
+  gimple_set_op (asm_stmt, index, out_op);
 }
 
 
-/* Return clobber operand INDEX of GIMPLE_ASM GS.  */
+/* Return clobber operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree
-gimple_asm_clobber_op (const_gimple gs, unsigned index)
+gimple_asm_clobber_op (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nc);
-  return gimple_op (gs, index + asm_stmt->ni + asm_stmt->no);
+  return gimple_op (asm_stmt, index + asm_stmt->ni + asm_stmt->no);
 }
 
 
-/* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM GS.  */
+/* Set CLOBBER_OP to be clobber operand INDEX in GIMPLE_ASM ASM_STMT.  */
 
 static inline void
-gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
+gimple_asm_set_clobber_op (gimple_asm asm_stmt, unsigned index, tree clobber_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nc
 			      && TREE_CODE (clobber_op) == TREE_LIST);
-  gimple_set_op (gs, index + asm_stmt->ni + asm_stmt->no, clobber_op);
+  gimple_set_op (asm_stmt, index + asm_stmt->ni + asm_stmt->no, clobber_op);
 }
 
-/* Return label operand INDEX of GIMPLE_ASM GS.  */
+/* Return label operand INDEX of GIMPLE_ASM ASM_STMT.  */
 
 static inline tree
-gimple_asm_label_op (const_gimple gs, unsigned index)
+gimple_asm_label_op (const_gimple_asm asm_stmt, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nl);
-  return gimple_op (gs, index + asm_stmt->ni + asm_stmt->nc);
+  return gimple_op (asm_stmt, index + asm_stmt->ni + asm_stmt->nc);
 }
 
-/* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM GS.  */
+/* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM ASM_STMT.  */
 
 static inline void
-gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
+gimple_asm_set_label_op (gimple_asm asm_stmt, unsigned index, tree label_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nl
 			      && TREE_CODE (label_op) == TREE_LIST);
-  gimple_set_op (gs, index + asm_stmt->ni + asm_stmt->nc, label_op);
+  gimple_set_op (asm_stmt, index + asm_stmt->ni + asm_stmt->nc, label_op);
 }
 
 /* Return the string representing the assembly instruction in
-   GIMPLE_ASM GS.  */
+   GIMPLE_ASM ASM_STMT.  */
 
 static inline const char *
-gimple_asm_string (const_gimple gs)
+gimple_asm_string (const_gimple_asm asm_stmt)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm> (gs);
   return asm_stmt->string;
 }
 
 
-/* Return true if GS is an asm statement marked volatile.  */
+/* Return true ASM_STMT ASM_STMT is an asm statement marked volatile.  */
 
 static inline bool
-gimple_asm_volatile_p (const_gimple gs)
+gimple_asm_volatile_p (const_gimple_asm asm_stmt)
 {
-  GIMPLE_CHECK (gs, GIMPLE_ASM);
-  return (gs->subcode & GF_ASM_VOLATILE) != 0;
+  return (asm_stmt->subcode & GF_ASM_VOLATILE) != 0;
 }
 
 
-/* If VOLATLE_P is true, mark asm statement GS as volatile.  */
+/* If VOLATLE_P is true, mark asm statement ASM_STMT as volatile.  */
 
 static inline void
-gimple_asm_set_volatile (gimple gs, bool volatile_p)
+gimple_asm_set_volatile (gimple_asm asm_stmt, bool volatile_p)
 {
-  GIMPLE_CHECK (gs, GIMPLE_ASM);
   if (volatile_p)
-    gs->subcode |= GF_ASM_VOLATILE;
+    asm_stmt->subcode |= GF_ASM_VOLATILE;
   else
-    gs->subcode &= ~GF_ASM_VOLATILE;
+    asm_stmt->subcode &= ~GF_ASM_VOLATILE;
 }
 
 
-/* If INPUT_P is true, mark asm GS as an ASM_INPUT.  */
+/* If INPUT_P is true, mark asm ASM_STMT as an ASM_INPUT.  */
 
 static inline void
-gimple_asm_set_input (gimple gs, bool input_p)
+gimple_asm_set_input (gimple_asm asm_stmt, bool input_p)
 {
-  GIMPLE_CHECK (gs, GIMPLE_ASM);
   if (input_p)
-    gs->subcode |= GF_ASM_INPUT;
+    asm_stmt->subcode |= GF_ASM_INPUT;
   else
-    gs->subcode &= ~GF_ASM_INPUT;
+    asm_stmt->subcode &= ~GF_ASM_INPUT;
 }
 
 
-/* Return true if asm GS is an ASM_INPUT.  */
+/* Return true if asm ASM_STMT is an ASM_INPUT.  */
 
 static inline bool
-gimple_asm_input_p (const_gimple gs)
+gimple_asm_input_p (const_gimple_asm asm_stmt)
 {
-  GIMPLE_CHECK (gs, GIMPLE_ASM);
-  return (gs->subcode & GF_ASM_INPUT) != 0;
+  return (asm_stmt->subcode & GF_ASM_INPUT) != 0;
 }
 
 
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 05e986a..7aaac08 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -183,7 +183,8 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
       break;
     case GIMPLE_ASM:
       {
-	size_t i, noutputs = gimple_asm_noutputs (stmt);
+	gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+	size_t i, noutputs = gimple_asm_noutputs (asm_stmt);
 	const char *constraint, **oconstraints;
 	bool allows_mem, allows_reg, is_inout;
 
@@ -191,7 +192,7 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
 	  = (const char **) alloca ((noutputs) * sizeof (const char *));
 	for (i = 0; i < noutputs; i++)
 	  {
-	    tree op = gimple_asm_output_op (stmt, i);
+	    tree op = gimple_asm_output_op (asm_stmt, i);
 	    constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
 	    oconstraints[i] = constraint;
 	    parse_output_constraint (&constraint, i, 0, 0, &allows_mem,
@@ -200,9 +201,9 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
 			   is_inout ? is_gimple_min_lval : is_gimple_lvalue,
 			   fb_lvalue | fb_mayfail);
 	  }
-	for (i = 0; i < gimple_asm_ninputs (stmt); i++)
+	for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++)
 	  {
-	    tree op = gimple_asm_input_op (stmt, i);
+	    tree op = gimple_asm_input_op (asm_stmt, i);
 	    constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op)));
 	    parse_input_constraint (&constraint, 0, 0, noutputs, 0,
 				    oconstraints, &allows_mem, &allows_reg);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b24ce70..e0444ca 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4861,7 +4861,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
   const char *constraint;
   bool allows_mem, allows_reg, is_inout;
   enum gimplify_status ret, tret;
-  gimple stmt;
+  gimple_asm stmt;
   vec<tree, va_gc> *inputs;
   vec<tree, va_gc> *outputs;
   vec<tree, va_gc> *clobbers;
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index e5ec305..133bc73 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -697,14 +697,14 @@ check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
 	}
       break;
     case GIMPLE_ASM:
-      if (gimple_asm_clobbers_memory_p (stmt))
+      if (gimple_asm_clobbers_memory_p (stmt->as_a_gimple_asm ()))
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "    memory asm clobber is not const/pure\n");
 	  /* Abandon all hope, ye who enter here. */
 	  local->pure_const_state = IPA_NEITHER;
 	}
-      if (gimple_asm_volatile_p (stmt))
+      if (gimple_asm_volatile_p (stmt->as_a_gimple_asm ()))
 	{
 	  if (dump_file)
 	    fprintf (dump_file, "    volatile is not const/pure\n");
diff --git a/gcc/ssa-iterators.h b/gcc/ssa-iterators.h
index 2c75e4a..126a46e 100644
--- a/gcc/ssa-iterators.h
+++ b/gcc/ssa-iterators.h
@@ -610,7 +610,7 @@ op_iter_init (ssa_op_iter *ptr, gimple stmt, int flags)
 	    ptr->numops = 1;
 	    break;
 	  case GIMPLE_ASM:
-	    ptr->numops = gimple_asm_noutputs (stmt);
+	    ptr->numops = gimple_asm_noutputs (stmt->as_a_gimple_asm ());
 	    break;
 	  default:
 	    ptr->numops = 0;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 8b8020e..6c0f157 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1203,7 +1203,7 @@ make_goto_expr_edges (basic_block bb)
 static void
 make_gimple_asm_edges (basic_block bb)
 {
-  gimple stmt = last_stmt (bb);
+  gimple_asm stmt = last_stmt (bb)->as_a_gimple_asm ();
   int i, n = gimple_asm_nlabels (stmt);
 
   for (i = 0; i < n; ++i)
@@ -1403,11 +1403,12 @@ cleanup_dead_labels (void)
 
 	case GIMPLE_ASM:
 	  {
-	    int i, n = gimple_asm_nlabels (stmt);
+	    gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+	    int i, n = gimple_asm_nlabels (asm_stmt);
 
 	    for (i = 0; i < n; ++i)
 	      {
-		tree cons = gimple_asm_label_op (stmt, i);
+		tree cons = gimple_asm_label_op (asm_stmt, i);
 		tree label = main_block_label (TREE_VALUE (cons));
 		TREE_VALUE (cons) = label;
 	      }
@@ -2379,7 +2380,7 @@ is_ctrl_altering_stmt (gimple t)
       return true;
 
     case GIMPLE_ASM:
-      if (gimple_asm_nlabels (t) > 0)
+      if (gimple_asm_nlabels (t->as_a_gimple_asm ()) > 0)
 	return true;
       break;
 
@@ -5465,12 +5466,13 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_ASM:
       {
-	int i, n = gimple_asm_nlabels (stmt);
+	gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+	int i, n = gimple_asm_nlabels (asm_stmt);
 	tree label = NULL;
 
 	for (i = 0; i < n; ++i)
 	  {
-	    tree cons = gimple_asm_label_op (stmt, i);
+	    tree cons = gimple_asm_label_op (asm_stmt, i);
 	    if (label_to_block (TREE_VALUE (cons)) == e->dest)
 	      {
 		if (!label)
@@ -7503,9 +7505,9 @@ need_fake_edge_p (gimple t)
 	  return true;
     }
 
-  if (gimple_code (t) == GIMPLE_ASM
-       && (gimple_asm_volatile_p (t) || gimple_asm_input_p (t)))
-    return true;
+  if (gimple_asm asm_stmt = t->dyn_cast_gimple_asm ())
+    if (gimple_asm_volatile_p (asm_stmt) || gimple_asm_input_p (asm_stmt))
+      return true;
 
   return false;
 }
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 55b120e..166eb1b 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -1420,7 +1420,7 @@ expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
 static void
 expand_complex_asm (gimple_stmt_iterator *gsi)
 {
-  gimple stmt = gsi_stmt (*gsi);
+  gimple_asm stmt = gsi_stmt (*gsi)->as_a_gimple_asm ();
   unsigned int i;
 
   for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 01d0a7a..8626753 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -4370,7 +4370,8 @@ get_references_in_stmt (gimple stmt, vec<data_ref_loc, va_heap> *references)
 	clobbers_memory = true;
     }
   else if (stmt_code == GIMPLE_ASM
-	   && (gimple_asm_volatile_p (stmt) || gimple_vuse (stmt)))
+	   && (gimple_asm_volatile_p (stmt->as_a_gimple_asm ())
+	       || gimple_vuse (stmt)))
     clobbers_memory = true;
 
   if (!gimple_vuse (stmt))
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index c9e9be1..c5eda1f 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -2801,7 +2801,7 @@ stmt_could_throw_p (gimple stmt)
     case GIMPLE_ASM:
       if (!cfun->can_throw_non_call_exceptions)
         return false;
-      return gimple_asm_volatile_p (stmt);
+      return gimple_asm_volatile_p (stmt->as_a_gimple_asm ());
 
     default:
       return false;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 9f06006..3c935b8 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3896,7 +3896,8 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
 
     case GIMPLE_ASM:
       {
-	int count = asm_str_count (gimple_asm_string (stmt));
+	int count =
+	  asm_str_count (gimple_asm_string (stmt->as_a_gimple_asm ()));
 	/* 1000 means infinity. This avoids overflows later
 	   with very long asm statements.  */
 	if (count > 1000)
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index ffef13d..60728aa 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1324,21 +1324,24 @@ scan_function (void)
 	      break;
 
 	    case GIMPLE_ASM:
-	      walk_stmt_load_store_addr_ops (stmt, NULL, NULL, NULL,
-					     asm_visit_addr);
-	      if (final_bbs)
-		bitmap_set_bit (final_bbs, bb->index);
+	      {
+		gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+		walk_stmt_load_store_addr_ops (asm_stmt, NULL, NULL, NULL,
+					       asm_visit_addr);
+		if (final_bbs)
+		  bitmap_set_bit (final_bbs, bb->index);
 
-	      for (i = 0; i < gimple_asm_ninputs (stmt); i++)
-		{
-		  t = TREE_VALUE (gimple_asm_input_op (stmt, i));
-		  ret |= build_access_from_expr (t, stmt, false);
-		}
-	      for (i = 0; i < gimple_asm_noutputs (stmt); i++)
-		{
-		  t = TREE_VALUE (gimple_asm_output_op (stmt, i));
-		  ret |= build_access_from_expr (t, stmt, true);
-		}
+		for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++)
+		  {
+		    t = TREE_VALUE (gimple_asm_input_op (asm_stmt, i));
+		    ret |= build_access_from_expr (t, asm_stmt, false);
+		  }
+		for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++)
+		  {
+		    t = TREE_VALUE (gimple_asm_output_op (asm_stmt, i));
+		    ret |= build_access_from_expr (t, asm_stmt, true);
+		  }
+	      }
 	      break;
 
 	    default:
@@ -3369,16 +3372,19 @@ sra_modify_function_body (void)
 	      break;
 
 	    case GIMPLE_ASM:
-	      for (i = 0; i < gimple_asm_ninputs (stmt); i++)
-		{
-		  t = &TREE_VALUE (gimple_asm_input_op (stmt, i));
-		  modified |= sra_modify_expr (t, &gsi, false);
-		}
-	      for (i = 0; i < gimple_asm_noutputs (stmt); i++)
-		{
-		  t = &TREE_VALUE (gimple_asm_output_op (stmt, i));
-		  modified |= sra_modify_expr (t, &gsi, true);
-		}
+	      {
+		gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+		for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++)
+		  {
+		    t = &TREE_VALUE (gimple_asm_input_op (asm_stmt, i));
+		    modified |= sra_modify_expr (t, &gsi, false);
+		  }
+		for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++)
+		  {
+		    t = &TREE_VALUE (gimple_asm_output_op (asm_stmt, i));
+		    modified |= sra_modify_expr (t, &gsi, true);
+		  }
+	      }
 	      break;
 
 	    default:
@@ -4635,16 +4641,19 @@ ipa_sra_modify_function_body (ipa_parm_adjustment_vec adjustments)
 	      break;
 
 	    case GIMPLE_ASM:
-	      for (i = 0; i < gimple_asm_ninputs (stmt); i++)
-		{
-		  t = &TREE_VALUE (gimple_asm_input_op (stmt, i));
-		  modified |= ipa_modify_expr (t, true, adjustments);
-		}
-	      for (i = 0; i < gimple_asm_noutputs (stmt); i++)
-		{
-		  t = &TREE_VALUE (gimple_asm_output_op (stmt, i));
-		  modified |= ipa_modify_expr (t, false, adjustments);
-		}
+	      {
+		gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+		for (i = 0; i < gimple_asm_ninputs (asm_stmt); i++)
+		  {
+		    t = &TREE_VALUE (gimple_asm_input_op (asm_stmt, i));
+		    modified |= ipa_modify_expr (t, true, adjustments);
+		  }
+		for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++)
+		  {
+		    t = &TREE_VALUE (gimple_asm_output_op (asm_stmt, i));
+		    modified |= ipa_modify_expr (t, false, adjustments);
+		  }
+	      }
 	      break;
 
 	    default:
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index c42a8eb..fa1c3cf 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -1007,15 +1007,16 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
 
 	    case GIMPLE_ASM:
 	      {
+		gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
 		unsigned long noutputs, i;
 		unsigned long ninputs;
 		tree *outputs, link;
-		noutputs = gimple_asm_noutputs (stmt);
-		ninputs = gimple_asm_ninputs (stmt);
+		noutputs = gimple_asm_noutputs (asm_stmt);
+		ninputs = gimple_asm_ninputs (asm_stmt);
 		outputs = (tree *) alloca (noutputs * sizeof (tree));
 		for (i = 0; i < noutputs; ++i)
 		  {
-		    link = gimple_asm_output_op (stmt, i);
+		    link = gimple_asm_output_op (asm_stmt, i);
 		    outputs[i] = TREE_VALUE (link);
 		  }
 
@@ -1026,7 +1027,7 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
 		    char *end;
 		    unsigned long match;
 
-		    link = gimple_asm_input_op (stmt, i);
+		    link = gimple_asm_input_op (asm_stmt, i);
 		    constraint
 		      = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
 		    input = TREE_VALUE (link);
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 8d3fc5b..1f885c6 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -878,14 +878,14 @@ propagate_necessity (bool aggressive)
 		    mark_all_reaching_defs_necessary (stmt);
 		}
 	    }
-	  else if (gimple_code (stmt) == GIMPLE_ASM)
+	  else if (gimple_asm asm_stmt = stmt->dyn_cast_gimple_asm ())
 	    {
 	      unsigned i;
 	      mark_all_reaching_defs_necessary (stmt);
 	      /* Inputs may perform loads.  */
-	      for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+	      for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 		{
-		  tree op = TREE_VALUE (gimple_asm_input_op (stmt, i));
+		  tree op = TREE_VALUE (gimple_asm_input_op (asm_stmt, i));
 		  if (TREE_CODE (op) != SSA_NAME
 		      && !is_gimple_min_invariant (op)
 		      && TREE_CODE (op) != CONSTRUCTOR
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index b95a273..d3f654c 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -662,7 +662,7 @@ maybe_add_call_vops (struct function *fn, gimple_call stmt)
 /* Scan operands in the ASM_EXPR stmt referred to in INFO.  */
 
 static void
-get_asm_stmt_operands (struct function *fn, gimple stmt)
+get_asm_stmt_operands (struct function *fn, gimple_asm stmt)
 {
   size_t i, noutputs;
   const char **oconstraints;
@@ -915,7 +915,7 @@ parse_ssa_operands (struct function *fn, gimple stmt)
   switch (code)
     {
     case GIMPLE_ASM:
-      get_asm_stmt_operands (fn, stmt);
+      get_asm_stmt_operands (fn, stmt->as_a_gimple_asm ());
       break;
 
     case GIMPLE_TRANSACTION:
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 01905cf..72b20f2 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -4774,17 +4774,18 @@ find_func_aliases (gimple origt)
   /* Handle asms conservatively by adding escape constraints to everything.  */
   else if (gimple_code (t) == GIMPLE_ASM)
     {
+      gimple_asm asm_stmt = t->as_a_gimple_asm ();
       unsigned i, noutputs;
       const char **oconstraints;
       const char *constraint;
       bool allows_mem, allows_reg, is_inout;
 
-      noutputs = gimple_asm_noutputs (t);
+      noutputs = gimple_asm_noutputs (asm_stmt);
       oconstraints = XALLOCAVEC (const char *, noutputs);
 
       for (i = 0; i < noutputs; ++i)
 	{
-	  tree link = gimple_asm_output_op (t, i);
+	  tree link = gimple_asm_output_op (asm_stmt, i);
 	  tree op = TREE_VALUE (link);
 
 	  constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
@@ -4812,9 +4813,9 @@ find_func_aliases (gimple origt)
 	      lhsc.release ();
 	    }
 	}
-      for (i = 0; i < gimple_asm_ninputs (t); ++i)
+      for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 	{
-	  tree link = gimple_asm_input_op (t, i);
+	  tree link = gimple_asm_input_op (asm_stmt, i);
 	  tree op = TREE_VALUE (link);
 
 	  constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link)));
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 0a4af13..03c6b4a 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -370,7 +370,8 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
       /* If the statement has volatile operands, then we assume we
 	 can not thread through this block.  This is overly
 	 conservative in some ways.  */
-      if (gimple_code (stmt) == GIMPLE_ASM && gimple_asm_volatile_p (stmt))
+      if (gimple_code (stmt) == GIMPLE_ASM
+	  && gimple_asm_volatile_p (stmt->as_a_gimple_asm ()))
 	return NULL;
 
       /* If duplicating this block is going to cause too much code
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 2927e0b..7d0e844 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1501,9 +1501,10 @@ execute_update_addresses_taken (void)
 
 	  else if (code == GIMPLE_ASM)
 	    {
-	      for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
+	      gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
+	      for (i = 0; i < gimple_asm_noutputs (asm_stmt); ++i)
 		{
-		  tree link = gimple_asm_output_op (stmt, i);
+		  tree link = gimple_asm_output_op (asm_stmt, i);
 		  tree lhs = TREE_VALUE (link);
 		  if (TREE_CODE (lhs) != SSA_NAME)
 		    {
@@ -1518,9 +1519,9 @@ execute_update_addresses_taken (void)
 			bitmap_set_bit (not_reg_needs, DECL_UID (decl));
 		    }
 		}
-	      for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+	      for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 		{
-		  tree link = gimple_asm_input_op (stmt, i);
+		  tree link = gimple_asm_input_op (asm_stmt, i);
 		  if ((decl = non_rewritable_mem_ref_base (TREE_VALUE (link))))
 		    bitmap_set_bit (not_reg_needs, DECL_UID (decl));
 		}
@@ -1631,16 +1632,17 @@ execute_update_addresses_taken (void)
 
 	    else if (gimple_code (stmt) == GIMPLE_ASM)
 	      {
+		gimple_asm asm_stmt = stmt->as_a_gimple_asm ();
 		unsigned i;
-		for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
+		for (i = 0; i < gimple_asm_noutputs (asm_stmt); ++i)
 		  {
-		    tree link = gimple_asm_output_op (stmt, i);
+		    tree link = gimple_asm_output_op (asm_stmt, i);
 		    maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
 						suitable_for_renaming);
 		  }
-		for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
+		for (i = 0; i < gimple_asm_ninputs (asm_stmt); ++i)
 		  {
-		    tree link = gimple_asm_input_op (stmt, i);
+		    tree link = gimple_asm_input_op (asm_stmt, i);
 		    maybe_rewrite_mem_ref_base (&TREE_VALUE (link),
 						suitable_for_renaming);
 		  }
-- 
1.8.5.3

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

* [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (84 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 68/89] Concretize three gimple_return_ accessors David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 17:16   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 23/89] Introduce gimple_asm David Malcolm
                   ` (5 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* tree-cfg.c (verify_gimple_call): Require a gimple_call rather
	than a plain gimple.
	(verify_gimple_stmt): Add checked cast to gimple_call within
	GIMPLE_CALL case of switch statement.
---
 gcc/tree-cfg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 0d3c0d7..b2cca43 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3174,7 +3174,7 @@ valid_fixed_convert_types_p (tree type1, tree type2)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_call (gimple stmt)
+verify_gimple_call (gimple_call stmt)
 {
   tree fn = gimple_call_fn (stmt);
   tree fntype, fndecl;
@@ -4411,7 +4411,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_label (stmt->as_a_gimple_label ());
 
     case GIMPLE_CALL:
-      return verify_gimple_call (stmt);
+      return verify_gimple_call (stmt->as_a_gimple_call ());
 
     case GIMPLE_COND:
       if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
-- 
1.8.5.3

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

* [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (79 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 12/89] tree-predcom.c: use gimple_phi in various places David Malcolm
@ 2014-04-21 17:15 ` David Malcolm
  2014-05-12 20:33   ` Jeff Law
  2014-04-21 17:15 ` [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call David Malcolm
                   ` (10 subsequent siblings)
  91 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* gimple.h (gimple_phi_arg_edge): Require a gimple_phi rather
	than a plain gimple.

	* graphite-sese-to-poly.c (rewrite_phi_out_of_ssa): Require a
	gimple_phi_iterator; strengthen local "phi" from gimple to a
	gimple_phi.
	(rewrite_cross_bb_scalar_deps): Strengthen local "psi" from
	a gimple_stmt_iterator to a gimple_phi_iterator.
	(edge_initial_value_for_loop_phi): Require a gimple phi.
	(initial_value_for_loop_phi): Likewise.

	* ipa-split.c (consider_split): Convert "bsi" to a
	gimple_phi_iterator and "stmt" to a gimple_phi.

	* predict.c (predict_extra_loop_exits): Convert "phi_stmt" to be
	a gimple_phi; introduce "lhs_def_stmt" as plain gimple.
	(apply_return_prediction): Convert "phi" to be a gimple_phi.

	* tree-cfg.c (replace_uses_by): Add checked cast to gimple_phi.
	(verify_gimple_in_cfg): Introduce gimple_phi_iterator "gpi" and use
	it to convert "phi" to a gimple_phi.

	* tree-eh.c (cleanup_empty_eh_merge_phis): Convert "ngsi", "ogsi"
	to be gimple_phi_iterators.  Convert "ophi", "nphi" to be
	gimple_phi.

	* tree-into-ssa.c (prepare_use_sites_for): Add checked cast to
	gimple_phi.

	* tree-ssa-coalesce.c (create_outofssa_var_map): Introduce
	gimple_phi_iterator "gpi" and use it to convert "phi" to a
	gimple_phi.

	* tree-ssa-dce.c (propagate_necessity): Introduce local "phi",
	from checked cast to gimple_phi.

	* tree-ssa-live.c (set_var_live_on_entry): Add checked cast to
	gimple_phi.

	* tree-ssa-propagate.c (replace_phi_args_in): Require a gimple_phi
	rather than a plain gimple.
	(substitute_and_fold): Introduce gimple_phi_iterator "gpi".

	* tree-ssa-sink.c (find_bb_for_arg): Require a gimple_phi rather
	than a plain gimple.
	(nearest_common_dominator_of_uses): Replace check of code against
	GIMPLE_PHI with a dyn_cast_gimple_phi, introducing a new local.
	(statement_sink_location): Add checked cast to gimple_phi.

	* tree-ssa-uninit.c (compute_uninit_opnds_pos): Require a
	gimple_phi rather than a plain gimple.
	(collect_phi_def_edges): Likewise.
	(find_def_preds): Likewise.
	(is_use_properly_guarded): Likewise.
	(prune_uninit_phi_opnds_in_unrealizable_paths): Likewise.  Also,
	convert "flag_arg_def", "phi_arg_def" to gimple_phi using
	dyn_cast_gimple_phi.  Similarly, introduce new local
	"opnd_def_phi".
	(use_pred_not_overlap_with_undef_path_pred): Require a
	gimple_phi rather than a plain gimple; add a checked cast.
	(find_uninit_use): Replace check of code against GIMPLE_PHI with
	a dyn_cast_gimple_phi, introducing a new local.
---
 gcc/gimple.h                |  6 +++---
 gcc/graphite-sese-to-poly.c | 10 +++++-----
 gcc/ipa-split.c             |  4 ++--
 gcc/predict.c               | 15 ++++++++++-----
 gcc/tree-cfg.c              |  9 ++++++---
 gcc/tree-eh.c               |  6 +++---
 gcc/tree-into-ssa.c         |  2 +-
 gcc/tree-ssa-coalesce.c     |  6 ++++--
 gcc/tree-ssa-dce.c          |  3 ++-
 gcc/tree-ssa-live.c         |  2 +-
 gcc/tree-ssa-propagate.c    |  6 +++---
 gcc/tree-ssa-sink.c         |  8 ++++----
 gcc/tree-ssa-uninit.c       | 41 +++++++++++++++++++++--------------------
 13 files changed, 65 insertions(+), 53 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6007516..72f67ce 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4251,12 +4251,12 @@ gimple_phi_arg_def_ptr (gimple_phi phi, size_t index)
   return &gimple_phi_arg (phi, index)->def;
 }
 
-/* Return the edge associated with argument I of phi node GS.  */
+/* Return the edge associated with argument I of phi node PHI.  */
 
 static inline edge
-gimple_phi_arg_edge (gimple gs, size_t i)
+gimple_phi_arg_edge (gimple_phi phi, size_t i)
 {
-  return EDGE_PRED (gimple_bb (gs), i);
+  return EDGE_PRED (gimple_bb (phi), i);
 }
 
 /* Return the source location of gimple argument I of phi node GS.  */
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 8dca109..11ea1d3 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2234,10 +2234,10 @@ rewrite_close_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
    dimension array for it.  */
 
 static void
-rewrite_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
+rewrite_phi_out_of_ssa (scop_p scop, gimple_phi_iterator *psi)
 {
   size_t i;
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   basic_block bb = gimple_bb (phi);
   tree res = gimple_phi_result (phi);
   tree zero_dim_array = create_zero_dim_array (res, "phi_out_of_ssa");
@@ -2447,7 +2447,7 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi)
     if (gimple_code (use_stmt) == GIMPLE_PHI
 	&& (res = true))
       {
-	gimple_stmt_iterator psi = gsi_for_stmt (use_stmt);
+	gimple_phi_iterator psi = gsi_start_phis (gimple_bb (use_stmt));
 
 	if (scalar_close_phi_node_p (gsi_stmt (psi)))
 	  rewrite_close_phi_out_of_ssa (scop, &psi);
@@ -2739,7 +2739,7 @@ follow_inital_value_to_phi (tree arg, tree lhs)
    from outside the loop.  */
 
 static edge
-edge_initial_value_for_loop_phi (gimple phi)
+edge_initial_value_for_loop_phi (gimple_phi phi)
 {
   size_t i;
 
@@ -2759,7 +2759,7 @@ edge_initial_value_for_loop_phi (gimple phi)
    from outside the loop.  */
 
 static tree
-initial_value_for_loop_phi (gimple phi)
+initial_value_for_loop_phi (gimple_phi phi)
 {
   size_t i;
 
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index e294dc3..0797abff 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -383,7 +383,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
   unsigned int call_overhead;
   edge e;
   edge_iterator ei;
-  gimple_stmt_iterator bsi;
+  gimple_phi_iterator bsi;
   unsigned int i;
   int incoming_freq = 0;
   tree retval;
@@ -440,7 +440,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
      incoming from header are the same.  */
   for (bsi = gsi_start_phis (current->entry_bb); !gsi_end_p (bsi); gsi_next (&bsi))
     {
-      gimple stmt = gsi_stmt (bsi);
+      gimple_phi stmt = bsi.phi ();
       tree val = NULL;
 
       if (virtual_operand_p (gimple_phi_result (stmt)))
diff --git a/gcc/predict.c b/gcc/predict.c
index 249433f..7b4bb12 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1462,7 +1462,8 @@ predict_extra_loop_exits (edge exit_edge)
 {
   unsigned i;
   bool check_value_one;
-  gimple phi_stmt;
+  gimple lhs_def_stmt;
+  gimple_phi phi_stmt;
   tree cmp_rhs, cmp_lhs;
   gimple cmp_stmt = last_stmt (exit_edge->src);
 
@@ -1483,8 +1484,12 @@ predict_extra_loop_exits (edge exit_edge)
 		    ^ (gimple_cond_code (cmp_stmt) == EQ_EXPR))
 		    ^ ((exit_edge->flags & EDGE_TRUE_VALUE) != 0));
 
-  phi_stmt = SSA_NAME_DEF_STMT (cmp_lhs);
-  if (!phi_stmt || gimple_code (phi_stmt) != GIMPLE_PHI)
+  lhs_def_stmt = SSA_NAME_DEF_STMT (cmp_lhs);
+  if (!lhs_def_stmt)
+    return;
+
+  phi_stmt = lhs_def_stmt->dyn_cast_gimple_phi ();
+  if (!phi_stmt)
     return;
 
   for (i = 0; i < gimple_phi_num_args (phi_stmt); i++)
@@ -2215,7 +2220,7 @@ apply_return_prediction (void)
   gimple return_stmt = NULL;
   tree return_val;
   edge e;
-  gimple phi;
+  gimple_phi phi;
   int phi_num_args, i;
   enum br_predictor pred;
   enum prediction direction;
@@ -2237,7 +2242,7 @@ apply_return_prediction (void)
       || !SSA_NAME_DEF_STMT (return_val)
       || gimple_code (SSA_NAME_DEF_STMT (return_val)) != GIMPLE_PHI)
     return;
-  phi = SSA_NAME_DEF_STMT (return_val);
+  phi = SSA_NAME_DEF_STMT (return_val)->as_a_gimple_phi ();
   phi_num_args = gimple_phi_num_args (phi);
   pred = return_prediction (PHI_ARG_DEF (phi, 0), &direction);
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 347b6b3..9efb01c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1692,7 +1692,8 @@ replace_uses_by (tree name, tree val)
 
 	  if (gimple_code (stmt) == GIMPLE_PHI)
 	    {
-	      e = gimple_phi_arg_edge (stmt, PHI_ARG_INDEX_FROM_USE (use));
+	      e = gimple_phi_arg_edge (stmt->as_a_gimple_phi (),
+				       PHI_ARG_INDEX_FROM_USE (use));
 	      if (e->flags & EDGE_ABNORMAL)
 		{
 		  /* This can only occur for virtual operands, since
@@ -4804,9 +4805,11 @@ verify_gimple_in_cfg (struct function *fn)
     {
       gimple_stmt_iterator gsi;
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+	   !gsi_end_p (gpi);
+	   gsi_next (&gpi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gpi.phi ();
 	  bool err2 = false;
 	  unsigned i;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 70a284b..928d397 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -4156,7 +4156,7 @@ static bool
 cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
 			     edge old_bb_out, bool change_region)
 {
-  gimple_stmt_iterator ngsi, ogsi;
+  gimple_phi_iterator ngsi, ogsi;
   edge_iterator ei;
   edge e;
   bitmap ophi_handled;
@@ -4186,7 +4186,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
      for the edges we're going to move.  */
   for (ngsi = gsi_start_phis (new_bb); !gsi_end_p (ngsi); gsi_next (&ngsi))
     {
-      gimple ophi, nphi = gsi_stmt (ngsi);
+      gimple_phi ophi, nphi = ngsi.phi ();
       tree nresult, nop;
 
       nresult = gimple_phi_result (nphi);
@@ -4197,7 +4197,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
       ophi = NULL;
       for (ogsi = gsi_start_phis (old_bb); !gsi_end_p (ogsi); gsi_next (&ogsi))
 	{
-	  ophi = gsi_stmt (ogsi);
+	  ophi = ogsi.phi ();
 	  if (gimple_phi_result (ophi) == nop)
 	    break;
 	  ophi = NULL;
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index dfe9108..217adeb 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2604,7 +2604,7 @@ prepare_use_sites_for (tree name, bool insert_phi_p)
       if (gimple_code (stmt) == GIMPLE_PHI)
 	{
 	  int ix = PHI_ARG_INDEX_FROM_USE (use_p);
-	  edge e = gimple_phi_arg_edge (stmt, ix);
+	  edge e = gimple_phi_arg_edge (stmt->as_a_gimple_phi (), ix);
 	  mark_use_interesting (name, stmt, e->src, insert_phi_p);
 	}
       else
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index fa1c3cf..cd4f5a1 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -933,9 +933,11 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
     {
       tree arg;
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+	   !gsi_end_p (gpi);
+	   gsi_next (&gpi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gpi.phi ();
 	  size_t i;
 	  int ver;
 	  tree res;
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 294fc33..2953a1b 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -657,6 +657,7 @@ propagate_necessity (bool aggressive)
 	     we also consider the control dependent edges leading to the
 	     predecessor block associated with each PHI alternative as
 	     necessary.  */
+	  gimple_phi phi = stmt->as_a_gimple_phi ();
 	  size_t k;
 
 	  for (k = 0; k < gimple_phi_num_args (stmt); k++)
@@ -739,7 +740,7 @@ propagate_necessity (bool aggressive)
 	    {
 	      for (k = 0; k < gimple_phi_num_args (stmt); k++)
 		{
-		  basic_block arg_bb = gimple_phi_arg_edge (stmt, k)->src;
+		  basic_block arg_bb = gimple_phi_arg_edge (phi, k)->src;
 
 		  if (gimple_bb (stmt)
 		      != get_immediate_dominator (CDI_POST_DOMINATORS, arg_bb))
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 2c431e7..3223a71 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1108,7 +1108,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
 	     as this is where a copy would be inserted.  Check to see if it is
 	     defined in that block, or whether its live on entry.  */
 	  int index = PHI_ARG_INDEX_FROM_USE (use);
-	  edge e = gimple_phi_arg_edge (use_stmt, index);
+	  edge e = gimple_phi_arg_edge (use_stmt->as_a_gimple_phi (), index);
 	  if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
 	    {
 	      if (e->src != def_bb)
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index a2afcdd..ad7f008 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -954,7 +954,7 @@ replace_uses_in (gimple stmt, ssa_prop_get_value_fn get_value)
    values from PROP_VALUE.  */
 
 static void
-replace_phi_args_in (gimple phi, ssa_prop_get_value_fn get_value)
+replace_phi_args_in (gimple_phi phi, ssa_prop_get_value_fn get_value)
 {
   size_t i;
   bool replaced = false;
@@ -1103,8 +1103,8 @@ substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
 
       /* Propagate known values into PHI nodes.  */
       if (get_value_fn)
-	for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
-	  replace_phi_args_in (gsi_stmt (i), get_value_fn);
+	for (gimple_phi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); gsi_next (&gpi))
+	  replace_phi_args_in (gpi.phi (), get_value_fn);
 
       /* Propagate known values into stmts.  Do a backward walk if
          do_dce is true. In some case it exposes
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 6d02975..295cf48 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -85,7 +85,7 @@ static struct
    we return NULL.  */
 
 static basic_block
-find_bb_for_arg (gimple phi, tree def)
+find_bb_for_arg (gimple_phi phi, tree def)
 {
   size_t i;
   bool foundone = false;
@@ -157,11 +157,11 @@ nearest_common_dominator_of_uses (gimple stmt, bool *debug_stmts)
 	  gimple usestmt = USE_STMT (use_p);
 	  basic_block useblock;
 
-	  if (gimple_code (usestmt) == GIMPLE_PHI)
+	  if (gimple_phi phi = usestmt->dyn_cast_gimple_phi ())
 	    {
 	      int idx = PHI_ARG_INDEX_FROM_USE (use_p);
 
-	      useblock = gimple_phi_arg_edge (usestmt, idx)->src;
+	      useblock = gimple_phi_arg_edge (phi, idx)->src;
 	    }
 	  else if (is_gimple_debug (usestmt))
 	    {
@@ -417,7 +417,7 @@ statement_sink_location (gimple stmt, basic_block frombb,
 	}
     }
 
-  sinkbb = find_bb_for_arg (use, DEF_FROM_PTR (def_p));
+  sinkbb = find_bb_for_arg (use->as_a_gimple_phi (), DEF_FROM_PTR (def_p));
 
   /* This can happen if there are multiple uses in a PHI.  */
   if (!sinkbb)
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 43be808..60c9cad 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -284,7 +284,7 @@ can_skip_redundant_opnd (tree opnd, gimple phi)
    that have empty (or possibly empty) definitions.  */
 
 static unsigned
-compute_uninit_opnds_pos (gimple phi)
+compute_uninit_opnds_pos (gimple_phi phi)
 {
   size_t i, n;
   unsigned uninit_opnds = 0;
@@ -636,7 +636,7 @@ find_predicates (pred_chain_union *preds,
    VISITED_PHIS is a pointer set for detecting cycles.  */
 
 static void
-collect_phi_def_edges (gimple phi, basic_block cd_root,
+collect_phi_def_edges (gimple_phi phi, basic_block cd_root,
                        vec<edge> *edges,
                        pointer_set_t *visited_phis)
 {
@@ -669,7 +669,7 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
           if (gimple_code (def) == GIMPLE_PHI
               && dominated_by_p (CDI_DOMINATORS,
                                  gimple_bb (def), cd_root))
-            collect_phi_def_edges (def, cd_root, edges,
+            collect_phi_def_edges (def->as_a_gimple_phi (), cd_root, edges,
                                    visited_phis);
           else if (!uninit_undefined_value_p (opnd))
             {
@@ -689,7 +689,7 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
    composite predicates pointed to by PREDS.  */
 
 static bool
-find_def_preds (pred_chain_union *preds, gimple phi)
+find_def_preds (pred_chain_union *preds, gimple_phi phi)
 {
   size_t num_chains = 0, i, n;
   vec<edge> dep_chains[MAX_NUM_CHAINS];
@@ -930,7 +930,7 @@ find_matching_predicate_in_rest_chains (pred_info pred,
 static bool
 is_use_properly_guarded (gimple use_stmt,
                          basic_block use_bb,
-                         gimple phi,
+                         gimple_phi phi,
                          unsigned uninit_opnds,
                          pointer_set_t *visited_phis);
 
@@ -969,9 +969,9 @@ is_use_properly_guarded (gimple use_stmt,
 */
 
 static bool
-prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
+prune_uninit_phi_opnds_in_unrealizable_paths (gimple_phi phi,
 					      unsigned uninit_opnds,
-					      gimple flag_def,
+					      gimple_phi flag_def,
 					      tree boundary_cst,
 					      enum tree_code cmp_code,
 					      pointer_set_t *visited_phis,
@@ -989,22 +989,22 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
       flag_arg = gimple_phi_arg_def (flag_def, i);
       if (!is_gimple_constant (flag_arg))
         {
-          gimple flag_arg_def, phi_arg_def;
+          gimple_phi flag_arg_def, phi_arg_def;
           tree phi_arg;
           unsigned uninit_opnds_arg_phi;
 
           if (TREE_CODE (flag_arg) != SSA_NAME)
             return false;
-          flag_arg_def = SSA_NAME_DEF_STMT (flag_arg);
-          if (gimple_code (flag_arg_def) != GIMPLE_PHI)
+          flag_arg_def = SSA_NAME_DEF_STMT (flag_arg)->dyn_cast_gimple_phi ();
+	  if (!flag_arg_def)
             return false;
 
           phi_arg = gimple_phi_arg_def (phi, i);
           if (TREE_CODE (phi_arg) != SSA_NAME)
             return false;
 
-          phi_arg_def = SSA_NAME_DEF_STMT (phi_arg);
-          if (gimple_code (phi_arg_def) != GIMPLE_PHI)
+          phi_arg_def = SSA_NAME_DEF_STMT (phi_arg)->dyn_cast_gimple_phi ();
+	  if (!phi_arg_def)
             return false;
 
           if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
@@ -1045,16 +1045,16 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
 
           opnd = gimple_phi_arg_def (phi, i);
           opnd_def = SSA_NAME_DEF_STMT (opnd);
-          if (gimple_code (opnd_def) == GIMPLE_PHI)
+          if (gimple_phi opnd_def_phi = opnd_def->dyn_cast_gimple_phi ())
             {
               edge opnd_edge;
               unsigned uninit_opnds2
-                  = compute_uninit_opnds_pos (opnd_def);
+                  = compute_uninit_opnds_pos (opnd_def_phi);
               gcc_assert (!MASK_EMPTY (uninit_opnds2));
               opnd_edge = gimple_phi_arg_edge (phi, i);
               if (!is_use_properly_guarded (phi,
                                             opnd_edge->src,
-                                            opnd_def,
+                                            opnd_def_phi,
                                             uninit_opnds2,
                                             visited_phis))
                   return false;
@@ -1143,7 +1143,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
 
 static bool
 use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
-				           gimple phi, unsigned uninit_opnds,
+				           gimple_phi phi,
+					   unsigned uninit_opnds,
 					   pointer_set_t *visited_phis)
 {
   unsigned int i, n;
@@ -1217,7 +1218,7 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
 
   all_pruned = prune_uninit_phi_opnds_in_unrealizable_paths (phi,
                                                              uninit_opnds,
-                                                             flag_def,
+                                                             flag_def->as_a_gimple_phi (),
                                                              boundary_cst,
                                                              cmp_code,
                                                              visited_phis,
@@ -2101,7 +2102,7 @@ normalize_preds (pred_chain_union preds, gimple use_or_def, bool is_use)
 static bool
 is_use_properly_guarded (gimple use_stmt,
                          basic_block use_bb,
-                         gimple phi,
+                         gimple_phi phi,
                          unsigned uninit_opnds,
                          pointer_set_t *visited_phis)
 {
@@ -2192,8 +2193,8 @@ find_uninit_use (gimple_phi phi, unsigned uninit_opnds,
 
       visited_phis = pointer_set_create ();
 
-      if (gimple_code (use_stmt) == GIMPLE_PHI)
-	use_bb = gimple_phi_arg_edge (use_stmt,
+      if (gimple_phi use_phi = use_stmt->dyn_cast_gimple_phi ())
+	use_bb = gimple_phi_arg_edge (use_phi,
 				      PHI_ARG_INDEX_FROM_USE (use_p))->src;
       else
 	use_bb = gimple_bb (use_stmt);
-- 
1.8.5.3

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

* [PATCH 30/89] Introduce gimple_eh_dispatch
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (87 preceding siblings ...)
  2014-04-21 17:15 ` [PATCH 35/89] Introduce gimple_omp_atomic_store David Malcolm
@ 2014-04-21 17:29 ` David Malcolm
  2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
                   ` (2 subsequent siblings)
  91 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-21 17:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

gcc/
	* coretypes.h (gimple_eh_dispatch): New typedef.
	(const_gimple_eh_dispatch): New typedef.

	* gimple-pretty-print.c (dump_gimple_eh_dispatch): Require a
	gimple_eh_dispatch rather than a plain gimple.
	(pp_gimple_stmt_1): Add a checked cast to gimple_eh_dispatch
	within GIMPLE_EH_DISPATCH case of switch statement.

	* gimple-streamer-in.c (input_gimple_stmt): Likewise.

	* gimple-streamer-out.c (output_gimple_stmt): Likewise.

	* gimple.c (gimple_build_eh_dispatch): Return a gimple_eh_dispatch
	rather than a plain gimple.

	* gimple.h (gimple_statement_base::as_a_gimple_eh_dispatch): New.
	(gimple_build_eh_dispatch): Return a gimple_eh_dispatch rather
	than a plain gimple.
	(gimple_eh_dispatch_region): Require a const_gimple_eh_dispatch
	rather than a plain const_gimple.
	(gimple_eh_dispatch_set_region): Require a gimple_eh_dispatch
	rather than a plain gimple.

	* tree-cfg.c (make_edges): Add a checked cast to gimple_eh_dispatch
	within GIMPLE_EH_DISPATCH case of switch statement.
	(gimple_verify_flow_info): Likewise.
	(gimple_redirect_edge_and_branch): Likewise.
	(move_stmt_r): Likewise, adding a local.

	* tree-eh.c (emit_eh_dispatch): Convert local from gimple to
	gimple_eh_dispatch.
	(make_eh_dispatch_edges): Require a gimple_eh_dispatch rather than
	a plain gimple.
	(redirect_eh_dispatch_edge): Likewise.
	(lower_eh_dispatch): Likewise.
	(execute_lower_eh_dispatch): Add a checked cast to
	gimple_eh_dispatch.
	(mark_reachable_handlers): Likewise.
	(verify_eh_dispatch_edge): Require a gimple_eh_dispatch rather
	than a plain gimple.

	* tree-eh.h (make_eh_dispatch_edges): Likewise.
	(redirect_eh_dispatch_edge): Likewise.
	(verify_eh_dispatch_edge): Likewise.

	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
	gimple_eh_dispatch within GIMPLE_EH_DISPATCH case of switch
	statement, adding a local.
	(copy_edges_for_bb): Add a checked cast to gimple_eh_dispatch.
---
 gcc/coretypes.h           |  4 ++++
 gcc/gimple-pretty-print.c |  5 +++--
 gcc/gimple-streamer-in.c  |  3 ++-
 gcc/gimple-streamer-out.c |  4 +++-
 gcc/gimple.c              |  8 ++++----
 gcc/gimple.h              | 21 ++++++++++++---------
 gcc/tree-cfg.c            | 12 +++++++-----
 gcc/tree-eh.c             | 17 ++++++++++-------
 gcc/tree-eh.h             |  6 +++---
 gcc/tree-inline.c         |  7 ++++---
 10 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 379ac6a..b997a8d 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -133,6 +133,10 @@ struct gimple_statement_resx;
 typedef struct gimple_statement_resx *gimple_resx;
 typedef const struct gimple_statement_resx *const_gimple_resx;
 
+struct gimple_statement_eh_dispatch;
+typedef struct gimple_statement_eh_dispatch *gimple_eh_dispatch;
+typedef const struct gimple_statement_eh_dispatch *const_gimple_eh_dispatch;
+
 struct gimple_statement_phi;
 typedef struct gimple_statement_phi *gimple_phi;
 typedef const struct gimple_statement_phi *const_gimple_phi;
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 93ac677..28234cb 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1059,7 +1059,7 @@ dump_gimple_resx (pretty_printer *buffer, gimple_resx gs, int spc, int flags)
 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_eh_dispatch (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_eh_dispatch (pretty_printer *buffer, gimple_eh_dispatch gs, int spc, int flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -2224,7 +2224,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_EH_DISPATCH:
-      dump_gimple_eh_dispatch (buffer, gs, spc, flags);
+      dump_gimple_eh_dispatch (buffer, gs->as_a_gimple_eh_dispatch (), spc,
+			       flags);
       break;
 
     case GIMPLE_DEBUG:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 4662832..4fb0b41 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -134,7 +134,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_EH_DISPATCH:
-      gimple_eh_dispatch_set_region (stmt, streamer_read_hwi (ib));
+      gimple_eh_dispatch_set_region (stmt->as_a_gimple_eh_dispatch (),
+				     streamer_read_hwi (ib));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index 521e789..5d3adf8 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -108,7 +108,9 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
       break;
 
     case GIMPLE_EH_DISPATCH:
-      streamer_write_hwi (ob, gimple_eh_dispatch_region (stmt));
+      streamer_write_hwi (ob,
+			  gimple_eh_dispatch_region (
+			    stmt->as_a_gimple_eh_dispatch ()));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 88d9203..e74fad3 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -756,12 +756,12 @@ gimple_build_switch (tree index, tree default_label, vec<tree> args)
 
 /* Build a GIMPLE_EH_DISPATCH statement.  */
 
-gimple
+gimple_eh_dispatch
 gimple_build_eh_dispatch (int region)
 {
-  gimple_statement_eh_dispatch *p =
-    as_a <gimple_statement_eh_dispatch> (
-      gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
+  gimple_eh_dispatch p =
+    gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0)
+      ->as_a_gimple_eh_dispatch ();
   p->region = region;
   return p;
 }
diff --git a/gcc/gimple.h b/gcc/gimple.h
index fbbb676..1ee15e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -318,6 +318,12 @@ public:
     return as_a <gimple_statement_resx> (this);
   }
 
+  inline gimple_eh_dispatch
+  as_a_gimple_eh_dispatch ()
+  {
+    return as_a <gimple_statement_eh_dispatch> (this);
+  }
+
   inline gimple_phi
   as_a_gimple_phi ()
   {
@@ -1545,7 +1551,7 @@ gimple gimple_build_wce (gimple_seq);
 gimple_resx gimple_build_resx (int);
 gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
 gimple_switch gimple_build_switch (tree, tree, vec<tree> );
-gimple gimple_build_eh_dispatch (int);
+gimple_eh_dispatch gimple_build_eh_dispatch (int);
 gimple_debug gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)			\
   gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
@@ -4212,23 +4218,20 @@ gimple_resx_set_region (gimple_resx resx_stmt, int region)
   resx_stmt->region = region;
 }
 
-/* Return the region number for GIMPLE_EH_DISPATCH GS.  */
+/* Return the region number for GIMPLE_EH_DISPATCH EH_DISPATCH_STMT.  */
 
 static inline int
-gimple_eh_dispatch_region (const_gimple gs)
+gimple_eh_dispatch_region (const_gimple_eh_dispatch eh_dispatch_stmt)
 {
-  const gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <const gimple_statement_eh_dispatch> (gs);
   return eh_dispatch_stmt->region;
 }
 
-/* Set REGION to be the region number for GIMPLE_EH_DISPATCH GS.  */
+/* Set REGION to be the region number for GIMPLE_EH_DISPATCH
+   EH_DISPATCH_STMT.  */
 
 static inline void
-gimple_eh_dispatch_set_region (gimple gs, int region)
+gimple_eh_dispatch_set_region (gimple_eh_dispatch eh_dispatch_stmt, int region)
 {
-  gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <gimple_statement_eh_dispatch> (gs);
   eh_dispatch_stmt->region = region;
 }
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a11f4f0..0d3c0d7 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -766,7 +766,8 @@ make_edges (void)
 	      fallthru = false;
 	      break;
 	    case GIMPLE_EH_DISPATCH:
-	      fallthru = make_eh_dispatch_edges (last);
+	      fallthru =
+		make_eh_dispatch_edges (last->as_a_gimple_eh_dispatch ());
 	      break;
 
 	    case GIMPLE_CALL:
@@ -5254,7 +5255,7 @@ gimple_verify_flow_info (void)
 	  break;
 
 	case GIMPLE_EH_DISPATCH:
-	  err |= verify_eh_dispatch_edge (stmt);
+	  err |= verify_eh_dispatch_edge (stmt->as_a_gimple_eh_dispatch ());
 	  break;
 
 	default:
@@ -5508,7 +5509,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_EH_DISPATCH:
       if (!(e->flags & EDGE_FALLTHRU))
-	redirect_eh_dispatch_edge (stmt, e, dest);
+	redirect_eh_dispatch_edge (stmt->as_a_gimple_eh_dispatch (), e, dest);
       break;
 
     case GIMPLE_TRANSACTION:
@@ -6469,9 +6470,10 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_EH_DISPATCH:
       {
-	int r = gimple_eh_dispatch_region (stmt);
+	gimple_eh_dispatch eh_dispatch_stmt = stmt->as_a_gimple_eh_dispatch ();
+	int r = gimple_eh_dispatch_region (eh_dispatch_stmt);
 	r = move_stmt_eh_region_nr (r, p);
-	gimple_eh_dispatch_set_region (stmt, r);
+	gimple_eh_dispatch_set_region (eh_dispatch_stmt, r);
       }
       break;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 0f2c77e..ee810b0 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -840,7 +840,7 @@ emit_resx (gimple_seq *seq, eh_region region)
 static void
 emit_eh_dispatch (gimple_seq *seq, eh_region region)
 {
-  gimple x = gimple_build_eh_dispatch (region->index);
+  gimple_eh_dispatch x = gimple_build_eh_dispatch (region->index);
   gimple_seq_add_stmt (seq, x);
 }
 
@@ -2225,7 +2225,7 @@ make_pass_lower_eh (gcc::context *ctxt)
    no fallthru edge; false if there is.  */
 
 bool
-make_eh_dispatch_edges (gimple stmt)
+make_eh_dispatch_edges (gimple_eh_dispatch stmt)
 {
   eh_region r;
   eh_catch c;
@@ -2383,7 +2383,7 @@ redirect_eh_edge (edge edge_in, basic_block new_bb)
    The actual edge update will happen in the caller.  */
 
 void
-redirect_eh_dispatch_edge (gimple stmt, edge e, basic_block new_bb)
+redirect_eh_dispatch_edge (gimple_eh_dispatch stmt, edge e, basic_block new_bb)
 {
   tree new_lab = gimple_block_label (new_bb);
   bool any_changed = false;
@@ -3598,7 +3598,7 @@ sink_clobbers (basic_block bb)
    we have found some duplicate labels and removed some edges.  */
 
 static bool
-lower_eh_dispatch (basic_block src, gimple stmt)
+lower_eh_dispatch (basic_block src, gimple_eh_dispatch stmt)
 {
   gimple_stmt_iterator gsi;
   int region_nr;
@@ -3759,7 +3759,8 @@ execute_lower_eh_dispatch (void)
 	continue;
       if (gimple_code (last) == GIMPLE_EH_DISPATCH)
 	{
-	  redirected |= lower_eh_dispatch (bb, last);
+	  redirected |= lower_eh_dispatch (bb,
+					   last->as_a_gimple_eh_dispatch ());
 	  flags |= TODO_update_ssa_only_virtuals;
 	}
       else if (gimple_code (last) == GIMPLE_RESX)
@@ -3887,7 +3888,9 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap *lp_reachablep)
 			      gimple_resx_region (stmt->as_a_gimple_resx ()));
 	      break;
 	    case GIMPLE_EH_DISPATCH:
-	      bitmap_set_bit (r_reachable, gimple_eh_dispatch_region (stmt));
+	      bitmap_set_bit (r_reachable,
+			      gimple_eh_dispatch_region (
+                                stmt->as_a_gimple_eh_dispatch ()));
 	      break;
 	    default:
 	      break;
@@ -4735,7 +4738,7 @@ verify_eh_edges (gimple stmt)
 /* Similarly, but handle GIMPLE_EH_DISPATCH specifically.  */
 
 DEBUG_FUNCTION bool
-verify_eh_dispatch_edge (gimple stmt)
+verify_eh_dispatch_edge (gimple_eh_dispatch stmt)
 {
   eh_region r;
   eh_catch c;
diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h
index cd9b40d..2d985ac 100644
--- a/gcc/tree-eh.h
+++ b/gcc/tree-eh.h
@@ -26,10 +26,10 @@ extern bool remove_stmt_from_eh_lp_fn (struct function *, gimple);
 extern bool remove_stmt_from_eh_lp (gimple);
 extern int lookup_stmt_eh_lp_fn (struct function *, gimple);
 extern int lookup_stmt_eh_lp (gimple);
-extern bool make_eh_dispatch_edges (gimple);
+extern bool make_eh_dispatch_edges (gimple_eh_dispatch);
 extern void make_eh_edges (gimple);
 extern edge redirect_eh_edge (edge, basic_block);
-extern void redirect_eh_dispatch_edge (gimple, edge, basic_block);
+extern void redirect_eh_dispatch_edge (gimple_eh_dispatch, edge, basic_block);
 extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,
 					   bool, tree, bool *);
 extern bool operation_could_trap_p (enum tree_code, bool, bool, tree);
@@ -47,6 +47,6 @@ extern bool maybe_duplicate_eh_stmt_fn (struct function *, gimple,
 extern bool maybe_duplicate_eh_stmt (gimple, gimple);
 extern void maybe_remove_unreachable_handlers (void);
 extern bool verify_eh_edges (gimple);
-extern bool verify_eh_dispatch_edge (gimple);
+extern bool verify_eh_dispatch_edge (gimple_eh_dispatch);
 
 #endif /* GCC_TREE_EH_H */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 49d326c..f1d2791 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1546,9 +1546,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id)
 
 	  case GIMPLE_EH_DISPATCH:
 	    {
-	      int r = gimple_eh_dispatch_region (copy);
+	      gimple_eh_dispatch eh_dispatch = copy->as_a_gimple_eh_dispatch ();
+	      int r = gimple_eh_dispatch_region (eh_dispatch);
 	      r = remap_eh_region_nr (r, id);
-	      gimple_eh_dispatch_set_region (copy, r);
+	      gimple_eh_dispatch_set_region (eh_dispatch, r);
 	    }
 	    break;
 
@@ -2057,7 +2058,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb,
 	}
 
       if (gimple_code (copy_stmt) == GIMPLE_EH_DISPATCH)
-	make_eh_dispatch_edges (copy_stmt);
+	make_eh_dispatch_edges (copy_stmt->as_a_gimple_eh_dispatch ());
       else if (can_throw)
 	make_eh_edges (copy_stmt);
 
-- 
1.8.5.3

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

* Re: [PATCH 01/89] Const-correctness fixes for some gimple accessors
  2014-04-21 16:56 ` [PATCH 01/89] Const-correctness fixes for some gimple accessors David Malcolm
@ 2014-04-21 18:46   ` Jeff Law
  2014-04-21 22:45     ` David Malcolm
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-21 18:46 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_assign_single_p): Accept a const_gimple rather
> 	than a gimple.
> 	(gimple_store_p): Likewise.
> 	(gimple_assign_load_p): Likewise.
> 	(gimple_assign_cast_p): Likewise.
> 	(gimple_clobber_p): Likewise.
I know you bootstrapped the entire 89 patch series.  Generally when we 
have a nice little independent patch like this, it should be separately 
bootstrapped and tested so that it can go forward independent of 
everything else.

Anyway, this is clearly OK and non-controversial.  OK for the trunk.

In fact, I would consider any const-correctness patch like this to be 
pre-approved.

jeff

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

* Re: [PATCH 33/89] Use more concrete types for various gimple statements
  2014-04-21 17:14 ` [PATCH 33/89] Use more concrete types for various gimple statements David Malcolm
@ 2014-04-21 20:20   ` Bill Schmidt
  2014-05-12 17:11   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Bill Schmidt @ 2014-04-21 20:20 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

Hi David,

Just a quick review of the gimple-ssa-strength-reduction.c changes.  I
have one stylistic comment:

On Mon, 2014-04-21 at 12:57 -0400, David Malcolm wrote:

> diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
> index 9320b51..35e15e0 100644
> --- a/gcc/gimple-ssa-strength-reduction.c
> +++ b/gcc/gimple-ssa-strength-reduction.c
> @@ -2058,7 +2058,7 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, double_int bump)
>        if (bump.is_zero ())
>  	{
>  	  tree lhs = gimple_assign_lhs (c->cand_stmt);
> -	  gimple copy_stmt = gimple_build_assign (lhs, basis_name);
> +	  gimple_assign copy_stmt = gimple_build_assign (lhs, basis_name);
>  	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
>  	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
>  	  gsi_replace (&gsi, copy_stmt, false);
> @@ -2159,7 +2159,7 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
>    basic_block insert_bb;
>    gimple_stmt_iterator gsi;
>    tree lhs, basis_type;
> -  gimple new_stmt;
> +  gimple_assign new_stmt;
> 
>    /* If the add candidate along this incoming edge has the same
>       index as C's hidden basis, the hidden basis represents this
> @@ -3118,7 +3118,7 @@ insert_initializers (slsr_cand_t c)
>      {
>        basic_block bb;
>        slsr_cand_t where = NULL;
> -      gimple init_stmt;
> +      gimple_assign init_stmt;
>        tree stride_type, new_name, incr_tree;
>        double_int incr = incr_vec[i].incr;
> 
> @@ -3256,7 +3256,7 @@ static tree
>  introduce_cast_before_cand (slsr_cand_t c, tree to_type, tree from_expr)
>  {
>    tree cast_lhs;
> -  gimple cast_stmt;
> +  gimple_assign cast_stmt;
>    gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
> 
>    cast_lhs = make_temp_ssa_name (to_type, NULL, "slsr");
> @@ -3418,7 +3418,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
>        
>        if (types_compatible_p (lhs_type, basis_type))
>  	{
> -	  gimple copy_stmt = gimple_build_assign (lhs, basis_name);
> +	  gimple_assign copy_stmt = gimple_build_assign (lhs, basis_name);
>  	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
>  	  gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
>  	  gsi_replace (&gsi, copy_stmt, false);
> @@ -3430,9 +3430,10 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name)
>        else
>  	{
>  	  gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
> -	  gimple cast_stmt = gimple_build_assign_with_ops (NOP_EXPR, lhs,
> -							   basis_name,
> -							   NULL_TREE);
> +	  gimple_assign cast_stmt =
> +	    gimple_build_assign_with_ops (NOP_EXPR, lhs,
> +					  basis_name,
> +					  NULL_TREE);

Please collapse the last three lines onto one line, now that it will
fit.

Thanks,
Bill

>  	  gimple_set_location (cast_stmt, gimple_location (c->cand_stmt));
>  	  gsi_replace (&gsi, cast_stmt, false);
>  	  c->cand_stmt = cast_stmt;


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

* Re: [PATCH 01/89] Const-correctness fixes for some gimple accessors
  2014-04-21 18:46   ` Jeff Law
@ 2014-04-21 22:45     ` David Malcolm
  2014-04-27  2:35       ` Gerald Pfeifer
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-21 22:45 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

On Mon, 2014-04-21 at 12:43 -0600, Jeff Law wrote:
> On 04/21/14 10:56, David Malcolm wrote:
> > gcc/
> > 	* gimple.h (gimple_assign_single_p): Accept a const_gimple rather
> > 	than a gimple.
> > 	(gimple_store_p): Likewise.
> > 	(gimple_assign_load_p): Likewise.
> > 	(gimple_assign_cast_p): Likewise.
> > 	(gimple_clobber_p): Likewise.
> I know you bootstrapped the entire 89 patch series.  Generally when we 
> have a nice little independent patch like this, it should be separately 
> bootstrapped and tested so that it can go forward independent of 
> everything else.
> 
> Anyway, this is clearly OK and non-controversial.  OK for the trunk.
> 
> In fact, I would consider any const-correctness patch like this to be 
> pre-approved.

Thanks.

It was pointed out to me off-list that this patch series lacks
documentation changes.  I'm working on fixing that, though am not sure I
want to fill everyone inboxes with an updated set of patches yet.
Should I send a combined patch for the documentation changes?  (I can
break it up and merge it into the individual changes on commit, or if
these need editing).

In any case I fixed up the corresponding entries in gcc/doc/gimple.texi,
double-checked the bootstrap/regtest/HTML generation of this one (on top
of r209545), and committed it to trunk as r209548.  I'm attaching what I
actually committed.

Dave

[-- Attachment #2: r209548.patch --]
[-- Type: text/x-patch, Size: 2826 bytes --]

Index: gcc/doc/gimple.texi
===================================================================
--- gcc/doc/gimple.texi	(revision 209547)
+++ gcc/doc/gimple.texi	(revision 209548)
@@ -701,7 +701,7 @@
 Return true if the code of g is @code{GIMPLE_DEBUG}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_assign_cast_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple g)
 Return true if g is a @code{GIMPLE_ASSIGN} that performs a type cast
 operation.
 @end deftypefn
@@ -1102,7 +1102,7 @@
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_assign_cast_p (gimple s)
+@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple s)
 Return true if @code{S} is a type-cast assignment.
 @end deftypefn
 
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 209547)
+++ gcc/ChangeLog	(revision 209548)
@@ -1,3 +1,16 @@
+2014-04-21  David Malcolm  <dmalcolm@redhat.com>
+
+	* gimple.h (gimple_assign_single_p): Accept a const_gimple rather
+	than a gimple.
+	(gimple_store_p): Likewise.
+	(gimple_assign_load_p): Likewise.
+	(gimple_assign_cast_p): Likewise.
+	(gimple_clobber_p): Likewise.
+
+	* doc/gimple.texi (gimple_assign_cast_p): Accept a const_gimple
+	rather than a gimple.
+	(gimple_assign_cast_p): Likewise.
+
 2014-04-21  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
 	PR target/60735
Index: gcc/gimple.h
===================================================================
--- gcc/gimple.h	(revision 209547)
+++ gcc/gimple.h	(revision 209548)
@@ -2330,7 +2330,7 @@
    and do not have the semantics of a copy, such as COND_EXPR.  */
 
 static inline bool
-gimple_assign_single_p (gimple gs)
+gimple_assign_single_p (const_gimple gs)
 {
   return (is_gimple_assign (gs)
           && gimple_assign_rhs_class (gs) == GIMPLE_SINGLE_RHS);
@@ -2339,7 +2339,7 @@
 /* Return true if GS performs a store to its lhs.  */
 
 static inline bool
-gimple_store_p (gimple gs)
+gimple_store_p (const_gimple gs)
 {
   tree lhs = gimple_get_lhs (gs);
   return lhs && !is_gimple_reg (lhs);
@@ -2348,7 +2348,7 @@
 /* Return true if GS is an assignment that loads from its rhs1.  */
 
 static inline bool
-gimple_assign_load_p (gimple gs)
+gimple_assign_load_p (const_gimple gs)
 {
   tree rhs;
   if (!gimple_assign_single_p (gs))
@@ -2365,7 +2365,7 @@
 /* Return true if S is a type-cast assignment.  */
 
 static inline bool
-gimple_assign_cast_p (gimple s)
+gimple_assign_cast_p (const_gimple s)
 {
   if (is_gimple_assign (s))
     {
@@ -2381,7 +2381,7 @@
 /* Return true if S is a clobber statement.  */
 
 static inline bool
-gimple_clobber_p (gimple s)
+gimple_clobber_p (const_gimple s)
 {
   return gimple_assign_single_p (s)
          && TREE_CLOBBER_P (gimple_assign_rhs1 (s));

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-21 16:56 ` [PATCH 02/89] Introduce gimple_switch and use it in various places David Malcolm
@ 2014-04-22  2:46   ` Trevor Saunders
  2014-04-22 14:21     ` Richard Biener
  2014-04-22 17:19     ` David Malcolm
  2014-04-23 20:01   ` Jeff Law
  1 sibling, 2 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-04-22  2:46 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

> --- a/gcc/tree-loop-distribution.c
> +++ b/gcc/tree-loop-distribution.c
> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
>  		}
>  	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
>  		{
> +		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();

maybe it would make more sense to do
else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
?

Trev


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (88 preceding siblings ...)
  2014-04-21 17:29 ` [PATCH 30/89] Introduce gimple_eh_dispatch David Malcolm
@ 2014-04-22  8:07 ` Richard Sandiford
  2014-04-22 13:20   ` Andrew MacLeod
                     ` (2 more replies)
  2014-04-22  8:37 ` Richard Biener
  2014-04-23 14:43 ` Michael Matz
  91 siblings, 3 replies; 250+ messages in thread
From: Richard Sandiford @ 2014-04-22  8:07 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

First of all, thanks a lot for doing this.  Maybe one day we'll have
the same in rtl :-)

But...

David Malcolm <dmalcolm@redhat.com> writes:
> In doing the checked downcasts I ran into the verbosity of the as_a <>
> API (in our "is-a.h").  I first tried simplifying them with custom
> functions e.g.:
>
>    static inline gimple_bind as_a_gimple_bind (gimple gs)
>    {
>      return as_a <gimple_statement_bind> (gs);
>    }
>
> but the approach I've gone with makes these checked casts be *methods* of
> the gimple_statement_base class, so that e.g. in a switch statement you
> can write:
>
>     case GIMPLE_SWITCH:
>       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
>       break;
>
> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> concrete "gimple_switch" in a release build, with runtime checking for
> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> internally).
>
> This is much less verbose than trying to do it with as_a <> directly, and
> I think doing it as a method reads better aloud (to my English-speaking
> mind, at-least):
>   "gs as a gimple switch",
> as opposed to:
>   "as a gimple switch... gs",
> which I find clunky.
>
> It makes the base class a little cluttered, but IMHO it hits a sweet-spot
> of readability and type-safety with relatively little verbosity (only 8
> more characters than doing it with a raw C-style cast).   Another
> advantage of having the checked cast as a *method* is that it implicitly
> documents the requirement that the input must be non-NULL.

...FWIW I really don't like these cast members.  The counterarguments are:

- as_a <...> (...) and dyn_cast <...> (...) follow the C++ syntax
  for other casts.

- the type you get is obvious, rather than being a contraction of
  the type name.

- having them as methods means that the base class needs to aware of
  all subclasses.  I realise that's probably inherently true of gimple
  due to the enum, but it seems like bad design.  You could potentially
  have different subclasses for the same enum, selected by a secondary field.

Maybe I've just been reading C code too long, but "as a gimple switch...gs"
doesn't seem any less natural than "is constant...address".

Another way of reducing the verbosity of as_a would be to shorten the
type names.  E.g. "gimple_statement" contracts to "gimple_stmt" in some
places, so "gimple_statement_bind" could become "gimple_stmt_bind" or
just "gimple_bind".  "gimple_bind" is probably better since it matches
the names of the accessors.

If the thing after "as_a_" matches the type name, the "X->as_a_foo ()"
takes the same number of characters as "as_a <foo> (X)".

Thanks,
Richard

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (89 preceding siblings ...)
  2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
@ 2014-04-22  8:37 ` Richard Biener
  2014-04-23 17:23   ` Jeff Law
  2014-04-23 14:43 ` Michael Matz
  91 siblings, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-22  8:37 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches

On Mon, Apr 21, 2014 at 6:56 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> This is a greatly-expanded version of:
>   http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01262.html
>
> As of r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and
> r205428 (a90353203da18288cdac1b0b78fe7b22c69fe63f) the various gimple
> statements form a C++ inheritance hierarchy, but we're not yet making much
> use of that in the code: everything refers to just "gimple" (or
> "const_gimple"), and type-checking is performed at run-time within the
> various gimple_foo_* accessors in gimple.h, and almost nowhere else.
>
> The following patch series introduces compile-time checking of much of
> the handling of gimple statements.
>
> Various new typedefs are introduced for pointers to statements where the
> specific code is known, matching the corresponding names from gimple.def.

Even though I like these changes in principle I also wear a release
managers hat.  Being one of the persons doing frequent backports
of trunk fixes to branches this will cause a _lot_ of headache.  So ... can
we delay this until, say, 4.9.1 is out?

Thanks,
Richard.

> For example, it introduces a "gimple_bind" typedef, which is a
>   (gimple_statement_bind *)
> which has the invariant that stmt->code == GIMPLE_BIND.
>
> The idea is that all of the gimple_foo_* accessors in gimple.h are
> converted from taking just a "gimple" to a "gimple_foo".  I've managed
> this so far for 15 of the gimple statement subclasses; for example, all
> of the "gimple_bind_*" accessors now require a "gimple_bind" rather than
> a plain "gimple".
>
> Similarly, variabless throughout the middle-end have their types
> strengthened from plain "gimple" to a typedef expressing a pointer to
> some concrete statement subclass, and similarly for vectors.  For example
> various variables have their types strengthened from "gimple" to
> "gimple_bind", and from plain vec<gimple> to vec<gimple_bind> (e.g. within
> gimplify.c for handling the bind stack).
>
> Numerous other such typedefs are introduced: essentially two for each of
> the gimple code values: a gimple_foo and a const_gimple_foo variant e.g.
> gimple_switch and const_gimple_switch (some of the rarer codes don't have
> such typedefs yet).
>
> Some of these typedefs are aliases for existing subclasses within the
> "gimple" class hierarchy, but others are new with this patch series.  As
> with the existing subclasses, they don't add any extra fields, they merely
> express invariants on the gimple's code.
>
> In each case there are some checked downcasts from "gimple" down to the
> more concrete statement-type, so that the runtime-checking in the checked
> build happens there, at the boundary between types, rather than the
> current checking, which is every time an accessor is called and almost
> nowhere else.
>
> Once we're in a more concrete type than "gimple", the compiler can enforce
> the type-checking for us at compile-time.
>
> An additional benefit is that human readers of the code should (I hope)
> have an easier time following what's going on: assumptions about the
> underlying gimple_code of a stmt that previously were hidden are now
> obvious, expressed directly in the type system.
>
> For example, various variables in tree-into-ssa.c change from just
> vec<gimple> to being vec<gimple_phi>, capturing the "phi-ness" of the
> contents as a compile-time check (and then not needing to check them any
> more); indeed great swathes of phi-manipulation code are changed from
> acting on vanilla "gimple" to acting on "gimple_phi".
>
> Similarly, within tree-inline.h's struct copy_body_data, the field
> "debug_stmts" can be "concretized" from a vec<gimple> to a
> vec<gimple_debug>.
>
> Another notable such concretization is that the "call_stmt" field of a
> cgraph_edge becomes a gimple_call, rather than a plain gimple.
>
> In doing the checked downcasts I ran into the verbosity of the as_a <>
> API (in our "is-a.h").  I first tried simplifying them with custom
> functions e.g.:
>
>    static inline gimple_bind as_a_gimple_bind (gimple gs)
>    {
>      return as_a <gimple_statement_bind> (gs);
>    }
>
> but the approach I've gone with makes these checked casts be *methods* of
> the gimple_statement_base class, so that e.g. in a switch statement you
> can write:
>
>     case GIMPLE_SWITCH:
>       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
>       break;
>
> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> concrete "gimple_switch" in a release build, with runtime checking for
> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> internally).
>
> This is much less verbose than trying to do it with as_a <> directly, and
> I think doing it as a method reads better aloud (to my English-speaking
> mind, at-least):
>   "gs as a gimple switch",
> as opposed to:
>   "as a gimple switch... gs",
> which I find clunky.
>
> It makes the base class a little cluttered, but IMHO it hits a sweet-spot
> of readability and type-safety with relatively little verbosity (only 8
> more characters than doing it with a raw C-style cast).   Another
> advantage of having the checked cast as a *method* is that it implicitly
> documents the requirement that the input must be non-NULL.
>
> There are an analogous family of "dyn_cast_gimple_foo" methods in the
> base class, again as an abbreviation of the rather verbose is-a.h API.
>
> For phis, I made gsi_start_phis return a gimple_phi_iterator, rather than
> a gimple_stmt_iterator, where the phi iterator type is new, a subclass of
> gimple_stmt_iterator.  It has identical layout, but adds a "phi ()" method,
> which is like gsi_stmt(), but does a checked cast to a gimple_phi.  This
> allows lots of phi-manipulation code to be concretized into working on
> type "gimple_phi" (rather than just "gimple"), with minimal patching.
>
> Having these typedefs around may also be useful for debugging, so that you
> can now type e.g.
>
>   (gdb) p *(gimple_cond)stmt
>
> to quickly get all fields of a stmt (without having to think
> "is this code a gimple_statement_with_ops?")
>
> ***********
> Correctness
> ***********
> Successfully bootstrapped&regtested the cumulative effect of the patches
> on x86_64-unknown-linux-gnu with cloog and thus graphite, with all
> frontends (via --enable-languages=all,ada,go), on top of r209027: the
> regrtest shows identical results to that of a control build, in both cases
> with:
>
>  gcc/testsuite/ada/acats/acats.sum : total: 2320 PASS: 2320
>  gcc/testsuite/g++/g++.sum : total: 90205 FAIL: 3 PASS: 86738 XFAIL: 445 UNSUPPORTED: 3019
>  gcc/testsuite/gcc/gcc.sum : total: 110165 FAIL: 31 PASS: 108028 XFAIL: 263 XPASS: 40 UNSUPPORTED: 1803
>  gcc/testsuite/gfortran/gfortran.sum : total: 45650 PASS: 45533 XFAIL: 52 UNSUPPORTED: 65
>  gcc/testsuite/gnat/gnat.sum : total: 1245 PASS: 1224 XFAIL: 18 UNSUPPORTED: 3
>  gcc/testsuite/go/go.sum : total: 7266 PASS: 7258 XFAIL: 1 UNTESTED: 6 UNSUPPORTED: 1
>  gcc/testsuite/objc/objc.sum : total: 2973 PASS: 2893 XFAIL: 6 UNSUPPORTED: 74
>  x86_64-unknown-linux-gnu/boehm-gc/testsuite/boehm-gc.sum : total: 13 PASS: 12 UNSUPPORTED: 1
>  x86_64-unknown-linux-gnu/libatomic/testsuite/libatomic.sum : total: 54 PASS: 54
>  x86_64-unknown-linux-gnu/libffi/testsuite/libffi.sum : total: 1856 PASS: 1801 UNSUPPORTED: 55
>  x86_64-unknown-linux-gnu/libgo/libgo.sum : total: 122 PASS: 122
>  x86_64-unknown-linux-gnu/libgomp/testsuite/libgomp.sum : total: 2412 PASS: 2412
>  x86_64-unknown-linux-gnu/libitm/testsuite/libitm.sum : total: 30 PASS: 26 XFAIL: 3 UNSUPPORTED: 1
>  x86_64-unknown-linux-gnu/libjava/testsuite/libjava.sum : total: 2586 PASS: 2582 XFAIL: 4
>  x86_64-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum : total: 10260 PASS: 9995 XFAIL: 41 UNSUPPORTED: 224
>
> apart from a test removed/test added false positive in:
>   go.test/test/dwarf/dwarf.dir/main.go
> due to the test summary containing embedded absolute paths, which vary
> between my control vs experiment builds.
>
> [FWIW, for the above I used a new DejaVu result-handling tool I've
> written, "jamais-vu":
>   https://github.com/davidmalcolm/jamais-vu
> which others on this list may find helpful]
>
> ***********
> Performance
> ***********
> I benchmarked the compiler with and without this patch series (experiment
> and control, respectively), by repeatedly building the two complicated C++
> files supplied by Michael Matz in:
>   http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00062.html
> with stripped cc1plus, using taskset(1) to pin the cc1plus invocations to
> cpu 0 for consistency on this NUMA box.
>
> There were no significant differences in timings or memory usage between
> the runs; full details (including links to timeline graphs) follow:
>
> Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: usr
>       control: [47.99, 47.91, 48.0, 47.99, 48.09, 48.36, 48.2, 48.11, 48.22, 47.88, 48.14, 48.25, 48.17, 48.17, 48.16, 48.24, 48.03, 47.88, 47.98, 47.98, 48.08, 48.02, 48.0, 47.99, 48.05, 48.21, 48.0, 48.16, 48.08, 48.05, 48.0, 48.13, 47.92, 47.9, 48.16, 48.03, 48.07, 48.12, 48.16, 48.14]
>    experiment: [48.48, 48.05, 48.01, 48.19, 47.99, 47.95, 48.0, 48.0, 47.89, 47.81, 47.75, 47.94, 48.1, 48.02, 47.88, 47.83, 48.16, 48.04, 48.03, 47.98, 48.12, 48.05, 47.89, 48.03, 47.81, 47.88, 48.06, 47.85, 48.27, 47.99, 47.81, 48.07, 48.01, 48.06, 48.07, 47.95, 48.03, 47.9, 47.94, 47.99]
> Min: 47.880000 -> 47.750000: 1.00x faster
> Avg: 48.075500 -> 47.997000: 1.00x faster
> Not significant
> Stddev: 0.11145 -> 0.13531: 1.2141x larger
> Timeline: http://goo.gl/k3ct18
>
> Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: sys
>       control: [6.19, 6.29, 6.16, 6.25, 6.18, 6.06, 6.06, 6.19, 6.2, 6.27, 6.11, 6.09, 6.11, 6.0, 6.12, 6.25, 6.1, 6.32, 6.22, 6.23, 6.12, 6.13, 6.22, 6.13, 6.08, 6.02, 6.15, 6.11, 6.16, 6.16, 6.15, 6.05, 6.22, 6.24, 6.09, 6.12, 6.11, 6.14, 6.0, 5.99]
>    experiment: [6.12, 6.1, 6.13, 6.17, 6.16, 6.18, 6.13, 6.15, 6.18, 6.3, 6.32, 6.17, 6.0, 6.17, 6.25, 6.25, 6.23, 6.15, 6.05, 6.13, 6.04, 6.12, 6.18, 6.14, 6.27, 6.18, 6.12, 6.23, 6.13, 6.09, 6.24, 6.12, 6.08, 6.07, 6.02, 6.33, 6.1, 6.19, 6.08, 6.14]
> Min: 5.990000 -> 6.000000: 1.00x slower
> Avg: 6.144750 -> 6.155250: 1.00x slower
> Not significant
> Stddev: 0.08105 -> 0.07782: 1.0415x smaller
> Timeline: http://goo.gl/wiiVbY
>
> Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: wall
>       control: [54.9, 54.38, 54.34, 54.42, 54.45, 54.6, 54.44, 54.47, 54.6, 54.33, 54.43, 54.52, 54.46, 54.35, 54.46, 54.67, 54.31, 54.38, 54.37, 54.4, 54.37, 54.34, 54.41, 54.3, 54.31, 54.41, 54.34, 54.45, 54.43, 54.39, 54.33, 54.36, 54.31, 54.31, 54.43, 54.33, 54.36, 54.44, 54.34, 54.31]
>    experiment: [54.96, 54.51, 54.53, 54.68, 54.56, 54.54, 54.54, 54.53, 54.44, 54.5, 54.47, 54.5, 54.5, 54.56, 54.46, 54.47, 54.78, 54.59, 54.48, 54.49, 54.5, 54.54, 54.46, 54.52, 54.47, 54.38, 54.47, 54.38, 54.74, 54.42, 54.4, 54.53, 54.41, 54.48, 54.44, 54.64, 54.49, 54.4, 54.31, 54.4]
> Min: 54.300000 -> 54.310000: 1.00x slower
> Avg: 54.413750 -> 54.511750: 1.00x slower
> Not significant
> Stddev: 0.11562 -> 0.11786: 1.0194x larger
> Timeline: http://goo.gl/1Xlhp6
>
> Compilation of kdecore.cc at -O3 with -g for x86_64-unknown-linux-gnu: ggc
>       control: [1298648.0, 1298649.0, 1298651.0, 1298656.0, 1298655.0, 1298651.0, 1298650.0, 1298652.0, 1298651.0, 1298650.0, 1298648.0, 1298644.0, 1298654.0, 1298655.0, 1298659.0, 1298659.0, 1298650.0, 1298652.0, 1298665.0, 1298655.0, 1298651.0, 1298655.0, 1298652.0, 1298656.0, 1298659.0, 1298653.0, 1298645.0, 1298649.0, 1298645.0, 1298643.0, 1298657.0, 1298653.0, 1298652.0, 1298659.0, 1298648.0, 1298651.0, 1298653.0, 1298651.0, 1298654.0, 1298651.0]
>    experiment: [1298653.0, 1298658.0, 1298649.0, 1298658.0, 1298654.0, 1298654.0, 1298647.0, 1298652.0, 1298651.0, 1298652.0, 1298656.0, 1298649.0, 1298644.0, 1298655.0, 1298648.0, 1298650.0, 1298648.0, 1298652.0, 1298651.0, 1298649.0, 1298647.0, 1298661.0, 1298641.0, 1298652.0, 1298645.0, 1298650.0, 1298652.0, 1298652.0, 1298651.0, 1298650.0, 1298650.0, 1298655.0, 1298663.0, 1298655.0, 1298646.0, 1298648.0, 1298646.0, 1298652.0, 1298662.0, 1298651.0]
> Mem max: 1298665.000 -> 1298663.000: 1.0000x smaller
> Usage over time: http://goo.gl/aoTh9I
>
> Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: usr
>       control: [37.03, 36.97, 36.99, 37.04, 36.97, 36.94, 37.02, 36.97, 37.05, 36.94, 36.92, 36.97, 37.03, 37.01, 37.04, 37.01, 36.99, 37.01, 37.07, 37.05, 36.98, 36.98, 37.05, 36.97, 36.95, 37.01, 37.0, 37.0, 37.23, 37.07, 36.78, 36.94, 37.04, 36.93, 36.98, 36.96, 36.91, 36.98, 37.05, 37.23]
>    experiment: [36.96, 36.98, 36.93, 36.97, 36.94, 37.27, 37.0, 36.96, 37.03, 37.09, 36.85, 36.94, 36.99, 37.01, 37.0, 36.99, 36.98, 37.1, 37.04, 37.07, 36.93, 36.95, 36.96, 37.01, 36.97, 37.06, 36.95, 37.01, 36.98, 36.93, 37.14, 37.0, 36.92, 36.89, 36.98, 37.24, 36.97, 36.98, 36.96, 36.95]
> Min: 36.780000 -> 36.850000: 1.00x slower
> Avg: 37.001500 -> 36.997000: 1.00x faster
> Not significant
> Stddev: 0.07543 -> 0.08178: 1.0842x larger
> Timeline: http://goo.gl/591YUR
>
> Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: sys
>       control: [1.29, 1.33, 1.32, 1.29, 1.32, 1.35, 1.3, 1.36, 1.25, 1.33, 1.33, 1.36, 1.28, 1.3, 1.28, 1.27, 1.29, 1.25, 1.27, 1.25, 1.29, 1.31, 1.33, 1.3, 1.3, 1.29, 1.28, 1.34, 1.3, 1.27, 1.34, 1.3, 1.28, 1.3, 1.3, 1.38, 1.37, 1.34, 1.24, 1.3]
>    experiment: [1.29, 1.29, 1.3, 1.27, 1.31, 1.3, 1.3, 1.32, 1.25, 1.32, 1.34, 1.33, 1.28, 1.25, 1.3, 1.27, 1.27, 1.32, 1.27, 1.25, 1.34, 1.32, 1.33, 1.3, 1.29, 1.3, 1.28, 1.29, 1.3, 1.31, 1.23, 1.31, 1.3, 1.33, 1.34, 1.31, 1.32, 1.31, 1.3, 1.3]
> Min: 1.240000 -> 1.230000: 1.01x faster
> Avg: 1.304500 -> 1.298500: 1.00x faster
> Not significant
> Stddev: 0.03412 -> 0.02637: 1.2939x smaller
> Timeline: http://goo.gl/UA1Bvh
>
> Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: wall
>       control: [38.43, 38.42, 38.43, 38.45, 38.41, 38.4, 38.43, 38.44, 38.41, 38.37, 38.37, 38.45, 38.42, 38.43, 38.43, 38.4, 38.39, 38.38, 38.45, 38.41, 38.38, 38.4, 38.49, 38.39, 38.36, 38.41, 38.39, 38.46, 38.65, 38.46, 38.23, 38.36, 38.44, 38.35, 38.39, 38.45, 38.39, 38.43, 38.41, 38.65]
>    experiment: [38.36, 38.38, 38.34, 38.35, 38.36, 38.68, 38.41, 38.39, 38.38, 38.52, 38.3, 38.38, 38.38, 38.38, 38.42, 38.37, 38.36, 38.53, 38.42, 38.44, 38.37, 38.38, 38.4, 38.42, 38.38, 38.48, 38.34, 38.41, 38.4, 38.36, 38.49, 38.42, 38.33, 38.32, 38.43, 38.66, 38.41, 38.39, 38.37, 38.37]
> Min: 38.230000 -> 38.300000: 1.00x slower
> Avg: 38.420250 -> 38.407000: 1.00x faster
> Not significant
> Stddev: 0.06822 -> 0.07816: 1.1457x larger
> Timeline: http://goo.gl/clfhdm
>
> Compilation of big-code.c at -O3 with -g for x86_64-unknown-linux-gnu: ggc
>       control: [662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 661798.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 661798.0, 661798.0, 662310.0, 662310.0]
>    experiment: [662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 661798.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0, 662310.0]
> Mem max: 662310.000 -> 662310.000: no change
> Usage over time: http://goo.gl/y77aRG
>
> ***********************
> Sizes of built binaries
> ***********************
> With --enable-checking=release, and stripping the resulting binaries:
> $ for binary in cc1 cc1obj cc1plus f951 jc1 ; do ls -al test/*/*/build/gcc/$binary ; done
> -rwxrwxr-x. 1 david david 15842584 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1
> -rwxrwxr-x. 1 david david 15838488 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1
> -rwxrwxr-x. 1 david david 16039192 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1obj
> -rwxrwxr-x. 1 david david 16035096 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1obj
> -rwxrwxr-x. 1 david david 17014104 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/cc1plus
> -rwxrwxr-x. 1 david david 17014104 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/cc1plus
> -rwxrwxr-x. 1 david david 16576600 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/f951
> -rwxrwxr-x. 1 david david 16572504 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/f951
> -rwxrwxr-x. 1 david david 15159256 Apr 17 14:27 test/control/x86_64-unknown-linux-gnu/build/gcc/jc1
> -rwxrwxr-x. 1 david david 15159256 Apr 17 14:27 test/experiment/x86_64-unknown-linux-gnu/build/gcc/jc1
>
> i.e. the sizes are either unchanged, or got very slightly smaller.
>
> ****
> Plan
> ****
> I'd like to commit this patch series to trunk for 4.10.  I hope the
> overall plan sounds good.  May I have reviews of the individual patches?
> (each patch builds on the ones before, but at any given patch in the
> series they should all compile cleanly together and not affect
> correctness/performance).
>
> I have a script that tracks how many of the gimple statement accessors
> take something more concrete than a plain gimple:
>   https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/gimple_typesafety.py
> which reports that the following statement subclasses are "done" in the
> sense that all of their accessors now accept a subclass pointer, rather
> than a plain gimple/const_gimple:
>
> gimple_asm_ (19 accessors)
> gimple_bind_ (10 accessors)
> gimple_catch_ (6 accessors)
> gimple_eh_dispatch_ (2 accessors)
> gimple_eh_else_ (6 accessors)
> gimple_eh_must_not_throw_ (2 accessors)
> gimple_label_ (2 accessors)
> gimple_omp_atomic_load_ (6 accessors)
> gimple_omp_atomic_store_ (3 accessors)
> gimple_omp_continue_ (6 accessors)
> gimple_omp_critical_ (3 accessors)
> gimple_resx_ (2 accessors)
> gimple_return_ (3 accessors)
> gimple_switch_ (9 accessors)
> gimple_transaction_ (8 accessors)
>
> and the following DONE/TODO breakdown by prefix:
>
> Accessors "concretized" by prefix
> ---------------------------------
>   %                         Prefix  DONE  TODO
> 100            gimple_transaction_     8     0
> 100                 gimple_switch_     9     0
> 100                 gimple_return_     3     0
> 100                   gimple_resx_     2     0
> 100           gimple_omp_critical_     3     0
> 100           gimple_omp_continue_     6     0
> 100       gimple_omp_atomic_store_     3     0
> 100        gimple_omp_atomic_load_     6     0
> 100                  gimple_label_     2     0
> 100      gimple_eh_must_not_throw_     2     0
> 100                gimple_eh_else_     6     0
> 100            gimple_eh_dispatch_     2     0
> 100                  gimple_catch_     6     0
> 100                   gimple_bind_    10     0
> 100                    gimple_asm_    19     0
>  83                   gimple_cond_    15     3
>  72             gimple_omp_target_     8     3
>  72           gimple_omp_parallel_     8     3
>  58                   gimple_call_    25    18
>  57                    gimple_phi_     8     6
>  50                   gimple_goto_     1     1
>  40                    gimple_try_     4     6
>  33              gimple_omp_teams_     1     2
>  33             gimple_omp_single_     1     2
>  33              gimple_eh_filter_     2     4
>  11                gimple_omp_for_     3    24
>   5                 gimple_assign_     1    17
>   0                    gimple_wce_     0     5
>   0                gimple_predict_     0     4
>   0               gimple_omp_task_     0    18
>   0           gimple_omp_sections_     0     6
>   0            gimple_omp_section_     0     2
>   0             gimple_omp_return_     0     5
>   0                    gimple_omp_     0    18
>   0                  gimple_debug_     0    12
>
> Overall totals
> --------------
> TODO: Builder calls still returning a plain gimple: 9
> TODO: Accessors not yet converted to taking a gimple: 159
> DONE: Builder calls converted to returning a gimple subclass: 37
> DONE: Accessors converted to taking a gimple subclass: 167
> NOTE: Accessors known not to need to be converted: 67
>
> So this patch series as-is takes us a little over halfway there.  The
> remaining accessors would involve more substantial re-indenting (typically
> to introduce blocks within case statements of a switch on statement code,
> so I can introduce a type-checked local).  I didn't want to go down that
> path until the overall approach was OKed, since those kinds of changes are
> much more prone to generating conflicts as I rebase (and hence to bitrot).
>
> Thoughts?
>
> Dave
>
> David Malcolm (89):
>   Const-correctness fixes for some gimple accessors
>   Introduce gimple_switch and use it in various places
>   Introduce gimple_bind and use it for accessors.
>   Introduce gimple_cond and use it in various places
>   Introduce gimple_assign and use it in various places
>   Introduce gimple_label and use it in a few places
>   Introduce gimple_debug and use it in a few places
>   Introduce gimple_phi and use it in various places
>   Introduce gimple_phi_iterator
>   Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
>   tree-parloops.c: use gimple_phi in various places
>   tree-predcom.c: use gimple_phi in various places
>   tree-ssa-phiprop.c: use gimple_phi
>   tree-ssa-loop-niter.c: use gimple_phi in a few places
>   tree-ssa-loop-manip.c: use gimple_phi in three places
>   tree-ssa-loop-ivopts.c: use gimple_phi in a few places
>   Update various expressions within tree-scalar-evolution.c to be
>     gimple_phi
>   Concretize get_loop_exit_condition et al to working on gimple_cond
>   Const-correctness of gimple_call_builtin_p
>   Introduce gimple_call
>   Introduce gimple_return
>   Introduce gimple_goto
>   Introduce gimple_asm
>   Introduce gimple_transaction
>   Introduce gimple_catch
>   Introduce gimple_eh_filter
>   Introduce gimple_eh_must_not_throw
>   Introduce gimple_eh_else
>   Introduce gimple_resx
>   Introduce gimple_eh_dispatch
>   Use subclasses of gimple in various places
>   Introduce gimple_try
>   Use more concrete types for various gimple statements
>   Introduce gimple_omp_atomic_load
>   Introduce gimple_omp_atomic_store
>   Introduce gimple_omp_continue
>   Introduce gimple_omp_critical
>   Introduce gimple_omp_for
>   Introduce gimple_omp_parallel
>   tree-cfg.c: Make verify_gimple_call require a gimple_call
>   Introduce gimple_omp_task
>   Introduce gimple_omp_single
>   Introduce gimple_omp_target
>   Introduce gimple_omp_teams
>   Introduce gimple_omp_sections
>   tree-parloops.c: Use gimple_phi in various places
>   omp-low.c: Use more concrete types of gimple statement for various
>     locals
>   Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a
>     gimple_phi
>   Make add_phi_arg require a gimple_phi
>   Make gimple_phi_arg_set_location require a gimple_phi
>   Update GRAPHITE to use more concrete gimple statement classes
>   Make gimple_phi_arg_edge require a gimple_phi
>   More gimple_phi
>   Make gimple_call_return_slot_opt_p require a gimple_call.
>   Use gimple_call for callgraph edges
>   Various gimple to gimple_call conversions in IPA
>   Concretize parameter to gimple_call_copy_skip_args
>   Make gimple_label_set_label require a gimple_label
>   Make gimple_goto_set_dest require a gimple_goto
>   Concretize gimple_catch_types
>   Concretize gimple_call_use_set and gimple_call_clobber_set
>   Concretize gimple_label_label
>   Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure
>   Concretize gimple_try_set_catch_is_cleanup
>   Concretize three gimple_try_set_ accessors
>   Make gimple_phi_arg_location_from_edge require a gimple_phi
>   Make gimple_phi_arg_location require a gimple_phi.
>   Concretize three gimple_return_ accessors
>   Make gimple_cond_set_{true|false}_label require gimple_cond.
>   Concretize locals within expand_omp_for_init_counts
>   Concretize gimple_cond_make_{false|true}
>   Concretize gimple_switch_index and gimple_switch_index_ptr
>   Concretize gimple_cond_{true|false}_label
>   Concretize gimple_cond_set_code
>   Concretize gimple_cond_set_{lhs|rhs}
>   Concretize gimple_cond_{lhs|rhs}_ptr
>   Concretize various expressions from gimple to gimple_cond
>   Concretize gimple_call_set_nothrow
>   Concretize gimple_call_nothrow_p
>   Tweak to gimplify_modify_expr
>   Concretize gimple_call_set_fn
>   Concretize gimple_call_set_fntype
>   Concretize gimple_call_set_tail and gimple_call_tail_p
>   Concretize gimple_call_arg_flags
>   Concretize gimple_assign_nontemporal_move_p
>   Concretize gimple_call_copy_flags and ipa_modify_call_arguments
>   Use gimple_call in some places within tree-ssa-dom.c
>   Use gimple_phi in many more places.
>   Convert various gimple to gimple_phi within ssa-iterators.h
>
>  gcc/asan.c                          |   23 +-
>  gcc/builtins.c                      |   11 +-
>  gcc/builtins.h                      |    2 +-
>  gcc/c-family/c-gimplify.c           |    4 +-
>  gcc/cfgexpand.c                     |   58 +-
>  gcc/cfgloop.c                       |    6 +-
>  gcc/cfgloopmanip.c                  |    4 +-
>  gcc/cgraph.c                        |   22 +-
>  gcc/cgraph.h                        |   17 +-
>  gcc/cgraphbuild.c                   |   41 +-
>  gcc/cgraphclones.c                  |    6 +-
>  gcc/cgraphunit.c                    |    6 +-
>  gcc/coretypes.h                     |  126 ++++
>  gcc/expr.h                          |    2 +-
>  gcc/gdbhooks.py                     |   19 +-
>  gcc/gimple-builder.c                |   16 +-
>  gcc/gimple-builder.h                |   16 +-
>  gcc/gimple-fold.c                   |   25 +-
>  gcc/gimple-fold.h                   |    2 +-
>  gcc/gimple-iterator.c               |   12 +-
>  gcc/gimple-iterator.h               |   11 +-
>  gcc/gimple-low.c                    |   39 +-
>  gcc/gimple-pretty-print.c           |  183 +++--
>  gcc/gimple-ssa-isolate-paths.c      |    6 +-
>  gcc/gimple-ssa-strength-reduction.c |   30 +-
>  gcc/gimple-streamer-in.c            |   34 +-
>  gcc/gimple-streamer-out.c           |   46 +-
>  gcc/gimple-walk.c                   |  169 +++--
>  gcc/gimple.c                        |  347 +++++----
>  gcc/gimple.h                        | 1379 +++++++++++++++++++++--------------
>  gcc/gimplify-me.c                   |   29 +-
>  gcc/gimplify.c                      |  125 ++--
>  gcc/gimplify.h                      |    6 +-
>  gcc/graphite-scop-detection.c       |   22 +-
>  gcc/graphite-sese-to-poly.c         |  141 ++--
>  gcc/internal-fn.c                   |   42 +-
>  gcc/internal-fn.def                 |    2 +-
>  gcc/internal-fn.h                   |    2 +-
>  gcc/ipa-inline-analysis.c           |   18 +-
>  gcc/ipa-prop.c                      |   37 +-
>  gcc/ipa-prop.h                      |    4 +-
>  gcc/ipa-pure-const.c                |   10 +-
>  gcc/ipa-split.c                     |   95 +--
>  gcc/java/java-gimplify.c            |    2 +-
>  gcc/lto-streamer-in.c               |    4 +-
>  gcc/lto-streamer-out.c              |   15 +-
>  gcc/omp-low.c                       |  441 ++++++-----
>  gcc/predict.c                       |   56 +-
>  gcc/sese.c                          |   13 +-
>  gcc/ssa-iterators.h                 |   20 +-
>  gcc/stmt.c                          |    4 +-
>  gcc/trans-mem.c                     |  132 ++--
>  gcc/tree-call-cdce.c                |   29 +-
>  gcc/tree-cfg.c                      |  407 ++++++-----
>  gcc/tree-cfg.h                      |    4 +-
>  gcc/tree-cfgcleanup.c               |   44 +-
>  gcc/tree-complex.c                  |   39 +-
>  gcc/tree-data-ref.c                 |    3 +-
>  gcc/tree-dfa.c                      |   10 +-
>  gcc/tree-eh.c                       |  274 ++++---
>  gcc/tree-eh.h                       |    6 +-
>  gcc/tree-emutls.c                   |   13 +-
>  gcc/tree-if-conv.c                  |   15 +-
>  gcc/tree-inline.c                   |  185 +++--
>  gcc/tree-inline.h                   |    2 +-
>  gcc/tree-into-ssa.c                 |   59 +-
>  gcc/tree-into-ssa.h                 |    2 +-
>  gcc/tree-loop-distribution.c        |   55 +-
>  gcc/tree-nested.c                   |   45 +-
>  gcc/tree-nrv.c                      |   11 +-
>  gcc/tree-object-size.c              |   20 +-
>  gcc/tree-outof-ssa.c                |   23 +-
>  gcc/tree-parloops.c                 |  101 +--
>  gcc/tree-phinodes.c                 |   41 +-
>  gcc/tree-phinodes.h                 |    8 +-
>  gcc/tree-predcom.c                  |   30 +-
>  gcc/tree-profile.c                  |   19 +-
>  gcc/tree-scalar-evolution.c         |   73 +-
>  gcc/tree-scalar-evolution.h         |    2 +-
>  gcc/tree-sra.c                      |  125 ++--
>  gcc/tree-ssa-alias.c                |   16 +-
>  gcc/tree-ssa-alias.h                |    2 +-
>  gcc/tree-ssa-ccp.c                  |   32 +-
>  gcc/tree-ssa-coalesce.c             |   29 +-
>  gcc/tree-ssa-copy.c                 |   11 +-
>  gcc/tree-ssa-copyrename.c           |   12 +-
>  gcc/tree-ssa-dce.c                  |   37 +-
>  gcc/tree-ssa-dom.c                  |   76 +-
>  gcc/tree-ssa-forwprop.c             |   21 +-
>  gcc/tree-ssa-ifcombine.c            |   27 +-
>  gcc/tree-ssa-live.c                 |   16 +-
>  gcc/tree-ssa-loop-im.c              |   65 +-
>  gcc/tree-ssa-loop-ivcanon.c         |   41 +-
>  gcc/tree-ssa-loop-ivopts.c          |   44 +-
>  gcc/tree-ssa-loop-manip.c           |   64 +-
>  gcc/tree-ssa-loop-niter.c           |   25 +-
>  gcc/tree-ssa-loop-prefetch.c        |    4 +-
>  gcc/tree-ssa-loop-unswitch.c        |   19 +-
>  gcc/tree-ssa-math-opts.c            |   44 +-
>  gcc/tree-ssa-operands.c             |    8 +-
>  gcc/tree-ssa-phiopt.c               |   38 +-
>  gcc/tree-ssa-phiprop.c              |   12 +-
>  gcc/tree-ssa-pre.c                  |   68 +-
>  gcc/tree-ssa-propagate.c            |   30 +-
>  gcc/tree-ssa-propagate.h            |    2 +-
>  gcc/tree-ssa-reassoc.c              |   39 +-
>  gcc/tree-ssa-sccvn.c                |   25 +-
>  gcc/tree-ssa-sccvn.h                |    2 +-
>  gcc/tree-ssa-sink.c                 |    8 +-
>  gcc/tree-ssa-strlen.c               |   13 +-
>  gcc/tree-ssa-structalias.c          |   85 ++-
>  gcc/tree-ssa-tail-merge.c           |   33 +-
>  gcc/tree-ssa-ter.c                  |    4 +-
>  gcc/tree-ssa-threadedge.c           |   19 +-
>  gcc/tree-ssa-threadedge.h           |    2 +-
>  gcc/tree-ssa-threadupdate.c         |   16 +-
>  gcc/tree-ssa-uncprop.c              |    7 +-
>  gcc/tree-ssa-uninit.c               |   57 +-
>  gcc/tree-ssa.c                      |   56 +-
>  gcc/tree-stdarg.c                   |   19 +-
>  gcc/tree-switch-conversion.c        |   57 +-
>  gcc/tree-tailcall.c                 |   46 +-
>  gcc/tree-vect-data-refs.c           |    7 +-
>  gcc/tree-vect-generic.c             |   13 +-
>  gcc/tree-vect-loop-manip.c          |   74 +-
>  gcc/tree-vect-loop.c                |   61 +-
>  gcc/tree-vect-patterns.c            |    2 +-
>  gcc/tree-vect-slp.c                 |   15 +-
>  gcc/tree-vect-stmts.c               |   22 +-
>  gcc/tree-vectorizer.h               |    2 +-
>  gcc/tree-vrp.c                      |  100 +--
>  gcc/tree.c                          |    5 +-
>  gcc/tree.h                          |    5 +-
>  gcc/ubsan.c                         |    5 +-
>  gcc/value-prof.c                    |   91 ++-
>  gcc/value-prof.h                    |    3 +-
>  gcc/vtable-verify.c                 |    2 +-
>  137 files changed, 4095 insertions(+), 3070 deletions(-)
>
> --
> 1.8.5.3
>

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

* Re: [PATCH 22/89] Introduce gimple_goto
  2014-04-21 16:57 ` [PATCH 22/89] Introduce gimple_goto David Malcolm
@ 2014-04-22 11:49   ` Trevor Saunders
  0 siblings, 0 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-04-22 11:49 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 6537 bytes --]

On Mon, Apr 21, 2014 at 12:56:53PM -0400, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_goto): New typedef.
> 	(const_gimple_goto): New typedef.
> 
> 	* gimple.h (gimple_statement_goto): New subclass of
> 	gimple_statement_with_ops, adding the invariant that
> 	stmt->code == GIMPLE_GOTO.
> 	(gimple_statement_base::as_a_gimple_goto): New.
> 	(gimple_statement_base::dyn_cast_gimple_goto): New.
> 	(is_a_helper <gimple_statement_goto>::test): New.
> 	(gimple_build_goto): Return a gimple_goto rather than a
> 	plain gimple.
> 
> 	* gimple-pretty-print.c (dump_gimple_goto): Require a gimple_goto
> 	rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_goto within
> 	GIMPLE_GOTO case of switch statement.
> 
> 	* gimple.c (gimple_build_goto): Return a gimple_goto rather than a
> 	plain gimple.
> 
> 	* tree-cfg.c (verify_gimple_goto): Require a gimple_goto rather
> 	than a plain gimple.
> 	(verify_gimple_stmt): Add a checked cast to gimple_goto within
> 	GIMPLE_GOTO case of switch statement.
> ---
>  gcc/coretypes.h           |  4 ++++
>  gcc/gimple-pretty-print.c |  4 ++--

didn't you miss updating the gdb pretty printers in this one?

Trev

>  gcc/gimple.c              |  5 +++--
>  gcc/gimple.h              | 36 +++++++++++++++++++++++++++++++++++-
>  gcc/tree-cfg.c            |  4 ++--
>  5 files changed, 46 insertions(+), 7 deletions(-)
> 
> diff --git a/gcc/coretypes.h b/gcc/coretypes.h
> index d5c62b9..1d04d07 100644
> --- a/gcc/coretypes.h
> +++ b/gcc/coretypes.h
> @@ -77,6 +77,10 @@ struct gimple_statement_debug;
>  typedef struct gimple_statement_debug *gimple_debug;
>  typedef const struct gimple_statement_debug *const_gimple_debug;
>  
> +struct gimple_statement_goto;
> +typedef struct gimple_statement_goto *gimple_goto;
> +typedef const struct gimple_statement_goto *const_gimple_goto;
> +
>  struct gimple_statement_label;
>  typedef struct gimple_statement_label *gimple_label;
>  typedef const struct gimple_statement_label *const_gimple_label;
> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
> index 90baded..6ee6ce9 100644
> --- a/gcc/gimple-pretty-print.c
> +++ b/gcc/gimple-pretty-print.c
> @@ -874,7 +874,7 @@ dump_gimple_label (pretty_printer *buffer, gimple_label gs, int spc, int flags)
>     TDF_* in dumpfile.h).  */
>  
>  static void
> -dump_gimple_goto (pretty_printer *buffer, gimple gs, int spc, int flags)
> +dump_gimple_goto (pretty_printer *buffer, gimple_goto gs, int spc, int flags)
>  {
>    tree label = gimple_goto_dest (gs);
>    if (flags & TDF_RAW)
> @@ -2115,7 +2115,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
>        break;
>  
>      case GIMPLE_GOTO:
> -      dump_gimple_goto (buffer, gs, spc, flags);
> +      dump_gimple_goto (buffer, gs->as_a_gimple_goto (), spc, flags);
>        break;
>  
>      case GIMPLE_NOP:
> diff --git a/gcc/gimple.c b/gcc/gimple.c
> index 222c068..b73fc74 100644
> --- a/gcc/gimple.c
> +++ b/gcc/gimple.c
> @@ -495,10 +495,11 @@ gimple_build_label (tree label)
>  
>  /* Build a GIMPLE_GOTO statement to label DEST.  */
>  
> -gimple
> +gimple_goto
>  gimple_build_goto (tree dest)
>  {
> -  gimple p = gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1);
> +  gimple_goto p = gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK,
> +					 1)->as_a_gimple_goto ();
>    gimple_goto_set_dest (p, dest);
>    return p;
>  }
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index 39ac2dc..a4c7b30 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -222,6 +222,12 @@ public:
>      return as_a <gimple_statement_debug> (this);
>    }
>  
> +  inline gimple_goto
> +  as_a_gimple_goto ()
> +  {
> +    return as_a <gimple_statement_goto> (this);
> +  }
> +
>    inline gimple_label
>    as_a_gimple_label ()
>    {
> @@ -290,6 +296,12 @@ public:
>      return dyn_cast <gimple_statement_debug> (this);
>    }
>  
> +  inline gimple_goto
> +  dyn_cast_gimple_goto ()
> +  {
> +    return dyn_cast <gimple_statement_goto> (this);
> +  }
> +
>    inline gimple_label
>    dyn_cast_gimple_label ()
>    {
> @@ -922,6 +934,20 @@ struct GTY((tag("GSS_WITH_OPS")))
>  };
>  
>  /* A statement with the invariant that
> +      stmt->code == GIMPLE_GOTO
> +   i.e. a goto statement.
> +
> +   This type will normally be accessed via the gimple_goto and
> +   const_gimple_goto typedefs (in coretypes.h), which are pointers to
> +   this type.  */
> +
> +struct GTY((tag("GSS_WITH_OPS")))
> +  gimple_statement_goto : public gimple_statement_with_ops
> +{
> +  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
> +};
> +
> +/* A statement with the invariant that
>        stmt->code == GIMPLE_LABEL
>     i.e. a label statement.
>  
> @@ -1024,6 +1050,14 @@ is_a_helper <gimple_statement_debug>::test (gimple gs)
>  template <>
>  template <>
>  inline bool
> +is_a_helper <gimple_statement_goto>::test (gimple gs)
> +{
> +  return gs->code == GIMPLE_GOTO;
> +}
> +
> +template <>
> +template <>
> +inline bool
>  is_a_helper <gimple_statement_label>::test (gimple gs)
>  {
>    return gs->code == GIMPLE_LABEL;
> @@ -1429,7 +1463,7 @@ gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
>  gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
>  void gimple_cond_set_condition_from_tree (gimple_cond, tree);
>  gimple_label gimple_build_label (tree label);
> -gimple gimple_build_goto (tree dest);
> +gimple_goto gimple_build_goto (tree dest);
>  gimple gimple_build_nop (void);
>  gimple_bind gimple_build_bind (tree, gimple_seq, tree);
>  gimple gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index 1bfed7d..8b8020e 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -4229,7 +4229,7 @@ verify_gimple_return (gimple_return stmt)
>     is a problem, otherwise false.  */
>  
>  static bool
> -verify_gimple_goto (gimple stmt)
> +verify_gimple_goto (gimple_goto stmt)
>  {
>    tree dest = gimple_goto_dest (stmt);
>  
> @@ -4429,7 +4429,7 @@ verify_gimple_stmt (gimple stmt)
>  				       gimple_cond_rhs (stmt));
>  
>      case GIMPLE_GOTO:
> -      return verify_gimple_goto (stmt);
> +      return verify_gimple_goto (stmt->as_a_gimple_goto ());
>  
>      case GIMPLE_SWITCH:
>        return verify_gimple_switch (stmt->as_a_gimple_switch ());
> -- 
> 1.8.5.3
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 26/89] Introduce gimple_eh_filter
  2014-04-21 17:14 ` [PATCH 26/89] Introduce gimple_eh_filter David Malcolm
@ 2014-04-22 12:15   ` Trevor Saunders
  0 siblings, 0 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-04-22 12:15 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 4178 bytes --]

On Mon, Apr 21, 2014 at 12:56:57PM -0400, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_eh_filter): New typedef.
> 	(const_gimple_eh_filter): New typedef.
> 
> 	* gimple.h (gimple_statement_base::as_a_gimple_eh_filter): New.
> 	(gimple_build_eh_filter): Return a gimple_eh_filter rather than a
> 	plain gimple.
> 
> 	* gimple-pretty-print.c (dump_gimple_eh_filter): Require a
> 	gimple_eh_filter rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_eh_filter within
> 	GIMPLE_EH_FILTER case of switch statement.
> 
> 	* gimple.c (gimple_build_eh_filter): Return a gimple_eh_filter
> 	rather than a plain gimple.
> ---
>  gcc/coretypes.h           | 4 ++++
>  gcc/gimple-pretty-print.c | 5 +++--

same question about pretty printers.

Trev

>  gcc/gimple.c              | 5 +++--
>  gcc/gimple.h              | 8 +++++++-
>  4 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/coretypes.h b/gcc/coretypes.h
> index 1dd36fb..592b9e5 100644
> --- a/gcc/coretypes.h
> +++ b/gcc/coretypes.h
> @@ -117,6 +117,10 @@ struct gimple_statement_catch;
>  typedef struct gimple_statement_catch *gimple_catch;
>  typedef const struct gimple_statement_catch *const_gimple_catch;
>  
> +struct gimple_statement_eh_filter;
> +typedef struct gimple_statement_eh_filter *gimple_eh_filter;
> +typedef const struct gimple_statement_eh_filter *const_gimple_eh_filter;
> +
>  struct gimple_statement_phi;
>  typedef struct gimple_statement_phi *gimple_phi;
>  typedef const struct gimple_statement_phi *const_gimple_phi;
> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
> index ec16f13..37f28d9 100644
> --- a/gcc/gimple-pretty-print.c
> +++ b/gcc/gimple-pretty-print.c
> @@ -994,7 +994,8 @@ dump_gimple_catch (pretty_printer *buffer, gimple_catch gs, int spc, int flags)
>     dumpfile.h).  */
>  
>  static void
> -dump_gimple_eh_filter (pretty_printer *buffer, gimple gs, int spc, int flags)
> +dump_gimple_eh_filter (pretty_printer *buffer, gimple_eh_filter gs, int spc,
> +		       int flags)
>  {
>    if (flags & TDF_RAW)
>      dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
> @@ -2204,7 +2205,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
>        break;
>  
>      case GIMPLE_EH_FILTER:
> -      dump_gimple_eh_filter (buffer, gs, spc, flags);
> +      dump_gimple_eh_filter (buffer, gs->as_a_gimple_eh_filter (), spc, flags);
>        break;
>  
>      case GIMPLE_EH_MUST_NOT_THROW:
> diff --git a/gcc/gimple.c b/gcc/gimple.c
> index 4bc844b..42eef46 100644
> --- a/gcc/gimple.c
> +++ b/gcc/gimple.c
> @@ -626,10 +626,11 @@ gimple_build_catch (tree types, gimple_seq handler)
>     TYPES are the filter's types.
>     FAILURE is the filter's failure action.  */
>  
> -gimple
> +gimple_eh_filter
>  gimple_build_eh_filter (tree types, gimple_seq failure)
>  {
> -  gimple p = gimple_alloc (GIMPLE_EH_FILTER, 0);
> +  gimple_eh_filter p =
> +    gimple_alloc (GIMPLE_EH_FILTER, 0)->as_a_gimple_eh_filter ();
>    gimple_eh_filter_set_types (p, types);
>    if (failure)
>      gimple_eh_filter_set_failure (p, failure);
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index e12e066..38b257c 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -294,6 +294,12 @@ public:
>      return as_a <gimple_statement_catch> (this);
>    }
>  
> +  inline gimple_eh_filter
> +  as_a_gimple_eh_filter ()
> +  {
> +    return as_a <gimple_statement_eh_filter> (this);
> +  }
> +
>    inline gimple_phi
>    as_a_gimple_phi ()
>    {
> @@ -1512,7 +1518,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec<tree, va_gc> *,
>  				 vec<tree, va_gc> *, vec<tree, va_gc> *,
>  				 vec<tree, va_gc> *);
>  gimple_catch gimple_build_catch (tree, gimple_seq);
> -gimple gimple_build_eh_filter (tree, gimple_seq);
> +gimple_eh_filter gimple_build_eh_filter (tree, gimple_seq);
>  gimple gimple_build_eh_must_not_throw (tree);
>  gimple gimple_build_eh_else (gimple_seq, gimple_seq);
>  gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
> -- 
> 1.8.5.3
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
@ 2014-04-22 13:20   ` Andrew MacLeod
  2014-04-22 16:04     ` Trevor Saunders
  2014-04-22 18:57     ` David Malcolm
  2014-04-22 17:13   ` David Malcolm
  2014-04-23 17:32   ` Jeff Law
  2 siblings, 2 replies; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-22 13:20 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, rdsandiford

On 04/22/2014 04:03 AM, Richard Sandiford wrote:
> First of all, thanks a lot for doing this.  Maybe one day we'll have
> the same in rtl :-)
>
> But...
>
> David Malcolm <dmalcolm@redhat.com> writes:
>> In doing the checked downcasts I ran into the verbosity of the as_a <>
>> API (in our "is-a.h").  I first tried simplifying them with custom
>> functions e.g.:
>>
>>     static inline gimple_bind as_a_gimple_bind (gimple gs)
>>     {
>>       return as_a <gimple_statement_bind> (gs);
>>     }
>>
>> but the approach I've gone with makes these checked casts be *methods* of
>> the gimple_statement_base class, so that e.g. in a switch statement you
>> can write:
>>
>>      case GIMPLE_SWITCH:
>>        dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
>>        break;
>>
>> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
>> concrete "gimple_switch" in a release build, with runtime checking for
>> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
>> internally).
>>
>> This is much less verbose than trying to do it with as_a <> directly, and
>> I think doing it as a method reads better aloud (to my English-speaking
>> mind, at-least):
>>    "gs as a gimple switch",
>> as opposed to:
>>    "as a gimple switch... gs",
>> which I find clunky.
>>
>> It makes the base class a little cluttered, but IMHO it hits a sweet-spot
>> of readability and type-safety with relatively little verbosity (only 8
>> more characters than doing it with a raw C-style cast).   Another
>> advantage of having the checked cast as a *method* is that it implicitly
>> documents the requirement that the input must be non-NULL.
> ...FWIW I really don't like these cast members.  The counterarguments are:
>
> - as_a <...> (...) and dyn_cast <...> (...) follow the C++ syntax
>    for other casts.
>
> - the type you get is obvious, rather than being a contraction of
>    the type name.
>
> - having them as methods means that the base class needs to aware of
>    all subclasses.  I realise that's probably inherently true of gimple
>    due to the enum, but it seems like bad design.  You could potentially
>    have different subclasses for the same enum, selected by a secondary field.
I'm not particularly fond of this aspect as well...  I fear that someday 
down the road we would regret this decision, and end up changing it all 
back to is_a<> and friends....      These kind of sweeping changes we 
ought to try very hard to make sure we only have to do it once.

If this is purely for verbosity, I think we can find better ways to 
reduce it...  Is there any other reason?

>
> Maybe I've just been reading C code too long, but "as a gimple switch...gs"
> doesn't seem any less natural than "is constant...address".
>
> Another way of reducing the verbosity of as_a would be to shorten the
> type names.  E.g. "gimple_statement" contracts to "gimple_stmt" in some
> places, so "gimple_statement_bind" could become "gimple_stmt_bind" or
> just "gimple_bind".  "gimple_bind" is probably better since it matches
> the names of the accessors.
>
> If the thing after "as_a_" matches the type name, the "X->as_a_foo ()"
> takes the same number of characters as "as_a <foo> (X)".
>

I was running into similar issues with the gimple re-arch work...

One thing I was going to bring up at some point was the possibility of 
some renaming of types.    In the context of these gimple statements,  I 
would propose that we drop the "gimple_" prefix completely, and end up 
with maybe something more concise like

bind_stmt,
switch_stmt,
assign_stmt,
etc.

There will be places in the code where we have used something like
   gimple switch_stmt = blah();
so those variables would have to be renamed...   and probably other 
dribble effects...  but it would make the code look cleaner. and then  
as_a<>, is_a<> and dyn_cast<> wouldn't look so bad.

I see the gimple part of the name as being redundant.   If we're really 
concerned about it, put the whole thing inside a namespace, say  
'Gimple' and then all the gimple source files can simply start with  
"using namespace Gimple;" and then use 'bind_stmt' throughout.  Non 
gimple source files could then refer to it directly as 
Gimple::bind_stmt...     This would tie in well with what I'm planning 
to propose for gimple types and values.

Of course, it would be ideal if we could use 'gimple' as the namespace, 
but that is currently taken by the gimple statement type... I'd even go 
so far as to propose that 'gimple' should  be renamed 'gimple::stmt'.. 
but that is much more work :-)

Andrew



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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22  2:46   ` Trevor Saunders
@ 2014-04-22 14:21     ` Richard Biener
  2014-04-22 17:19     ` David Malcolm
  1 sibling, 0 replies; 250+ messages in thread
From: Richard Biener @ 2014-04-22 14:21 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: David Malcolm, GCC Patches

On Tue, Apr 22, 2014 at 12:45 AM, Trevor Saunders <tsaunders@mozilla.com> wrote:
>> --- a/gcc/tree-loop-distribution.c
>> +++ b/gcc/tree-loop-distribution.c
>> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
>>               }
>>             else if (gimple_code (stmt) == GIMPLE_SWITCH)
>>               {
>> +               gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
>
> maybe it would make more sense to do
> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
> ?

_please_ use is_a<> as_a<> etc. from is-a.h instead of member functions.

Richard.

> Trev
>

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

* Re: [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-04-21 17:13 ` [PATCH 71/89] Concretize gimple_cond_make_{false|true} David Malcolm
@ 2014-04-22 15:58   ` Trevor Saunders
  2014-04-22 18:21     ` David Malcolm
  2014-05-12 19:56   ` Jeff Law
  1 sibling, 1 reply; 250+ messages in thread
From: Trevor Saunders @ 2014-04-22 15:58 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 690 bytes --]

> diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> index 902b879..62ec9f5 100644
> --- a/gcc/tree-vrp.c
> +++ b/gcc/tree-vrp.c
> @@ -9517,10 +9517,11 @@ fold_predicate_in (gimple_stmt_iterator *si)
>        else
>  	{
>  	  gcc_assert (gimple_code (stmt) == GIMPLE_COND);
> +	  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();

the assert isn't needed now right?

Trev

>  	  if (integer_zerop (val))
> -	    gimple_cond_make_false (stmt);
> +	    gimple_cond_make_false (cond_stmt);
>  	  else if (integer_onep (val))
> -	    gimple_cond_make_true (stmt);
> +	    gimple_cond_make_true (cond_stmt);
>  	  else
>  	    gcc_unreachable ();
>  	}
> -- 
> 1.8.5.3
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 13:20   ` Andrew MacLeod
@ 2014-04-22 16:04     ` Trevor Saunders
  2014-04-22 18:57     ` David Malcolm
  1 sibling, 0 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-04-22 16:04 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: David Malcolm, gcc-patches, rdsandiford

[-- Attachment #1: Type: text/plain, Size: 6007 bytes --]

On Tue, Apr 22, 2014 at 09:05:43AM -0400, Andrew MacLeod wrote:
> On 04/22/2014 04:03 AM, Richard Sandiford wrote:
> >First of all, thanks a lot for doing this.  Maybe one day we'll have
> >the same in rtl :-)
> >
> >But...
> >
> >David Malcolm <dmalcolm@redhat.com> writes:
> >>In doing the checked downcasts I ran into the verbosity of the as_a <>
> >>API (in our "is-a.h").  I first tried simplifying them with custom
> >>functions e.g.:
> >>
> >>    static inline gimple_bind as_a_gimple_bind (gimple gs)
> >>    {
> >>      return as_a <gimple_statement_bind> (gs);
> >>    }
> >>
> >>but the approach I've gone with makes these checked casts be *methods* of
> >>the gimple_statement_base class, so that e.g. in a switch statement you
> >>can write:
> >>
> >>     case GIMPLE_SWITCH:
> >>       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
> >>       break;
> >>
> >>where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> >>concrete "gimple_switch" in a release build, with runtime checking for
> >>code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> >>internally).
> >>
> >>This is much less verbose than trying to do it with as_a <> directly, and
> >>I think doing it as a method reads better aloud (to my English-speaking
> >>mind, at-least):
> >>   "gs as a gimple switch",
> >>as opposed to:
> >>   "as a gimple switch... gs",
> >>which I find clunky.
> >>
> >>It makes the base class a little cluttered, but IMHO it hits a sweet-spot
> >>of readability and type-safety with relatively little verbosity (only 8
> >>more characters than doing it with a raw C-style cast).   Another
> >>advantage of having the checked cast as a *method* is that it implicitly
> >>documents the requirement that the input must be non-NULL.
> >...FWIW I really don't like these cast members.  The counterarguments are:
> >
> >- as_a <...> (...) and dyn_cast <...> (...) follow the C++ syntax
> >   for other casts.
> >
> >- the type you get is obvious, rather than being a contraction of
> >   the type name.
> >
> >- having them as methods means that the base class needs to aware of
> >   all subclasses.  I realise that's probably inherently true of gimple
> >   due to the enum, but it seems like bad design.  You could potentially
> >   have different subclasses for the same enum, selected by a secondary field.

That seems kind of unlikely to me given that other things depend on the
enum having an element for each "sub class", but who knows.

> I'm not particularly fond of this aspect as well...  I fear that someday
> down the road we would regret this decision, and end up changing it all back

fwiw I don't really have an opinion either way.

> to is_a<> and friends....      These kind of sweeping changes we ought to
> try very hard to make sure we only have to do it once.

I'm not convinced having to change it would be *that* bad, I would
expect most of the change could be done with sed.

> If this is purely for verbosity, I think we can find better ways to reduce
> it...  Is there any other reason?
> 
> >
> >Maybe I've just been reading C code too long, but "as a gimple switch...gs"
> >doesn't seem any less natural than "is constant...address".
> >
> >Another way of reducing the verbosity of as_a would be to shorten the
> >type names.  E.g. "gimple_statement" contracts to "gimple_stmt" in some
> >places, so "gimple_statement_bind" could become "gimple_stmt_bind" or
> >just "gimple_bind".  "gimple_bind" is probably better since it matches
> >the names of the accessors.

as well as the typedef gimple_bind being what's used all over, so it
would seem to make sense to rename the class and drop the typedef.

> >
> >If the thing after "as_a_" matches the type name, the "X->as_a_foo ()"
> >takes the same number of characters as "as_a <foo> (X)".
> >
> 
> I was running into similar issues with the gimple re-arch work...
> 
> One thing I was going to bring up at some point was the possibility of some
> renaming of types.    In the context of these gimple statements,  I would
> propose that we drop the "gimple_" prefix completely, and end up with maybe
> something more concise like
> 
> bind_stmt,
> switch_stmt,
> assign_stmt,
> etc.

That seems nice, but I'd worry about name conflicts with rtl or tree
types or something.

> There will be places in the code where we have used something like
>   gimple switch_stmt = blah();

We already have things like
loop loop = get_loop ();
so conflicts like this don't seem *that* terrible, and I guess we don't
absolutely need to rename stuff.

> so those variables would have to be renamed...   and probably other dribble
> effects...  but it would make the code look cleaner. and then  as_a<>,
> is_a<> and dyn_cast<> wouldn't look so bad.

Well, it would be nice if the typename wasn't repeated twice, but I fear
there's no way out of that without auto.

> I see the gimple part of the name as being redundant.   If we're really

I'd tend to agree accept...

> concerned about it, put the whole thing inside a namespace, say  'Gimple'

We'd need to beet gengtype into dealing with that, I'm not sure exactly
how hard that is.

> and then all the gimple source files can simply start with  "using namespace
> Gimple;" and then use 'bind_stmt' throughout.  Non gimple source files could
> then refer to it directly as Gimple::bind_stmt...     This would tie in well
> with what I'm planning to propose for gimple types and values.
> 
> Of course, it would be ideal if we could use 'gimple' as the namespace, but
> that is currently taken by the gimple statement type... I'd even go so far
> as to propose that 'gimple' should  be renamed 'gimple::stmt'.. but that is
> much more work :-)

if the rest of them are getting renamed then I think renaming gimple too
would make sense, and that's what sed is for.

Trev

> Andrew
> 
> 
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
  2014-04-22 13:20   ` Andrew MacLeod
@ 2014-04-22 17:13   ` David Malcolm
  2014-04-22 19:11     ` Richard Sandiford
  2014-04-23 17:32   ` Jeff Law
  2 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-22 17:13 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 6988 bytes --]

On Tue, 2014-04-22 at 09:03 +0100, Richard Sandiford wrote:
> First of all, thanks a lot for doing this.  Maybe one day we'll have
> the same in rtl :-)
> 
> But...
> 
> David Malcolm <dmalcolm@redhat.com> writes:
> > In doing the checked downcasts I ran into the verbosity of the as_a <>
> > API (in our "is-a.h").  I first tried simplifying them with custom
> > functions e.g.:
> >
> >    static inline gimple_bind as_a_gimple_bind (gimple gs)
> >    {
> >      return as_a <gimple_statement_bind> (gs);
> >    }
> >
> > but the approach I've gone with makes these checked casts be *methods* of
> > the gimple_statement_base class, so that e.g. in a switch statement you
> > can write:
> >
> >     case GIMPLE_SWITCH:
> >       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
> >       break;
> >
> > where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> > concrete "gimple_switch" in a release build, with runtime checking for
> > code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> > internally).
> >
> > This is much less verbose than trying to do it with as_a <> directly, and
> > I think doing it as a method reads better aloud (to my English-speaking
> > mind, at-least):
> >   "gs as a gimple switch",
> > as opposed to:
> >   "as a gimple switch... gs",
> > which I find clunky.
> >
> > It makes the base class a little cluttered, but IMHO it hits a sweet-spot
> > of readability and type-safety with relatively little verbosity (only 8
> > more characters than doing it with a raw C-style cast).   Another
> > advantage of having the checked cast as a *method* is that it implicitly
> > documents the requirement that the input must be non-NULL.
> 
> ...FWIW I really don't like these cast members.  The counterarguments are:
> 
> - as_a <...> (...) and dyn_cast <...> (...) follow the C++ syntax
>   for other casts.
> 
> - the type you get is obvious, rather than being a contraction of
>   the type name.
> 
> - having them as methods means that the base class needs to aware of
>   all subclasses.  I realise that's probably inherently true of gimple
>   due to the enum, but it seems like bad design.  You could potentially
>   have different subclasses for the same enum, selected by a secondary field.
> 
> Maybe I've just been reading C code too long, but "as a gimple switch...gs"
> doesn't seem any less natural than "is constant...address".
> 
> Another way of reducing the verbosity of as_a would be to shorten the
> type names.  E.g. "gimple_statement" contracts to "gimple_stmt" in some
> places, so "gimple_statement_bind" could become "gimple_stmt_bind" or
> just "gimple_bind".  "gimple_bind" is probably better since it matches
> the names of the accessors.
> 
> If the thing after "as_a_" matches the type name, the "X->as_a_foo ()"
> takes the same number of characters as "as_a <foo> (X)".

Beauty is indeed in the eye of the beholder :)

I prefer my proposal, but I also like yours. It would convert these
fragments (from patch 2):

  static void
  dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
                      int flags)
  [...snip...]

  [...later, within pp_gimple_stmt_1:]

     case GIMPLE_SWITCH:
       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
       break;

to these:

  static void
  dump_gimple_switch (pretty_printer *buffer, gimple_switch *gs, int spc,
                      int flags)
  [...snip...]

  [...later, within pp_gimple_stmt_1:]

     case GIMPLE_SWITCH:
       dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
       break;

Note that this affects the "pointerness" of the types: in the patches I
sent, since is-a.h has:

  template <typename T, typename U>
  inline T *
         ^^^  Note how it returns a (T*)
  as_a (U *p)
  {
    gcc_checking_assert (is_a <T> (p));
                         ^^^^^^^^ but uses the specialization of T, not T*
                                  here
    return is_a_helper <T>::cast (p);
           ^^^^^^^^^^^^^^^ and here

  }

i.e. in the current proposal, "gimple_switch" is a typedef of a
*pointer* to the GIMPLE_SWITCH subclass:
   class gimple_statement_switch
whereas direct use of the is-a.h interface would eliminate the new
typedefs and give us:
  class gimple_switch
and all vars and params that took a subclass would convert from status
quo:

     gimple some_switch_stmt;

to:
     gimple_switch *some_switch_stmt;

I like this API.

One drawback is that it leads to an inconsistency in "pointerness"
between the typedef "gimple", a pointer to the baseclass, and these
subclass types, so you might have local decls looking like this:

  gimple some_stmt;  /* note how this doesn't have a star... */
  gimple_assign *assign_stmt; /* ...whereas these ones do */
  gimple_cond *assign_stmt;
  gimple_phi *phi;

This could be resolved by renaming
  class gimple_statement_base
to
  class gimple
and eliminating the "gimple" typedef, so that we might have locals
declared like this:
  gimple *some_stmt;  /* note how this has gained a star */
  gimple_assign *assign_stmt;
  gimple_cond *assign_stmt;
  gimple_phi *phi;

though clearly that's a hugely invasive patch compared to these ones, or
by renaming:
  class gimple_statement_base
to
  class gimple_stmt
and *eventually* eliminating the "gimple" typedef, so that we might have
locals declared like this:
  gimple_stmt *some_stmt;
  gimple_assign *assign_stmt;
  gimple_cond *assign_stmt;
  gimple_phi *phi;
which gives us a clearer path to the namespace idea that Andrew posted,
if people like that.  (basically a search-and-replace of "gimple_" to
"gimple::", or possibly using a "using gimple" decl).

[IIRC we ran into a similar issue with the symtable/callgraph reorg
where we ended up doing a big renamining, but that was just 3 classes]

Alternatively we could change the is-a.h API to eliminate this
discrepancy, and keep the typedefs; giving something like the following:

  static void
  dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
                      int flags)
  [...snip...]

  [...later, within pp_gimple_stmt_1:]

     case GIMPLE_SWITCH:
       dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
       break;

which is concise, readable, and avoid the change in pointerness compared
to the "gimple" typedef; the local decls above would look like this:
  gimple some_stmt;  /* note how this doesn't have a star... */
  gimple_assign assign_stmt; /* ...and neither do these */
  gimple_cond assign_stmt;
  gimple_phi phi;

I think this last proposal is my preferred API, but it requires the
change to is-a.h

Attached is a proposed change to the is-a.h API that elimintates the
discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
compile, but hopefully illustrates the idea).  Note how it changes the
API to match C++'s  dynamic_cast<> operator i.e. you do

  Q* q = dyn_cast<Q*> (p);

not:

  Q* q = dyn_cast<Q> (p);

Dave

[-- Attachment #2: fix-pointerness-of-is-a.h --]
[-- Type: text/x-chdr, Size: 3410 bytes --]

diff --git a/gcc/is-a.h b/gcc/is-a.h
index bc756b1..a14e344 100644
--- a/gcc/is-a.h
+++ b/gcc/is-a.h
@@ -34,21 +34,21 @@ bool is_a <TYPE> (pointer)
     Suppose you have a symtab_node *ptr, AKA symtab_node *ptr.  You can test
     whether it points to a 'derived' cgraph_node as follows.
 
-      if (is_a <cgraph_node> (ptr))
+      if (is_a <cgraph_node *> (ptr))
         ....
 
 
-TYPE *as_a <TYPE> (pointer)
+TYPE as_a <TYPE> (pointer)
 
-    Converts pointer to a TYPE*.
+    Converts pointer to a TYPE.
 
     You can just assume that it is such a node.
 
-      do_something_with (as_a <cgraph_node> *ptr);
+      do_something_with (as_a <cgraph_node *> *ptr);
 
-TYPE *dyn_cast <TYPE> (pointer)
+TYPE dyn_cast <TYPE> (pointer)
 
-    Converts pointer to TYPE* if and only if "is_a <TYPE> pointer".  Otherwise,
+    Converts pointer to TYPE if and only if "is_a <TYPE> pointer".  Otherwise,
     returns NULL.  This function is essentially a checked down cast.
 
     This functions reduce compile time and increase type safety when treating a
@@ -57,7 +57,7 @@ TYPE *dyn_cast <TYPE> (pointer)
     You can test and obtain a pointer to the 'derived' type in one indivisible
     operation.
 
-      if (cgraph_node *cptr = dyn_cast <cgraph_node> (ptr))
+      if (cgraph_node *cptr = dyn_cast <cgraph_node *> (ptr))
         ....
 
     As an example, the code change is from
@@ -70,7 +70,7 @@ TYPE *dyn_cast <TYPE> (pointer)
 
     to
 
-      if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
+      if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node))
         {
           ....
         }
@@ -88,7 +88,7 @@ TYPE *dyn_cast <TYPE> (pointer)
 
     becomes
 
-      varpool_node *vnode = dyn_cast <varpool_node> (node);
+      varpool_node *vnode = dyn_cast <varpool_node *> (node);
       if (vnode && vnode->finalized)
         varpool_analyze_node (vnode);
 
@@ -110,7 +110,7 @@ example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::test (symtab_node *p)
+  is_a_helper <cgraph_node *>::test (symtab_node *p)
   {
     return p->type == SYMTAB_FUNCTION;
   }
@@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::cast (symtab_node *p)
+  is_a_helper <cgraph_node *>::cast (symtab_node *p)
   {
     return &p->x_function;
   }
@@ -140,7 +140,7 @@ struct is_a_helper
   template <typename U>
   static inline bool test (U *p);
   template <typename U>
-  static inline T *cast (U *p);
+  static inline T cast (U *p);
 };
 
 /* Note that we deliberately do not define the 'test' member template.  Not
@@ -154,10 +154,10 @@ struct is_a_helper
 
 template <typename T>
 template <typename U>
-inline T *
+inline T
 is_a_helper <T>::cast (U *p)
 {
-  return reinterpret_cast <T *> (p);
+  return reinterpret_cast <T> (p);
 }
 
 
@@ -178,7 +178,7 @@ is_a (U *p)
    discussion above for when to use this function.  */
 
 template <typename T, typename U>
-inline T *
+inline T
 as_a (U *p)
 {
   gcc_checking_assert (is_a <T> (p));
@@ -189,13 +189,13 @@ as_a (U *p)
    the discussion above for when to use this function.  */
 
 template <typename T, typename U>
-inline T *
+inline T
 dyn_cast (U *p)
 {
   if (is_a <T> (p))
     return is_a_helper <T>::cast (p);
   else
-    return static_cast <T *> (0);
+    return static_cast <T> (0);
 }
 
 #endif  /* GCC_IS_A_H  */

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22  2:46   ` Trevor Saunders
  2014-04-22 14:21     ` Richard Biener
@ 2014-04-22 17:19     ` David Malcolm
  2014-04-22 20:21       ` David Malcolm
  2014-04-22 22:04       ` Richard Henderson
  1 sibling, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-22 17:19 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: gcc-patches

On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
> > --- a/gcc/tree-loop-distribution.c
> > +++ b/gcc/tree-loop-distribution.c
> > @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
> >  		}
> >  	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
> >  		{
> > +		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
> 
> maybe it would make more sense to do
> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())

Thanks.  Yes, or indeed something like:

  else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))

(modulo the "pointerness" issues mentioned in 
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )

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

* Re: [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-04-22 15:58   ` Trevor Saunders
@ 2014-04-22 18:21     ` David Malcolm
  0 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-22 18:21 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: gcc-patches

On Tue, 2014-04-22 at 11:37 -0400, Trevor Saunders wrote:
> > diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> > index 902b879..62ec9f5 100644
> > --- a/gcc/tree-vrp.c
> > +++ b/gcc/tree-vrp.c
> > @@ -9517,10 +9517,11 @@ fold_predicate_in (gimple_stmt_iterator *si)
> >        else
> >  	{
> >  	  gcc_assert (gimple_code (stmt) == GIMPLE_COND);
> > +	  gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
> 
> the assert isn't needed now right?

Correct.  I guess my thinking here was that the original code was
checking for it, presumably to fail early, rather than hitting the
GIMPLE_CHECK macros when calling the accessors later on, but the checked
cast to gimple_cond gives us that.

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 13:20   ` Andrew MacLeod
  2014-04-22 16:04     ` Trevor Saunders
@ 2014-04-22 18:57     ` David Malcolm
  2014-04-22 19:19       ` Andrew MacLeod
  1 sibling, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-22 18:57 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: gcc-patches, rdsandiford

On Tue, 2014-04-22 at 09:05 -0400, Andrew MacLeod wrote:
> On 04/22/2014 04:03 AM, Richard Sandiford wrote:
> > First of all, thanks a lot for doing this.  Maybe one day we'll have
> > the same in rtl :-)
> >
> > But...
> >
> > David Malcolm <dmalcolm@redhat.com> writes:
> >> In doing the checked downcasts I ran into the verbosity of the as_a <>
> >> API (in our "is-a.h").  I first tried simplifying them with custom
> >> functions e.g.:
> >>
> >>     static inline gimple_bind as_a_gimple_bind (gimple gs)
> >>     {
> >>       return as_a <gimple_statement_bind> (gs);
> >>     }
> >>
> >> but the approach I've gone with makes these checked casts be *methods* of
> >> the gimple_statement_base class, so that e.g. in a switch statement you
> >> can write:
> >>
> >>      case GIMPLE_SWITCH:
> >>        dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
> >>        break;
> >>
> >> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> >> concrete "gimple_switch" in a release build, with runtime checking for
> >> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> >> internally).
> >>
> >> This is much less verbose than trying to do it with as_a <> directly, and
> >> I think doing it as a method reads better aloud (to my English-speaking
> >> mind, at-least):
> >>    "gs as a gimple switch",
> >> as opposed to:
> >>    "as a gimple switch... gs",
> >> which I find clunky.
> >>
> >> It makes the base class a little cluttered, but IMHO it hits a sweet-spot
> >> of readability and type-safety with relatively little verbosity (only 8
> >> more characters than doing it with a raw C-style cast).   Another
> >> advantage of having the checked cast as a *method* is that it implicitly
> >> documents the requirement that the input must be non-NULL.
> > ...FWIW I really don't like these cast members.  The counterarguments are:
> >
> > - as_a <...> (...) and dyn_cast <...> (...) follow the C++ syntax
> >    for other casts.
> >
> > - the type you get is obvious, rather than being a contraction of
> >    the type name.
> >
> > - having them as methods means that the base class needs to aware of
> >    all subclasses.  I realise that's probably inherently true of gimple
> >    due to the enum, but it seems like bad design.  You could potentially
> >    have different subclasses for the same enum, selected by a secondary field.
> I'm not particularly fond of this aspect as well...  I fear that someday 
> down the road we would regret this decision, and end up changing it all 
> back to is_a<> and friends....      These kind of sweeping changes we 
> ought to try very hard to make sure we only have to do it once.
> 
> If this is purely for verbosity, I think we can find better ways to 
> reduce it...  Is there any other reason?

There was also the idea that a method carries with it the implication
that the ptr is non-NULL... but the main reason was verbosity.

I think that with a change to is-a.h to better support typedefs, we can
achieve a relatively terse API; see:
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html

> > Maybe I've just been reading C code too long, but "as a gimple switch...gs"
> > doesn't seem any less natural than "is constant...address".
> >
> > Another way of reducing the verbosity of as_a would be to shorten the
> > type names.  E.g. "gimple_statement" contracts to "gimple_stmt" in some
> > places, so "gimple_statement_bind" could become "gimple_stmt_bind" or
> > just "gimple_bind".  "gimple_bind" is probably better since it matches
> > the names of the accessors.
> >
> > If the thing after "as_a_" matches the type name, the "X->as_a_foo ()"
> > takes the same number of characters as "as_a <foo> (X)".
> >
> 
> I was running into similar issues with the gimple re-arch work...
> 
> One thing I was going to bring up at some point was the possibility of 
> some renaming of types.    In the context of these gimple statements,  I 
> would propose that we drop the "gimple_" prefix completely, and end up 
> with maybe something more concise like
> 
> bind_stmt,
> switch_stmt,
> assign_stmt,
> etc.
> 
> There will be places in the code where we have used something like
>    gimple switch_stmt = blah();
> so those variables would have to be renamed...   and probably other 
> dribble effects...  but it would make the code look cleaner. and then  
> as_a<>, is_a<> and dyn_cast<> wouldn't look so bad.
> 
> I see the gimple part of the name as being redundant.   If we're really 
> concerned about it, put the whole thing inside a namespace, say  
> 'Gimple' and then all the gimple source files can simply start with  
> "using namespace Gimple;" and then use 'bind_stmt' throughout.  Non 
> gimple source files could then refer to it directly as 
> Gimple::bind_stmt...     This would tie in well with what I'm planning 
> to propose for gimple types and values.

That would require teaching gengtype about namespaces (rather than the
current hack), which I'd prefer to avoid.

> Of course, it would be ideal if we could use 'gimple' as the namespace, 
> but that is currently taken by the gimple statement type... I'd even go 
> so far as to propose that 'gimple' should  be renamed 'gimple::stmt'.. 
> but that is much more work :-)

I'm not at all keen on that further suggestion: I wanted to make this
patch series as minimal as possible whilst giving us the compile-time
tracking of gimple codes.  Although people's inboxes may find this
surprising, I was trying to be conservative with the patch series :) [1]

We're both working on large changes that improve the type-safety of the
middle-end: this patch series affects statements, whereas AIUI you have
a branch working on expressions and types.   How do we best co-ordinate
this so that we don't bitrot each other's work, so that the result is
reviewable, and the changes are understandable in, say, 5 years time?
My plan was to do the statement work as a (large) series of small
patches against trunk, trying to minimize the number of lines I touch,
mostly function and variable decls with a few lines adding is_a and
dyn_cast, whereas your change AIUI by necessity involves more
substantial changes to function bodies.  I think we can only have zero
or one such "touch every line" change(s) landing at once.

Dave

[1] for example, a more aggressive cleanup would be to convert the
accessors to be methods of the underlying statement classes, and make
all the data fields be private.  But the cost/benefit tradeoff doesn't
appeal: doing so would touch basically every line of code in the middle
end, and it isn't necessary to give us the compile-time checking
benefits that motivates this patch series  [potentially we could use
"friend" decls to allow the data fields to be private whilst granting
access to the existing accessors, I guess].

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 17:13   ` David Malcolm
@ 2014-04-22 19:11     ` Richard Sandiford
  2014-04-22 19:28       ` Andrew MacLeod
  2014-04-22 19:45       ` Richard Biener
  0 siblings, 2 replies; 250+ messages in thread
From: Richard Sandiford @ 2014-04-22 19:11 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

David Malcolm <dmalcolm@redhat.com> writes:
> Alternatively we could change the is-a.h API to eliminate this
> discrepancy, and keep the typedefs; giving something like the following:
>
>   static void
>   dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
>                       int flags)
>   [...snip...]
>
>   [...later, within pp_gimple_stmt_1:]
>
>      case GIMPLE_SWITCH:
>        dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
>        break;
>
> which is concise, readable, and avoid the change in pointerness compared
> to the "gimple" typedef; the local decls above would look like this:
>   gimple some_stmt;  /* note how this doesn't have a star... */
>   gimple_assign assign_stmt; /* ...and neither do these */
>   gimple_cond assign_stmt;
>   gimple_phi phi;
>
> I think this last proposal is my preferred API, but it requires the
> change to is-a.h
>
> Attached is a proposed change to the is-a.h API that elimintates the
> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
> compile, but hopefully illustrates the idea).  Note how it changes the
> API to match C++'s  dynamic_cast<> operator i.e. you do
>
>   Q* q = dyn_cast<Q*> (p);
>
> not:
>
>   Q* q = dyn_cast<Q> (p);

Thanks for being flexible. :-)  I like this version too FWIW, for the
reason you said: it really does look like a proper C++ cast.

If we ever decide to get rid of the typedefs (maybe at the same time as
using "auto") then the choice might be different, but that would be a much
more systematic and easily-automated change than this one.

Thanks,
Richard

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 18:57     ` David Malcolm
@ 2014-04-22 19:19       ` Andrew MacLeod
  0 siblings, 0 replies; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-22 19:19 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, rdsandiford

On 04/22/2014 01:50 PM, David Malcolm wrote:
> On Tue, 2014-04-22 at 09:05 -0400, Andrew MacLeod wrote:
>
>> Of course, it would be ideal if we could use 'gimple' as the namespace,
>> but that is currently taken by the gimple statement type... I'd even go
>> so far as to propose that 'gimple' should  be renamed 'gimple::stmt'..
>> but that is much more work :-)
> I'm not at all keen on that further suggestion: I wanted to make this
> patch series as minimal as possible whilst giving us the compile-time
> tracking of gimple codes.  Although people's inboxes may find this
> surprising, I was trying to be conservative with the patch series :) [1]
I wasn't suggesting you do it in this patch set... It would clearly be 
its own patch set, and doesn't even need to be done by you. Merely 
bringing up the option for future consideration since I'd like to see 
the generic 'gimple' name re-purposed :-)


>
> We're both working on large changes that improve the type-safety of the
> middle-end: this patch series affects statements, whereas AIUI you have
> a branch working on expressions and types.   How do we best co-ordinate
> this so that we don't bitrot each other's work, so that the result is
> reviewable, and the changes are understandable in, say, 5 years time?
> My plan was to do the statement work as a (large) series of small
> patches against trunk, trying to minimize the number of lines I touch,
> mostly function and variable decls with a few lines adding is_a and
> dyn_cast, whereas your change AIUI by necessity involves more
> substantial changes to function bodies.  I think we can only have zero
> or one such "touch every line" change(s) landing at once.
>
> Dave

I don't think you should worry about bit-rotting other in-progress 
branches when making these decisions...at least  not mine..  I think you 
should "do the right thing", whatever that turns out to be :-)

My stuff wont land as a "touch every line" change through the source 
base.  its designed to fully convert a file at a time and transparently 
coexist with the existing tree interface...  Impact on other files is 
minimal.  Plus I expect it will go through at least one more massive 
round of changes after I finish documenting it and bring it forth for 
discussions in the coming month(s).  So it'll be all bit-rotted then 
anyway.

Andrew


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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 19:11     ` Richard Sandiford
@ 2014-04-22 19:28       ` Andrew MacLeod
  2014-04-22 19:45       ` Richard Biener
  1 sibling, 0 replies; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-22 19:28 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, rdsandiford

On 04/22/2014 02:56 PM, Richard Sandiford wrote:
> David Malcolm <dmalcolm@redhat.com> writes:
>> Alternatively we could change the is-a.h API to eliminate this
>> discrepancy, and keep the typedefs; giving something like the following:
>>
>>    static void
>>    dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
>>                        int flags)
>>    [...snip...]
>>
>>    [...later, within pp_gimple_stmt_1:]
>>
>>       case GIMPLE_SWITCH:
>>         dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
>>         break;
>>
>> which is concise, readable, and avoid the change in pointerness compared
>> to the "gimple" typedef; the local decls above would look like this:
>>    gimple some_stmt;  /* note how this doesn't have a star... */
>>    gimple_assign assign_stmt; /* ...and neither do these */
>>    gimple_cond assign_stmt;
>>    gimple_phi phi;
>>
>> I think this last proposal is my preferred API, but it requires the
>> change to is-a.h
>>
>> Attached is a proposed change to the is-a.h API that elimintates the
>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
>> compile, but hopefully illustrates the idea).  Note how it changes the
>> API to match C++'s  dynamic_cast<> operator i.e. you do
>>
>>    Q* q = dyn_cast<Q*> (p);
>>
>> not:
>>
>>    Q* q = dyn_cast<Q> (p);
> Thanks for being flexible. :-)  I like this version too FWIW, for the
> reason you said: it really does look like a proper C++ cast.
>
> If we ever decide to get rid of the typedefs (maybe at the same time as
> using "auto") then the choice might be different, but that would be a much
> more systematic and easily-automated change than this one.
>
>

Can we also consider making dyn_cast  handle NULL at the same time? the 
C++ dynamic_cast<>  does, and I ended up supporting it in my branch as well.


so dyn_cast would be more like:

inline T
dyn_cast (U *p)
{
   if (p && is_a <T> (p))
     return is_a_helper <T>::cast (p);
   else
     return static_cast <T > (0);
}


both is_a<> and as_a<> would still require a valid pointer or you get a 
NULL dereference...


I've found it very pragmatic...

Andrew

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 19:11     ` Richard Sandiford
  2014-04-22 19:28       ` Andrew MacLeod
@ 2014-04-22 19:45       ` Richard Biener
  2014-04-23 14:29         ` Richard Biener
  1 sibling, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-22 19:45 UTC (permalink / raw)
  To: Richard Sandiford, David Malcolm; +Cc: gcc-patches

On April 22, 2014 8:56:56 PM CEST, Richard Sandiford <rdsandiford@googlemail.com> wrote:
>David Malcolm <dmalcolm@redhat.com> writes:
>> Alternatively we could change the is-a.h API to eliminate this
>> discrepancy, and keep the typedefs; giving something like the
>following:
>>
>>   static void
>>   dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int
>spc,
>>                       int flags)
>>   [...snip...]
>>
>>   [...later, within pp_gimple_stmt_1:]
>>
>>      case GIMPLE_SWITCH:
>>        dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc,
>flags);
>>        break;
>>
>> which is concise, readable, and avoid the change in pointerness
>compared
>> to the "gimple" typedef; the local decls above would look like this:
>>   gimple some_stmt;  /* note how this doesn't have a star... */
>>   gimple_assign assign_stmt; /* ...and neither do these */
>>   gimple_cond assign_stmt;
>>   gimple_phi phi;
>>
>> I think this last proposal is my preferred API, but it requires the
>> change to is-a.h
>>
>> Attached is a proposed change to the is-a.h API that elimintates the
>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
>> compile, but hopefully illustrates the idea).  Note how it changes
>the
>> API to match C++'s  dynamic_cast<> operator i.e. you do
>>
>>   Q* q = dyn_cast<Q*> (p);
>>
>> not:
>>
>>   Q* q = dyn_cast<Q> (p);
>
>Thanks for being flexible. :-)  I like this version too FWIW, for the
>reason you said: it really does look like a proper C++ cast.

Indeed. I even wasn't aware it is different Than a c++ cast...

Richard.

>If we ever decide to get rid of the typedefs (maybe at the same time as
>using "auto") then the choice might be different, but that would be a
>much
>more systematic and easily-automated change than this one.
>
>Thanks,
>Richard


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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22 17:19     ` David Malcolm
@ 2014-04-22 20:21       ` David Malcolm
  2014-04-23  7:38         ` Florian Weimer
  2014-04-22 22:04       ` Richard Henderson
  1 sibling, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-22 20:21 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: gcc-patches

On Tue, 2014-04-22 at 13:13 -0400, David Malcolm wrote:
> On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
> > > --- a/gcc/tree-loop-distribution.c
> > > +++ b/gcc/tree-loop-distribution.c
> > > @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
> > >  		}
> > >  	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
> > >  		{
> > > +		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
> > 
> > maybe it would make more sense to do
> > else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
> 
> Thanks.  Yes, or indeed something like:
> 
>   else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
> 
> (modulo the "pointerness" issues mentioned in 
> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )

or indeed, something like:

	      else if (gimple_switch switch_stmt =
		          dyn_cast <gimple_switch> (stmt))
               {


to avoid an 83-character-wide line :)

Hope that's the appropriate way to split such a line; I can never
remember if one is supposed to put the linebreak before or after the =.

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22 17:19     ` David Malcolm
  2014-04-22 20:21       ` David Malcolm
@ 2014-04-22 22:04       ` Richard Henderson
  2014-04-23 19:58         ` Jeff Law
  1 sibling, 1 reply; 250+ messages in thread
From: Richard Henderson @ 2014-04-22 22:04 UTC (permalink / raw)
  To: David Malcolm, Trevor Saunders; +Cc: gcc-patches

On 04/22/2014 10:13 AM, David Malcolm wrote:
> On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
>>> --- a/gcc/tree-loop-distribution.c
>>> +++ b/gcc/tree-loop-distribution.c
>>> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
>>>  		}
>>>  	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
>>>  		{
>>> +		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
>>
>> maybe it would make more sense to do
>> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
> 
> Thanks.  Yes, or indeed something like:
> 
>   else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
> 
> (modulo the "pointerness" issues mentioned in 
> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )
> 

I'm not keen on embedding assignments into conditionals like this, much less
embedding variable declarations as well.  I think David's original is perfect.


r~

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22 20:21       ` David Malcolm
@ 2014-04-23  7:38         ` Florian Weimer
  0 siblings, 0 replies; 250+ messages in thread
From: Florian Weimer @ 2014-04-23  7:38 UTC (permalink / raw)
  To: David Malcolm, Trevor Saunders; +Cc: gcc-patches

On 04/22/2014 10:17 PM, David Malcolm wrote:

> or indeed, something like:
>
> 	      else if (gimple_switch switch_stmt =
> 		          dyn_cast <gimple_switch> (stmt))
>                 {
>
>
> to avoid an 83-character-wide line :)
>
> Hope that's the appropriate way to split such a line; I can never
> remember if one is supposed to put the linebreak before or after the =.

It's supposed to come before, so that the equal sign is at the start of 
the line.  Operators are also supposed to be at the start and not the 
end.  At least the operator part is covered in the coding standards:

<http://www.gnu.org/prep/standards/html_node/Formatting.html>

-- 
Florian Weimer / Red Hat Product Security Team

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22 19:45       ` Richard Biener
@ 2014-04-23 14:29         ` Richard Biener
  2014-04-23 14:36           ` Richard Biener
                             ` (2 more replies)
  0 siblings, 3 replies; 250+ messages in thread
From: Richard Biener @ 2014-04-23 14:29 UTC (permalink / raw)
  To: Richard Sandiford, David Malcolm; +Cc: GCC Patches

On Tue, Apr 22, 2014 at 9:42 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On April 22, 2014 8:56:56 PM CEST, Richard Sandiford <rdsandiford@googlemail.com> wrote:
>>David Malcolm <dmalcolm@redhat.com> writes:
>>> Alternatively we could change the is-a.h API to eliminate this
>>> discrepancy, and keep the typedefs; giving something like the
>>following:
>>>
>>>   static void
>>>   dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int
>>spc,
>>>                       int flags)
>>>   [...snip...]
>>>
>>>   [...later, within pp_gimple_stmt_1:]
>>>
>>>      case GIMPLE_SWITCH:
>>>        dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc,
>>flags);
>>>        break;
>>>
>>> which is concise, readable, and avoid the change in pointerness
>>compared
>>> to the "gimple" typedef; the local decls above would look like this:
>>>   gimple some_stmt;  /* note how this doesn't have a star... */
>>>   gimple_assign assign_stmt; /* ...and neither do these */
>>>   gimple_cond assign_stmt;
>>>   gimple_phi phi;
>>>
>>> I think this last proposal is my preferred API, but it requires the
>>> change to is-a.h
>>>
>>> Attached is a proposed change to the is-a.h API that elimintates the
>>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
>>> compile, but hopefully illustrates the idea).  Note how it changes
>>the
>>> API to match C++'s  dynamic_cast<> operator i.e. you do
>>>
>>>   Q* q = dyn_cast<Q*> (p);
>>>
>>> not:
>>>
>>>   Q* q = dyn_cast<Q> (p);
>>
>>Thanks for being flexible. :-)  I like this version too FWIW, for the
>>reason you said: it really does look like a proper C++ cast.
>
> Indeed. I even wasn't aware it is different Than a c++ cast...

It would be nice if you can change that with a separate patch posted
in a separate thread to be more visible.

Also I see you introduce a const_FOO class with every FOO one.
I wonder whether, now that we have C++, can address const-correctness
in a less awkward way than with a typedef.  Can you try to go back
in time and see why we did with that in the first place?  ISTR that
it was "oh, if we were only using C++ we wouldn't need to jump through
that hoop".

Thanks,
Richard.

> Richard.
>
>>If we ever decide to get rid of the typedefs (maybe at the same time as
>>using "auto") then the choice might be different, but that would be a
>>much
>>more systematic and easily-automated change than this one.
>>
>>Thanks,
>>Richard
>
>

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 14:29         ` Richard Biener
@ 2014-04-23 14:36           ` Richard Biener
  2014-04-30 21:40             ` Jeff Law
  2014-04-23 15:38           ` [PATCH 00/89] Compile-time gimple-checking David Malcolm
  2014-04-23 16:15           ` Andrew MacLeod
  2 siblings, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-23 14:36 UTC (permalink / raw)
  To: Richard Sandiford, David Malcolm; +Cc: GCC Patches

On Wed, Apr 23, 2014 at 4:19 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Apr 22, 2014 at 9:42 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On April 22, 2014 8:56:56 PM CEST, Richard Sandiford <rdsandiford@googlemail.com> wrote:
>>>David Malcolm <dmalcolm@redhat.com> writes:
>>>> Alternatively we could change the is-a.h API to eliminate this
>>>> discrepancy, and keep the typedefs; giving something like the
>>>following:
>>>>
>>>>   static void
>>>>   dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int
>>>spc,
>>>>                       int flags)
>>>>   [...snip...]
>>>>
>>>>   [...later, within pp_gimple_stmt_1:]
>>>>
>>>>      case GIMPLE_SWITCH:
>>>>        dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc,
>>>flags);
>>>>        break;
>>>>
>>>> which is concise, readable, and avoid the change in pointerness
>>>compared
>>>> to the "gimple" typedef; the local decls above would look like this:
>>>>   gimple some_stmt;  /* note how this doesn't have a star... */
>>>>   gimple_assign assign_stmt; /* ...and neither do these */
>>>>   gimple_cond assign_stmt;
>>>>   gimple_phi phi;
>>>>
>>>> I think this last proposal is my preferred API, but it requires the
>>>> change to is-a.h
>>>>
>>>> Attached is a proposed change to the is-a.h API that elimintates the
>>>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
>>>> compile, but hopefully illustrates the idea).  Note how it changes
>>>the
>>>> API to match C++'s  dynamic_cast<> operator i.e. you do
>>>>
>>>>   Q* q = dyn_cast<Q*> (p);
>>>>
>>>> not:
>>>>
>>>>   Q* q = dyn_cast<Q> (p);
>>>
>>>Thanks for being flexible. :-)  I like this version too FWIW, for the
>>>reason you said: it really does look like a proper C++ cast.
>>
>> Indeed. I even wasn't aware it is different Than a c++ cast...
>
> It would be nice if you can change that with a separate patch posted
> in a separate thread to be more visible.
>
> Also I see you introduce a const_FOO class with every FOO one.
> I wonder whether, now that we have C++, can address const-correctness
> in a less awkward way than with a typedef.  Can you try to go back
> in time and see why we did with that in the first place?  ISTR that
> it was "oh, if we were only using C++ we wouldn't need to jump through
> that hoop".

To followup myself here, it's because 'tree' is a typedef to a pointer
and thus 'const tree' is different from 'const tree_node *'.

Not sure why we re-introduced the 'mistake' of making 'tree' a pointer
when we introduced 'gimple'.  If we were to make 'gimple' the class
type itself we can use gimple *, const gimple * and also const gimple &
(when a NULL pointer is not expected).

Anyway, gazillion new typedefs are ugly :/  (typedefs are ugly)

Richard.

> Thanks,
> Richard.
>
>> Richard.
>>
>>>If we ever decide to get rid of the typedefs (maybe at the same time as
>>>using "auto") then the choice might be different, but that would be a
>>>much
>>>more systematic and easily-automated change than this one.
>>>
>>>Thanks,
>>>Richard
>>
>>

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
                   ` (90 preceding siblings ...)
  2014-04-22  8:37 ` Richard Biener
@ 2014-04-23 14:43 ` Michael Matz
  2014-04-24 13:25   ` Andrew MacLeod
  91 siblings, 1 reply; 250+ messages in thread
From: Michael Matz @ 2014-04-23 14:43 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

Hi,

On Mon, 21 Apr 2014, David Malcolm wrote:

> This is a greatly-expanded version of:
>   http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01262.html
> 
> As of r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and
> r205428 (a90353203da18288cdac1b0b78fe7b22c69fe63f) the various gimple
> statements form a C++ inheritance hierarchy, but we're not yet making much
> use of that in the code: everything refers to just "gimple" (or
> "const_gimple"), and type-checking is performed at run-time within the
> various gimple_foo_* accessors in gimple.h, and almost nowhere else.
> 
> The following patch series introduces compile-time checking of much of
> the handling of gimple statements.

FWIW, I still don't like any of this for reasons already outlined here: 
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00773.html

(basically: I consider automatically creating types a very bad idea.  You 
do do that by simply creating a type for every gimple code.)

>     case GIMPLE_SWITCH:
>       dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
>       break;
> 
> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
> concrete "gimple_switch" in a release build, with runtime checking for
> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
> internally).

Unlike others here I do like the cast-as-method (if we absolutely _must_ 
have a complicated type hierarchy for gimple), but would suggest different 
a name: the "gimple_" is tautological, and the "a_" just noise, just name 
it "gs->as_switch()" (incidentally then it's _really_ shorter than the 
ugly is_a/as_a syntax).


Ciao,
Michael.

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 14:29         ` Richard Biener
  2014-04-23 14:36           ` Richard Biener
@ 2014-04-23 15:38           ` David Malcolm
  2014-04-23 16:15           ` Andrew MacLeod
  2 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-23 15:38 UTC (permalink / raw)
  To: Richard Biener; +Cc: Richard Sandiford, GCC Patches

On Wed, 2014-04-23 at 16:19 +0200, Richard Biener wrote:
> On Tue, Apr 22, 2014 at 9:42 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
> > On April 22, 2014 8:56:56 PM CEST, Richard Sandiford <rdsandiford@googlemail.com> wrote:
> >>David Malcolm <dmalcolm@redhat.com> writes:
> >>> Alternatively we could change the is-a.h API to eliminate this
> >>> discrepancy, and keep the typedefs; giving something like the
> >>following:
> >>>
> >>>   static void
> >>>   dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int
> >>spc,
> >>>                       int flags)
> >>>   [...snip...]
> >>>
> >>>   [...later, within pp_gimple_stmt_1:]
> >>>
> >>>      case GIMPLE_SWITCH:
> >>>        dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc,
> >>flags);
> >>>        break;
> >>>
> >>> which is concise, readable, and avoid the change in pointerness
> >>compared
> >>> to the "gimple" typedef; the local decls above would look like this:
> >>>   gimple some_stmt;  /* note how this doesn't have a star... */
> >>>   gimple_assign assign_stmt; /* ...and neither do these */
> >>>   gimple_cond assign_stmt;
> >>>   gimple_phi phi;
> >>>
> >>> I think this last proposal is my preferred API, but it requires the
> >>> change to is-a.h
> >>>
> >>> Attached is a proposed change to the is-a.h API that elimintates the
> >>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
> >>> compile, but hopefully illustrates the idea).  Note how it changes
> >>the
> >>> API to match C++'s  dynamic_cast<> operator i.e. you do
> >>>
> >>>   Q* q = dyn_cast<Q*> (p);
> >>>
> >>> not:
> >>>
> >>>   Q* q = dyn_cast<Q> (p);
> >>
> >>Thanks for being flexible. :-)  I like this version too FWIW, for the
> >>reason you said: it really does look like a proper C++ cast.
> >
> > Indeed. I even wasn't aware it is different Than a c++ cast...
> 
> It would be nice if you can change that with a separate patch posted
> in a separate thread to be more visible.

Done, as:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01439.html

I've experimentally ported patch 2 of the series (gimple_switch) to this
approach, dropping the unloved casting methods in favor of as_a and
dyn_cast, and it works.

> Also I see you introduce a const_FOO class with every FOO one.
> I wonder whether, now that we have C++, can address const-correctness
> in a less awkward way than with a typedef.  Can you try to go back
> in time and see why we did with that in the first place?  ISTR that
> it was "oh, if we were only using C++ we wouldn't need to jump through
> that hoop".
> 
> Thanks,
> Richard.
> 
> > Richard.
> >
> >>If we ever decide to get rid of the typedefs (maybe at the same time as
> >>using "auto") then the choice might be different, but that would be a
> >>much
> >>more systematic and easily-automated change than this one.
> >>
> >>Thanks,
> >>Richard
> >
> >


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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 14:29         ` Richard Biener
  2014-04-23 14:36           ` Richard Biener
  2014-04-23 15:38           ` [PATCH 00/89] Compile-time gimple-checking David Malcolm
@ 2014-04-23 16:15           ` Andrew MacLeod
  2 siblings, 0 replies; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-23 16:15 UTC (permalink / raw)
  To: Richard Biener, Richard Sandiford, David Malcolm; +Cc: GCC Patches

On 04/23/2014 10:19 AM, Richard Biener wrote:
> On Tue, Apr 22, 2014 at 9:42 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On April 22, 2014 8:56:56 PM CEST, Richard Sandiford <rdsandiford@googlemail.com> wrote:
>>> David Malcolm <dmalcolm@redhat.com> writes:
>>>> Alternatively we could change the is-a.h API to eliminate this
>>>> discrepancy, and keep the typedefs; giving something like the
>>> following:
>>>>    static void
>>>>    dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int
>>> spc,
>>>>                        int flags)
>>>>    [...snip...]
>>>>
>>>>    [...later, within pp_gimple_stmt_1:]
>>>>
>>>>       case GIMPLE_SWITCH:
>>>>         dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc,
>>> flags);
>>>>         break;
>>>>
>>>> which is concise, readable, and avoid the change in pointerness
>>> compared
>>>> to the "gimple" typedef; the local decls above would look like this:
>>>>    gimple some_stmt;  /* note how this doesn't have a star... */
>>>>    gimple_assign assign_stmt; /* ...and neither do these */
>>>>    gimple_cond assign_stmt;
>>>>    gimple_phi phi;
>>>>
>>>> I think this last proposal is my preferred API, but it requires the
>>>> change to is-a.h
>>>>
>>>> Attached is a proposed change to the is-a.h API that elimintates the
>>>> discrepancy, allowing the use of typedefs with is-a.h (doesn't yet
>>>> compile, but hopefully illustrates the idea).  Note how it changes
>>> the
>>>> API to match C++'s  dynamic_cast<> operator i.e. you do
>>>>
>>>>    Q* q = dyn_cast<Q*> (p);
>>>>
>>>> not:
>>>>
>>>>    Q* q = dyn_cast<Q> (p);
>>> Thanks for being flexible. :-)  I like this version too FWIW, for the
>>> reason you said: it really does look like a proper C++ cast.
>> Indeed. I even wasn't aware it is different Than a c++ cast...
> It would be nice if you can change that with a separate patch posted
> in a separate thread to be more visible.
>
> Also I see you introduce a const_FOO class with every FOO one.
> I wonder whether, now that we have C++, can address const-correctness
> in a less awkward way than with a typedef.  Can you try to go back
> in time and see why we did with that in the first place?  ISTR that
> it was "oh, if we were only using C++ we wouldn't need to jump through
> that hoop".
>
>
I was also wondering if we shouldn't be able to get rid of the 'const_' 
versions and just properly use const with the c++ classes.

I think we can...

Andrew


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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22  8:37 ` Richard Biener
@ 2014-04-23 17:23   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-04-23 17:23 UTC (permalink / raw)
  To: Richard Biener, David Malcolm; +Cc: GCC Patches

On 04/22/14 02:36, Richard Biener wrote:
> On Mon, Apr 21, 2014 at 6:56 PM, David Malcolm <dmalcolm@redhat.com> wrote:
>> This is a greatly-expanded version of:
>>    http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01262.html
>>
>> As of r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and
>> r205428 (a90353203da18288cdac1b0b78fe7b22c69fe63f) the various gimple
>> statements form a C++ inheritance hierarchy, but we're not yet making much
>> use of that in the code: everything refers to just "gimple" (or
>> "const_gimple"), and type-checking is performed at run-time within the
>> various gimple_foo_* accessors in gimple.h, and almost nowhere else.
>>
>> The following patch series introduces compile-time checking of much of
>> the handling of gimple statements.
>>
>> Various new typedefs are introduced for pointers to statements where the
>> specific code is known, matching the corresponding names from gimple.def.
>
> Even though I like these changes in principle I also wear a release
> managers hat.  Being one of the persons doing frequent backports
> of trunk fixes to branches this will cause a _lot_ of headache.  So ... can
> we delay this until, say, 4.9.1 is out?
Understood.

So how about we proceed with the review & approvals, but they stage in 
after 4.9.1?  Ideally by the time 4.9.1 is ready, the entire series in 
its final form has been reviewed and approved.



jeff

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
  2014-04-22 13:20   ` Andrew MacLeod
  2014-04-22 17:13   ` David Malcolm
@ 2014-04-23 17:32   ` Jeff Law
  2014-04-24 12:23     ` Richard Sandiford
  2 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-23 17:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, rdsandiford

On 04/22/14 02:03, Richard Sandiford wrote:
> First of all, thanks a lot for doing this.  Maybe one day we'll have
> the same in rtl :-)
Funny you should mention that.  I blocked off a hunk of time for David 
to investigate doing some work on that this year.

Jeff

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-22 22:04       ` Richard Henderson
@ 2014-04-23 19:58         ` Jeff Law
  2014-04-23 20:35           ` Richard Henderson
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-23 19:58 UTC (permalink / raw)
  To: Richard Henderson, David Malcolm, Trevor Saunders; +Cc: gcc-patches

On 04/22/14 15:38, Richard Henderson wrote:
> On 04/22/2014 10:13 AM, David Malcolm wrote:
>> On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
>>>> --- a/gcc/tree-loop-distribution.c
>>>> +++ b/gcc/tree-loop-distribution.c
>>>> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
>>>>   		}
>>>>   	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
>>>>   		{
>>>> +		  gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
>>>
>>> maybe it would make more sense to do
>>> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
>>
>> Thanks.  Yes, or indeed something like:
>>
>>    else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
>>
>> (modulo the "pointerness" issues mentioned in
>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )
>>
>
> I'm not keen on embedding assignments into conditionals like this, much less
> embedding variable declarations as well.  I think David's original is perfect.
Likewise, though I am less annoyed by such things than I was in the 
past.  Perhaps that's an artifact of actually liking that kind of style 
for 'for' loops.


Jeff

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-21 16:56 ` [PATCH 02/89] Introduce gimple_switch and use it in various places David Malcolm
  2014-04-22  2:46   ` Trevor Saunders
@ 2014-04-23 20:01   ` Jeff Law
  2014-04-24 13:39     ` David Malcolm
  1 sibling, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-23 20:01 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_statement_switch): New subclass of
> 	gimple_statement_with_ops, adding the invariant that
> 	stmt->code == GIMPLE_SWITCH.
> 	(gimple_statement_base::as_a_gimple_switch): New.
> 	(gimple_statement_base::dyn_cast_gimple_switch): New.
> 	(is_a_helper <gimple_statement_switch>::test (gimple)): New.
>
> 	* coretypes.h (gimple_switch): New typedef
> 	(const_gimple_switch): Likewise.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_switch
> 	and its variants, using the gimple printer.
>
> 	* gimple.c (gimple_build_switch_nlabels): Return a gimple_switch
> 	rather than just a gimple.
> 	(gimple_build_switch): Likewise.
> 	* gimple.h (gimple_build_switch_nlabels): Likewise.
> 	(gimple_build_switch): Likewise.
>
> 	* gimple.h (gimple_switch_num_labels): Update type-signature to
> 	require a gimple_switch rather than just a gimple.
> 	(gimple_switch_set_num_labels): Likewise.
> 	(gimple_switch_set_index): Likewise.
> 	(gimple_switch_label): Likewise.
> 	(gimple_switch_set_label): Likewise.
> 	(gimple_switch_default_label): Likewise.
> 	(gimple_switch_set_default_label): Likewise.
> 	* expr.h (expand_case): Likewise.
> 	* gimple-pretty-print.c (dump_gimple_call): Likewise.
> 	* stmt.c (compute_cases_per_edge): Likewise.
> 	(expand_case): Likewise.
> 	* tree-cfg.h (group_case_labels_stmt): Likewise.
> 	* tree-cfg.c (make_gimple_switch_edges): Likewise.
> 	(find_taken_edge_switch_expr) Likewise.
> 	(find_case_label_for_value) Likewise.
> 	(get_cases_for_edge): Likewise.
> 	(group_case_labels_stmt): Likewise.
> 	(verify_gimple_switch): Likewise.
> 	* tree-eh.c (verify_norecord_switch_expr): Likewise.
> 	* tree-eh.c (lower_eh_constructs_2): Likewise.
> 	* tree-loop-distribution.c (generate_loops_for_partition): Likewise.
> 	* tree-ssa-dom.c (record_edge_info): Likewise.
> 	* tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise.
> 	(simplify_gimple_switch): Likewise.
> 	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
> 	(collect_switch_conv_info): Likewise.
> 	(build_constructors): Likewise.
> 	(array_value_type): Likewise.
> 	(build_one_array): Likewise.
> 	(build_arrays): Likewise.
> 	(gen_inbound_check): Likewise.
> 	* tree-vrp.c (find_switch_asserts): Likewise.
> 	(find_case_label_range): Likewise.
> 	(find_case_label_ranges): Likewise.
> 	(vrp_visit_switch_stmt): Likewise.
> 	(simplify_switch_using_ranges): Likewise.
>
> 	* tree-vrp.c (switch_update): Strengthen field "stmt" from being
> 	merely a gimple to being a gimple_switch.
>
> 	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to
> 	gimple_switch in regions where the stmt code has been tested as
> 	GIMPLE_SWITCH.
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
> 	* tree-cfg.c (make_edges): Likewise.
> 	(end_recording_case_labels): Likewise.
> 	(cleanup_dead_labels): Likewise.
> 	(cleanup_dead_labels): Likewise.
> 	(group_case_labels): Likewise.
> 	(find_taken_edge): Likewise.
> 	(find_case_label_for_value): Likewise.
> 	(verify_gimple_stmt): Likewise.
> 	(gimple_verify_flow_info): Likewise.
> 	(gimple_redirect_edge_and_branch): Likewise.
> 	* tree-inline.c (estimate_num_insns): Likewise.
> 	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
> 	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
> 	* tree-switch-conversion.c (do_switchconv): Likewise.
> 	* tree-vrp.c  (find_assert_locations_1): Likewise.
> 	(vrp_visit_stmt): Likewise.
> 	(simplify_stmt_using_ranges): Likewise.
>
> 	* ipa-inline-analysis.c (set_switch_stmt_execution_predicate):
> 	Introduce local "lastg" as a generic gimple, so that local "last"
> 	can be of type gimple_switch once lastg's code has been verified.
>
> 	* omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle
> 	the GIMPLE_SWITCH case.
>
> 	* tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch
> 	argument, since the caller (find_taken_edge) has checked that
> 	last_stmt is a switch.
So, generally I like it.  It looks pretty much like what I'd expect from 
this kind of work.

So it sounds like Richi really prefers the explicit casting rather than 
member functions.  It seems like a minor issue to me, so let's go with 
explicit casting.

OK for the trunk with that change.  Per Richi's request, please hold off 
until 4.9.1 goes out the door (~2 months?)

Jeff
ps.  If/when your work exposes a problem with the existing code base, 
please point it out.  This is just for my own curiosity than anything.



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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-23 19:58         ` Jeff Law
@ 2014-04-23 20:35           ` Richard Henderson
  2014-04-23 20:38             ` Trevor Saunders
  0 siblings, 1 reply; 250+ messages in thread
From: Richard Henderson @ 2014-04-23 20:35 UTC (permalink / raw)
  To: Jeff Law, David Malcolm, Trevor Saunders; +Cc: gcc-patches

On 04/23/2014 12:56 PM, Jeff Law wrote:
> On 04/22/14 15:38, Richard Henderson wrote:
>> On 04/22/2014 10:13 AM, David Malcolm wrote:
>>> On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
>>>>> --- a/gcc/tree-loop-distribution.c
>>>>> +++ b/gcc/tree-loop-distribution.c
>>>>> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop,
>>>>> partition_t partition,
>>>>>           }
>>>>>             else if (gimple_code (stmt) == GIMPLE_SWITCH)
>>>>>           {
>>>>> +          gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
>>>>
>>>> maybe it would make more sense to do
>>>> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
>>>
>>> Thanks.  Yes, or indeed something like:
>>>
>>>    else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
>>>
>>> (modulo the "pointerness" issues mentioned in
>>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )
>>>
>>
>> I'm not keen on embedding assignments into conditionals like this, much less
>> embedding variable declarations as well.  I think David's original is perfect.
> Likewise, though I am less annoyed by such things than I was in the past. 
> Perhaps that's an artifact of actually liking that kind of style for 'for' loops.

I'll admit that with *just* the declaration and assignment in the if,
it's not that bad, if others are strongly in favor of not reproducing the test
vs the enum value.

Perhaps I'm just reacting to previous uses of assignments within conditionals
in gcc, which looked more like

  if (test1
      && test2
      && (x = foo, test3(x))
      && test4(x)
      && (y = bar(x), test5))

and which caused all sorts of trouble.  Especially when the if conditional
expanded to fill an entire 80x25 screen.


r~

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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-23 20:35           ` Richard Henderson
@ 2014-04-23 20:38             ` Trevor Saunders
  0 siblings, 0 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-04-23 20:38 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jeff Law, David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]

On Wed, Apr 23, 2014 at 01:32:24PM -0700, Richard Henderson wrote:
> On 04/23/2014 12:56 PM, Jeff Law wrote:
> > On 04/22/14 15:38, Richard Henderson wrote:
> >> On 04/22/2014 10:13 AM, David Malcolm wrote:
> >>> On Mon, 2014-04-21 at 18:45 -0400, Trevor Saunders wrote:
> >>>>> --- a/gcc/tree-loop-distribution.c
> >>>>> +++ b/gcc/tree-loop-distribution.c
> >>>>> @@ -687,8 +687,9 @@ generate_loops_for_partition (struct loop *loop,
> >>>>> partition_t partition,
> >>>>>           }
> >>>>>             else if (gimple_code (stmt) == GIMPLE_SWITCH)
> >>>>>           {
> >>>>> +          gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
> >>>>
> >>>> maybe it would make more sense to do
> >>>> else if (gimple_switch switch_stmt = stmt->dyn_cast_gimple_switch ())
> >>>
> >>> Thanks.  Yes, or indeed something like:
> >>>
> >>>    else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
> >>>
> >>> (modulo the "pointerness" issues mentioned in
> >>> http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01334.html )
> >>>
> >>
> >> I'm not keen on embedding assignments into conditionals like this, much less
> >> embedding variable declarations as well.  I think David's original is perfect.
> > Likewise, though I am less annoyed by such things than I was in the past. 
> > Perhaps that's an artifact of actually liking that kind of style for 'for' loops.
> 
> I'll admit that with *just* the declaration and assignment in the if,
> it's not that bad, if others are strongly in favor of not reproducing the test
> vs the enum value.

oh, I totally see where your coming from, and tbh I think most of the
hand rolled downcasting in C++ I've written doesn't do it with an
assignment in the if.  That said I think its nice you can limmit the
scope of the variable and have fewer lines.

Trev

> 
> Perhaps I'm just reacting to previous uses of assignments within conditionals
> in gcc, which looked more like
> 
>   if (test1
>       && test2
>       && (x = foo, test3(x))
>       && test4(x)
>       && (y = bar(x), test5))
> 
> and which caused all sorts of trouble.  Especially when the if conditional
> expanded to fill an entire 80x25 screen.
> 
> 
> r~
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-21 16:57 ` [PATCH 03/89] Introduce gimple_bind and use it for accessors David Malcolm
@ 2014-04-23 21:12   ` Jeff Law
  2014-04-23 21:19     ` David Malcolm
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-23 21:12 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> This updates all of the gimple_bind_* accessors in gimple.h from taking a
> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
> checking happening at the point of cast.
>
> Various other types are strengthened from gimple to gimple_bind, and from
> plain vec<gimple> to vec<gimple_bind>.
>
> gcc/
> 	* coretypes.h (gimple_bind): New typedef.
> 	(const_gimple_bind): New typedef.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_bind
> 	and its variants, using the gimple printer.
>
> 	* gimple-pretty-print.c (dump_gimple_bind): Update type-signature to
> 	require a gimple_bind rather than just a gimple.
>
> 	* gimple.c (gimple_build_bind): Return a gimple_bind rather than
> 	just a gimple.
> 	* gimple.h (gimple_build_bind): Likewise.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_bind): New.
> 	(gimple_statement_base::dyn_cast_gimple_bind): New.
> 	(gimple_seq_first_stmt_as_a_bind): New.
>
> 	* gimple.h (gimple_bind_vars): Update type-signature to
> 	require a gimple_bind rather than just a gimple, removing
> 	as_a and hence run-time check.
> 	(gimple_bind_set_vars): Likewise.
> 	(gimple_bind_append_vars): Likewise.
> 	(gimple_bind_body_ptr): Likewise.
> 	(gimple_bind_body): Likewise.
> 	(gimple_bind_set_body): Likewise.
> 	(gimple_bind_add_stmt): Likewise.
> 	(gimple_bind_add_seq): Likewise.
> 	(gimple_bind_block): Likewise.
> 	(gimple_bind_set_block): Likewise.
> 	* gimplify.c (gimple_push_bind_expr): Likewise.
> 	(gimple_current_bind_expr): Likewise.
> 	* tree-inline.c (copy_gimple_bind): Likewise.
>
> 	* gimplify.h (gimple_current_bind_expr): Return a gimple_bind
> 	rather than a plain gimple.
> 	(gimplify_body): Likewise.
> 	(gimple_bind_expr_stack): Return a vec<gimple_bind> rather than
> 	a vec<gimple>.
>
> 	* gimplify.c (struct gimplify_ctx): Strengthen field
> 	"bind_expr_stack" from vec<gimple> to vec<gimple_bind>.
> 	(gimple_bind_expr_stack): Likewise for type of returned value.
>
> 	* gimplify.c (gimplify_body): Strengthen various types from gimple
> 	to gimple_bind, including the return type.
>
> 	* gimplify.c (declare_vars): Introduce "gs" as a generic gimple,
> 	so that local "scope" can be of type gimple_bind once we've reached
> 	the region where it must be of code GIMPLE_BIND.
>
> 	* gimple-low.c (lower_gimple_bind): Add checked cast to
> 	gimple_bind, since both callers (lower_function_body and
> 	lower_stmt) have checked the code for us.
>
> 	* gimple.c (gimple_copy): Add checked cast to gimple_bind in
> 	region guarded by check for code GIMPLE_BIND.
> 	* gimple-low.c (gimple_stmt_may_fallthru): Likewise.
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
> 	* gimple-walk.c (walk_gimple_stmt): Likewise.
> 	* omp-low.c (scan_omp_1_stmt): Likewise.
> 	(lower_omp_1): Likewise.
> 	(lower_omp_for): Likewise.
> 	* tree-cfg.c (verify_gimple_in_seq_2): Likewise.
> 	(do_warn_unused_result): Likewise.
> 	* tree-inline.c (remap_gimple_stmt): Likewise.
> 	(estimate_num_insns): Likewise.
> 	* tree-nested.c (convert_nonlocal_reference_stmt): Likewise.
>
> 	* gimplify.c (gimplify_bind_expr): Update local(s) to be a
> 	gimple_bind rather than just a gimple.
> 	(gimplify_function_tree): Likewise.
> 	* omp-low.c (lower_omp_sections): Likewise.
> 	(lower_omp_single): Likewise.
> 	(lower_omp_master): Likewise.
> 	(lower_omp_taskgroup): Likewise.
> 	(lower_omp_ordered): Likewise.
> 	(lower_omp_critical): Likewise.
> 	(lower_omp_taskreg): Likewise.
> 	(lower_omp_teams): Likewise.
> 	* omp-low.c (lower_omp_for): Likewise; use
> 	gimple_seq_first_stmt_as_a_bind to encapsulate the checked cast.
> 	(lower_omp_target): Likewise.
> 	* tree-nested.c (finalize_nesting_tree_1): Likewise.
>
> 	* gimple.c (empty_stmt_p): Add dyn_cast to a gimple_bind.
> 	* tree-inline.c (replace_locals_stmt): Add dyn_cast to gimple_bind.
>
> gcc/c-family/
> 	* c-gimplify.c (add_block_to_enclosing): Strengthen local "stack"
> 	from being just a vec<gimple> to a vec<gimple_bind>.
>
> gcc/java/
> 	* java-gimplify.c (java_gimplify_block): Update local to be a
> 	gimple_bind rather than just a gimple.
This is fine, with the same requested changes as #2; specifically using 
an explicit cast rather than hiding the conversion in a method.  Once 
those changes are in place, it's good for 4.9.1.

Thanks,
Jeff

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

* Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-23 21:12   ` Jeff Law
@ 2014-04-23 21:19     ` David Malcolm
  2014-04-23 21:38       ` Jeff Law
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-23 21:19 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
> On 04/21/14 10:56, David Malcolm wrote:
> > This updates all of the gimple_bind_* accessors in gimple.h from taking a
> > plain gimple to taking a gimple_bind (or const_gimple_bind), with the
> > checking happening at the point of cast.
> >
> > Various other types are strengthened from gimple to gimple_bind, and from
> > plain vec<gimple> to vec<gimple_bind>.

[...]

> This is fine, with the same requested changes as #2; specifically using 
> an explicit cast rather than hiding the conversion in a method.  Once 
> those changes are in place, it's good for 4.9.1.
Thanks - presumably you mean
  "good for *trunk* after 4.9.1 is released"
right?

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

* Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-23 21:19     ` David Malcolm
@ 2014-04-23 21:38       ` Jeff Law
  2014-04-24  8:37         ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-23 21:38 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

On 04/23/14 15:13, David Malcolm wrote:
> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
>> On 04/21/14 10:56, David Malcolm wrote:
>>> This updates all of the gimple_bind_* accessors in gimple.h from taking a
>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
>>> checking happening at the point of cast.
>>>
>>> Various other types are strengthened from gimple to gimple_bind, and from
>>> plain vec<gimple> to vec<gimple_bind>.
>
> [...]
>
>> This is fine, with the same requested changes as #2; specifically using
>> an explicit cast rather than hiding the conversion in a method.  Once
>> those changes are in place, it's good for 4.9.1.
> Thanks - presumably you mean
>    "good for *trunk* after 4.9.1 is released"
Right.  Sorry for the confusion.

jeff

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

* Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-23 21:38       ` Jeff Law
@ 2014-04-24  8:37         ` Richard Biener
  2014-04-24 13:12           ` Andrew MacLeod
  0 siblings, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-24  8:37 UTC (permalink / raw)
  To: Jeff Law; +Cc: David Malcolm, GCC Patches

On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
> On 04/23/14 15:13, David Malcolm wrote:
>>
>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
>>>
>>> On 04/21/14 10:56, David Malcolm wrote:
>>>>
>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
>>>> a
>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
>>>> checking happening at the point of cast.
>>>>
>>>> Various other types are strengthened from gimple to gimple_bind, and
>>>> from
>>>> plain vec<gimple> to vec<gimple_bind>.
>>
>>
>> [...]
>>
>>> This is fine, with the same requested changes as #2; specifically using
>>> an explicit cast rather than hiding the conversion in a method.  Once
>>> those changes are in place, it's good for 4.9.1.
>>
>> Thanks - presumably you mean
>>    "good for *trunk* after 4.9.1 is released"
>
> Right.  Sorry for the confusion.

Note I still want that less-typedefs (esp. the const_*) variants to be explored.
Changing this will touch all the code again, so I'd like to avoid that.

That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
and not 'gimple_statement_base *'?  The main reason that we have so
many typedefs is that in C you had to use 'struct foo' each time you
refer to foo as a type - I suppose it was then convenient to do the
typedef to the pointer type.  With 'gimple' being not a pointer type
we get const correctness in the way people would expect it to work.
[no, I don't suggest you change 'tree' or 'const_tree' at this point, just
gimple (and maybe gimple_seq) as you are working on the 'gimple'
type anyway].

So I'd rather not say "ok for trunk after 4.9.1" for the current form
with the cast changes.  Not yet.

Thanks,
Richard.

> jeff

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 17:32   ` Jeff Law
@ 2014-04-24 12:23     ` Richard Sandiford
  0 siblings, 0 replies; 250+ messages in thread
From: Richard Sandiford @ 2014-04-24 12:23 UTC (permalink / raw)
  To: Jeff Law; +Cc: David Malcolm, gcc-patches

Jeff Law <law@redhat.com> writes:
> On 04/22/14 02:03, Richard Sandiford wrote:
>> First of all, thanks a lot for doing this.  Maybe one day we'll have
>> the same in rtl :-)
> Funny you should mention that.  I blocked off a hunk of time for David 
> to investigate doing some work on that this year.

That'd be great.  The fact that we had to turn rtl checking off by default
for being too expensive suggests that we do far too many opaque accesses.
Hopefully something like this will either eliminate the need for rtl
checking (probably a bit optimistic) or at least make it cheap enough
to be turned on by default.

E.g. "instruction" rtxes should be mostly distinct from "pattern" rtxes.
Having them as different types would also avoid cases of patterns being
accidentally passed to functions that take insns, or vice versa.

Thanks,
Richard

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

* Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.
  2014-04-24  8:37         ` Richard Biener
@ 2014-04-24 13:12           ` Andrew MacLeod
  2014-04-24 15:14             ` Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.) David Malcolm
  0 siblings, 1 reply; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-24 13:12 UTC (permalink / raw)
  To: Richard Biener, Jeff Law; +Cc: David Malcolm, GCC Patches

On 04/24/2014 04:33 AM, Richard Biener wrote:
> On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
>> On 04/23/14 15:13, David Malcolm wrote:
>>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
>>>> On 04/21/14 10:56, David Malcolm wrote:
>>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
>>>>> a
>>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
>>>>> checking happening at the point of cast.
>>>>>
>>>>> Various other types are strengthened from gimple to gimple_bind, and
>>>>> from
>>>>> plain vec<gimple> to vec<gimple_bind>.
>>>
>>> [...]
>>>
>>>> This is fine, with the same requested changes as #2; specifically using
>>>> an explicit cast rather than hiding the conversion in a method.  Once
>>>> those changes are in place, it's good for 4.9.1.
>>> Thanks - presumably you mean
>>>     "good for *trunk* after 4.9.1 is released"
>> Right.  Sorry for the confusion.
> Note I still want that less-typedefs (esp. the const_*) variants to be explored.
> Changing this will touch all the code again, so I'd like to avoid that.
>
> That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
> and not 'gimple_statement_base *'?  The main reason that we have so
> many typedefs is that in C you had to use 'struct foo' each time you
> refer to foo as a type - I suppose it was then convenient to do the
> typedef to the pointer type.  With 'gimple' being not a pointer type
> we get const correctness in the way people would expect it to work.
> [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
> gimple (and maybe gimple_seq) as you are working on the 'gimple'
> type anyway].
>
>

So if we change 'gimple' everywhere to be 'gimple *', can we just 
abandon the 'gimple' typedef completely and go directly to using 
something like gimple_stmt, or some other agreeable name instead?

I think its more descriptive and then frees up the generic 'gimple' name 
should we decide to do something more with namespaces in the future...

Andrew

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 14:43 ` Michael Matz
@ 2014-04-24 13:25   ` Andrew MacLeod
  2014-04-24 15:01     ` Michael Matz
  0 siblings, 1 reply; 250+ messages in thread
From: Andrew MacLeod @ 2014-04-24 13:25 UTC (permalink / raw)
  To: Michael Matz, David Malcolm; +Cc: gcc-patches

On 04/23/2014 10:42 AM, Michael Matz wrote:
> Hi,
>
> On Mon, 21 Apr 2014, David Malcolm wrote:
>
>
>>      case GIMPLE_SWITCH:
>>        dump_gimple_switch (buffer, gs->as_a_gimple_switch (), spc, flags);
>>        break;
>>
>> where the ->as_a_gimple_switch is a no-op cast from "gimple" to the more
>> concrete "gimple_switch" in a release build, with runtime checking for
>> code == GIMPLE_SWITCH added in a checked build (it uses as_a <>
>> internally).
> Unlike others here I do like the cast-as-method (if we absolutely _must_
> have a complicated type hierarchy for gimple), but would suggest different
> a name: the "gimple_" is tautological, and the "a_" just noise, just name
> it "gs->as_switch()" (incidentally then it's _really_ shorter than the
> ugly is_a/as_a syntax).
>
>
>

Well, we ought to settle on one... either use the is_a, as_a, and 
dyn_cast  paradigm as they exist today, or we use the cast_as_method 
approach everywhere.  I'm not fond of each potential project having a 
different approach...  I'd like to see a consistent look throughout.

I suspect the cast_as_method has compile time advantages, as well as 
error reporting ones.... (have you seen the kind of message you get when 
the template instantiation doesn't work right? ick!)  , but it suffers 
from having to modify the base class whenever a new derived class is 
added... (which seems a little "dirty" and could impact possible future 
enhancements).

Andrew


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

* Re: [PATCH 02/89] Introduce gimple_switch and use it in various places
  2014-04-23 20:01   ` Jeff Law
@ 2014-04-24 13:39     ` David Malcolm
  0 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-24 13:39 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

On Wed, 2014-04-23 at 13:58 -0600, Jeff Law wrote:
> On 04/21/14 10:56, David Malcolm wrote:
[...]
> So, generally I like it.  It looks pretty much like what I'd expect from 
> this kind of work.
> 
> So it sounds like Richi really prefers the explicit casting rather than 
> member functions.  It seems like a minor issue to me, so let's go with 
> explicit casting.
> 
> OK for the trunk with that change.  Per Richi's request, please hold off 
> until 4.9.1 goes out the door (~2 months?)

Thanks.  I see that Richi wants me to investigate ways of doing this
without introducing all the typedefs:

  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html

so I'm not going to commit this without further discussion, but for
reference, I'm attaching the port I did of patch 2 to directly use the
is-a.h API (i.e. without the casting methods in the base class) [1].
This version of the patch also fixes up the decls in doc/gimple.texi to
match the changes in gimple.h [2], and I tweaked some of the hunks to
favor dyn_cast over "check the of code, then do an as_a", for example:

-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return simplify_switch_using_ranges (stmt);
+  else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
+    return simplify_switch_using_ranges (switch_stmt);

It bootstrapped&regrtested on x86_64-unknown-linux-gnu, but as I said
above, I'm merely posting this for reference.

> Jeff
> ps.  If/when your work exposes a problem with the existing code base, 
> please point it out.  This is just for my own curiosity than anything.

Definitely.

Dave

[1] specifically, using the revised is-a.h API from r209719.
[2] though I wish we were using Doxygen instead, to avoid having to
repeat the decls and manually keep them in sync.

[-- Attachment #2: gimple-switch-without-casting-methods.patch --]
[-- Type: text/x-patch, Size: 40726 bytes --]

commit bf955db0ef4f7e86860c1c3d30e435c79abf6c69
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Apr 22 16:47:11 2014 -0400

    Introduce gimple_switch and use it in various places
    
    gcc/
    	* gimple.h (gimple_statement_switch): New subclass of
    	gimple_statement_with_ops, adding the invariant that
    	stmt->code == GIMPLE_SWITCH.
    	(is_a_helper <gimple_switch>::test (gimple)): New.
    
    	* coretypes.h (gimple_switch): New typedef
    	(const_gimple_switch): Likewise.
    
    	* gdbhooks.py (build_pretty_printer): Add gimple_switch
    	and its variants, using the gimple printer.
    
    	* gimple.c (gimple_build_switch_nlabels): Return a gimple_switch
    	rather than just a gimple.
    	(gimple_build_switch): Likewise.
    	* gimple.h (gimple_build_switch_nlabels): Likewise.
    	(gimple_build_switch): Likewise.
    
    	* gimple.h (gimple_switch_num_labels): Update type-signature to
    	require a gimple_switch rather than just a gimple.
    	(gimple_switch_set_num_labels): Likewise.
    	(gimple_switch_set_index): Likewise.
    	(gimple_switch_label): Likewise.
    	(gimple_switch_set_label): Likewise.
    	(gimple_switch_default_label): Likewise.
    	(gimple_switch_set_default_label): Likewise.
    	* expr.h (expand_case): Likewise.
    	* gimple-pretty-print.c (dump_gimple_call): Likewise.
    	* stmt.c (compute_cases_per_edge): Likewise.
    	(expand_case): Likewise.
    	* tree-cfg.h (group_case_labels_stmt): Likewise.
    	* tree-cfg.c (make_gimple_switch_edges): Likewise.
    	(find_taken_edge_switch_expr) Likewise.
    	(find_case_label_for_value) Likewise.
    	(get_cases_for_edge): Likewise.
    	(group_case_labels_stmt): Likewise.
    	(verify_gimple_switch): Likewise.
    	* tree-eh.c (verify_norecord_switch_expr): Likewise.
    	* tree-eh.c (lower_eh_constructs_2): Likewise.
    	* tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise.
    	(simplify_gimple_switch): Likewise.
    	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
    	(collect_switch_conv_info): Likewise.
    	(build_constructors): Likewise.
    	(array_value_type): Likewise.
    	(build_one_array): Likewise.
    	(build_arrays): Likewise.
    	(gen_inbound_check): Likewise.
    	(pass_convert_switch::execute): Likewise.
    	* tree-vrp.c (find_switch_asserts): Likewise.
    	(find_case_label_range): Likewise.
    	(find_case_label_ranges): Likewise.
    	(vrp_visit_switch_stmt): Likewise.
    	(simplify_switch_using_ranges): Likewise.
    
    	* tree-vrp.c (switch_update): Strengthen field "stmt" from being
    	merely a gimple to being a gimple_switch.
    
    	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to
    	gimple_switch in regions where the stmt code has been tested as
    	GIMPLE_SWITCH.
    	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
    	* tree-cfg.c (make_edges): Likewise.
    	(end_recording_case_labels): Likewise.
    	(cleanup_dead_labels): Likewise.
    	(cleanup_dead_labels): Likewise.
    	(group_case_labels): Likewise.
    	(find_case_label_for_value): Likewise.
    	(verify_gimple_stmt): Likewise.
    	(gimple_verify_flow_info): Likewise.
    	(gimple_redirect_edge_and_branch): Likewise.
    	* tree-inline.c (estimate_num_insns): Likewise.
    	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
    	* tree-switch-conversion.c (do_switchconv): Likewise.
    	* tree-vrp.c (find_assert_locations_1): Likewise.
    
    	* ipa-inline-analysis.c (set_switch_stmt_execution_predicate):
    	Introduce local "lastg" as a generic gimple, so that local "last"
    	can be of type gimple_switch once lastg's code has been verified.
    
    	* omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle
    	the GIMPLE_SWITCH case.
    
    	* tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch
    	argument, since the caller (find_taken_edge) has checked that
    	last_stmt is a switch.
    
    	* tree-cfg.c (find_taken_edge): Replace check for GIMPLE_CODE with
    	a dyn_cast to gimple_switch.
    	* tree-loop-distribution.c (generate_loops_for_partition):
    	Likewise.
    	* tree-ssa-dom.c (record_edge_info): Likewise.
    	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
    	* tree-vrp.c (vrp_visit_stmt): Likewise.
    	(simplify_stmt_using_ranges): Likewise.
    
    	* doc/gimple.texi (gimple_build_switch): Return a gimple_switch
    	rather than just a gimple; update VEC param to take a vec.
    	(gimple_switch_num_labels): Update type signature to
    	require a gimple_switch rather than just a gimple.
    	(gimple_switch_set_num_labels): Likewise.
    	(gimple_switch_index): Likewise.
    	(gimple_switch_set_index): Likewise.
    	(gimple_switch_label): Likewise.
    	(gimple_switch_set_label): Likewise.
    	(gimple_switch_default_label): Likewise.
    	(gimple_switch_set_default_label): Likewise.

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 78eca25..a547967 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3161,7 +3161,7 @@ expand_gimple_stmt_1 (gimple stmt)
     case GIMPLE_PREDICT:
       break;
     case GIMPLE_SWITCH:
-      expand_case (stmt);
+      expand_case (as_a <gimple_switch> (stmt));
       break;
     case GIMPLE_ASM:
       expand_asm_stmt (stmt);
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d07a604..a39ae1a 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -65,6 +65,14 @@ typedef struct gimple_statement_base *gimple;
 typedef const struct gimple_statement_base *const_gimple;
 typedef gimple gimple_seq;
 struct gimple_stmt_iterator;
+
+/* Typedefs for leaf gimple subclasses (for individual gimple codes).
+   Keep this in the same order as the corresponding codes in gimple.def.  */
+
+struct gimple_statement_switch;
+typedef struct gimple_statement_switch *gimple_switch;
+typedef const struct gimple_statement_switch *const_gimple_switch;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 9bb16e8..1a3978d 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -2029,50 +2029,53 @@ Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
 @subsection @code{GIMPLE_SWITCH}
 @cindex @code{GIMPLE_SWITCH}
 
-@deftypefn {GIMPLE function} gimple gimple_build_switch (tree index, tree @
-default_label, @code{VEC}(tree,heap) *args)
+@deftypefn {GIMPLE function} gimple_switch gimple_build_switch (tree index, tree @
+default_label, @code{vec}<tree> args)
 Build a @code{GIMPLE_SWITCH} statement.  @code{INDEX} is the index variable
 to switch on, and @code{DEFAULT_LABEL} represents the default label.
 @code{ARGS} is a vector of @code{CASE_LABEL_EXPR} trees that contain the
 non-default case labels.  Each label is a tree of code @code{CASE_LABEL_EXPR}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (gimple_switch @
+g)
 Return the number of labels associated with the switch statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_num_labels (gimple g, @
-unsigned nlabels)
+@deftypefn {GIMPLE function} void gimple_switch_set_num_labels (gimple_switch @
+g, unsigned nlabels)
 Set @code{NLABELS} to be the number of labels for the switch statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_index (gimple g)
+@deftypefn {GIMPLE function} tree gimple_switch_index (const_gimple_switch g)
 Return the index variable used by the switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple g, tree index)
+@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple_switch g, @
+tree index)
 Set @code{INDEX} to be the index variable for switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_label (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_switch_label (gimple_switch g, @
+unsigned index)
 Return the label numbered @code{INDEX}. The default label is 0, followed
 by any labels in a switch statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple g, unsigned @
-index, tree label)
+@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple_switch g, @
+unsigned index, tree label)
 Set the label number @code{INDEX} to @code{LABEL}. 0 is always the default
 label.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_default_label (gimple g)
+@deftypefn {GIMPLE function} tree gimple_switch_default_label (gimple_switch g)
 Return the default label for a switch statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_default_label (gimple g, @
-tree label)
+@deftypefn {GIMPLE function} void gimple_switch_set_default_label (@
+gimple_switch g, tree label)
 Set the default label for a switch statement.
 @end deftypefn
 
diff --git a/gcc/expr.h b/gcc/expr.h
index 524da67..12c3e34 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -769,7 +769,7 @@ rtx get_personality_function (tree);
 /* In stmt.c */
 
 /* Expand a GIMPLE_SWITCH statement.  */
-extern void expand_case (gimple);
+extern void expand_case (gimple_switch);
 
 /* Like expand_case but special-case for SJLJ exception dispatching.  */
 extern void expand_sjlj_dispatch_table (rtx, vec<tree> );
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 85608dc..891877a 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -454,7 +454,12 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
-    pp.add_printer_for_types(['gimple', 'gimple_statement_base *'],
+    pp.add_printer_for_types(['gimple', 'gimple_statement_base *',
+
+                              # Keep this in the same order as gimple.def:
+                              'gimple_switch', 'const_gimple_switch',
+                              'gimple_statement_switch *'],
+
                              'gimple',
                              GimplePrinter)
     pp.add_printer_for_types(['basic_block', 'basic_block_def *'],
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 741cd92..3d1c9f5 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -775,7 +775,8 @@ dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_switch (pretty_printer *buffer, gimple_switch gs, int spc,
+		    int flags)
 {
   unsigned int i;
 
@@ -2126,7 +2127,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
       break;
 
     case GIMPLE_SWITCH:
-      dump_gimple_switch (buffer, gs, spc, flags);
+      dump_gimple_switch (buffer, as_a <gimple_switch> (gs), spc, flags);
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 8552a17..2e43fa6 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -714,13 +714,14 @@ gimple_build_resx (int region)
    NLABELS is the number of labels in the switch excluding the default.
    DEFAULT_LABEL is the default label for the switch statement.  */
 
-gimple
+gimple_switch
 gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
 {
   /* nlabels + 1 default label + 1 index.  */
   gcc_checking_assert (default_label);
-  gimple p = gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
-				    1 + 1 + nlabels);
+  gimple_switch p =
+    as_a <gimple_switch> (gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
+						 1 + 1 + nlabels));
   gimple_switch_set_index (p, index);
   gimple_switch_set_default_label (p, default_label);
   return p;
@@ -732,12 +733,12 @@ gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
    DEFAULT_LABEL is the default label
    ARGS is a vector of labels excluding the default.  */
 
-gimple
+gimple_switch
 gimple_build_switch (tree index, tree default_label, vec<tree> args)
 {
   unsigned i, nlabels = args.length ();
 
-  gimple p = gimple_build_switch_nlabels (nlabels, index, default_label);
+  gimple_switch p = gimple_build_switch_nlabels (nlabels, index, default_label);
 
   /* Copy the labels from the vector to the switch statement.  */
   for (i = 0; i < nlabels; i++)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index edb4635..2c8e4a9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -764,6 +764,16 @@ enum gimple_statement_structure_enum {
 };
 #undef DEFGSSTRUCT
 
+/* A statement with the invariant that
+      stmt->code == GIMPLE_SWITCH
+   i.e. a switch statement.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_statement_switch : public gimple_statement_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
 template <>
 template <>
 inline bool
@@ -1143,6 +1153,14 @@ is_a_helper <const gimple_statement_phi *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_switch>::test (gimple gs)
+{
+  return gs->code == GIMPLE_SWITCH;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <const gimple_statement_transaction *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
@@ -1193,8 +1211,8 @@ gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
 					enum gimple_try_flags);
 gimple gimple_build_wce (gimple_seq);
 gimple gimple_build_resx (int);
-gimple gimple_build_switch_nlabels (unsigned, tree, tree);
-gimple gimple_build_switch (tree, tree, vec<tree> );
+gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree);
+gimple_switch gimple_build_switch (tree, tree, vec<tree> );
 gimple gimple_build_eh_dispatch (int);
 gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)			\
@@ -3942,7 +3960,7 @@ gimple_eh_dispatch_set_region (gimple gs, int region)
 /* Return the number of labels associated with the switch statement GS.  */
 
 static inline unsigned
-gimple_switch_num_labels (const_gimple gs)
+gimple_switch_num_labels (const_gimple_switch gs)
 {
   unsigned num_ops;
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
@@ -3955,7 +3973,7 @@ gimple_switch_num_labels (const_gimple gs)
 /* Set NLABELS to be the number of labels for the switch statement GS.  */
 
 static inline void
-gimple_switch_set_num_labels (gimple g, unsigned nlabels)
+gimple_switch_set_num_labels (gimple_switch g, unsigned nlabels)
 {
   GIMPLE_CHECK (g, GIMPLE_SWITCH);
   gimple_set_num_ops (g, nlabels + 1);
@@ -3985,7 +4003,7 @@ gimple_switch_index_ptr (const_gimple gs)
 /* Set INDEX to be the index variable for switch statement GS.  */
 
 static inline void
-gimple_switch_set_index (gimple gs, tree index)
+gimple_switch_set_index (gimple_switch gs, tree index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
@@ -3997,7 +4015,7 @@ gimple_switch_set_index (gimple gs, tree index)
    labels in a switch statement.  */
 
 static inline tree
-gimple_switch_label (const_gimple gs, unsigned index)
+gimple_switch_label (const_gimple_switch gs, unsigned index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
@@ -4007,7 +4025,7 @@ gimple_switch_label (const_gimple gs, unsigned index)
 /* Set the label number INDEX to LABEL.  0 is always the default label.  */
 
 static inline void
-gimple_switch_set_label (gimple gs, unsigned index, tree label)
+gimple_switch_set_label (gimple_switch gs, unsigned index, tree label)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
@@ -4019,7 +4037,7 @@ gimple_switch_set_label (gimple gs, unsigned index, tree label)
 /* Return the default label for a switch statement.  */
 
 static inline tree
-gimple_switch_default_label (const_gimple gs)
+gimple_switch_default_label (const_gimple_switch gs)
 {
   tree label = gimple_switch_label (gs, 0);
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
@@ -4029,7 +4047,7 @@ gimple_switch_default_label (const_gimple gs)
 /* Set the default label for a switch statement.  */
 
 static inline void
-gimple_switch_set_default_label (gimple gs, tree label)
+gimple_switch_set_default_label (gimple_switch gs, tree label)
 {
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
   gimple_switch_set_label (gs, 0, label);
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 2bb3759..b994736 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -1801,7 +1801,7 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
 				     struct inline_summary *summary,
 				     basic_block bb)
 {
-  gimple last;
+  gimple lastg;
   tree op;
   int index;
   struct agg_position_info aggpos;
@@ -1810,9 +1810,10 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
   size_t n;
   size_t case_idx;
 
-  last = last_stmt (bb);
-  if (!last || gimple_code (last) != GIMPLE_SWITCH)
+  lastg = last_stmt (bb);
+  if (!lastg || gimple_code (lastg) != GIMPLE_SWITCH)
     return;
+  gimple_switch last = as_a <gimple_switch> (lastg);
   op = gimple_switch_index (last);
   if (!unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos))
     return;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d0489e1..4171e8e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10448,10 +10448,11 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch switch_stmt = as_a <gimple_switch> (stmt);
 	unsigned int i;
-	for (i = 0; i < gimple_switch_num_labels (stmt); ++i)
+	for (i = 0; i < gimple_switch_num_labels (switch_stmt); ++i)
 	  {
-	    tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+	    tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 	    n = splay_tree_lookup (all_labels, (splay_tree_key) lab);
 	    if (n && diagnose_sb_0 (gsi_p, context, (gimple) n->value))
 	      break;
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 5d68edb..19a7f09 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1130,7 +1130,7 @@ reset_out_edges_aux (basic_block bb)
    STMT. Record this information in the aux field of the edge.  */
 
 static inline void
-compute_cases_per_edge (gimple stmt)
+compute_cases_per_edge (gimple_switch stmt)
 {
   basic_block bb = gimple_bb (stmt);
   reset_out_edges_aux (bb);
@@ -1152,7 +1152,7 @@ compute_cases_per_edge (gimple stmt)
    Generate the code to test it and jump to the right place.  */
 
 void
-expand_case (gimple stmt)
+expand_case (gimple_switch stmt)
 {
   tree minval = NULL_TREE, maxval = NULL_TREE, range = NULL_TREE;
   rtx default_label = NULL_RTX;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 0fb2681..afb813c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -150,7 +150,7 @@ static void make_blocks (gimple_seq);
 static void make_edges (void);
 static void assign_discriminators (void);
 static void make_cond_expr_edges (basic_block);
-static void make_gimple_switch_edges (basic_block);
+static void make_gimple_switch_edges (gimple_switch, basic_block);
 static bool make_goto_expr_edges (basic_block);
 static void make_gimple_asm_edges (basic_block);
 static edge gimple_redirect_edge_and_branch (edge, basic_block);
@@ -169,8 +169,8 @@ static bool gimple_can_merge_blocks_p (basic_block, basic_block);
 static void remove_bb (basic_block);
 static edge find_taken_edge_computed_goto (basic_block, tree);
 static edge find_taken_edge_cond_expr (basic_block, tree);
-static edge find_taken_edge_switch_expr (basic_block, tree);
-static tree find_case_label_for_value (gimple, tree);
+static edge find_taken_edge_switch_expr (gimple_switch, basic_block, tree);
+static tree find_case_label_for_value (gimple_switch, tree);
 
 void
 init_empty_tree_cfg_for_function (struct function *fn)
@@ -769,7 +769,7 @@ make_edges (void)
 	      fallthru = false;
 	      break;
 	    case GIMPLE_SWITCH:
-	      make_gimple_switch_edges (bb);
+	      make_gimple_switch_edges (as_a <gimple_switch> (last), bb);
 	      fallthru = false;
 	      break;
 	    case GIMPLE_RESX:
@@ -1094,7 +1094,7 @@ end_recording_case_labels (void)
 	{
 	  gimple stmt = last_stmt (bb);
 	  if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	    group_case_labels_stmt (stmt);
+	    group_case_labels_stmt (as_a <gimple_switch> (stmt));
 	}
     }
   BITMAP_FREE (touched_switch_bbs);
@@ -1106,7 +1106,7 @@ end_recording_case_labels (void)
    Otherwise return NULL.  */
 
 static tree
-get_cases_for_edge (edge e, gimple t)
+get_cases_for_edge (edge e, gimple_switch t)
 {
   void **slot;
   size_t i, n;
@@ -1145,9 +1145,8 @@ get_cases_for_edge (edge e, gimple t)
 /* Create the edges for a GIMPLE_SWITCH starting at block BB.  */
 
 static void
-make_gimple_switch_edges (basic_block bb)
+make_gimple_switch_edges (gimple_switch entry, basic_block bb)
 {
-  gimple entry = last_stmt (bb);
   size_t i, n;
 
   n = gimple_switch_num_labels (entry);
@@ -1398,12 +1397,13 @@ cleanup_dead_labels (void)
 
 	case GIMPLE_SWITCH:
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    gimple_switch switch_stmt = as_a <gimple_switch> (stmt);
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Replace all destination labels.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree case_label = gimple_switch_label (stmt, i);
+		tree case_label = gimple_switch_label (switch_stmt, i);
 		label = CASE_LABEL (case_label);
 		new_label = main_block_label (label);
 		if (new_label != label)
@@ -1500,7 +1500,7 @@ cleanup_dead_labels (void)
    Eg. three separate entries 1: 2: 3: become one entry 1..3:  */
 
 void
-group_case_labels_stmt (gimple stmt)
+group_case_labels_stmt (gimple_switch stmt)
 {
   int old_size = gimple_switch_num_labels (stmt);
   int i, j, new_size = old_size;
@@ -1588,7 +1588,7 @@ group_case_labels (void)
     {
       gimple stmt = last_stmt (bb);
       if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	group_case_labels_stmt (stmt);
+	group_case_labels_stmt (as_a <gimple_switch> (stmt));
     }
 }
 
@@ -2053,8 +2053,8 @@ find_taken_edge (basic_block bb, tree val)
   if (gimple_code (stmt) == GIMPLE_COND)
     return find_taken_edge_cond_expr (bb, val);
 
-  if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return find_taken_edge_switch_expr (bb, val);
+  if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
+    return find_taken_edge_switch_expr (switch_stmt, bb, val);
 
   if (computed_goto_p (stmt))
     {
@@ -2113,14 +2113,13 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
    NULL if any edge may be taken.  */
 
 static edge
-find_taken_edge_switch_expr (basic_block bb, tree val)
+find_taken_edge_switch_expr (gimple_switch switch_stmt, basic_block bb,
+			     tree val)
 {
   basic_block dest_bb;
   edge e;
-  gimple switch_stmt;
   tree taken_case;
 
-  switch_stmt = last_stmt (bb);
   taken_case = find_case_label_for_value (switch_stmt, val);
   dest_bb = label_to_block (CASE_LABEL (taken_case));
 
@@ -2135,7 +2134,7 @@ find_taken_edge_switch_expr (basic_block bb, tree val)
    sorted: We can do a binary search for a case matching VAL.  */
 
 static tree
-find_case_label_for_value (gimple switch_stmt, tree val)
+find_case_label_for_value (gimple_switch switch_stmt, tree val)
 {
   size_t low, high, n = gimple_switch_num_labels (switch_stmt);
   tree default_case = gimple_switch_default_label (switch_stmt);
@@ -4262,7 +4261,7 @@ verify_gimple_goto (gimple stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_switch (gimple stmt)
+verify_gimple_switch (gimple_switch stmt)
 {
   unsigned int i, n;
   tree elt, prev_upper_bound = NULL_TREE;
@@ -4444,7 +4443,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_goto (stmt);
 
     case GIMPLE_SWITCH:
-      return verify_gimple_switch (stmt);
+      return verify_gimple_switch (as_a <gimple_switch> (stmt));
 
     case GIMPLE_RETURN:
       return verify_gimple_return (stmt);
@@ -5176,26 +5175,27 @@ gimple_verify_flow_info (void)
 
 	case GIMPLE_SWITCH:
 	  {
+	    gimple_switch switch_stmt = as_a <gimple_switch> (stmt);
 	    tree prev;
 	    edge e;
 	    size_t i, n;
 
-	    n = gimple_switch_num_labels (stmt);
+	    n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Mark all the destination basic blocks.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 		gcc_assert (!label_bb->aux || label_bb->aux == (void *)1);
 		label_bb->aux = (void *)1;
 	      }
 
 	    /* Verify that the case labels are sorted.  */
-	    prev = gimple_switch_label (stmt, 0);
+	    prev = gimple_switch_label (switch_stmt, 0);
 	    for (i = 1; i < n; ++i)
 	      {
-		tree c = gimple_switch_label (stmt, i);
+		tree c = gimple_switch_label (switch_stmt, i);
 		if (!CASE_LOW (c))
 		  {
 		    error ("found default case not at the start of "
@@ -5241,7 +5241,7 @@ gimple_verify_flow_info (void)
 	    /* Check that we have all of them.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 
 		if (label_bb->aux != (void *)2)
@@ -5429,8 +5429,9 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch switch_stmt = as_a <gimple_switch> (stmt);
 	tree label = gimple_block_label (dest);
-        tree cases = get_cases_for_edge (e, stmt);
+        tree cases = get_cases_for_edge (e, switch_stmt);
 
 	/* If we have a list of cases associated with E, then use it
 	   as it's a lot faster than walking the entire case vector.  */
@@ -5451,7 +5452,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	       to move all the cases associated with E to E2.  */
 	    if (e2)
 	      {
-		tree cases2 = get_cases_for_edge (e2, stmt);
+		tree cases2 = get_cases_for_edge (e2, switch_stmt);
 
 		CASE_CHAIN (last) = CASE_CHAIN (cases2);
 		CASE_CHAIN (cases2) = first;
@@ -5460,11 +5461,11 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	  }
 	else
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    for (i = 0; i < n; i++)
 	      {
-		tree elt = gimple_switch_label (stmt, i);
+		tree elt = gimple_switch_label (switch_stmt, i);
 		if (label_to_block (CASE_LABEL (elt)) == e->dest)
 		  CASE_LABEL (elt) = label;
 	      }
diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index a115df5..c15d6ab 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -32,7 +32,7 @@ extern void end_recording_case_labels (void);
 extern basic_block label_to_block_fn (struct function *, tree);
 #define label_to_block(t) (label_to_block_fn (cfun, t))
 extern void cleanup_dead_labels (void);
-extern void group_case_labels_stmt (gimple);
+extern void group_case_labels_stmt (gimple_switch);
 extern void group_case_labels (void);
 extern void replace_uses_by (tree, tree);
 extern basic_block single_noncomplex_succ (basic_block bb);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 960c04a..b6b188a 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -713,7 +713,8 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple stmt)
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
 
 static void
-verify_norecord_switch_expr (struct leh_state *state, gimple switch_expr)
+verify_norecord_switch_expr (struct leh_state *state,
+			     gimple_switch switch_expr)
 {
   struct leh_tf_state *tf = state->tf;
   size_t i, n;
@@ -2055,7 +2056,7 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi)
       break;
 
     case GIMPLE_SWITCH:
-      verify_norecord_switch_expr (state, stmt);
+      verify_norecord_switch_expr (state, as_a <gimple_switch> (stmt));
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 802d25f..7224ef2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3813,15 +3813,18 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
       break;
 
     case GIMPLE_SWITCH:
-      /* Take into account cost of the switch + guess 2 conditional jumps for
-         each case label.
-
-	 TODO: once the switch expansion logic is sufficiently separated, we can
-	 do better job on estimating cost of the switch.  */
-      if (weights->time_based)
-        cost = floor_log2 (gimple_switch_num_labels (stmt)) * 2;
-      else
-        cost = gimple_switch_num_labels (stmt) * 2;
+      {
+	gimple_switch switch_stmt = as_a <gimple_switch> (stmt);
+	/* Take into account cost of the switch + guess 2 conditional jumps for
+	   each case label.
+
+	   TODO: once the switch expansion logic is sufficiently separated, we can
+	   do better job on estimating cost of the switch.  */
+	if (weights->time_based)
+	  cost = floor_log2 (gimple_switch_num_labels (switch_stmt)) * 2;
+	else
+	  cost = gimple_switch_num_labels (switch_stmt) * 2;
+      }
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 5fff7be..435da80 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -685,10 +685,11 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 		  gimple_cond_make_false (stmt);
 		  update_stmt (stmt);
 		}
-	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
+	      else if (gimple_switch switch_stmt =
+		         dyn_cast <gimple_switch> (stmt))
 		{
 		  gimple_switch_set_index
-		      (stmt, CASE_LOW (gimple_switch_label (stmt, 1)));
+		      (switch_stmt, CASE_LOW (gimple_switch_label (switch_stmt, 1)));
 		  update_stmt (stmt);
 		}
 	      else
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 15c4fb0..f2caff0 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1784,21 +1784,21 @@ record_edge_info (basic_block bb)
       gimple stmt = gsi_stmt (gsi);
       location_t loc = gimple_location (stmt);
 
-      if (gimple_code (stmt) == GIMPLE_SWITCH)
+      if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
 	{
-	  tree index = gimple_switch_index (stmt);
+	  tree index = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (index) == SSA_NAME)
 	    {
 	      int i;
-              int n_labels = gimple_switch_num_labels (stmt);
+              int n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 	      edge e;
 	      edge_iterator ei;
 
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block target_bb = label_to_block (CASE_LABEL (label));
 		  if (CASE_HIGH (label)
 		      || !CASE_LOW (label)
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index a623005..b4c24aa 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1284,7 +1284,7 @@ simplify_not_neg_expr (gimple_stmt_iterator *gsi_p)
    have values outside the range of the new type.  */
 
 static void
-simplify_gimple_switch_label_vec (gimple stmt, tree index_type)
+simplify_gimple_switch_label_vec (gimple_switch stmt, tree index_type)
 {
   unsigned int branch_num = gimple_switch_num_labels (stmt);
   auto_vec<tree> labels (branch_num);
@@ -1354,7 +1354,7 @@ simplify_gimple_switch_label_vec (gimple stmt, tree index_type)
    the condition which we may be able to optimize better.  */
 
 static bool
-simplify_gimple_switch (gimple stmt)
+simplify_gimple_switch (gimple_switch stmt)
 {
   /* The optimization that we really care about is removing unnecessary
      casts.  That will let us do much better in propagating the inferred
@@ -3809,7 +3809,7 @@ pass_forwprop::execute (function *fun)
 	      }
 
 	    case GIMPLE_SWITCH:
-	      changed = simplify_gimple_switch (stmt);
+	      changed = simplify_gimple_switch (as_a <gimple_switch> (stmt));
 	      break;
 
 	    case GIMPLE_COND:
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index 52c568a..150d797 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -171,14 +171,14 @@ associate_equivalences_with_edges (void)
       /* For a SWITCH_EXPR, a case label which represents a single
 	 value and which is the only case label which reaches the
 	 target block creates an equivalence.  */
-      else if (gimple_code (stmt) == GIMPLE_SWITCH)
+      else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
 	{
-	  tree cond = gimple_switch_index (stmt);
+	  tree cond = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (cond) == SSA_NAME
 	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
 	    {
-	      int i, n_labels = gimple_switch_num_labels (stmt);
+	      int i, n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 
 	      /* Walk over the case label vector.  Record blocks
@@ -186,7 +186,7 @@ associate_equivalences_with_edges (void)
 		 a single value.  */
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block bb = label_to_block (CASE_LABEL (label));
 
 		  if (CASE_HIGH (label)
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 34edc64..7c38764 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -299,7 +299,7 @@ case_bit_test_cmp (const void *p1, const void *p2)
     node targets.  */
 
 static void
-emit_case_bit_tests (gimple swtch, tree index_expr,
+emit_case_bit_tests (gimple_switch swtch, tree index_expr,
 		     tree minval, tree range)
 {
   struct case_bit_test test[MAX_CASE_BIT_TESTS];
@@ -609,7 +609,7 @@ struct switch_conv_info
 /* Collect information about GIMPLE_SWITCH statement SWTCH into INFO.  */
 
 static void
-collect_switch_conv_info (gimple swtch, struct switch_conv_info *info)
+collect_switch_conv_info (gimple_switch swtch, struct switch_conv_info *info)
 {
   unsigned int branch_num = gimple_switch_num_labels (swtch);
   tree min_case, max_case;
@@ -853,7 +853,7 @@ gather_default_values (tree default_case, struct switch_conv_info *info)
    order of phi nodes.  SWTCH is the switch statement being converted.  */
 
 static void
-build_constructors (gimple swtch, struct switch_conv_info *info)
+build_constructors (gimple_switch swtch, struct switch_conv_info *info)
 {
   unsigned i, branch_num = gimple_switch_num_labels (swtch);
   tree pos = info->range_min;
@@ -945,7 +945,7 @@ constructor_contains_same_values_p (vec<constructor_elt, va_gc> *vec)
    all the constants.  */
 
 static tree
-array_value_type (gimple swtch, tree type, int num,
+array_value_type (gimple_switch swtch, tree type, int num,
 		  struct switch_conv_info *info)
 {
   unsigned int i, len = vec_safe_length (info->constructors[num]);
@@ -1022,8 +1022,8 @@ array_value_type (gimple swtch, tree type, int num,
    new array.  */
 
 static void
-build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
-		 tree tidx, struct switch_conv_info *info)
+build_one_array (gimple_switch swtch, int num, tree arr_index_type,
+		 gimple phi, tree tidx, struct switch_conv_info *info)
 {
   tree name, cst;
   gimple load;
@@ -1088,7 +1088,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
    them.  */
 
 static void
-build_arrays (gimple swtch, struct switch_conv_info *info)
+build_arrays (gimple_switch swtch, struct switch_conv_info *info)
 {
   tree arr_index_type;
   tree tidx, sub, utype;
@@ -1209,7 +1209,7 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf,
 */
 
 static void
-gen_inbound_check (gimple swtch, struct switch_conv_info *info)
+gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
 {
   tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
   tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
@@ -1329,7 +1329,7 @@ gen_inbound_check (gimple swtch, struct switch_conv_info *info)
    conversion failed.  */
 
 static const char *
-process_switch (gimple swtch)
+process_switch (gimple_switch swtch)
 {
   struct switch_conv_info info;
 
@@ -1467,7 +1467,7 @@ pass_convert_switch::execute (function *fun)
 	    putc ('\n', dump_file);
 	  }
 
-	failure_reason = process_switch (stmt);
+	failure_reason = process_switch (as_a <gimple_switch> (stmt));
 	if (! failure_reason)
 	  {
 	    if (dump_file)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 34255ce..1e4577e 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -168,7 +168,7 @@ static bool values_propagated;
 static int *vr_phi_edge_counts;
 
 typedef struct {
-  gimple stmt;
+  gimple_switch stmt;
   tree vec;
 } switch_update;
 
@@ -5662,7 +5662,7 @@ compare_case_labels (const void *p1, const void *p2)
    list of assertions for the corresponding operands.  */
 
 static bool
-find_switch_asserts (basic_block bb, gimple last)
+find_switch_asserts (basic_block bb, gimple_switch last)
 {
   bool need_assert;
   gimple_stmt_iterator bsi;
@@ -5833,7 +5833,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
   if (last
       && gimple_code (last) == GIMPLE_SWITCH
       && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
-    need_assert |= find_switch_asserts (bb, last);
+    need_assert |= find_switch_asserts (bb, as_a <gimple_switch> (last));
 
   /* Traverse all the statements in BB marking used names and looking
      for statements that may infer assertions for their used operands.  */
@@ -7315,7 +7315,7 @@ vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
    returned. */
 
 static bool
-find_case_label_index (gimple stmt, size_t start_idx, tree val, size_t *idx)
+find_case_label_index (gimple_switch stmt, size_t start_idx, tree val, size_t *idx)
 {
   size_t n = gimple_switch_num_labels (stmt);
   size_t low, high;
@@ -7365,7 +7365,7 @@ find_case_label_index (gimple stmt, size_t start_idx, tree val, size_t *idx)
    Returns true if the default label is not needed. */
 
 static bool
-find_case_label_range (gimple stmt, tree min, tree max, size_t *min_idx,
+find_case_label_range (gimple_switch stmt, tree min, tree max, size_t *min_idx,
 		       size_t *max_idx)
 {
   size_t i, j;
@@ -7421,7 +7421,7 @@ find_case_label_range (gimple stmt, tree min, tree max, size_t *min_idx,
    Returns true if the default label is not needed.  */
 
 static bool
-find_case_label_ranges (gimple stmt, value_range_t *vr, size_t *min_idx1,
+find_case_label_ranges (gimple_switch stmt, value_range_t *vr, size_t *min_idx1,
 			size_t *max_idx1, size_t *min_idx2,
 			size_t *max_idx2)
 {
@@ -7499,7 +7499,7 @@ find_case_label_ranges (gimple stmt, value_range_t *vr, size_t *min_idx1,
    SSA_PROP_VARYING.  */
 
 static enum ssa_prop_result
-vrp_visit_switch_stmt (gimple stmt, edge *taken_edge_p)
+vrp_visit_switch_stmt (gimple_switch stmt, edge *taken_edge_p)
 {
   tree op, val;
   value_range_t *vr;
@@ -7614,8 +7614,8 @@ vrp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
     return vrp_visit_assignment_or_call (stmt, output_p);
   else if (gimple_code (stmt) == GIMPLE_COND)
     return vrp_visit_cond_stmt (stmt, taken_edge_p);
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return vrp_visit_switch_stmt (stmt, taken_edge_p);
+  else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
+    return vrp_visit_switch_stmt (switch_stmt, taken_edge_p);
 
   /* All other statements produce nothing of interest for VRP, so mark
      their outputs varying and prevent further simulation.  */
@@ -9066,7 +9066,7 @@ simplify_cond_using_ranges (gimple stmt)
    argument.  */
 
 static bool
-simplify_switch_using_ranges (gimple stmt)
+simplify_switch_using_ranges (gimple_switch stmt)
 {
   tree op = gimple_switch_index (stmt);
   value_range_t *vr;
@@ -9460,8 +9460,8 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
     }
   else if (gimple_code (stmt) == GIMPLE_COND)
     return simplify_cond_using_ranges (stmt);
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return simplify_switch_using_ranges (stmt);
+  else if (gimple_switch switch_stmt = dyn_cast <gimple_switch> (stmt))
+    return simplify_switch_using_ranges (switch_stmt);
   else if (is_gimple_call (stmt)
 	   && gimple_call_internal_p (stmt))
     return simplify_internal_call_using_ranges (gsi, stmt);

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-24 13:25   ` Andrew MacLeod
@ 2014-04-24 15:01     ` Michael Matz
  2014-04-25  8:24       ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Michael Matz @ 2014-04-24 15:01 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: David Malcolm, gcc-patches

Hi,

On Thu, 24 Apr 2014, Andrew MacLeod wrote:

> Well, we ought to settle on one... either use the is_a, as_a, and 
> dyn_cast paradigm as they exist today, or we use the cast_as_method 
> approach everywhere.  I'm not fond of each potential project having a 
> different approach...  I'd like to see a consistent look throughout.
> 
> I suspect the cast_as_method has compile time advantages, as well as 
> error reporting ones.... (have you seen the kind of message you get when 
> the template instantiation doesn't work right? ick!)  , but it suffers 
> from having to modify the base class whenever a new derived class is 
> added...

Well, when adding new derived classes is such a frequent event that this 
would be of any worry, then we have much more difficult problems.  Adding 
types should be a well thought out and hence rare event.

> (which seems a little "dirty" and could impact possible future 
> enhancements).

Perhaps dirty from some artificial language cleanliness perspective 
(although why would methods be regarded as dirty?).  I call it pragmatic 
and visually undisturbing.


Ciao,
Michael.

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

* Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)
  2014-04-24 13:12           ` Andrew MacLeod
@ 2014-04-24 15:14             ` David Malcolm
  2014-04-24 16:12               ` Michael Matz
  2014-04-25  8:40               ` Richard Biener
  0 siblings, 2 replies; 250+ messages in thread
From: David Malcolm @ 2014-04-24 15:14 UTC (permalink / raw)
  To: Andrew MacLeod; +Cc: Richard Biener, Jeff Law, GCC Patches

On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
> On 04/24/2014 04:33 AM, Richard Biener wrote:
> > On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
> >> On 04/23/14 15:13, David Malcolm wrote:
> >>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
> >>>> On 04/21/14 10:56, David Malcolm wrote:
> >>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
> >>>>> a
> >>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
> >>>>> checking happening at the point of cast.
> >>>>>
> >>>>> Various other types are strengthened from gimple to gimple_bind, and
> >>>>> from
> >>>>> plain vec<gimple> to vec<gimple_bind>.
> >>>
> >>> [...]
> >>>
> >>>> This is fine, with the same requested changes as #2; specifically using
> >>>> an explicit cast rather than hiding the conversion in a method.  Once
> >>>> those changes are in place, it's good for 4.9.1.
> >>> Thanks - presumably you mean
> >>>     "good for *trunk* after 4.9.1 is released"
> >> Right.  Sorry for the confusion.
> > Note I still want that less-typedefs (esp. the const_*) variants to be explored.
> > Changing this will touch all the code again, so I'd like to avoid that.
> >
> > That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
> > and not 'gimple_statement_base *'?  The main reason that we have so
> > many typedefs is that in C you had to use 'struct foo' each time you
> > refer to foo as a type - I suppose it was then convenient to do the
> > typedef to the pointer type.  With 'gimple' being not a pointer type
> > we get const correctness in the way people would expect it to work.
> > [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
> > gimple (and maybe gimple_seq) as you are working on the 'gimple'
> > type anyway].
> >
> >
> 
> So if we change 'gimple' everywhere to be 'gimple *', can we just 
> abandon the 'gimple' typedef completely and go directly to using 
> something like gimple_stmt, or some other agreeable name instead?
> 
> I think its more descriptive and then frees up the generic 'gimple' name 
> should we decide to do something more with namespaces in the future...

There have been a few different proposals as to what the resulting
gimple API might look like, in various subthreads of this discusssion,
so I thought it might help the discussion to gather up the proposals,
and to apply them to some specific code examples, to see what the
results might look like.

So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
and gcc/tree-ssa-uninit.c respectively:

Status quo
==========

   static gimple
   detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
                                 vec<gimple> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
         gimple def, loop_phi, phi, close_phi = stmt;
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
     gimple_stmt_iterator gsi;
     vec<gimple> worklist = vNULL;
     pointer_set_t *added_to_worklist;

The currently-posted patch series
=================================
Here's the cumulative effect of the patch series I posted, using the
casting methods of the base class (the "stmt->as_a_gimple_phi" call):

  -static gimple
  +static gimple_phi
   detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
                                vec<gimple> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  +      gimple def;
  +      gimple_phi loop_phi, phi, close_phi = stmt->as_a_gimple_phi ();
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  gimple_phi_iterator gsi;
  +  vec<gimple_phi> worklist = vNULL;
     pointer_set_t *added_to_worklist;

Direct use of is-a.h, retaining typedefs of pointers
====================================================
The following patch shows what the above might look like using the patch
series as posted, but eliminating the casting methods  in favor of
direct use of the is-a.h API (but still using lots of typedefs of
pointers):

  -static gimple
  +static gimple_phi
   detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
                                 vec<gimple> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      gimple def;
  +      gimple_phi loop_phi, phi, close_phi = as_a <gimple_phi> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  gimple_phi_iterator gsi;
  +  vec<gimple_phi> worklist = vNULL;
     pointer_set_t *added_to_worklist;

I posted an example of porting a patch in the series to this approach as:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html

Explicit pointers, rather than typedefs
=======================================
Richi suggested making pointers be explicit rather than hidden in the
typedefs in:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html
which might give something like this:

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static gimple_phi *
  +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
  +                              vec<gimple *> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      gimple *def;
  +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  gimple_phi_iterator gsi;
  +  vec<gimple_phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;

Changing the meaning of "gimple" makes this a much bigger patch IMHO
than what I've currently posted.  One way to achieve this could be a
mega-patch (ugh) which ports the whole middle-end at once to change the
"pointerness" of "gimple", probably auto-generated and, once that's in
place, then look at introducing subclass usage.

Note: it's more fiddly than a simply sed of "gimple" to "gimple *" (or
whatever); consider the gimple_phi decls above, which would change
thusly:
  -      gimple def, loop_phi, phi, close_phi = stmt;
  +      gimple *def, *loop_phi, *phi, *close_phi = stmt;

Implicit naming
===============
Several people have suggested that the "gimple_" prefix is redundant.

Andrew MacLeod suggested in:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
that we could simple drop the "gimple_" prefix.  Combining this with the
pointer approach, for example, gives:

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static phi *
  +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
  +                              vec<gimple *> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      gimple *def;
  +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  phi_iterator gsi;
  +  vec<phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;

though it could also be done with typedefs of pointers, rather than the
"explicit pointers" above.


Namespaces (explicit)
=====================
Continuing with the idea that the "gimple_" prefix is redundant, Andrew
MacLeod also suggested in:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
that we could repurpose "gimple" to be a namespace.  Here's what things
might look like written out in full (perhaps using gimple::stmt to be
the base class):

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static gimple::phi *
  +detect_commutative_reduction (scop_p scop, gimple::stmt *stmt,
  +                              vec<gimple::stmt *> *in,
  +                              vec<gimple::stmt *> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      gimple::stmt *def;
  +      gimple::phi loop_phi, phi, close_phi = as_a <gimple::phi *> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  gimple::phi_iterator gsi;
  +  vec<gimple::phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;

This may require some gengtype support, for the case of fields within
structs.

Andrew suggested renaming "gimple" to "gimple_stmt" in:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
as a possible migration path towards this.

Namespaces (implicit)
=====================
The above is, of course, verbose - I'm mostly posting it to clarify the
following, which uses a "using" decl to eliminate all of the "gimple::"
from the above:

   using gimple;

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static phi *
  +detect_commutative_reduction (scop_p scop, stmt *stmt,
  +                              vec<stmt *> *in,
  +                              vec<stmt *> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      stmt *def;
  +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  phi_iterator gsi;
  +  vec<phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;

This would require some gengtype support (again, for the case of fields
within structs).

C++ references (without namespaces)
===================================
Richi suggested the use of references rather than pointers when the
address is required to be non-NULL:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01427.html
though there's been some pushback on C++ references in the past e.g.
from Jeff:
  http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01430.html

Here's what the "Explicit pointers, rather than typedefs" might look
like, but with references rather than ptrs for some vars where NULL
isn't valid:

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static gimple_phi *
  +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple &> *in,
  +                              vec<gimple &> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      gimple *def;
  +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
         tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  gimple_phi_iterator gsi;
  +  vec<gimple_phi &> worklist = vNULL;
     pointer_set_t *added_to_worklist;

...though arguably there's plenty more conversion of the above that
could be done: "def" is initialized once, with a non-NULL ptr, so
arguably could be reference, but that would require moving the decl down
to the point of initialization so I didn't touch it above.  I think use
of references would tend to break up such declarations of locals.

C++ references (with implicit namespaces)
=========================================
...and here's what the above "namespaces with a using decl" approach
might look like with references:

   using gimple;

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static phi *
  +detect_commutative_reduction (scop_p scop, stmt &stmt,
  +                              vec<stmt &> &in,
  +                              vec<stmt &> &out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  -      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
  +      stmt *def;
  +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
  +      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  phi_iterator gsi;
  +  vec<phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;


So the above hopefully gives an idea of what a more compile-time
type-safe gimple API might look like; sorry if I've mischaracterized any
of the ideas.  I believe they're roughly sorted by increasing
invasiveness, and by increasing "C++ ness" (both of which give me
pause).

Thoughts?

FWIW, my own preference is for "Direct use of is-a.h, retaining typedefs
of pointers" but that may be because it would be less work for me ;)

Andrew: I know you've been working on improving the typesafety of
expressions vs types in the middle-end.  I'm curious as to what the
above code fragments look like with just your changes?

Hope this is useful.
Dave


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

* Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)
  2014-04-24 15:14             ` Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.) David Malcolm
@ 2014-04-24 16:12               ` Michael Matz
  2014-04-25  8:40               ` Richard Biener
  1 sibling, 0 replies; 250+ messages in thread
From: Michael Matz @ 2014-04-24 16:12 UTC (permalink / raw)
  To: David Malcolm; +Cc: Andrew MacLeod, Richard Biener, Jeff Law, GCC Patches

Hi,

On Thu, 24 Apr 2014, David Malcolm wrote:

> Implicit naming
> ===============
> Several people have suggested that the "gimple_" prefix is redundant.

Not generally though (for instance I find it redundant in the 
cast-method names, but _not_ in the global types).

> Andrew MacLeod suggested in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> that we could simple drop the "gimple_" prefix.  Combining this with the
> pointer approach, for example, gives:
> 
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple *def;
>   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);

That is, I'm not fond of a global type named just "phi" or "bind" or 
"assign".  There the gimple_ prefix is sort of fine, we could perhaps 
trade it for a _t suffix though (phi_t, assign_t?  hmm don't know, still 
feels too broad).  But for method names (that necessarily don't conflict 
with method names from other classes or even just with local variable 
names) such prefixes are useless.

For similar reasons I find the "as_a_" prefix too verbose in method names, 
"as_" is enough to convey the meaning.  OTOH the awkward _a suffix is 
necessary for the globally named templates to not clash with single word 
names of local variable like "as" or "is".  That is, methods simply can be 
named much more sensible and still be shorter than global entities as they 
always carry class context with them.  I'm sorta fond of methods :)


Ciao,
Michael.

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-24 15:01     ` Michael Matz
@ 2014-04-25  8:24       ` Richard Biener
  2014-04-28 13:01         ` Michael Matz
  0 siblings, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-25  8:24 UTC (permalink / raw)
  To: Michael Matz; +Cc: Andrew MacLeod, David Malcolm, GCC Patches

On Thu, Apr 24, 2014 at 4:49 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Thu, 24 Apr 2014, Andrew MacLeod wrote:
>
>> Well, we ought to settle on one... either use the is_a, as_a, and
>> dyn_cast paradigm as they exist today, or we use the cast_as_method
>> approach everywhere.  I'm not fond of each potential project having a
>> different approach...  I'd like to see a consistent look throughout.
>>
>> I suspect the cast_as_method has compile time advantages, as well as
>> error reporting ones.... (have you seen the kind of message you get when
>> the template instantiation doesn't work right? ick!)  , but it suffers
>> from having to modify the base class whenever a new derived class is
>> added...
>
> Well, when adding new derived classes is such a frequent event that this
> would be of any worry, then we have much more difficult problems.  Adding
> types should be a well thought out and hence rare event.
>
>> (which seems a little "dirty" and could impact possible future
>> enhancements).
>
> Perhaps dirty from some artificial language cleanliness perspective
> (although why would methods be regarded as dirty?).  I call it pragmatic
> and visually undisturbing.

Btw, I agree we should stick to one style throughout the code-base.
The advantage of the cast variant is that it can be made work with
NULL pointers (in the dyn_cast <> case).

Oh, and you could avoid all the base-class changing stuff if you'd
do the method like

class Foo
{
  template <class T> T *as () { return as_a <T> (this); }
}

Best (or worst) of both worlds.

  gimple_cond c = g->as<gimple_cond> ();

;)  (you can even put those methods in a separate feature class you
can simply inherit from)

Richard.

>
> Ciao,
> Michael.

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

* Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)
  2014-04-24 15:14             ` Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.) David Malcolm
  2014-04-24 16:12               ` Michael Matz
@ 2014-04-25  8:40               ` Richard Biener
  2014-04-25 17:22                 ` David Malcolm
  1 sibling, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-04-25  8:40 UTC (permalink / raw)
  To: David Malcolm; +Cc: Andrew MacLeod, Jeff Law, GCC Patches

On Thu, Apr 24, 2014 at 4:59 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
>> On 04/24/2014 04:33 AM, Richard Biener wrote:
>> > On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
>> >> On 04/23/14 15:13, David Malcolm wrote:
>> >>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
>> >>>> On 04/21/14 10:56, David Malcolm wrote:
>> >>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
>> >>>>> a
>> >>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
>> >>>>> checking happening at the point of cast.
>> >>>>>
>> >>>>> Various other types are strengthened from gimple to gimple_bind, and
>> >>>>> from
>> >>>>> plain vec<gimple> to vec<gimple_bind>.
>> >>>
>> >>> [...]
>> >>>
>> >>>> This is fine, with the same requested changes as #2; specifically using
>> >>>> an explicit cast rather than hiding the conversion in a method.  Once
>> >>>> those changes are in place, it's good for 4.9.1.
>> >>> Thanks - presumably you mean
>> >>>     "good for *trunk* after 4.9.1 is released"
>> >> Right.  Sorry for the confusion.
>> > Note I still want that less-typedefs (esp. the const_*) variants to be explored.
>> > Changing this will touch all the code again, so I'd like to avoid that.
>> >
>> > That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
>> > and not 'gimple_statement_base *'?  The main reason that we have so
>> > many typedefs is that in C you had to use 'struct foo' each time you
>> > refer to foo as a type - I suppose it was then convenient to do the
>> > typedef to the pointer type.  With 'gimple' being not a pointer type
>> > we get const correctness in the way people would expect it to work.
>> > [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
>> > gimple (and maybe gimple_seq) as you are working on the 'gimple'
>> > type anyway].
>> >
>> >
>>
>> So if we change 'gimple' everywhere to be 'gimple *', can we just
>> abandon the 'gimple' typedef completely and go directly to using
>> something like gimple_stmt, or some other agreeable name instead?
>>
>> I think its more descriptive and then frees up the generic 'gimple' name
>> should we decide to do something more with namespaces in the future...
>
> There have been a few different proposals as to what the resulting
> gimple API might look like, in various subthreads of this discusssion,
> so I thought it might help the discussion to gather up the proposals,
> and to apply them to some specific code examples, to see what the
> results might look like.
>
> So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
> and gcc/tree-ssa-uninit.c respectively:
>
> Status quo
> ==========
>
>    static gimple
>    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>                                  vec<gimple> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>          gimple def, loop_phi, phi, close_phi = stmt;
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>      gimple_stmt_iterator gsi;
>      vec<gimple> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> The currently-posted patch series
> =================================
> Here's the cumulative effect of the patch series I posted, using the
> casting methods of the base class (the "stmt->as_a_gimple_phi" call):
>
>   -static gimple
>   +static gimple_phi
>    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>                                 vec<gimple> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   +      gimple def;
>   +      gimple_phi loop_phi, phi, close_phi = stmt->as_a_gimple_phi ();
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  gimple_phi_iterator gsi;
>   +  vec<gimple_phi> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> Direct use of is-a.h, retaining typedefs of pointers
> ====================================================
> The following patch shows what the above might look like using the patch
> series as posted, but eliminating the casting methods  in favor of
> direct use of the is-a.h API (but still using lots of typedefs of
> pointers):
>
>   -static gimple
>   +static gimple_phi
>    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>                                  vec<gimple> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple def;
>   +      gimple_phi loop_phi, phi, close_phi = as_a <gimple_phi> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  gimple_phi_iterator gsi;
>   +  vec<gimple_phi> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> I posted an example of porting a patch in the series to this approach as:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html
>
> Explicit pointers, rather than typedefs
> =======================================
> Richi suggested making pointers be explicit rather than hidden in the
> typedefs in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html
> which might give something like this:
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static gimple_phi *
>   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
>   +                              vec<gimple *> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple *def;
>   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  gimple_phi_iterator gsi;
>   +  vec<gimple_phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> Changing the meaning of "gimple" makes this a much bigger patch IMHO
> than what I've currently posted.  One way to achieve this could be a
> mega-patch (ugh) which ports the whole middle-end at once to change the
> "pointerness" of "gimple", probably auto-generated and, once that's in
> place, then look at introducing subclass usage.
>
> Note: it's more fiddly than a simply sed of "gimple" to "gimple *" (or
> whatever); consider the gimple_phi decls above, which would change
> thusly:
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   +      gimple *def, *loop_phi, *phi, *close_phi = stmt;
>
> Implicit naming
> ===============
> Several people have suggested that the "gimple_" prefix is redundant.
>
> Andrew MacLeod suggested in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> that we could simple drop the "gimple_" prefix.  Combining this with the
> pointer approach, for example, gives:
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static phi *
>   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
>   +                              vec<gimple *> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple *def;
>   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  phi_iterator gsi;
>   +  vec<phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> though it could also be done with typedefs of pointers, rather than the
> "explicit pointers" above.
>
>
> Namespaces (explicit)
> =====================
> Continuing with the idea that the "gimple_" prefix is redundant, Andrew
> MacLeod also suggested in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> that we could repurpose "gimple" to be a namespace.  Here's what things
> might look like written out in full (perhaps using gimple::stmt to be
> the base class):
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static gimple::phi *
>   +detect_commutative_reduction (scop_p scop, gimple::stmt *stmt,
>   +                              vec<gimple::stmt *> *in,
>   +                              vec<gimple::stmt *> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple::stmt *def;
>   +      gimple::phi loop_phi, phi, close_phi = as_a <gimple::phi *> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  gimple::phi_iterator gsi;
>   +  vec<gimple::phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> This may require some gengtype support, for the case of fields within
> structs.
>
> Andrew suggested renaming "gimple" to "gimple_stmt" in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> as a possible migration path towards this.
>
> Namespaces (implicit)
> =====================
> The above is, of course, verbose - I'm mostly posting it to clarify the
> following, which uses a "using" decl to eliminate all of the "gimple::"
> from the above:
>
>    using gimple;
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static phi *
>   +detect_commutative_reduction (scop_p scop, stmt *stmt,
>   +                              vec<stmt *> *in,
>   +                              vec<stmt *> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      stmt *def;
>   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  phi_iterator gsi;
>   +  vec<phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> This would require some gengtype support (again, for the case of fields
> within structs).
>
> C++ references (without namespaces)
> ===================================
> Richi suggested the use of references rather than pointers when the
> address is required to be non-NULL:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01427.html
> though there's been some pushback on C++ references in the past e.g.
> from Jeff:
>   http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01430.html
>
> Here's what the "Explicit pointers, rather than typedefs" might look
> like, but with references rather than ptrs for some vars where NULL
> isn't valid:
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static gimple_phi *
>   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple &> *in,
>   +                              vec<gimple &> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple *def;
>   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
>          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  gimple_phi_iterator gsi;
>   +  vec<gimple_phi &> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> ...though arguably there's plenty more conversion of the above that
> could be done: "def" is initialized once, with a non-NULL ptr, so
> arguably could be reference, but that would require moving the decl down
> to the point of initialization so I didn't touch it above.  I think use
> of references would tend to break up such declarations of locals.
>
> C++ references (with implicit namespaces)
> =========================================
> ...and here's what the above "namespaces with a using decl" approach
> might look like with references:
>
>    using gimple;
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static phi *
>   +detect_commutative_reduction (scop_p scop, stmt &stmt,
>   +                              vec<stmt &> &in,
>   +                              vec<stmt &> &out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   -      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
>   +      stmt *def;
>   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
>   +      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  phi_iterator gsi;
>   +  vec<phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
>
> So the above hopefully gives an idea of what a more compile-time
> type-safe gimple API might look like; sorry if I've mischaracterized any
> of the ideas.  I believe they're roughly sorted by increasing
> invasiveness, and by increasing "C++ ness" (both of which give me
> pause).
>
> Thoughts?

The 'should gimple be a pointer typedef' issue is rather orthogonal
and it merely affects how we do const-correctness
(but it affects your ongoing work, thus I brought it up - also because
you address the const correctness issue).

It's convenient to do such change first IMHO.  And I never liked the
const_ typedef variants that were introduced.  The main reason for
them was probably to avoid all the churn of replacing the tree pointer
typedef with a tree (non-pointer) typedef.  The mistake was to
repeat that for 'gimple' ...

I have no strong opinion on const correctness in general, but I do
have a strong opinion against introducing more of the const_*
typedefs.  Those simply feel completely bogus (and alienate the new
GCC developers we want to attract with C++ and all these changes (uh? heh!?)).

So if you turn gimple up-side-down (which you do with more static
type checking) then please fix const correctness first.

As of namespaces - yes, ideally we'd move the various prefixes
to namespaces (that a gimple pass can simply use for example).
But that's again an orthogonal issue.  You could always add the
namespace with your work and add typedefs like

typedef gimple::phi gimple_phi;

(though that invites inconsistent coding-style, using gimple::phi
vs. gimple_phi throughout the code)

Richard.

> FWIW, my own preference is for "Direct use of is-a.h, retaining typedefs
> of pointers" but that may be because it would be less work for me ;)
>
> Andrew: I know you've been working on improving the typesafety of
> expressions vs types in the middle-end.  I'm curious as to what the
> above code fragments look like with just your changes?
>
> Hope this is useful.
> Dave
>
>

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

* Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)
  2014-04-25  8:40               ` Richard Biener
@ 2014-04-25 17:22                 ` David Malcolm
  2014-04-28  9:36                   ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-04-25 17:22 UTC (permalink / raw)
  To: Richard Biener; +Cc: Andrew MacLeod, Jeff Law, GCC Patches

On Fri, 2014-04-25 at 10:37 +0200, Richard Biener wrote:
> On Thu, Apr 24, 2014 at 4:59 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> > On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
> >> On 04/24/2014 04:33 AM, Richard Biener wrote:
> >> > On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
> >> >> On 04/23/14 15:13, David Malcolm wrote:
> >> >>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
> >> >>>> On 04/21/14 10:56, David Malcolm wrote:
> >> >>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
> >> >>>>> a
> >> >>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
> >> >>>>> checking happening at the point of cast.
> >> >>>>>
> >> >>>>> Various other types are strengthened from gimple to gimple_bind, and
> >> >>>>> from
> >> >>>>> plain vec<gimple> to vec<gimple_bind>.
> >> >>>
> >> >>> [...]
> >> >>>
> >> >>>> This is fine, with the same requested changes as #2; specifically using
> >> >>>> an explicit cast rather than hiding the conversion in a method.  Once
> >> >>>> those changes are in place, it's good for 4.9.1.
> >> >>> Thanks - presumably you mean
> >> >>>     "good for *trunk* after 4.9.1 is released"
> >> >> Right.  Sorry for the confusion.
> >> > Note I still want that less-typedefs (esp. the const_*) variants to be explored.
> >> > Changing this will touch all the code again, so I'd like to avoid that.
> >> >
> >> > That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
> >> > and not 'gimple_statement_base *'?  The main reason that we have so
> >> > many typedefs is that in C you had to use 'struct foo' each time you
> >> > refer to foo as a type - I suppose it was then convenient to do the
> >> > typedef to the pointer type.  With 'gimple' being not a pointer type
> >> > we get const correctness in the way people would expect it to work.
> >> > [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
> >> > gimple (and maybe gimple_seq) as you are working on the 'gimple'
> >> > type anyway].
> >> >
> >> >
> >>
> >> So if we change 'gimple' everywhere to be 'gimple *', can we just
> >> abandon the 'gimple' typedef completely and go directly to using
> >> something like gimple_stmt, or some other agreeable name instead?
> >>
> >> I think its more descriptive and then frees up the generic 'gimple' name
> >> should we decide to do something more with namespaces in the future...
> >
> > There have been a few different proposals as to what the resulting
> > gimple API might look like, in various subthreads of this discusssion,
> > so I thought it might help the discussion to gather up the proposals,
> > and to apply them to some specific code examples, to see what the
> > results might look like.
> >
> > So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
> > and gcc/tree-ssa-uninit.c respectively:
> >
> > Status quo
> > ==========
> >
> >    static gimple
> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >                                  vec<gimple> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >          gimple def, loop_phi, phi, close_phi = stmt;
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >      gimple_stmt_iterator gsi;
> >      vec<gimple> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > The currently-posted patch series
> > =================================
> > Here's the cumulative effect of the patch series I posted, using the
> > casting methods of the base class (the "stmt->as_a_gimple_phi" call):
> >
> >   -static gimple
> >   +static gimple_phi
> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >                                 vec<gimple> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   +      gimple def;
> >   +      gimple_phi loop_phi, phi, close_phi = stmt->as_a_gimple_phi ();
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  gimple_phi_iterator gsi;
> >   +  vec<gimple_phi> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > Direct use of is-a.h, retaining typedefs of pointers
> > ====================================================
> > The following patch shows what the above might look like using the patch
> > series as posted, but eliminating the casting methods  in favor of
> > direct use of the is-a.h API (but still using lots of typedefs of
> > pointers):
> >
> >   -static gimple
> >   +static gimple_phi
> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >                                  vec<gimple> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      gimple def;
> >   +      gimple_phi loop_phi, phi, close_phi = as_a <gimple_phi> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  gimple_phi_iterator gsi;
> >   +  vec<gimple_phi> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > I posted an example of porting a patch in the series to this approach as:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html
> >
> > Explicit pointers, rather than typedefs
> > =======================================
> > Richi suggested making pointers be explicit rather than hidden in the
> > typedefs in:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html
> > which might give something like this:
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static gimple_phi *
> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
> >   +                              vec<gimple *> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      gimple *def;
> >   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  gimple_phi_iterator gsi;
> >   +  vec<gimple_phi *> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > Changing the meaning of "gimple" makes this a much bigger patch IMHO
> > than what I've currently posted.  One way to achieve this could be a
> > mega-patch (ugh) which ports the whole middle-end at once to change the
> > "pointerness" of "gimple", probably auto-generated and, once that's in
> > place, then look at introducing subclass usage.
> >
> > Note: it's more fiddly than a simply sed of "gimple" to "gimple *" (or
> > whatever); consider the gimple_phi decls above, which would change
> > thusly:
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   +      gimple *def, *loop_phi, *phi, *close_phi = stmt;
> >
> > Implicit naming
> > ===============
> > Several people have suggested that the "gimple_" prefix is redundant.
> >
> > Andrew MacLeod suggested in:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> > that we could simple drop the "gimple_" prefix.  Combining this with the
> > pointer approach, for example, gives:
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static phi *
> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
> >   +                              vec<gimple *> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      gimple *def;
> >   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  phi_iterator gsi;
> >   +  vec<phi *> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > though it could also be done with typedefs of pointers, rather than the
> > "explicit pointers" above.
> >
> >
> > Namespaces (explicit)
> > =====================
> > Continuing with the idea that the "gimple_" prefix is redundant, Andrew
> > MacLeod also suggested in:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> > that we could repurpose "gimple" to be a namespace.  Here's what things
> > might look like written out in full (perhaps using gimple::stmt to be
> > the base class):
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static gimple::phi *
> >   +detect_commutative_reduction (scop_p scop, gimple::stmt *stmt,
> >   +                              vec<gimple::stmt *> *in,
> >   +                              vec<gimple::stmt *> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      gimple::stmt *def;
> >   +      gimple::phi loop_phi, phi, close_phi = as_a <gimple::phi *> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  gimple::phi_iterator gsi;
> >   +  vec<gimple::phi *> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > This may require some gengtype support, for the case of fields within
> > structs.
> >
> > Andrew suggested renaming "gimple" to "gimple_stmt" in:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> > as a possible migration path towards this.
> >
> > Namespaces (implicit)
> > =====================
> > The above is, of course, verbose - I'm mostly posting it to clarify the
> > following, which uses a "using" decl to eliminate all of the "gimple::"
> > from the above:
> >
> >    using gimple;
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static phi *
> >   +detect_commutative_reduction (scop_p scop, stmt *stmt,
> >   +                              vec<stmt *> *in,
> >   +                              vec<stmt *> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      stmt *def;
> >   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  phi_iterator gsi;
> >   +  vec<phi *> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > This would require some gengtype support (again, for the case of fields
> > within structs).
> >
> > C++ references (without namespaces)
> > ===================================
> > Richi suggested the use of references rather than pointers when the
> > address is required to be non-NULL:
> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01427.html
> > though there's been some pushback on C++ references in the past e.g.
> > from Jeff:
> >   http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01430.html
> >
> > Here's what the "Explicit pointers, rather than typedefs" might look
> > like, but with references rather than ptrs for some vars where NULL
> > isn't valid:
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static gimple_phi *
> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple &> *in,
> >   +                              vec<gimple &> *out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   +      gimple *def;
> >   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  gimple_phi_iterator gsi;
> >   +  vec<gimple_phi &> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> > ...though arguably there's plenty more conversion of the above that
> > could be done: "def" is initialized once, with a non-NULL ptr, so
> > arguably could be reference, but that would require moving the decl down
> > to the point of initialization so I didn't touch it above.  I think use
> > of references would tend to break up such declarations of locals.
> >
> > C++ references (with implicit namespaces)
> > =========================================
> > ...and here's what the above "namespaces with a using decl" approach
> > might look like with references:
> >
> >    using gimple;
> >
> >   -static gimple
> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
> >   -                              vec<gimple> *out)
> >   +static phi *
> >   +detect_commutative_reduction (scop_p scop, stmt &stmt,
> >   +                              vec<stmt &> &in,
> >   +                              vec<stmt &> &out)
> >    {
> >      if (scalar_close_phi_node_p (stmt))
> >        {
> >   -      gimple def, loop_phi, phi, close_phi = stmt;
> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
> >   -      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
> >   +      stmt *def;
> >   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
> >   +      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
> >
> >          if (TREE_CODE (arg) != SSA_NAME)
> >
> >    /* ...etc... */
> >
> >    static unsigned int
> >    execute_late_warn_uninitialized (void)
> >    {
> >      basic_block bb;
> >   -  gimple_stmt_iterator gsi;
> >   -  vec<gimple> worklist = vNULL;
> >   +  phi_iterator gsi;
> >   +  vec<phi *> worklist = vNULL;
> >      pointer_set_t *added_to_worklist;
> >
> >
> > So the above hopefully gives an idea of what a more compile-time
> > type-safe gimple API might look like; sorry if I've mischaracterized any
> > of the ideas.  I believe they're roughly sorted by increasing
> > invasiveness, and by increasing "C++ ness" (both of which give me
> > pause).
> >
> > Thoughts?
> 
> The 'should gimple be a pointer typedef' issue is rather orthogonal
> and it merely affects how we do const-correctness
> (but it affects your ongoing work, thus I brought it up - also because
> you address the const correctness issue).
> 
> It's convenient to do such change first IMHO.  And I never liked the
> const_ typedef variants that were introduced.  The main reason for
> them was probably to avoid all the churn of replacing the tree pointer
> typedef with a tree (non-pointer) typedef.  The mistake was to
> repeat that for 'gimple' ...
> 
> I have no strong opinion on const correctness in general, but I do
> have a strong opinion against introducing more of the const_*
> typedefs.  Those simply feel completely bogus (and alienate the new
> GCC developers we want to attract with C++ and all these changes (uh? heh!?)).
> 
> So if you turn gimple up-side-down (which you do with more static
> type checking) then please fix const correctness first.

OK.  I've started looking at this, and immediately ran into an annoying
gengtype limitation; it can't yet cope with anything beyond:

   vec<ID1, ID2, ..., IDN>

and so complains with things like:

  vec<gimple *>
  vec<const gimple *>

so I'll have a look at fixing that, since that would otherwise block the
more concrete things like:

  vec<const gimple_phi *>

that motivate this upheaval.

> As of namespaces - yes, ideally we'd move the various prefixes
> to namespaces (that a gimple pass can simply use for example).
> But that's again an orthogonal issue.  You could always add the
> namespace with your work and add typedefs like
> 
> typedef gimple::phi gimple_phi;
> 
> (though that invites inconsistent coding-style, using gimple::phi
> vs. gimple_phi throughout the code)

OK.  Given your preference for doing this without typedefs, I'm working
on an automated way to convert "gimple" / "const_gimple" to...
something, making it (I hope) relatively easy to choose whether that
something should be:
  gimple *           const gimple *
or
  gimple_stmt *      const gimple_stmt *
or
  gimple::stmt *     const gimple::stmt *
or
  stmt *             const stmt *
with the last one maybe using C++ namespaces with a "using gimple" decl
(and thus actually a "gimple::stmt", or maybe just being a plain class.

One much more invasive possible change I didn't mention in the
"Examples" email would be to convert the gimple accessors to be actual
methods, giving something like this (in this case built on top of the
renaming, with implicit namespaces idea):

   using gimple;

  -static gimple
  -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
  -                              vec<gimple> *out)
  +static phi *
  +detect_commutative_reduction (scop_p scop, stmt *stmt,
  +                              vec<stmt *> *in,
  +                              vec<stmt *> *out)
   {
     if (scalar_close_phi_node_p (stmt))
       {
  -      gimple def, loop_phi, phi, close_phi = stmt;
  -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
  +      stmt *def;
  +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
  +      tree init, lhs, arg = close_phi->arg_def (0);
   
         if (TREE_CODE (arg) != SSA_NAME)
  
   /* ...etc... */
  
   static unsigned int
   execute_late_warn_uninitialized (void)
   {
     basic_block bb;
  -  gimple_stmt_iterator gsi;
  -  vec<gimple> worklist = vNULL;
  +  phi_iterator gsi;
  +  vec<phi *> worklist = vNULL;
     pointer_set_t *added_to_worklist;

(i.e. note how the call to gimple_phi_arg_def has become a method call).

I assumed that such a change would be simply too much upheaval (and
would impact greppability), but since you seem to be advocating for a
"if we're going to do it, do it properly" position, I was wondering your
thoughts on that kind of change?  (the patches would be *much* bigger,
of course, since it means changing every callsite rather than just every
decl).  Again, this may be simply orthogonal to the original goal of
expressing the gimple codes in a way that can be checked at
compile-time.   I'm not especially keen on such a further transition -
more work and churn [I can envisage a transition path in which the
accessor functions become calls to methods so that no callsites need
changing, and then the accessor functions gradually get removed, porting
their callsites to use methods].

Dave

> Richard.
> 
> > FWIW, my own preference is for "Direct use of is-a.h, retaining typedefs
> > of pointers" but that may be because it would be less work for me ;)
> >
> > Andrew: I know you've been working on improving the typesafety of
> > expressions vs types in the middle-end.  I'm curious as to what the
> > above code fragments look like with just your changes?
> >
> > Hope this is useful.
> > Dave
> >
> >


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

* Re: [PATCH 01/89] Const-correctness fixes for some gimple accessors
  2014-04-21 22:45     ` David Malcolm
@ 2014-04-27  2:35       ` Gerald Pfeifer
  0 siblings, 0 replies; 250+ messages in thread
From: Gerald Pfeifer @ 2014-04-27  2:35 UTC (permalink / raw)
  To: David Malcolm; +Cc: Jeff Law, gcc-patches

On Mon, 21 Apr 2014, David Malcolm wrote:
> It was pointed out to me off-list that this patch series lacks
> documentation changes.  I'm working on fixing that, though am not sure I
> want to fill everyone inboxes with an updated set of patches yet.
> Should I send a combined patch for the documentation changes?  (I can
> break it up and merge it into the individual changes on commit, or if
> these need editing).
> 
> In any case I fixed up the corresponding entries in gcc/doc/gimple.texi,
> double-checked the bootstrap/regtest/HTML generation of this one (on top
> of r209545), and committed it to trunk as r209548.  I'm attaching what I
> actually committed.

You certainly can consider any doc changes that mirror code changes
as pre-approved.

Based on what Jeff said, about changes like this one (const-correctness)
going in right away, perhaps get these off your table together with their
associated documentation aspects?  And then do one doc change for all the
rest -- or individual ones, I don't have a strong preference.

Thanks for working on this!

Gerald

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

* Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)
  2014-04-25 17:22                 ` David Malcolm
@ 2014-04-28  9:36                   ` Richard Biener
  0 siblings, 0 replies; 250+ messages in thread
From: Richard Biener @ 2014-04-28  9:36 UTC (permalink / raw)
  To: David Malcolm; +Cc: Andrew MacLeod, Jeff Law, GCC Patches

On Fri, Apr 25, 2014 at 5:28 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Fri, 2014-04-25 at 10:37 +0200, Richard Biener wrote:
>> On Thu, Apr 24, 2014 at 4:59 PM, David Malcolm <dmalcolm@redhat.com> wrote:
>> > On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
>> >> On 04/24/2014 04:33 AM, Richard Biener wrote:
>> >> > On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law <law@redhat.com> wrote:
>> >> >> On 04/23/14 15:13, David Malcolm wrote:
>> >> >>> On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
>> >> >>>> On 04/21/14 10:56, David Malcolm wrote:
>> >> >>>>> This updates all of the gimple_bind_* accessors in gimple.h from taking
>> >> >>>>> a
>> >> >>>>> plain gimple to taking a gimple_bind (or const_gimple_bind), with the
>> >> >>>>> checking happening at the point of cast.
>> >> >>>>>
>> >> >>>>> Various other types are strengthened from gimple to gimple_bind, and
>> >> >>>>> from
>> >> >>>>> plain vec<gimple> to vec<gimple_bind>.
>> >> >>>
>> >> >>> [...]
>> >> >>>
>> >> >>>> This is fine, with the same requested changes as #2; specifically using
>> >> >>>> an explicit cast rather than hiding the conversion in a method.  Once
>> >> >>>> those changes are in place, it's good for 4.9.1.
>> >> >>> Thanks - presumably you mean
>> >> >>>     "good for *trunk* after 4.9.1 is released"
>> >> >> Right.  Sorry for the confusion.
>> >> > Note I still want that less-typedefs (esp. the const_*) variants to be explored.
>> >> > Changing this will touch all the code again, so I'd like to avoid that.
>> >> >
>> >> > That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
>> >> > and not 'gimple_statement_base *'?  The main reason that we have so
>> >> > many typedefs is that in C you had to use 'struct foo' each time you
>> >> > refer to foo as a type - I suppose it was then convenient to do the
>> >> > typedef to the pointer type.  With 'gimple' being not a pointer type
>> >> > we get const correctness in the way people would expect it to work.
>> >> > [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
>> >> > gimple (and maybe gimple_seq) as you are working on the 'gimple'
>> >> > type anyway].
>> >> >
>> >> >
>> >>
>> >> So if we change 'gimple' everywhere to be 'gimple *', can we just
>> >> abandon the 'gimple' typedef completely and go directly to using
>> >> something like gimple_stmt, or some other agreeable name instead?
>> >>
>> >> I think its more descriptive and then frees up the generic 'gimple' name
>> >> should we decide to do something more with namespaces in the future...
>> >
>> > There have been a few different proposals as to what the resulting
>> > gimple API might look like, in various subthreads of this discusssion,
>> > so I thought it might help the discussion to gather up the proposals,
>> > and to apply them to some specific code examples, to see what the
>> > results might look like.
>> >
>> > So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
>> > and gcc/tree-ssa-uninit.c respectively:
>> >
>> > Status quo
>> > ==========
>> >
>> >    static gimple
>> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >                                  vec<gimple> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >          gimple def, loop_phi, phi, close_phi = stmt;
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >      gimple_stmt_iterator gsi;
>> >      vec<gimple> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > The currently-posted patch series
>> > =================================
>> > Here's the cumulative effect of the patch series I posted, using the
>> > casting methods of the base class (the "stmt->as_a_gimple_phi" call):
>> >
>> >   -static gimple
>> >   +static gimple_phi
>> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >                                 vec<gimple> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   +      gimple def;
>> >   +      gimple_phi loop_phi, phi, close_phi = stmt->as_a_gimple_phi ();
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  gimple_phi_iterator gsi;
>> >   +  vec<gimple_phi> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > Direct use of is-a.h, retaining typedefs of pointers
>> > ====================================================
>> > The following patch shows what the above might look like using the patch
>> > series as posted, but eliminating the casting methods  in favor of
>> > direct use of the is-a.h API (but still using lots of typedefs of
>> > pointers):
>> >
>> >   -static gimple
>> >   +static gimple_phi
>> >    detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >                                  vec<gimple> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      gimple def;
>> >   +      gimple_phi loop_phi, phi, close_phi = as_a <gimple_phi> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  gimple_phi_iterator gsi;
>> >   +  vec<gimple_phi> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > I posted an example of porting a patch in the series to this approach as:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html
>> >
>> > Explicit pointers, rather than typedefs
>> > =======================================
>> > Richi suggested making pointers be explicit rather than hidden in the
>> > typedefs in:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html
>> > which might give something like this:
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static gimple_phi *
>> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
>> >   +                              vec<gimple *> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      gimple *def;
>> >   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  gimple_phi_iterator gsi;
>> >   +  vec<gimple_phi *> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > Changing the meaning of "gimple" makes this a much bigger patch IMHO
>> > than what I've currently posted.  One way to achieve this could be a
>> > mega-patch (ugh) which ports the whole middle-end at once to change the
>> > "pointerness" of "gimple", probably auto-generated and, once that's in
>> > place, then look at introducing subclass usage.
>> >
>> > Note: it's more fiddly than a simply sed of "gimple" to "gimple *" (or
>> > whatever); consider the gimple_phi decls above, which would change
>> > thusly:
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   +      gimple *def, *loop_phi, *phi, *close_phi = stmt;
>> >
>> > Implicit naming
>> > ===============
>> > Several people have suggested that the "gimple_" prefix is redundant.
>> >
>> > Andrew MacLeod suggested in:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
>> > that we could simple drop the "gimple_" prefix.  Combining this with the
>> > pointer approach, for example, gives:
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static phi *
>> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple *> *in,
>> >   +                              vec<gimple *> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      gimple *def;
>> >   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  phi_iterator gsi;
>> >   +  vec<phi *> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > though it could also be done with typedefs of pointers, rather than the
>> > "explicit pointers" above.
>> >
>> >
>> > Namespaces (explicit)
>> > =====================
>> > Continuing with the idea that the "gimple_" prefix is redundant, Andrew
>> > MacLeod also suggested in:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
>> > that we could repurpose "gimple" to be a namespace.  Here's what things
>> > might look like written out in full (perhaps using gimple::stmt to be
>> > the base class):
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static gimple::phi *
>> >   +detect_commutative_reduction (scop_p scop, gimple::stmt *stmt,
>> >   +                              vec<gimple::stmt *> *in,
>> >   +                              vec<gimple::stmt *> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      gimple::stmt *def;
>> >   +      gimple::phi loop_phi, phi, close_phi = as_a <gimple::phi *> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  gimple::phi_iterator gsi;
>> >   +  vec<gimple::phi *> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > This may require some gengtype support, for the case of fields within
>> > structs.
>> >
>> > Andrew suggested renaming "gimple" to "gimple_stmt" in:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
>> > as a possible migration path towards this.
>> >
>> > Namespaces (implicit)
>> > =====================
>> > The above is, of course, verbose - I'm mostly posting it to clarify the
>> > following, which uses a "using" decl to eliminate all of the "gimple::"
>> > from the above:
>> >
>> >    using gimple;
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static phi *
>> >   +detect_commutative_reduction (scop_p scop, stmt *stmt,
>> >   +                              vec<stmt *> *in,
>> >   +                              vec<stmt *> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      stmt *def;
>> >   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  phi_iterator gsi;
>> >   +  vec<phi *> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > This would require some gengtype support (again, for the case of fields
>> > within structs).
>> >
>> > C++ references (without namespaces)
>> > ===================================
>> > Richi suggested the use of references rather than pointers when the
>> > address is required to be non-NULL:
>> >   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01427.html
>> > though there's been some pushback on C++ references in the past e.g.
>> > from Jeff:
>> >   http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01430.html
>> >
>> > Here's what the "Explicit pointers, rather than typedefs" might look
>> > like, but with references rather than ptrs for some vars where NULL
>> > isn't valid:
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static gimple_phi *
>> >   +detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple &> *in,
>> >   +                              vec<gimple &> *out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   +      gimple *def;
>> >   +      gimple_phi *loop_phi, *phi, *close_phi = as_a <gimple_phi *> (stmt);
>> >          tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  gimple_phi_iterator gsi;
>> >   +  vec<gimple_phi &> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> > ...though arguably there's plenty more conversion of the above that
>> > could be done: "def" is initialized once, with a non-NULL ptr, so
>> > arguably could be reference, but that would require moving the decl down
>> > to the point of initialization so I didn't touch it above.  I think use
>> > of references would tend to break up such declarations of locals.
>> >
>> > C++ references (with implicit namespaces)
>> > =========================================
>> > ...and here's what the above "namespaces with a using decl" approach
>> > might look like with references:
>> >
>> >    using gimple;
>> >
>> >   -static gimple
>> >   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>> >   -                              vec<gimple> *out)
>> >   +static phi *
>> >   +detect_commutative_reduction (scop_p scop, stmt &stmt,
>> >   +                              vec<stmt &> &in,
>> >   +                              vec<stmt &> &out)
>> >    {
>> >      if (scalar_close_phi_node_p (stmt))
>> >        {
>> >   -      gimple def, loop_phi, phi, close_phi = stmt;
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>> >   -      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
>> >   +      stmt *def;
>> >   +      phi *loop_phi, phi, close_phi = as_a <phi *> (stmt);
>> >   +      tree init, lhs, arg = gimple_phi_arg_def (*close_phi, 0);
>> >
>> >          if (TREE_CODE (arg) != SSA_NAME)
>> >
>> >    /* ...etc... */
>> >
>> >    static unsigned int
>> >    execute_late_warn_uninitialized (void)
>> >    {
>> >      basic_block bb;
>> >   -  gimple_stmt_iterator gsi;
>> >   -  vec<gimple> worklist = vNULL;
>> >   +  phi_iterator gsi;
>> >   +  vec<phi *> worklist = vNULL;
>> >      pointer_set_t *added_to_worklist;
>> >
>> >
>> > So the above hopefully gives an idea of what a more compile-time
>> > type-safe gimple API might look like; sorry if I've mischaracterized any
>> > of the ideas.  I believe they're roughly sorted by increasing
>> > invasiveness, and by increasing "C++ ness" (both of which give me
>> > pause).
>> >
>> > Thoughts?
>>
>> The 'should gimple be a pointer typedef' issue is rather orthogonal
>> and it merely affects how we do const-correctness
>> (but it affects your ongoing work, thus I brought it up - also because
>> you address the const correctness issue).
>>
>> It's convenient to do such change first IMHO.  And I never liked the
>> const_ typedef variants that were introduced.  The main reason for
>> them was probably to avoid all the churn of replacing the tree pointer
>> typedef with a tree (non-pointer) typedef.  The mistake was to
>> repeat that for 'gimple' ...
>>
>> I have no strong opinion on const correctness in general, but I do
>> have a strong opinion against introducing more of the const_*
>> typedefs.  Those simply feel completely bogus (and alienate the new
>> GCC developers we want to attract with C++ and all these changes (uh? heh!?)).
>>
>> So if you turn gimple up-side-down (which you do with more static
>> type checking) then please fix const correctness first.
>
> OK.  I've started looking at this, and immediately ran into an annoying
> gengtype limitation; it can't yet cope with anything beyond:
>
>    vec<ID1, ID2, ..., IDN>
>
> and so complains with things like:
>
>   vec<gimple *>
>   vec<const gimple *>
>
> so I'll have a look at fixing that, since that would otherwise block the
> more concrete things like:
>
>   vec<const gimple_phi *>
>
> that motivate this upheaval.
>
>> As of namespaces - yes, ideally we'd move the various prefixes
>> to namespaces (that a gimple pass can simply use for example).
>> But that's again an orthogonal issue.  You could always add the
>> namespace with your work and add typedefs like
>>
>> typedef gimple::phi gimple_phi;
>>
>> (though that invites inconsistent coding-style, using gimple::phi
>> vs. gimple_phi throughout the code)
>
> OK.  Given your preference for doing this without typedefs, I'm working
> on an automated way to convert "gimple" / "const_gimple" to...
> something, making it (I hope) relatively easy to choose whether that
> something should be:
>   gimple *           const gimple *
> or
>   gimple_stmt *      const gimple_stmt *
> or
>   gimple::stmt *     const gimple::stmt *
> or
>   stmt *             const stmt *
> with the last one maybe using C++ namespaces with a "using gimple" decl
> (and thus actually a "gimple::stmt", or maybe just being a plain class.
>
> One much more invasive possible change I didn't mention in the
> "Examples" email would be to convert the gimple accessors to be actual
> methods, giving something like this (in this case built on top of the
> renaming, with implicit namespaces idea):

Yeah ... the usual argument against this is that it makes grepping
harder (unless you make it phi->phi_arg_def () ...).  Not the very
strongest argument I'd say, but I'd like to defer this to a separate
discussion ... ;)  We'd still have the mix of tree and GIMPLE
objects everywhere so mixing both styles will make our code-base
very ugly (unless you volunteer to apply the same transforms to
'tree' ...).

So, please not at this point in time ;)

Thanks,
Richard.

>    using gimple;
>
>   -static gimple
>   -detect_commutative_reduction (scop_p scop, gimple stmt, vec<gimple> *in,
>   -                              vec<gimple> *out)
>   +static phi *
>   +detect_commutative_reduction (scop_p scop, stmt *stmt,
>   +                              vec<stmt *> *in,
>   +                              vec<stmt *> *out)
>    {
>      if (scalar_close_phi_node_p (stmt))
>        {
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      stmt *def;
>   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);
>   +      tree init, lhs, arg = close_phi->arg_def (0);
>
>          if (TREE_CODE (arg) != SSA_NAME)
>
>    /* ...etc... */
>
>    static unsigned int
>    execute_late_warn_uninitialized (void)
>    {
>      basic_block bb;
>   -  gimple_stmt_iterator gsi;
>   -  vec<gimple> worklist = vNULL;
>   +  phi_iterator gsi;
>   +  vec<phi *> worklist = vNULL;
>      pointer_set_t *added_to_worklist;
>
> (i.e. note how the call to gimple_phi_arg_def has become a method call).
>
> I assumed that such a change would be simply too much upheaval (and
> would impact greppability), but since you seem to be advocating for a
> "if we're going to do it, do it properly" position, I was wondering your
> thoughts on that kind of change?  (the patches would be *much* bigger,
> of course, since it means changing every callsite rather than just every
> decl).  Again, this may be simply orthogonal to the original goal of
> expressing the gimple codes in a way that can be checked at
> compile-time.   I'm not especially keen on such a further transition -
> more work and churn [I can envisage a transition path in which the
> accessor functions become calls to methods so that no callsites need
> changing, and then the accessor functions gradually get removed, porting
> their callsites to use methods].
>
> Dave
>
>> Richard.
>>
>> > FWIW, my own preference is for "Direct use of is-a.h, retaining typedefs
>> > of pointers" but that may be because it would be less work for me ;)
>> >
>> > Andrew: I know you've been working on improving the typesafety of
>> > expressions vs types in the middle-end.  I'm curious as to what the
>> > above code fragments look like with just your changes?
>> >
>> > Hope this is useful.
>> > Dave
>> >
>> >
>
>

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-25  8:24       ` Richard Biener
@ 2014-04-28 13:01         ` Michael Matz
  0 siblings, 0 replies; 250+ messages in thread
From: Michael Matz @ 2014-04-28 13:01 UTC (permalink / raw)
  To: Richard Biener; +Cc: Andrew MacLeod, David Malcolm, GCC Patches

Hi,

On Fri, 25 Apr 2014, Richard Biener wrote:

> Btw, I agree we should stick to one style throughout the code-base.
> The advantage of the cast variant is that it can be made work with
> NULL pointers (in the dyn_cast <> case).

NULL pointers shouldn't even be casted at all, there should be sensible 
early-outs or conditions to avoid work on NULL.

> Oh, and you could avoid all the base-class changing stuff if you'd
> do the method like
> 
> class Foo
> {
>   template <class T> T *as () { return as_a <T> (this); }
> }
> 
> Best (or worst) of both worlds.
> 
>   gimple_cond c = g->as<gimple_cond> ();
> 
> ;)  (you can even put those methods in a separate feature class you
> can simply inherit from)

Yeah, well, I can write ugly C++ as well, it's just that I don't want to 
:-/


Ciao,
Michael.

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-23 14:36           ` Richard Biener
@ 2014-04-30 21:40             ` Jeff Law
  2014-05-02  9:09               ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-04-30 21:40 UTC (permalink / raw)
  To: Richard Biener, Richard Sandiford, David Malcolm; +Cc: GCC Patches

On 04/23/14 08:32, Richard Biener wrote:

>> Also I see you introduce a const_FOO class with every FOO one.
>> I wonder whether, now that we have C++, can address const-correctness
>> in a less awkward way than with a typedef.  Can you try to go back
>> in time and see why we did with that in the first place?  ISTR that
>> it was "oh, if we were only using C++ we wouldn't need to jump through
>> that hoop".
>
> To followup myself here, it's because 'tree' is a typedef to a pointer
> and thus 'const tree' is different from 'const tree_node *'.
Right.

>
> Not sure why we re-introduced the 'mistake' of making 'tree' a pointer
> when we introduced 'gimple'.  If we were to make 'gimple' the class
> type itself we can use gimple *, const gimple * and also const gimple &
> (when a NULL pointer is not expected).
It wasn't ever really discussed to the best of my recollection.

>
> Anyway, gazillion new typedefs are ugly :/  (typedefs are ugly)
Yea, can't argue with that.  However, do we want to ask David to fix up 
the gimple vs gimple * vs const gimple * vs const gimple & as a 
prerequisite for this patchset or are you comfortable going forward with 
the patchset, then researching if there's a cleaner way to handle the 
const/typedef issues?

jeff

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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-04-30 21:40             ` Jeff Law
@ 2014-05-02  9:09               ` Richard Biener
  2014-05-02 16:02                 ` Jeff Law
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
  0 siblings, 2 replies; 250+ messages in thread
From: Richard Biener @ 2014-05-02  9:09 UTC (permalink / raw)
  To: Jeff Law, Richard Sandiford, David Malcolm; +Cc: GCC Patches

On April 30, 2014 11:26:35 PM CEST, Jeff Law <law@redhat.com> wrote:
>On 04/23/14 08:32, Richard Biener wrote:
>
>>> Also I see you introduce a const_FOO class with every FOO one.
>>> I wonder whether, now that we have C++, can address
>const-correctness
>>> in a less awkward way than with a typedef.  Can you try to go back
>>> in time and see why we did with that in the first place?  ISTR that
>>> it was "oh, if we were only using C++ we wouldn't need to jump
>through
>>> that hoop".
>>
>> To followup myself here, it's because 'tree' is a typedef to a
>pointer
>> and thus 'const tree' is different from 'const tree_node *'.
>Right.
>
>>
>> Not sure why we re-introduced the 'mistake' of making 'tree' a
>pointer
>> when we introduced 'gimple'.  If we were to make 'gimple' the class
>> type itself we can use gimple *, const gimple * and also const gimple
>&
>> (when a NULL pointer is not expected).
>It wasn't ever really discussed to the best of my recollection.
>
>>
>> Anyway, gazillion new typedefs are ugly :/  (typedefs are ugly)
>Yea, can't argue with that.  However, do we want to ask David to fix up
>
>the gimple vs gimple * vs const gimple * vs const gimple & as a 
>prerequisite for this patchset or are you comfortable going forward
>with 
>the patchset, then researching if there's a cleaner way to handle the 
>const/typedef issues?

Well, I'd like to see both and one affects the other. Doing the const correctness thing first seems more natural to me.
Of course both need to wait for 4.9.1.

Thanks,
Richard.

>
>jeff


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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-05-02  9:09               ` Richard Biener
@ 2014-05-02 16:02                 ` Jeff Law
  2014-05-02 16:22                   ` David Malcolm
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
  1 sibling, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-02 16:02 UTC (permalink / raw)
  To: Richard Biener, Richard Sandiford, David Malcolm; +Cc: GCC Patches

On 05/02/14 03:09, Richard Biener wrote:
>
> Well, I'd like to see both and one affects the other. Doing the const correctness thing first seems more natural to me.
> Of course both need to wait for 4.9.1.
Well, it looks like David is already on that path to some extent with 
the proposed gengtype changes.

I guess I'm just trying to figure out how to stage this stuff in.  ie, 
is it easier to go with the #89 patchkit, then followup with fixing the 
const stuff, or is it easier to first fix the const stuff, then adjust 
the #89 kit.  You're recommending the latter, which is fine with me, but 
I'd like David to chime in as well since he's doing the work :-)

jeff


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

* Re: [PATCH 00/89] Compile-time gimple-checking
  2014-05-02 16:02                 ` Jeff Law
@ 2014-05-02 16:22                   ` David Malcolm
  0 siblings, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-05-02 16:22 UTC (permalink / raw)
  To: Jeff Law; +Cc: Richard Biener, Richard Sandiford, GCC Patches

On Fri, 2014-05-02 at 10:02 -0600, Jeff Law wrote:
> On 05/02/14 03:09, Richard Biener wrote:
> >
> > Well, I'd like to see both and one affects the other. Doing the const correctness thing first seems more natural to me.
> > Of course both need to wait for 4.9.1.
> Well, it looks like David is already on that path to some extent with 
> the proposed gengtype changes.
> 
> I guess I'm just trying to figure out how to stage this stuff in.  ie, 
> is it easier to go with the #89 patchkit, then followup with fixing the 
> const stuff, or is it easier to first fix the const stuff, then adjust 
> the #89 kit.  You're recommending the latter, which is fine with me, but 
> I'd like David to chime in as well since he's doing the work :-)

I'm about 4 or 5 hours from having patches I can post :)

[my automated typedef-removal script seems to work, but I need to write
some ChangeLogs and port one of the patches from the #89 kit, then
rebootstrap&regrtest]


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

* [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-02  9:09               ` Richard Biener
  2014-05-02 16:02                 ` Jeff Law
@ 2014-05-02 21:53                 ` David Malcolm
  2014-05-02 21:54                   ` [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *" David Malcolm
                                     ` (4 more replies)
  1 sibling, 5 replies; 250+ messages in thread
From: David Malcolm @ 2014-05-02 21:53 UTC (permalink / raw)
  To: GCC Patches
  Cc: Jeff Law, Richard Biener, Richard Sandiford, Andrew MacLeod,
	David Malcolm

This patch series demonstrates a way of reimplementing the 89-patch series:
  "[PATCH 00/89] Compile-time gimple-checking"
     http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01148.html

whilst avoiding introducing a pair of "gimple_foo/const_gimple_foo" typedefs
for each subclass.

It eliminates the "gimple" and "const_gimple" typedefs,
renaming "gimple_statement_base" to "gimple_stmt", giving types:
  "gimple_stmt *" and "const gimple_stmt *"
thoughout the middle-end.  The rest of the gimple statement classes are
renamed, converting the various
  gimple_statement_with_FOO
to:
  gimple_stmt_with_FOO
and the remainder:
  gimple_statement_SOME_SUBCLASS
to just:
  gimple_SOME_SUBCLASS

The idea is then to reimplement the earlier patch series, porting many of
these:
  gimple_stmt *something
to point to some more concrete subclass; I've done this for GIMPLE_SWITCH.

It requires two patches that I've already posted separately:

  (A): "[PATCH] gengtype: Support explicit pointers in template arguments":
          http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00003.html
       (which apparently will need reworking after wide-int is merged;
        oh well).

  (B): "[PATCH 19/89] Const-correctness of gimple_call_builtin_p":
          http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01194.html
       (I have a separate bootstrap&regrtest in progress for just this one,
        which appears to be pre-approved per Jeff's earlier comments).

Of the 3 patches in the series itself:

  Patch 1:
    This one is handwritten: it renames the gimple statement classes in
    their declarations, in the docs, in the selftests and renames explicit
    uses of *subclasses*.

  Patch 2:
     This one is autogenerated: it does the mass conversion of "gimple" to
     "gimple_stmt *" and "const_gimple" to "const gimple_stmt *" throughout
     the code.

     The conversion script is at:
       https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/rename_gimple.py

     It's not a real C++ parser, but it has some smarts for handling
     awkward cases like:
        gimple def0, def2;
     which must become:
        gimple_stmt *def0, *def2;
                           ^ note the second '*' character.

     You can see the selftests for the conversion script at:
       https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/test_rename_gimple.py

  Patch 3:
    This one is a port of the previously-posted:
      "[PATCH 02/89] Introduce gimple_switch and use it in various places"
         http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01154.html
    to the new approach.  As per an earlier revision:
      http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html
    it *eliminates* the
      stmt->as_a_gimple_switch ()
    and
      stmt->dyn_cast_gimple_switch ()
    casting methods from the base class in favor of direct usage of is-a.h:
      as_a <gimple_switch *> (stmt)
    and
      dyn_cast <gimple_switch *> (stmt)

    This version of the patch also eliminates the
       gimple_switch / const_gimple_switch
    typedefs from the initial patch series in favor of "gimple_switch"
    being the name of the subclass.
    
Hopefully porting this first patch in the series gives a sense of what
the end-result would look like.

There are a few possible variations on the names we could pick in this
approach.

I deliberately renamed "gimple" to "gimple_stmt" since IIRC Andrew MacLeod
had suggested something like this, for the potential of making "gimple"
be a namespace. That said, using namespaces may be controversial, and
would need further gengtype support, which may be tricky (i.e. fully teach
gengtype about C++ namespaces, which may be a gengtype hack too far).
[I'd much prefer to avoid C++ namespaces in the core code, mostly because
of gengtype].

Also, AIUI, Andrew is looking at introducing concepts of gimple types and
gimple expressions, so "gimple" may no longer imply a *statement*.

Alternatively, we could make the base class be just "gimple" (which would
be more consistent with the names of the accessor functions).

There's also the "bargain basement" namespaces approach, where we don't
have an implicit "gimple" namespace, but just *pretend* we do, and rename
the base type to "stmt", with e.g. "gimple_statement_phi" becoming just
"phi". ["gimple_switch" would need to become "switch_", say, to avoid the
reserved word].

Successfully bootstrapped and regrtested on x86_64-unknown-linux-gnu
(Fedora 20) (on top of the 2 dependent patches mentioned above; equal
results compared to a control build of r209953.

How does this look? (for trunk; after 4.9.1 is released).


David Malcolm (3):
  Handwritten part of conversion of "gimple" to "gimple_stmt *"
  Autogenerated part of conversion of "gimple" to "gimple_stmt *"
  Introduce gimple_switch and use it in various places

 gcc/asan.c                               |   36 +-
 gcc/builtins.c                           |   10 +-
 gcc/builtins.h                           |    2 +-
 gcc/c-family/c-gimplify.c                |    4 +-
 gcc/calls.c                              |    2 +-
 gcc/calls.h                              |    2 +-
 gcc/cfgexpand.c                          |   48 +-
 gcc/cfgexpand.h                          |    2 +-
 gcc/cfgloop.c                            |    2 +-
 gcc/cfgloop.h                            |    2 +-
 gcc/cfgloopmanip.c                       |    4 +-
 gcc/cgraph.c                             |   32 +-
 gcc/cgraph.h                             |   24 +-
 gcc/cgraphbuild.c                        |   12 +-
 gcc/cgraphclones.c                       |    8 +-
 gcc/cgraphunit.c                         |   12 +-
 gcc/config/aarch64/aarch64-builtins.c    |    4 +-
 gcc/config/alpha/alpha.c                 |   14 +-
 gcc/config/i386/i386.c                   |   14 +-
 gcc/config/rs6000/rs6000.c               |    4 +-
 gcc/coretypes.h                          |   10 +-
 gcc/cp/cp-gimplify.c                     |    2 +-
 gcc/doc/gimple.texi                      |  824 ++++++++------
 gcc/dumpfile.c                           |    4 +-
 gcc/dumpfile.h                           |    4 +-
 gcc/except.h                             |    2 +-
 gcc/expr.c                               |   28 +-
 gcc/expr.h                               |    2 +-
 gcc/fold-const.c                         |    2 +-
 gcc/fold-const.h                         |    2 +-
 gcc/gdbhooks.py                          |    4 +-
 gcc/ggc.h                                |    6 +-
 gcc/gimple-builder.c                     |   26 +-
 gcc/gimple-builder.h                     |   16 +-
 gcc/gimple-fold.c                        |   58 +-
 gcc/gimple-fold.h                        |    8 +-
 gcc/gimple-iterator.c                    |   36 +-
 gcc/gimple-iterator.h                    |   22 +-
 gcc/gimple-low.c                         |   30 +-
 gcc/gimple-low.h                         |    2 +-
 gcc/gimple-pretty-print.c                |  110 +-
 gcc/gimple-pretty-print.h                |   12 +-
 gcc/gimple-ssa-isolate-paths.c           |   14 +-
 gcc/gimple-ssa-strength-reduction.c      |   92 +-
 gcc/gimple-ssa.h                         |   22 +-
 gcc/gimple-streamer-in.c                 |   12 +-
 gcc/gimple-streamer-out.c                |    8 +-
 gcc/gimple-walk.c                        |   18 +-
 gcc/gimple-walk.h                        |   12 +-
 gcc/gimple.c                             |  315 +++---
 gcc/gimple.h                             | 1782 +++++++++++++++---------------
 gcc/gimplify-me.c                        |    4 +-
 gcc/gimplify-me.h                        |    2 +-
 gcc/gimplify.c                           |  102 +-
 gcc/gimplify.h                           |   12 +-
 gcc/graphite-poly.c                      |    8 +-
 gcc/graphite-scop-detection.c            |   20 +-
 gcc/graphite-sese-to-poly.c              |  168 +--
 gcc/gsstruct.def                         |   52 +-
 gcc/internal-fn.c                        |   40 +-
 gcc/internal-fn.h                        |    2 +-
 gcc/ipa-inline-analysis.c                |   45 +-
 gcc/ipa-inline.c                         |    4 +-
 gcc/ipa-profile.c                        |    2 +-
 gcc/ipa-prop.c                           |   80 +-
 gcc/ipa-prop.h                           |    6 +-
 gcc/ipa-pure-const.c                     |   12 +-
 gcc/ipa-ref.c                            |   10 +-
 gcc/ipa-ref.h                            |   12 +-
 gcc/ipa-split.c                          |   40 +-
 gcc/java/java-gimplify.c                 |    2 +-
 gcc/lto-streamer-in.c                    |   16 +-
 gcc/lto-streamer-out.c                   |    6 +-
 gcc/omp-low.c                            |  253 ++---
 gcc/passes.c                             |    4 +-
 gcc/predict.c                            |   32 +-
 gcc/profile.c                            |    8 +-
 gcc/sese.c                               |   18 +-
 gcc/sese.h                               |    8 +-
 gcc/ssa-iterators.h                      |   42 +-
 gcc/stmt.c                               |    4 +-
 gcc/system.h                             |    2 +-
 gcc/target.def                           |    2 +-
 gcc/testsuite/g++.dg/plugin/selfassign.c |    8 +-
 gcc/testsuite/gcc.dg/plugin/selfassign.c |    8 +-
 gcc/tracer.c                             |    4 +-
 gcc/trans-mem.c                          |  114 +-
 gcc/trans-mem.h                          |    2 +-
 gcc/tree-affine.c                        |    2 +-
 gcc/tree-call-cdce.c                     |   50 +-
 gcc/tree-cfg.c                           |  277 ++---
 gcc/tree-cfg.h                           |   22 +-
 gcc/tree-cfgcleanup.c                    |   28 +-
 gcc/tree-cfgcleanup.h                    |    2 +-
 gcc/tree-chrec.c                         |   10 +-
 gcc/tree-chrec.h                         |    6 +-
 gcc/tree-complex.c                       |   34 +-
 gcc/tree-core.h                          |    4 +-
 gcc/tree-data-ref.c                      |   14 +-
 gcc/tree-data-ref.h                      |    8 +-
 gcc/tree-dfa.c                           |   16 +-
 gcc/tree-dfa.h                           |    2 +-
 gcc/tree-eh.c                            |  199 ++--
 gcc/tree-eh.h                            |   38 +-
 gcc/tree-emutls.c                        |    8 +-
 gcc/tree-if-conv.c                       |   34 +-
 gcc/tree-inline.c                        |  105 +-
 gcc/tree-inline.h                        |    6 +-
 gcc/tree-into-ssa.c                      |   62 +-
 gcc/tree-into-ssa.h                      |    4 +-
 gcc/tree-loop-distribution.c             |   67 +-
 gcc/tree-nested.c                        |   32 +-
 gcc/tree-nrv.c                           |    8 +-
 gcc/tree-object-size.c                   |   28 +-
 gcc/tree-outof-ssa.c                     |   26 +-
 gcc/tree-outof-ssa.h                     |    4 +-
 gcc/tree-parloops.c                      |   52 +-
 gcc/tree-pass.h                          |    6 +-
 gcc/tree-phinodes.c                      |   52 +-
 gcc/tree-phinodes.h                      |   14 +-
 gcc/tree-predcom.c                       |   62 +-
 gcc/tree-profile.c                       |   32 +-
 gcc/tree-scalar-evolution.c              |   72 +-
 gcc/tree-scalar-evolution.h              |    2 +-
 gcc/tree-sra.c                           |   62 +-
 gcc/tree-ssa-alias.c                     |   38 +-
 gcc/tree-ssa-alias.h                     |   14 +-
 gcc/tree-ssa-ccp.c                       |   48 +-
 gcc/tree-ssa-coalesce.c                  |   10 +-
 gcc/tree-ssa-copy.c                      |   14 +-
 gcc/tree-ssa-copyrename.c                |    2 +-
 gcc/tree-ssa-dce.c                       |   40 +-
 gcc/tree-ssa-dom.c                       |   90 +-
 gcc/tree-ssa-dom.h                       |    2 +-
 gcc/tree-ssa-dse.c                       |   10 +-
 gcc/tree-ssa-forwprop.c                  |  154 +--
 gcc/tree-ssa-ifcombine.c                 |   20 +-
 gcc/tree-ssa-live.c                      |   18 +-
 gcc/tree-ssa-loop-ch.c                   |    6 +-
 gcc/tree-ssa-loop-im.c                   |   70 +-
 gcc/tree-ssa-loop-ivcanon.c              |   20 +-
 gcc/tree-ssa-loop-ivopts.c               |   68 +-
 gcc/tree-ssa-loop-manip.c                |   32 +-
 gcc/tree-ssa-loop-niter.c                |   56 +-
 gcc/tree-ssa-loop-niter.h                |    4 +-
 gcc/tree-ssa-loop-prefetch.c             |   16 +-
 gcc/tree-ssa-loop-unswitch.c             |    8 +-
 gcc/tree-ssa-loop.h                      |    2 +-
 gcc/tree-ssa-math-opts.c                 |   90 +-
 gcc/tree-ssa-operands.c                  |   42 +-
 gcc/tree-ssa-operands.h                  |   10 +-
 gcc/tree-ssa-phiopt.c                    |   86 +-
 gcc/tree-ssa-phiprop.c                   |   18 +-
 gcc/tree-ssa-pre.c                       |   52 +-
 gcc/tree-ssa-propagate.c                 |   46 +-
 gcc/tree-ssa-propagate.h                 |   14 +-
 gcc/tree-ssa-reassoc.c                   |  176 +--
 gcc/tree-ssa-sccvn.c                     |   58 +-
 gcc/tree-ssa-sccvn.h                     |    8 +-
 gcc/tree-ssa-sink.c                      |   22 +-
 gcc/tree-ssa-strlen.c                    |   42 +-
 gcc/tree-ssa-structalias.c               |   44 +-
 gcc/tree-ssa-tail-merge.c                |   40 +-
 gcc/tree-ssa-ter.c                       |   12 +-
 gcc/tree-ssa-threadedge.c                |   46 +-
 gcc/tree-ssa-threadedge.h                |    4 +-
 gcc/tree-ssa-threadupdate.c              |   10 +-
 gcc/tree-ssa-uncprop.c                   |   12 +-
 gcc/tree-ssa-uninit.c                    |   78 +-
 gcc/tree-ssa.c                           |   40 +-
 gcc/tree-ssa.h                           |    4 +-
 gcc/tree-ssanames.c                      |    8 +-
 gcc/tree-ssanames.h                      |   16 +-
 gcc/tree-stdarg.c                        |   12 +-
 gcc/tree-switch-conversion.c             |   50 +-
 gcc/tree-tailcall.c                      |   30 +-
 gcc/tree-vect-data-refs.c                |  100 +-
 gcc/tree-vect-generic.c                  |   22 +-
 gcc/tree-vect-loop-manip.c               |   62 +-
 gcc/tree-vect-loop.c                     |  174 +--
 gcc/tree-vect-patterns.c                 |  194 ++--
 gcc/tree-vect-slp.c                      |  124 +--
 gcc/tree-vect-stmts.c                    |  244 ++--
 gcc/tree-vectorizer.c                    |   22 +-
 gcc/tree-vectorizer.h                    |  116 +-
 gcc/tree-vrp.c                           |  152 +--
 gcc/tree.c                               |    4 +-
 gcc/tree.h                               |    4 +-
 gcc/tsan.c                               |   12 +-
 gcc/ubsan.c                              |   20 +-
 gcc/value-prof.c                         |   96 +-
 gcc/value-prof.h                         |   26 +-
 gcc/vtable-verify.c                      |   10 +-
 193 files changed, 4851 insertions(+), 4670 deletions(-)

-- 
1.8.5.3

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

* [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *"
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
@ 2014-05-02 21:54                   ` David Malcolm
  2014-05-09  6:50                     ` Jeff Law
  2014-05-02 21:54                   ` [PATCH 3/3] Introduce gimple_switch and use it in various places David Malcolm
                                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-02 21:54 UTC (permalink / raw)
  To: GCC Patches
  Cc: Jeff Law, Richard Biener, Richard Sandiford, Andrew MacLeod,
	David Malcolm

This autogenerated patch is 1.2M in size, so I've uploaded it to:
http://dmalcolm.fedorapeople.org/gcc/large-patches/e5a7d209a8789e6df9eccb9210d4a6dbe26d0fd4-0002-Autogenerated-part-of-conversion-of-gimple-to-gimple.patch

to avoid being anti-social on the mailing list.

ChangeLog follows (without the patch itself):

gcc/

	Patch autogenerated by rename_gimple.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 6a01b854f462cd86b84173b0c45db90f11c00359

	* asan.c (has_mem_ref_been_instrumented): Replace "gimple" typedef
	with "gimple_stmt *".
	(get_mem_ref_of_assignment): Likewise.
	(get_mem_refs_of_builtin_call): Likewise.
	(create_cond_insert_point): Likewise.
	(build_check_stmt): Likewise.
	(instrument_mem_region_access): Likewise.
	(instrument_strlen_call): Likewise.
	(instrument_builtin_call): Likewise.
	(maybe_instrument_assignment): Likewise.
	(maybe_instrument_call): Likewise.
	(transform_statements): Likewise.
	(make_pass_asan_O0): Likewise.
	* builtins.c (validate_arg): Likewise.
	(do_mpc_arg2): Likewise.
	(gimple_fold_builtin_sprintf_chk): Likewise.
	(gimple_fold_builtin_snprintf_chk): Likewise.
	(gimple_fold_builtin_varargs): Likewise.
	* builtins.h (validate_gimple_arglist): Likewise.
	* calls.c (setjmp_call_p): Likewise.
	* calls.h (gimple_alloca_call_p): Likewise.
	* cfgexpand.c (Copyright): Likewise.
	(gimple_assign_rhs_to_tree): Likewise.
	(stack_var_conflict_p): Likewise.
	(visit_op): Likewise.
	(add_scope_conflicts_1): Likewise.
	(expand_used_vars): Likewise.
	(label_rtx_for_bb): Likewise.
	(maybe_cleanup_end_of_block): Likewise.
	(expand_gimple_cond): Likewise.
	(mark_transaction_restart_calls): Likewise.
	(expand_call_stmt): Likewise.
	(expand_asm_operands): Likewise.
	(expand_return): Likewise.
	(expand_gimple_stmt_1): Likewise.
	(expand_gimple_stmt): Likewise.
	(expand_debug_expr): Likewise.
	(expand_gimple_basic_block): Likewise.
	(discover_nonconstant_array_refs): Likewise.
	* cfgexpand.h (gimple_assign_rhs_to_tree): Likewise.
	* cfgloop.c (find_subloop_latch_edge_by_ivs): Likewise.
	* cfgloop.h (GTY): Likewise.
	* cfgloopmanip.c (create_empty_if_region_on_edge): Likewise.
	(create_empty_loop_on_edge): Likewise.
	* cgraph.c (cgraph_add_edge_to_call_site_hash): Likewise.
	(cgraph_edge): Likewise.
	(cgraph_set_call_stmt): Likewise.
	(cgraph_create_edge_1): Likewise.
	(cgraph_allocate_init_indirect_info): Likewise.
	(cgraph_make_edge_direct): Likewise.
	(cgraph_redirect_edge_call_stmt_to_callee): Likewise.
	(cgraph_update_edges_for_call_stmt_node): Likewise.
	(verify_edge_count_and_frequency): Likewise.
	(verify_cgraph_node): Likewise.
	(cgraph_get_body): Likewise.
	(gimple_check_call_args): Likewise.
	* cgraph.h (delete_function_version): Likewise.
	(cgraph_create_edge): Likewise.
	(cgraph_create_indirect_edge): Likewise.
	(cgraph_edge): Likewise.
	(cgraph_set_call_stmt): Likewise.
	(cgraph_update_edges_for_call_stmt): Likewise.
	(cgraph_remove_node_duplication_hook): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	* cgraphbuild.c (compute_call_stmt_bb_frequency): Likewise.
	(mark_address): Likewise.
	(mark_load): Likewise.
	(mark_store): Likewise.
	(ipa_record_stmt_references): Likewise.
	(rebuild_cgraph_edges): Likewise.
	* cgraphclones.c (function): Likewise.
	(cgraph_find_replacement_node): Likewise.
	(cgraph_set_call_stmt_including_clones): Likewise.
	* cgraphunit.c (thunk_adjust): Likewise.
	(expand_thunk): Likewise.
	* config/aarch64/aarch64-builtins.c (aarch64_gimple_fold_builtin):
	Likewise.
	* config/alpha/alpha.c (alpha_build_builtin_va_list): Likewise.
	(va_list_skip_additions): Likewise.
	(alpha_stdarg_optimize_hook): Likewise.
	* config/i386/i386.c (add_condition_to_bb): Likewise.
	(dispatch_function_versions): Likewise.
	(ix86_expand_builtin): Likewise.
	* config/rs6000/rs6000.c (rs6000_density_test): Likewise.
	(rs6000_gimplify_va_arg): Likewise.
	* dumpfile.c (dump_loc): Likewise.
	(dump_gimple_stmt): Likewise.
	* dumpfile.h (dump_gimple_stmt_loc): Likewise.
	(dump_gimple_stmt): Likewise.
	* except.h (finish_eh_generation): Likewise.
	* expr.c (use_group_regs): Likewise.
	(get_def_for_expr): Likewise.
	(get_def_for_expr_class): Likewise.
	(optimize_bitfield_assignment_op): Likewise.
	(store_field): Likewise.
	(expand_cond_expr_using_cmove): Likewise.
	(expand_expr_real_2): Likewise.
	(expand_expr_real_1): Likewise.
	(do_store_flag): Likewise.
	* expr.h (expand_normal): Likewise.
	* fold-const.c (fold_defer_overflow_warnings): Likewise.
	* fold-const.h (fold_undefer_overflow_warnings): Likewise.
	* gimple-builder.c (get_expr_type): Likewise.
	(build_assign): Likewise.
	(build_type_cast): Likewise.
	* gimple-builder.h (Copyright): Likewise.
	(build_assign): Likewise.
	(build_type_cast): Likewise.
	* gimple-fold.c (fold_gimple_assign): Likewise.
	(gimplify_and_update_call_from_tree): Likewise.
	(get_maxval_strlen): Likewise.
	(gimple_fold_call): Likewise.
	(fold_stmt_1): Likewise.
	(fold_stmt_inplace): Likewise.
	(same_bool_comparison_p): Likewise.
	(and_var_with_comparison): Likewise.
	(and_var_with_comparison_1): Likewise.
	(and_comparisons_1): Likewise.
	(or_var_with_comparison): Likewise.
	(or_var_with_comparison_1): Likewise.
	(or_comparisons_1): Likewise.
	(maybe_fold_or_comparisons): Likewise.
	(gimple_fold_stmt_to_constant_1): Likewise.
	(gimple_val_nonnegative_real_p): Likewise.
	(arith_code_with_undefined_signed_overflow): Likewise.
	(rewrite_to_defined_overflow): Likewise.
	* gimple-fold.h (gimple_fold_builtin): Likewise.
	(gimple_fold_stmt_to_constant_1): Likewise.
	(gimple_fold_stmt_to_constant): Likewise.
	(rewrite_to_defined_overflow): Likewise.
	* gimple-iterator.c (update_modified_stmt): Likewise.
	(gsi_split_seq_after): Likewise.
	(gsi_set_stmt): Likewise.
	(gsi_split_seq_before): Likewise.
	(gsi_replace): Likewise.
	(gsi_replace_with_seq): Likewise.
	(gsi_insert_before_without_update): Likewise.
	(gsi_insert_before): Likewise.
	(gsi_insert_after_without_update): Likewise.
	(gsi_remove): Likewise.
	(gsi_move_after): Likewise.
	(gsi_move_before): Likewise.
	(gsi_move_to_bb_end): Likewise.
	(gimple_find_edge_insert_loc): Likewise.
	* gimple-iterator.h (gsi_set_stmt): Likewise.
	(gsi_replace): Likewise.
	(gsi_insert_before_without_update): Likewise.
	(gsi_insert_before): Likewise.
	(gsi_insert_after_without_update): Likewise.
	(gsi_insert_after): Likewise.
	(gsi_for_stmt): Likewise.
	(gsi_insert_on_edge): Likewise.
	(gsi_insert_on_edge_immediate): Likewise.
	(gsi_prev): Likewise.
	* gimple-low.c (hierarchy): Likewise.
	(lower_function_body): Likewise.
	(lower_omp_directive): Likewise.
	(lower_stmt): Likewise.
	(lower_gimple_bind): Likewise.
	(lower_try_catch): Likewise.
	(gimple_try_catch_may_fallthru): Likewise.
	(lower_gimple_return): Likewise.
	(lower_builtin_setjmp): Likewise.
	(lower_builtin_posix_memalign): Likewise.
	* gimple-low.h (gimple_stmt_may_fallthru): Likewise.
	* gimple-pretty-print.c (do_niy): Likewise.
	(newline_and_indent): Likewise.
	(debug_gimple_stmt): Likewise.
	(debug): Likewise.
	(dump_gimple_seq): Likewise.
	(dump_gimple_fmt): Likewise.
	(dump_unary_rhs): Likewise.
	(dump_binary_rhs): Likewise.
	(dump_ternary_rhs): Likewise.
	(dump_gimple_assign): Likewise.
	(dump_gimple_return): Likewise.
	(pp_points_to_solution): Likewise.
	(dump_gimple_call): Likewise.
	(dump_gimple_switch): Likewise.
	(dump_gimple_cond): Likewise.
	(dump_gimple_label): Likewise.
	(dump_gimple_goto): Likewise.
	(dump_gimple_bind): Likewise.
	(dump_gimple_try): Likewise.
	(dump_gimple_catch): Likewise.
	(dump_gimple_eh_filter): Likewise.
	(dump_gimple_eh_must_not_throw): Likewise.
	(dump_gimple_eh_else): Likewise.
	(dump_gimple_resx): Likewise.
	(dump_gimple_eh_dispatch): Likewise.
	(dump_gimple_debug): Likewise.
	(dump_gimple_omp_for): Likewise.
	(dump_gimple_omp_continue): Likewise.
	(dump_gimple_omp_single): Likewise.
	(dump_gimple_omp_target): Likewise.
	(dump_gimple_omp_teams): Likewise.
	(dump_gimple_omp_sections): Likewise.
	(dump_gimple_omp_block): Likewise.
	(dump_gimple_omp_critical): Likewise.
	(dump_gimple_omp_return): Likewise.
	(dump_gimple_transaction): Likewise.
	(dump_ssaname_info): Likewise.
	(dump_gimple_phi): Likewise.
	(dump_gimple_omp_parallel): Likewise.
	(dump_gimple_omp_task): Likewise.
	(dump_gimple_omp_atomic_load): Likewise.
	(dump_gimple_omp_atomic_store): Likewise.
	(dump_gimple_mem_ops): Likewise.
	(dump_gimple_bb_header): Likewise.
	(dump_phi_nodes): Likewise.
	(pp_cfg_jump): Likewise.
	(dump_implicit_edges): Likewise.
	(gimple_dump_bb_buff): Likewise.
	(gimple_dump_bb_for_graph): Likewise.
	* gimple-pretty-print.h (debug_gimple_stmt): Likewise.
	(print_gimple_stmt): Likewise.
	(print_gimple_expr): Likewise.
	(pp_gimple_stmt_1): Likewise.
	* gimple-ssa-isolate-paths.c (check_loadstore): Likewise.
	(insert_trap_and_remove_trailing_statements): Likewise.
	(find_implicit_erroneous_behaviour): Likewise.
	(find_explicit_erroneous_behaviour): Likewise.
	* gimple-ssa-strength-reduction.c (of): Likewise.
	(record_potential_basis): Likewise.
	(alloc_cand_and_find_basis): Likewise.
	(base_cand_from_table): Likewise.
	(add_cand_for_stmt): Likewise.
	(slsr_process_phi): Likewise.
	(restructure_reference): Likewise.
	(slsr_process_ref): Likewise.
	(create_mul_ssa_cand): Likewise.
	(create_mul_imm_cand): Likewise.
	(slsr_process_mul): Likewise.
	(create_add_ssa_cand): Likewise.
	(create_add_imm_cand): Likewise.
	(slsr_process_add): Likewise.
	(legal_cast_p_1): Likewise.
	(legal_cast_p): Likewise.
	(slsr_process_cast): Likewise.
	(slsr_process_copy): Likewise.
	(replace_mult_candidate): Likewise.
	(create_add_on_incoming_edge): Likewise.
	(create_phi_basis): Likewise.
	(replace_conditional_candidate): Likewise.
	(phi_add_costs): Likewise.
	(replace_uncond_cands_and_profitable_phis): Likewise.
	(record_increment): Likewise.
	(record_phi_increments): Likewise.
	(record_increments): Likewise.
	(phi_incr_cost): Likewise.
	(lowest_cost_path): Likewise.
	(total_savings): Likewise.
	(ncd_for_two_cands): Likewise.
	(ncd_with_phi): Likewise.
	(insert_initializers): Likewise.
	(all_phi_incrs_profitable): Likewise.
	(introduce_cast_before_cand): Likewise.
	(replace_one_candidate): Likewise.
	(replace_profitable_candidates): Likewise.
	* gimple-ssa.h (gimple_vop): Likewise.
	(Copyright): Likewise.
	(gimple_vuse_op): Likewise.
	(gimple_vdef_op): Likewise.
	(update_stmt): Likewise.
	(update_stmt_if_modified): Likewise.
	* gimple-streamer-in.c (Copyright): Likewise.
	(input_phi): Likewise.
	(input_gimple_stmt): Likewise.
	(input_bb): Likewise.
	* gimple-streamer-out.c (output_phi): Likewise.
	(output_bb): Likewise.
	* gimple-walk.c (callback): Likewise.
	(walk_gimple_seq_mod): Likewise.
	(walk_gimple_seq): Likewise.
	(walk_gimple_asm): Likewise.
	(walk_gimple_stmt): Likewise.
	(get_base_loadstore): Likewise.
	(walk_stmt_load_store_addr_ops): Likewise.
	* gimple-walk.h (tree): Likewise.
	(walk_gimple_seq_mod): Likewise.
	(walk_gimple_op): Likewise.
	(bool): Likewise.
	(walk_stmt_load_store_addr_ops): Likewise.
	(walk_stmt_load_store_ops): Likewise.
	* gimple.c (gimple_call_same_target_p): Likewise.
	(gimple_call_flags): Likewise.
	(gimple_call_fnspec): Likewise.
	(gimple_call_arg_flags): Likewise.
	(validate_type): Likewise.
	(gimple_builtin_call_types_compatible_p): Likewise.
	(gimple_call_builtin_p): Likewise.
	(gimple_set_code): Likewise.
	(gimple_size): Likewise.
	(gimple_alloc_stat): Likewise.
	(gimple_set_subcode): Likewise.
	(gimple_build_with_ops_stat): Likewise.
	(gimple_build_return): Likewise.
	(gimple_call_reset_alias_info): Likewise.
	(gimple_build_call_1): Likewise.
	(gimple_build_call_vec): Likewise.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal_1): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_build_assign_stat): Likewise.
	(gimple_build_assign_with_ops): Likewise.
	(gimple_build_cond): Likewise.
	(gimple_build_cond_from_tree): Likewise.
	(gimple_cond_set_condition_from_tree): Likewise.
	(gimple_build_label): Likewise.
	(gimple_build_goto): Likewise.
	(gimple_build_nop): Likewise.
	(gimple_build_bind): Likewise.
	(gimple_build_asm_1): Likewise.
	(gimple_build_asm_vec): Likewise.
	(gimple_build_catch): Likewise.
	(gimple_build_eh_filter): Likewise.
	(gimple_build_eh_must_not_throw): Likewise.
	(gimple_build_eh_else): Likewise.
	(gimple_build_try): Likewise.
	(gimple_build_wce): Likewise.
	(gimple_build_resx): Likewise.
	(gimple_build_switch_nlabels): Likewise.
	(gimple_build_switch): Likewise.
	(gimple_build_eh_dispatch): Likewise.
	(gimple_build_debug_bind_stat): Likewise.
	(gimple_build_debug_source_bind_stat): Likewise.
	(gimple_build_omp_critical): Likewise.
	(gimple_build_omp_for): Likewise.
	(gimple_build_omp_parallel): Likewise.
	(gimple_build_omp_task): Likewise.
	(gimple_build_omp_section): Likewise.
	(gimple_build_omp_master): Likewise.
	(gimple_build_omp_taskgroup): Likewise.
	(gimple_build_omp_continue): Likewise.
	(gimple_build_omp_ordered): Likewise.
	(gimple_build_omp_return): Likewise.
	(gimple_build_omp_sections): Likewise.
	(gimple_build_omp_sections_switch): Likewise.
	(gimple_build_omp_single): Likewise.
	(gimple_build_omp_target): Likewise.
	(gimple_build_omp_teams): Likewise.
	(gimple_build_omp_atomic_load): Likewise.
	(gimple_build_omp_atomic_store): Likewise.
	(gimple_build_transaction): Likewise.
	(gimple_build_predict): Likewise.
	(gimple_check_failed): Likewise.
	(gimple_seq_add_stmt): Likewise.
	(gimple_seq_add_seq): Likewise.
	(should_carry_location_p): Likewise.
	(annotate_all_with_location): Likewise.
	(gimple_seq_copy): Likewise.
	(gimple_call_return_flags): Likewise.
	(gimple_assign_copy_p): Likewise.
	(gimple_assign_ssa_name_copy_p): Likewise.
	(gimple_assign_unary_nop_p): Likewise.
	(gimple_assign_set_rhs_with_ops_1): Likewise.
	(gimple_get_lhs): Likewise.
	(gimple_set_lhs): Likewise.
	(gimple_copy): Likewise.
	(gimple_has_side_effects): Likewise.
	(gimple_could_trap_p_1): Likewise.
	(gimple_could_trap_p): Likewise.
	(canonicalize_cond_expr_cond): Likewise.
	(gimple_call_copy_skip_args): Likewise.
	(gimple_get_alias_set): Likewise.
	(gimple_ior_addresses_taken_1): Likewise.
	(dump_decl_set): Likewise.
	(nonfreeing_call_p): Likewise.
	(check_loadstore): Likewise.
	* gimple.h (gimple_call_same_target_p): Likewise.
	(gimple_call_flags): Likewise.
	(gimple_call_arg_flags): Likewise.
	(gimple_call_return_flags): Likewise.
	(gimple_get_lhs): Likewise.
	(gimple_has_side_effects): Likewise.
	(gimple_builtin_call_types_compatible_p): Likewise.
	(gimple_call_builtin_p): Likewise.
	(gimple_asm_clobbers_memory_p): Likewise.
	(set_bb_seq): Likewise.
	(gimple_has_substatements): Likewise.
	(gimple_bb): Likewise.
	(gimple_set_block): Likewise.
	(gimple_location): Likewise.
	(gimple_set_location): Likewise.
	(gimple_has_location): Likewise.
	(gimple_filename): Likewise.
	(gimple_seq_singleton_p): Likewise.
	(gimple_set_uid): Likewise.
	(gimple_init_singleton): Likewise.
	(gimple_set_use_ops): Likewise.
	(gimple_vuse): Likewise.
	(gimple_set_vdef): Likewise.
	(gimple_set_modified): Likewise.
	(gimple_expr_code): Likewise.
	(gimple_references_memory_p): Likewise.
	(gimple_omp_return_set_nowait): Likewise.
	(gimple_omp_return_set_lhs): Likewise.
	(gimple_omp_return_lhs_ptr): Likewise.
	(gimple_omp_section_set_last): Likewise.
	(gimple_omp_parallel_set_combined_p): Likewise.
	(gimple_omp_atomic_set_need_value): Likewise.
	(gimple_omp_atomic_set_seq_cst): Likewise.
	(gimple_ops): Likewise.
	(gimple_op): Likewise.
	(gimple_set_op): Likewise.
	(get_gimple_rhs_class): Likewise.
	(gimple_assign_lhs): Likewise.
	(gimple_assign_set_lhs): Likewise.
	(gimple_assign_rhs1): Likewise.
	(gimple_assign_set_rhs1): Likewise.
	(gimple_assign_rhs2): Likewise.
	(gimple_assign_set_rhs2): Likewise.
	(gimple_assign_rhs3): Likewise.
	(gimple_assign_set_rhs_with_ops): Likewise.
	(gimple_assign_set_nontemporal_move): Likewise.
	(gimple_assign_set_rhs_code): Likewise.
	(gimple_assign_rhs_class): Likewise.
	(gimple_assign_single_p): Likewise.
	(gimple_store_p): Likewise.
	(gimple_assign_load_p): Likewise.
	(gimple_assign_cast_p): Likewise.
	(gimple_clobber_p): Likewise.
	(is_gimple_call): Likewise.
	(gimple_call_lhs): Likewise.
	(gimple_call_set_lhs): Likewise.
	(gimple_call_internal_p): Likewise.
	(gimple_call_internal_fn): Likewise.
	(gimple_call_set_fntype): Likewise.
	(gimple_call_fn): Likewise.
	(gimple_call_set_internal_fn): Likewise.
	(gimple_call_fndecl): Likewise.
	(gimple_call_return_type): Likewise.
	(gimple_call_chain): Likewise.
	(gimple_call_set_chain): Likewise.
	(gimple_call_num_args): Likewise.
	(gimple_call_arg): Likewise.
	(gimple_has_lhs): Likewise.
	(gimple_cond_set_code): Likewise.
	(gimple_cond_lhs): Likewise.
	(gimple_cond_set_lhs): Likewise.
	(gimple_cond_rhs): Likewise.
	(gimple_cond_set_rhs): Likewise.
	(gimple_cond_set_false_label): Likewise.
	(gimple_cond_make_true): Likewise.
	(gimple_cond_true_p): Likewise.
	(gimple_cond_set_condition): Likewise.
	(gimple_label_set_label): Likewise.
	(gimple_goto_set_dest): Likewise.
	(gimple_bind_add_seq): Likewise.
	(gimple_bind_set_block): Likewise.
	(gimple_asm_ninputs): Likewise.
	(gimple_asm_noutputs): Likewise.
	(gimple_asm_nclobbers): Likewise.
	(gimple_asm_nlabels): Likewise.
	(gimple_asm_input_op): Likewise.
	(gimple_asm_set_input_op): Likewise.
	(gimple_asm_output_op): Likewise.
	(gimple_asm_set_output_op): Likewise.
	(gimple_asm_set_clobber_op): Likewise.
	(gimple_asm_set_label_op): Likewise.
	(gimple_asm_string): Likewise.
	(gimple_asm_set_input): Likewise.
	(gimple_asm_input_p): Likewise.
	(gimple_catch_set_handler): Likewise.
	(gimple_eh_else_set_e_body): Likewise.
	(gimple_try_set_kind): Likewise.
	(gimple_wce_set_cleanup): Likewise.
	(gimple_wce_set_cleanup_eh_only): Likewise.
	(gimple_phi_capacity): Likewise.
	(gimple_phi_num_args): Likewise.
	(gimple_phi_arg_has_location): Likewise.
	(gimple_resx_set_region): Likewise.
	(gimple_eh_dispatch_set_region): Likewise.
	(gimple_switch_set_num_labels): Likewise.
	(gimple_switch_index): Likewise.
	(gimple_switch_set_index): Likewise.
	(gimple_switch_set_label): Likewise.
	(gimple_switch_set_default_label): Likewise.
	(is_gimple_debug): Likewise.
	(gimple_debug_bind_has_value_p): Likewise.
	(gimple_debug_source_bind_set_value): Likewise.
	(gimple_omp_set_body): Likewise.
	(gimple_omp_critical_set_name): Likewise.
	(gimple_omp_for_set_kind): Likewise.
	(gimple_omp_for_set_combined_p): Likewise.
	(gimple_omp_for_set_combined_into_p): Likewise.
	(gimple_omp_for_collapse): Likewise.
	(gimple_omp_for_set_index): Likewise.
	(gimple_omp_for_set_initial): Likewise.
	(gimple_omp_for_set_final): Likewise.
	(gimple_omp_for_set_pre_body): Likewise.
	(gimple_omp_parallel_set_clauses): Likewise.
	(gimple_omp_parallel_set_child_fn): Likewise.
	(gimple_omp_parallel_set_data_arg): Likewise.
	(gimple_omp_task_set_clauses): Likewise.
	(gimple_omp_task_set_child_fn): Likewise.
	(gimple_omp_task_set_data_arg): Likewise.
	(gimple_omp_taskreg_set_clauses): Likewise.
	(gimple_omp_taskreg_set_child_fn): Likewise.
	(gimple_omp_taskreg_set_data_arg): Likewise.
	(gimple_omp_task_set_copy_fn): Likewise.
	(gimple_omp_task_set_arg_size): Likewise.
	(gimple_omp_task_set_arg_align): Likewise.
	(gimple_omp_single_set_clauses): Likewise.
	(gimple_omp_target_set_clauses): Likewise.
	(gimple_omp_target_set_kind): Likewise.
	(gimple_omp_target_set_child_fn): Likewise.
	(gimple_omp_target_set_data_arg): Likewise.
	(gimple_omp_teams_set_clauses): Likewise.
	(gimple_omp_sections_set_clauses): Likewise.
	(gimple_omp_for_set_cond): Likewise.
	(gimple_omp_atomic_store_set_val): Likewise.
	(gimple_omp_atomic_load_set_lhs): Likewise.
	(gimple_omp_atomic_load_set_rhs): Likewise.
	(gimple_omp_atomic_load_rhs_ptr): Likewise.
	(gimple_omp_continue_set_control_def): Likewise.
	(gimple_transaction_body): Likewise.
	(gimple_transaction_label_ptr): Likewise.
	(gimple_transaction_set_subcode): Likewise.
	(gimple_return_retval_ptr): Likewise.
	(gimple_return_set_retval): Likewise.
	(is_gimple_omp): Likewise.
	(gimple_nop_p): Likewise.
	(gimple_predict_set_outcome): Likewise.
	(Copyright): Likewise.
	(gimple_check_failed): Likewise.
	(GTY): Likewise.
	(gimple_alloc_stat): Likewise.
	(gimple_call_reset_alias_info): Likewise.
	(gimple_build_call_vec): Likewise.
	(gimple_build_call): Likewise.
	(gimple_build_call_valist): Likewise.
	(gimple_build_call_internal): Likewise.
	(gimple_build_call_internal_vec): Likewise.
	(gimple_build_call_from_tree): Likewise.
	(gimple_build_assign_stat): Likewise.
	(gimple_build_assign_with_ops): Likewise.
	(gimple_build_cond): Likewise.
	(gimple_cond_set_condition_from_tree): Likewise.
	(gimple_build_label): Likewise.
	(gimple_build_goto): Likewise.
	(gimple_build_nop): Likewise.
	(gimple_build_bind): Likewise.
	(gimple_build_asm_vec): Likewise.
	(gimple_build_catch): Likewise.
	(gimple_build_eh_filter): Likewise.
	(gimple_build_eh_must_not_throw): Likewise.
	(gimple_build_try): Likewise.
	(gimple_build_wce): Likewise.
	(gimple_build_resx): Likewise.
	(gimple_build_switch_nlabels): Likewise.
	(gimple_build_switch): Likewise.
	(gimple_build_eh_dispatch): Likewise.
	(gimple_build_debug_bind_stat): Likewise.
	(gimple_build_debug_source_bind_stat): Likewise.
	(gimple_build_omp_critical): Likewise.
	(gimple_build_omp_for): Likewise.
	(gimple_build_omp_parallel): Likewise.
	(gimple_build_omp_task): Likewise.
	(gimple_build_omp_section): Likewise.
	(gimple_build_omp_master): Likewise.
	(gimple_build_omp_taskgroup): Likewise.
	(gimple_build_omp_continue): Likewise.
	(gimple_build_omp_ordered): Likewise.
	(gimple_build_omp_return): Likewise.
	(gimple_build_omp_sections): Likewise.
	(gimple_build_omp_sections_switch): Likewise.
	(gimple_build_omp_single): Likewise.
	(gimple_build_omp_target): Likewise.
	(gimple_build_omp_teams): Likewise.
	(gimple_build_omp_atomic_load): Likewise.
	(gimple_build_omp_atomic_store): Likewise.
	(gimple_build_transaction): Likewise.
	(gimple_seq_add_stmt): Likewise.
	(gimple_seq_add_stmt_without_update): Likewise.
	(gimple_assign_copy_p): Likewise.
	(gimple_assign_ssa_name_copy_p): Likewise.
	(gimple_assign_unary_nop_p): Likewise.
	(gimple_set_bb): Likewise.
	(gimple_set_lhs): Likewise.
	(gimple_copy): Likewise.
	(gimple_could_trap_p_1): Likewise.
	(gimple_could_trap_p): Likewise.
	(gimple_assign_rhs_could_trap_p): Likewise.
	(canonicalize_cond_expr_cond): Likewise.
	(gimple_call_copy_skip_args): Likewise.
	(gimple_ior_addresses_taken): Likewise.
	(nonfreeing_call_p): Likewise.
	(infer_nonnull_range): Likewise.
	(gimple_seq_first): Likewise.
	(gimple_seq_last): Likewise.
	(gimple_seq_empty_p): Likewise.
	(gss_for_code): Likewise.
	(gimple_statement_structure): Likewise.
	(gimple_block): Likewise.
	(gimple_location_ptr): Likewise.
	(gimple_no_warning_p): Likewise.
	(gimple_set_no_warning): Likewise.
	(gimple_set_visited): Likewise.
	(gimple_visited_p): Likewise.
	(gimple_set_plf): Likewise.
	(gimple_plf): Likewise.
	(gimple_uid): Likewise.
	(gimple_has_ops): Likewise.
	(gimple_has_mem_ops): Likewise.
	(gimple_use_ops): Likewise.
	(gimple_vdef): Likewise.
	(gimple_vuse_ptr): Likewise.
	(gimple_vdef_ptr): Likewise.
	(gimple_set_vuse): Likewise.
	(gimple_modified_p): Likewise.
	(gimple_has_volatile_ops): Likewise.
	(gimple_set_has_volatile_ops): Likewise.
	(gimple_in_transaction): Likewise.
	(gimple_omp_subcode): Likewise.
	(gimple_omp_set_subcode): Likewise.
	(gimple_omp_return_nowait_p): Likewise.
	(gimple_omp_return_lhs): Likewise.
	(gimple_omp_section_last_p): Likewise.
	(gimple_omp_parallel_combined_p): Likewise.
	(gimple_omp_atomic_need_value_p): Likewise.
	(gimple_omp_atomic_seq_cst_p): Likewise.
	(gimple_num_ops): Likewise.
	(gimple_set_num_ops): Likewise.
	(gimple_op_ptr): Likewise.
	(gimple_assign_lhs_ptr): Likewise.
	(gimple_assign_rhs1_ptr): Likewise.
	(gimple_assign_rhs2_ptr): Likewise.
	(gimple_assign_rhs3_ptr): Likewise.
	(gimple_assign_nontemporal_move_p): Likewise.
	(gimple_assign_rhs_code): Likewise.
	(gimple_call_lhs_ptr): Likewise.
	(gimple_call_fntype): Likewise.
	(gimple_call_fn_ptr): Likewise.
	(gimple_call_set_fn): Likewise.
	(gimple_call_set_fndecl): Likewise.
	(gimple_call_chain_ptr): Likewise.
	(gimple_call_arg_ptr): Likewise.
	(gimple_call_set_arg): Likewise.
	(gimple_call_set_tail): Likewise.
	(gimple_call_tail_p): Likewise.
	(gimple_call_set_return_slot_opt): Likewise.
	(gimple_call_return_slot_opt_p): Likewise.
	(gimple_call_set_from_thunk): Likewise.
	(gimple_call_from_thunk_p): Likewise.
	(gimple_call_set_va_arg_pack): Likewise.
	(gimple_call_va_arg_pack_p): Likewise.
	(gimple_call_noreturn_p): Likewise.
	(gimple_call_set_nothrow): Likewise.
	(gimple_call_nothrow_p): Likewise.
	(gimple_call_set_alloca_for_var): Likewise.
	(gimple_call_alloca_for_var_p): Likewise.
	(gimple_call_copy_flags): Likewise.
	(gimple_call_use_set): Likewise.
	(gimple_call_clobber_set): Likewise.
	(gimple_cond_code): Likewise.
	(gimple_cond_lhs_ptr): Likewise.
	(gimple_cond_rhs_ptr): Likewise.
	(gimple_cond_true_label): Likewise.
	(gimple_cond_set_true_label): Likewise.
	(gimple_cond_false_label): Likewise.
	(gimple_cond_make_false): Likewise.
	(gimple_cond_false_p): Likewise.
	(gimple_label_label): Likewise.
	(gimple_goto_dest): Likewise.
	(gimple_bind_vars): Likewise.
	(gimple_bind_set_vars): Likewise.
	(gimple_bind_append_vars): Likewise.
	(gimple_bind_body_ptr): Likewise.
	(gimple_bind_body): Likewise.
	(gimple_bind_set_body): Likewise.
	(gimple_bind_add_stmt): Likewise.
	(gimple_bind_block): Likewise.
	(gimple_asm_input_op_ptr): Likewise.
	(gimple_asm_output_op_ptr): Likewise.
	(gimple_asm_clobber_op): Likewise.
	(gimple_asm_label_op): Likewise.
	(gimple_asm_volatile_p): Likewise.
	(gimple_asm_set_volatile): Likewise.
	(gimple_catch_types): Likewise.
	(gimple_catch_types_ptr): Likewise.
	(gimple_catch_handler_ptr): Likewise.
	(gimple_catch_handler): Likewise.
	(gimple_catch_set_types): Likewise.
	(gimple_eh_filter_types): Likewise.
	(gimple_eh_filter_types_ptr): Likewise.
	(gimple_eh_filter_failure_ptr): Likewise.
	(gimple_eh_filter_failure): Likewise.
	(gimple_eh_filter_set_types): Likewise.
	(gimple_eh_filter_set_failure): Likewise.
	(gimple_eh_must_not_throw_fndecl): Likewise.
	(gimple_eh_must_not_throw_set_fndecl): Likewise.
	(gimple_eh_else_n_body_ptr): Likewise.
	(gimple_eh_else_n_body): Likewise.
	(gimple_eh_else_e_body_ptr): Likewise.
	(gimple_eh_else_e_body): Likewise.
	(gimple_eh_else_set_n_body): Likewise.
	(gimple_try_kind): Likewise.
	(gimple_try_catch_is_cleanup): Likewise.
	(gimple_try_eval_ptr): Likewise.
	(gimple_try_eval): Likewise.
	(gimple_try_cleanup_ptr): Likewise.
	(gimple_try_cleanup): Likewise.
	(gimple_try_set_catch_is_cleanup): Likewise.
	(gimple_try_set_eval): Likewise.
	(gimple_try_set_cleanup): Likewise.
	(gimple_wce_cleanup_ptr): Likewise.
	(gimple_wce_cleanup): Likewise.
	(gimple_wce_cleanup_eh_only): Likewise.
	(gimple_phi_result): Likewise.
	(gimple_phi_result_ptr): Likewise.
	(gimple_phi_set_result): Likewise.
	(gimple_phi_arg): Likewise.
	(phi_nodes_ptr): Likewise.
	(gimple_phi_arg_def): Likewise.
	(gimple_phi_arg_def_ptr): Likewise.
	(gimple_phi_arg_edge): Likewise.
	(gimple_phi_arg_location): Likewise.
	(gimple_phi_arg_location_from_edge): Likewise.
	(gimple_phi_arg_set_location): Likewise.
	(gimple_resx_region): Likewise.
	(gimple_eh_dispatch_region): Likewise.
	(gimple_switch_num_labels): Likewise.
	(gimple_switch_index_ptr): Likewise.
	(gimple_switch_label): Likewise.
	(gimple_switch_default_label): Likewise.
	(gimple_debug_bind_p): Likewise.
	(gimple_debug_bind_get_var): Likewise.
	(gimple_debug_bind_get_value): Likewise.
	(gimple_debug_bind_get_value_ptr): Likewise.
	(gimple_debug_bind_set_var): Likewise.
	(gimple_debug_bind_set_value): Likewise.
	(gimple_debug_bind_reset_value): Likewise.
	(gimple_debug_source_bind_p): Likewise.
	(gimple_debug_source_bind_get_var): Likewise.
	(gimple_debug_source_bind_get_value): Likewise.
	(gimple_debug_source_bind_get_value_ptr): Likewise.
	(gimple_debug_source_bind_set_var): Likewise.
	(get_lineno): Likewise.
	(gimple_omp_body_ptr): Likewise.
	(gimple_omp_body): Likewise.
	(gimple_omp_critical_name): Likewise.
	(gimple_omp_critical_name_ptr): Likewise.
	(gimple_omp_for_kind): Likewise.
	(gimple_omp_for_combined_p): Likewise.
	(gimple_omp_for_combined_into_p): Likewise.
	(gimple_omp_for_clauses): Likewise.
	(gimple_omp_for_clauses_ptr): Likewise.
	(gimple_omp_for_set_clauses): Likewise.
	(gimple_omp_for_index): Likewise.
	(gimple_omp_for_index_ptr): Likewise.
	(gimple_omp_for_initial): Likewise.
	(gimple_omp_for_initial_ptr): Likewise.
	(gimple_omp_for_final): Likewise.
	(gimple_omp_for_final_ptr): Likewise.
	(gimple_omp_for_incr): Likewise.
	(gimple_omp_for_incr_ptr): Likewise.
	(gimple_omp_for_set_incr): Likewise.
	(gimple_omp_for_pre_body_ptr): Likewise.
	(gimple_omp_for_pre_body): Likewise.
	(gimple_omp_parallel_clauses): Likewise.
	(gimple_omp_parallel_clauses_ptr): Likewise.
	(gimple_omp_parallel_child_fn): Likewise.
	(gimple_omp_parallel_child_fn_ptr): Likewise.
	(gimple_omp_parallel_data_arg): Likewise.
	(gimple_omp_parallel_data_arg_ptr): Likewise.
	(gimple_omp_task_clauses): Likewise.
	(gimple_omp_task_clauses_ptr): Likewise.
	(gimple_omp_task_child_fn): Likewise.
	(gimple_omp_task_child_fn_ptr): Likewise.
	(gimple_omp_task_data_arg): Likewise.
	(gimple_omp_task_data_arg_ptr): Likewise.
	(gimple_omp_taskreg_clauses): Likewise.
	(gimple_omp_taskreg_clauses_ptr): Likewise.
	(gimple_omp_taskreg_child_fn): Likewise.
	(gimple_omp_taskreg_child_fn_ptr): Likewise.
	(gimple_omp_taskreg_data_arg): Likewise.
	(gimple_omp_taskreg_data_arg_ptr): Likewise.
	(gimple_omp_task_copy_fn): Likewise.
	(gimple_omp_task_copy_fn_ptr): Likewise.
	(gimple_omp_task_arg_size): Likewise.
	(gimple_omp_task_arg_size_ptr): Likewise.
	(gimple_omp_task_arg_align): Likewise.
	(gimple_omp_task_arg_align_ptr): Likewise.
	(gimple_omp_single_clauses): Likewise.
	(gimple_omp_single_clauses_ptr): Likewise.
	(gimple_omp_target_clauses): Likewise.
	(gimple_omp_target_clauses_ptr): Likewise.
	(gimple_omp_target_kind): Likewise.
	(gimple_omp_target_child_fn): Likewise.
	(gimple_omp_target_child_fn_ptr): Likewise.
	(gimple_omp_target_data_arg): Likewise.
	(gimple_omp_target_data_arg_ptr): Likewise.
	(gimple_omp_teams_clauses): Likewise.
	(gimple_omp_teams_clauses_ptr): Likewise.
	(gimple_omp_sections_clauses): Likewise.
	(gimple_omp_sections_clauses_ptr): Likewise.
	(gimple_omp_sections_control): Likewise.
	(gimple_omp_sections_control_ptr): Likewise.
	(gimple_omp_sections_set_control): Likewise.
	(gimple_omp_for_cond): Likewise.
	(gimple_omp_atomic_store_val): Likewise.
	(gimple_omp_atomic_store_val_ptr): Likewise.
	(gimple_omp_atomic_load_lhs): Likewise.
	(gimple_omp_atomic_load_lhs_ptr): Likewise.
	(gimple_omp_atomic_load_rhs): Likewise.
	(gimple_omp_continue_control_def): Likewise.
	(gimple_omp_continue_control_def_ptr): Likewise.
	(gimple_omp_continue_control_use): Likewise.
	(gimple_omp_continue_control_use_ptr): Likewise.
	(gimple_omp_continue_set_control_use): Likewise.
	(gimple_transaction_body_ptr): Likewise.
	(gimple_transaction_label): Likewise.
	(gimple_transaction_subcode): Likewise.
	(gimple_transaction_set_body): Likewise.
	(gimple_transaction_set_label): Likewise.
	(gimple_return_retval): Likewise.
	(is_gimple_resx): Likewise.
	(gimple_predict_predictor): Likewise.
	(gimple_predict_set_predictor): Likewise.
	(gimple_predict_outcome): Likewise.
	(gimple_alloc_kind): Likewise.
	(gimple_do_not_emit_location_p): Likewise.
	* gimplify-me.c (force_gimple_operand_gsi): Likewise.
	(gimple_regimplify_operands): Likewise.
	* gimplify-me.h (gimple_regimplify_operands): Likewise.
	* gimplify.c (equal): Likewise.
	(gimplify_seq_add_stmt): Likewise.
	(push_gimplify_context): Likewise.
	(pop_gimplify_context): Likewise.
	(gimple_pop_bind_expr): Likewise.
	(gimple_current_bind_expr): Likewise.
	(gimplify_and_add): Likewise.
	(get_initialized_tmp_var): Likewise.
	(voidify_wrapper_expr): Likewise.
	(gimplify_bind_expr): Likewise.
	(gimplify_return_expr): Likewise.
	(gimplify_switch_expr): Likewise.
	(gimplify_case_label_expr): Likewise.
	(gimplify_call_expr): Likewise.
	(gimplify_cond_expr): Likewise.
	(gimplify_modify_expr_to_memcpy): Likewise.
	(gimplify_modify_expr_to_memset): Likewise.
	(gimplify_init_constructor): Likewise.
	(gimplify_modify_expr): Likewise.
	(gimplify_asm_expr): Likewise.
	(gimplify_cleanup_point_expr): Likewise.
	(gimple_push_cleanup): Likewise.
	(gimplify_omp_parallel): Likewise.
	(gimplify_omp_task): Likewise.
	(gimplify_omp_for): Likewise.
	(gimplify_omp_workshare): Likewise.
	(gimplify_omp_target_update): Likewise.
	(gimplify_omp_atomic): Likewise.
	(gimplify_transaction): Likewise.
	(gimplify_expr): Likewise.
	(gimplify_one_sizepos): Likewise.
	(gimplify_body): Likewise.
	(gimplify_function_tree): Likewise.
	(gimplify_va_arg_expr): Likewise.
	* gimplify.h (pop_gimplify_context): Likewise.
	(gimple_current_bind_expr): Likewise.
	(declare_vars): Likewise.
	(gimplify_one_sizepos): Likewise.
	(gimplify_va_arg_expr): Likewise.
	* graphite-poly.c (dump_gbb_cases): Likewise.
	(dump_gbb_conditions): Likewise.
	* graphite-scop-detection.c (graphite_can_represent_expr): Likewise.
	(stmt_has_simple_data_refs_p): Likewise.
	(stmt_simple_for_scop_p): Likewise.
	(scopdet_basic_block_info): Likewise.
	(limit_scops): Likewise.
	(same_close_phi_node): Likewise.
	(remove_duplicate_close_phi): Likewise.
	(make_close_phi_nodes_unique): Likewise.
	(canonicalize_loop_closed_ssa): Likewise.
	* graphite-sese-to-poly.c (tree_int_to_gmp): Likewise.
	(remove_simple_copy_phi): Likewise.
	(remove_invariant_phi): Likewise.
	(reduction_phi_p): Likewise.
	(try_generate_gimple_bb): Likewise.
	(find_params_in_bb): Likewise.
	(create_pw_aff_from_tree): Likewise.
	(add_conditions_to_domain): Likewise.
	(add_conditions_to_constraints): Likewise.
	(single_pred_cond_non_loop_exit): Likewise.
	(build_scop_drs): Likewise.
	(gsi_for_phi_node): Likewise.
	(analyze_drs_in_stmts): Likewise.
	(insert_stmts): Likewise.
	(insert_out_of_ssa_copy): Likewise.
	(insert_out_of_ssa_copy_on_edge): Likewise.
	(create_zero_dim_array): Likewise.
	(propagate_expr_outside_region): Likewise.
	(rewrite_close_phi_out_of_ssa): Likewise.
	(rewrite_phi_out_of_ssa): Likewise.
	(rewrite_degenerate_phi): Likewise.
	(rewrite_reductions_out_of_ssa): Likewise.
	(rewrite_cross_bb_scalar_dependence): Likewise.
	(handle_scalar_deps_crossing_scop_limits): Likewise.
	(rewrite_cross_bb_scalar_deps): Likewise.
	(nb_data_writes_in_bb): Likewise.
	(split_pbb): Likewise.
	(split_reduction_stmt): Likewise.
	(is_reduction_operation_p): Likewise.
	(phi_contains_arg): Likewise.
	(follow_ssa_with_commutative_ops): Likewise.
	(detect_commutative_reduction_arg): Likewise.
	(detect_commutative_reduction_assign): Likewise.
	(follow_inital_value_to_phi): Likewise.
	(edge_initial_value_for_loop_phi): Likewise.
	(initial_value_for_loop_phi): Likewise.
	(used_outside_reduction): Likewise.
	(detect_commutative_reduction): Likewise.
	(translate_scalar_reduction_to_array_for_stmt): Likewise.
	(remove_phi): Likewise.
	(dr_indices_valid_in_loop): Likewise.
	(close_phi_written_to_memory): Likewise.
	(translate_scalar_reduction_to_array): Likewise.
	(rewrite_commutative_reductions_out_of_ssa_close_phi): Likewise.
	(scop_ivs_can_be_represented): Likewise.
	* internal-fn.c (get_multi_vector_move): Likewise.
	(expand_LOAD_LANES): Likewise.
	(expand_STORE_LANES): Likewise.
	(expand_ANNOTATE): Likewise.
	(expand_GOMP_SIMD_LANE): Likewise.
	(expand_GOMP_SIMD_VF): Likewise.
	(expand_GOMP_SIMD_LAST_LANE): Likewise.
	(expand_UBSAN_NULL): Likewise.
	(ubsan_expand_si_overflow_addsub_check): Likewise.
	(ubsan_expand_si_overflow_neg_check): Likewise.
	(ubsan_expand_si_overflow_mul_check): Likewise.
	(expand_UBSAN_CHECK_ADD): Likewise.
	(expand_UBSAN_CHECK_SUB): Likewise.
	(expand_UBSAN_CHECK_MUL): Likewise.
	(expand_LOOP_VECTORIZED): Likewise.
	(expand_MASK_LOAD): Likewise.
	(expand_MASK_STORE): Likewise.
	(expand_ABNORMAL_DISPATCHER): Likewise.
	(expand_BUILTIN_EXPECT): Likewise.
	* internal-fn.h (internal_fn_flags): Likewise.
	* ipa-inline-analysis.c (mark_modified): Likewise.
	(unmodified_parm_1): Likewise.
	(unmodified_parm): Likewise.
	(unmodified_parm_or_parm_agg_item): Likewise.
	(set_cond_stmt_execution_predicate): Likewise.
	(set_switch_stmt_execution_predicate): Likewise.
	(will_be_nonconstant_expr_predicate): Likewise.
	(will_be_nonconstant_predicate): Likewise.
	(record_modified): Likewise.
	(phi_result_unknown_predicate): Likewise.
	(array_index_predicate): Likewise.
	(find_foldable_builtin_expect): Likewise.
	(clobber_only_eh_bb_p): Likewise.
	(estimate_function_body_sizes): Likewise.
	* ipa-inline.c (inline_small_functions): Likewise.
	* ipa-profile.c (ipa_profile_generate_summary): Likewise.
	* ipa-prop.c (ipa_binfo_from_known_type_jfunc): Likewise.
	(stmt_may_be_vtbl_ptr_store): Likewise.
	(check_stmt_for_type_change): Likewise.
	(detect_type_change): Likewise.
	(mark_modified): Likewise.
	(parm_preserved_before_stmt_p): Likewise.
	(load_from_unmodified_param): Likewise.
	(parm_ref_data_preserved_p): Likewise.
	(parm_ref_data_pass_through_p): Likewise.
	(ipa_load_from_parm_agg_1): Likewise.
	(ipa_load_from_parm_agg): Likewise.
	(compute_complex_assign_jump_func): Likewise.
	(get_ancestor_addr_info): Likewise.
	(compute_complex_ancestor_jump_func): Likewise.
	(get_ssa_def_if_simple_copy): Likewise.
	(determine_known_aggregate_parts): Likewise.
	(ipa_compute_jump_functions_for_edge): Likewise.
	(ipa_compute_jump_functions): Likewise.
	(ipa_is_ssa_with_stmt_def): Likewise.
	(ipa_note_param_call): Likewise.
	(ipa_analyze_indirect_call_uses): Likewise.
	(ipa_analyze_virtual_call_uses): Likewise.
	(ipa_analyze_call_uses): Likewise.
	(ipa_analyze_stmt_uses): Likewise.
	(ipa_analyze_params_uses): Likewise.
	(ipa_analyze_node): Likewise.
	(ipa_modify_formal_parameters): Likewise.
	(ipa_modify_call_arguments): Likewise.
	(ipcp_transform_function): Likewise.
	* ipa-prop.h (ipa_get_agg_replacements_for_node): Likewise.
	* ipa-pure-const.c (special_builtin_state): Likewise.
	(check_call): Likewise.
	(check_load): Likewise.
	(check_store): Likewise.
	(check_ipa_load): Likewise.
	(check_stmt): Likewise.
	* ipa-ref.c (statement): Likewise.
	(ipa_record_reference): Likewise.
	(ipa_dump_referring): Likewise.
	(ipa_ref_has_aliases_p): Likewise.
	(ipa_find_reference): Likewise.
	* ipa-ref.h (Copyright): Likewise.
	(ENUM_BITFIELD): Likewise.
	(ipa_clone_referring): Likewise.
	(ipa_ref_has_aliases_p): Likewise.
	(ipa_remove_stmt_references): Likewise.
	* ipa-split.c (test_nonssa_use): Likewise.
	(verify_non_ssa_vars): Likewise.
	(check_forbidden_calls): Likewise.
	(consider_split): Likewise.
	(find_return_bb): Likewise.
	(find_retval): Likewise.
	(visit_bb): Likewise.
	(split_function): Likewise.
	(execute_split_functions): Likewise.
	* lto-streamer-in.c (input_ssa_names): Likewise.
	(fixup_call_stmt_edges_1): Likewise.
	(input_function): Likewise.
	* lto-streamer-out.c (output_function): Likewise.
	* omp-low.c (Copyright): Likewise.
	(is_combined_parallel): Likewise.
	(workshare_safe_to_combine_p): Likewise.
	(determine_parallel_type): Likewise.
	(free_omp_regions): Likewise.
	(new_omp_context): Likewise.
	(finalize_task_copyfn): Likewise.
	(find_combined_for): Likewise.
	(scan_omp_parallel): Likewise.
	(scan_omp_task): Likewise.
	(scan_omp_for): Likewise.
	(scan_omp_sections): Likewise.
	(scan_omp_single): Likewise.
	(scan_omp_target): Likewise.
	(scan_omp_teams): Likewise.
	(scan_omp_1_stmt): Likewise.
	(scan_omp): Likewise.
	(build_omp_barrier): Likewise.
	(lower_rec_input_clauses): Likewise.
	(lower_lastprivate_clauses): Likewise.
	(lower_reduction_clauses): Likewise.
	(lower_send_shared_vars): Likewise.
	(gimple_build_cond_empty): Likewise.
	(expand_parallel_call): Likewise.
	(maybe_catch_exception): Likewise.
	(remove_exit_barrier): Likewise.
	(remove_exit_barriers): Likewise.
	(optimize_omp_library_calls): Likewise.
	(expand_omp_build_assign): Likewise.
	(expand_omp_taskreg): Likewise.
	(expand_omp_for_init_counts): Likewise.
	(expand_omp_for_init_vars): Likewise.
	(extract_omp_for_update_vars): Likewise.
	(expand_omp_for_generic): Likewise.
	(expand_omp_for_static_nochunk): Likewise.
	(expand_omp_for_static_chunk): Likewise.
	(expand_omp_simd): Likewise.
	(expand_omp_sections): Likewise.
	(expand_omp_atomic_load): Likewise.
	(expand_omp_atomic_store): Likewise.
	(expand_omp_atomic_fetch_op): Likewise.
	(expand_omp_atomic_pipeline): Likewise.
	(expand_omp_atomic_mutex): Likewise.
	(expand_omp_atomic): Likewise.
	(expand_omp_target): Likewise.
	(expand_omp): Likewise.
	(build_omp_regions_1): Likewise.
	(maybe_add_implicit_barrier_cancel): Likewise.
	(lower_omp_sections): Likewise.
	(lower_omp_single_simple): Likewise.
	(lower_omp_single): Likewise.
	(lower_omp_master): Likewise.
	(lower_omp_taskgroup): Likewise.
	(lower_omp_ordered): Likewise.
	(lower_omp_critical): Likewise.
	(lower_omp_for): Likewise.
	(check_combined_parallel): Likewise.
	(task_copyfn_remap_type): Likewise.
	(create_task_copyfn): Likewise.
	(lower_depend_clauses): Likewise.
	(lower_omp_taskreg): Likewise.
	(lower_omp_target): Likewise.
	(lower_omp_teams): Likewise.
	(lower_omp_1): Likewise.
	(make_pass_lower_omp): Likewise.
	(diagnose_sb_1): Likewise.
	(diagnose_sb_2): Likewise.
	(make_gimple_omp_edges): Likewise.
	(simd_clone_init_simd_arrays): Likewise.
	(ipa_simd_modify_stmt_ops): Likewise.
	(ipa_simd_modify_function_body): Likewise.
	(simd_clone_adjust): Likewise.
	* passes.c (execute_ipa_pass_list): Likewise.
	(execute_ipa_stmt_fixups): Likewise.
	* predict.c (get_base_value): Likewise.
	(expr_coherent_p): Likewise.
	(predict_iv_comparison): Likewise.
	(predict_extra_loop_exits): Likewise.
	(predict_loops): Likewise.
	(expr_expected_value_1): Likewise.
	(tree_predict_by_opcode): Likewise.
	(apply_return_prediction): Likewise.
	(tree_bb_level_predictions): Likewise.
	(tree_estimate_probability_bb): Likewise.
	(make_pass_profile): Likewise.
	* profile.c (compute_value_histograms): Likewise.
	(branch_prob): Likewise.
	* sese.c (sese_build_liveouts_bb): Likewise.
	(sese_reset_debug_liveouts_bb): Likewise.
	(sese_add_exit_phis_edge): Likewise.
	(set_rename): Likewise.
	(graphite_copy_stmts_from_block): Likewise.
	(set_ifsese_condition): Likewise.
	(scalar_evolution_in_region): Likewise.
	* sese.h (bb_in_sese_p): Likewise.
	(defined_in_sese_p): Likewise.
	(recompute_all_dominators): Likewise.
	* ssa-iterators.h (single_imm_use_1): Likewise.
	(set_ssa_use_from_ptr): Likewise.
	(relink_imm_use): Likewise.
	(has_single_use): Likewise.
	(clear_and_done_ssa_iter): Likewise.
	(op_iter_init): Likewise.
	(op_iter_init_use): Likewise.
	(op_iter_init_def): Likewise.
	(op_iter_init_tree): Likewise.
	(single_ssa_tree_operand): Likewise.
	(single_ssa_use_operand): Likewise.
	(single_ssa_def_operand): Likewise.
	(zero_ssa_operands): Likewise.
	(num_ssa_operands): Likewise.
	(single_phi_def): Likewise.
	(op_iter_init_phiuse): Likewise.
	(link_use_stmts_after): Likewise.
	(first_imm_use_stmt): Likewise.
	(next_imm_use_on_stmt): Likewise.
	* stmt.c (reset_out_edges_aux): Likewise.
	(compute_cases_per_edge): Likewise.
	* tracer.c (ignore_bb_p): Likewise.
	(count_insns): Likewise.
	* trans-mem.c (is_tm_safe): Likewise.
	(is_tm_ending_fndecl): Likewise.
	(is_tm_ending): Likewise.
	(is_tm_load): Likewise.
	(is_tm_simple_load): Likewise.
	(is_tm_store): Likewise.
	(tm_malloc_replacement): Likewise.
	(diagnose_tm_1): Likewise.
	(transaction_invariant_address_p): Likewise.
	(tm_log_add): Likewise.
	(gimplify_addr): Likewise.
	(tm_log_emit_stmt): Likewise.
	(tm_log_emit): Likewise.
	(tm_log_emit_saves): Likewise.
	(tm_log_emit_restores): Likewise.
	(thread_private_new_memory): Likewise.
	(examine_assign_tm): Likewise.
	(examine_call_tm): Likewise.
	(lower_transaction): Likewise.
	(lower_sequence_tm): Likewise.
	(lower_sequence_no_tm): Likewise.
	(make_pass_lower_tm): Likewise.
	(tm_region_init_1): Likewise.
	(tm_region_init): Likewise.
	(transaction_subcode_ior): Likewise.
	(build_tm_load): Likewise.
	(build_tm_store): Likewise.
	(expand_assign_tm): Likewise.
	(expand_call_tm): Likewise.
	(expand_block_tm): Likewise.
	(expand_transaction): Likewise.
	(make_pass_tm_mark): Likewise.
	(expand_block_edges): Likewise.
	(expand_regions): Likewise.
	(tm_memopt_accumulate_memops): Likewise.
	(tm_memopt_compute_antic): Likewise.
	(dump_tm_memopt_transform): Likewise.
	(tm_memopt_transform_blocks): Likewise.
	(ipa_uninstrument_transaction): Likewise.
	(ipa_tm_scan_calls_block): Likewise.
	(ipa_tm_scan_irr_block): Likewise.
	(ipa_tm_decrement_clone_counts): Likewise.
	(ipa_tm_diagnose_transaction): Likewise.
	(ipa_tm_insert_irr_call): Likewise.
	(ipa_tm_insert_gettmclone_call): Likewise.
	(ipa_tm_transform_calls_redirect): Likewise.
	(ipa_tm_transform_calls_1): Likewise.
	* trans-mem.h (is_tm_ending): Likewise.
	* tree-affine.c (aff_combination_expand): Likewise.
	* tree-call-cdce.c (check_target_format): Likewise.
	(check_pow): Likewise.
	(check_builtin_call): Likewise.
	(is_call_dce_candidate): Likewise.
	(gen_one_condition): Likewise.
	(gen_conditions_for_domain): Likewise.
	(gen_conditions_for_pow_cst_base): Likewise.
	(gen_conditions_for_pow_int_base): Likewise.
	(get_no_error_domain): Likewise.
	(gen_shrink_wrap_conditions): Likewise.
	(shrink_wrap_one_built_in_call): Likewise.
	(shrink_wrap_conditional_dead_built_in_calls): Likewise.
	* tree-cfg.c (verify_gimple_transaction): Likewise.
	(find_case_label_for_value): Likewise.
	(replace_loop_annotate): Likewise.
	(make_pass_build_cfg): Likewise.
	(assert_unreachable_fallthru_edge_p): Likewise.
	(make_blocks): Likewise.
	(fold_cond_expr_cond): Likewise.
	(get_abnormal_succ_dispatcher): Likewise.
	(handle_abnormal_edges): Likewise.
	(make_edges): Likewise.
	(assign_discriminators): Likewise.
	(make_cond_expr_edges): Likewise.
	(end_recording_case_labels): Likewise.
	(make_gimple_switch_edges): Likewise.
	(label_to_block_fn): Likewise.
	(make_goto_expr_edges): Likewise.
	(make_gimple_asm_edges): Likewise.
	(cleanup_dead_labels): Likewise.
	(group_case_labels): Likewise.
	(gimple_can_merge_blocks_p): Likewise.
	(replace_uses_by): Likewise.
	(gimple_merge_blocks): Likewise.
	(single_noncomplex_succ): Likewise.
	(remove_bb): Likewise.
	(find_taken_edge): Likewise.
	(find_taken_edge_switch_expr): Likewise.
	(debug_cfg_stats): Likewise.
	(call_can_make_abnormal_goto): Likewise.
	(stmt_can_make_abnormal_goto): Likewise.
	(is_ctrl_stmt): Likewise.
	(is_ctrl_altering_stmt): Likewise.
	(simple_goto_p): Likewise.
	(stmt_starts_bb_p): Likewise.
	(delete_tree_cfg_annotations): Likewise.
	(first_stmt): Likewise.
	(first_non_label_stmt): Likewise.
	(last_stmt): Likewise.
	(last_and_only_stmt): Likewise.
	(reinstall_phi_args): Likewise.
	(valid_fixed_convert_types_p): Likewise.
	(verify_gimple_comparison): Likewise.
	(verify_gimple_assign_unary): Likewise.
	(verify_gimple_assign_binary): Likewise.
	(verify_gimple_assign_ternary): Likewise.
	(verify_gimple_assign_single): Likewise.
	(verify_gimple_assign): Likewise.
	(verify_gimple_return): Likewise.
	(verify_gimple_goto): Likewise.
	(verify_gimple_switch): Likewise.
	(verify_gimple_debug): Likewise.
	(verify_gimple_label): Likewise.
	(verify_gimple_stmt): Likewise.
	(verify_gimple_in_seq_2): Likewise.
	(verify_gimple_in_cfg): Likewise.
	(gimple_verify_flow_info): Likewise.
	(gimple_make_forwarder_block): Likewise.
	(gimple_block_label): Likewise.
	(gimple_try_redirect_by_replacing_jump): Likewise.
	(gimple_redirect_edge_and_branch): Likewise.
	(gimple_split_block): Likewise.
	(gimple_split_block_before_cond_jump): Likewise.
	(gimple_duplicate_bb): Likewise.
	(add_phi_args_after_copy_edge): Likewise.
	(gimple_duplicate_sese_tail): Likewise.
	(move_stmt_r): Likewise.
	(move_block_to_fn): Likewise.
	(find_outermost_region_in_block): Likewise.
	(gimple_block_ends_with_condjump_p): Likewise.
	(gimple_flow_call_edges_add): Likewise.
	(gimple_purge_dead_eh_edges): Likewise.
	(gimple_purge_dead_abnormal_call_edges): Likewise.
	(gimple_lv_adjust_loop_header_phi): Likewise.
	(gimple_lv_add_condition_to_bb): Likewise.
	(extract_true_false_edges_from_block): Likewise.
	(do_warn_unused_result): Likewise.
	(execute_fixup_cfg): Likewise.
	(make_pass_fixup_cfg): Likewise.
	(gt_ggc_mx): Likewise.
	* tree-cfg.h (group_case_labels_stmt): Likewise.
	(notice_special_calls): Likewise.
	(computed_goto_p): Likewise.
	(stmt_can_make_abnormal_goto): Likewise.
	(is_ctrl_stmt): Likewise.
	(is_ctrl_altering_stmt): Likewise.
	(simple_goto_p): Likewise.
	(stmt_ends_bb_p): Likewise.
	(delete_tree_cfg_annotations): Likewise.
	(first_stmt): Likewise.
	(last_stmt): Likewise.
	* tree-cfgcleanup.c (cleanup_control_expr_graph): Likewise.
	(cleanup_control_flow_bb): Likewise.
	(tree_forwarder_block_p): Likewise.
	(phi_alternatives_equal): Likewise.
	(remove_forwarder_block): Likewise.
	(fixup_noreturn_call): Likewise.
	(split_bbs_on_noreturn_calls): Likewise.
	(remove_forwarder_block_with_phi): Likewise.
	* tree-cfgcleanup.h (fixup_noreturn_call): Likewise.
	* tree-chrec.c (nb_vars_in_chrec): Likewise.
	(convert_affine_scev): Likewise.
	(chrec_convert_rhs): Likewise.
	(chrec_convert): Likewise.
	* tree-chrec.h (tree_is_chrec): Likewise.
	* tree-complex.c (init_dont_simulate_again): Likewise.
	(complex_visit_stmt): Likewise.
	(set_component_ssa_name): Likewise.
	(extract_component): Likewise.
	(update_complex_assignment): Likewise.
	(update_phi_components): Likewise.
	(expand_complex_move): Likewise.
	(expand_complex_libcall): Likewise.
	(expand_complex_div_wide): Likewise.
	(expand_complex_comparison): Likewise.
	(expand_complex_asm): Likewise.
	(expand_complex_operations_1): Likewise.
	* tree-core.h (GTY): Likewise.
	* tree-data-ref.c (split_constant_offset_1): Likewise.
	(dr_analyze_innermost): Likewise.
	(free_data_ref): Likewise.
	(compute_all_dependences): Likewise.
	(get_references_in_stmt): Likewise.
	(find_data_references_in_stmt): Likewise.
	(find_data_references_in_bb): Likewise.
	* tree-data-ref.h (am_vector_index_for_loop): Likewise.
	* tree-dfa.c (renumber_gimple_stmt_uids): Likewise.
	(renumber_gimple_stmt_uids_in_blocks): Likewise.
	(collect_dfa_stats): Likewise.
	(get_addr_base_and_unit_offset): Likewise.
	* tree-dfa.h (stmt_references_abnormal_ssa_name): Likewise.
	* tree-eh.c (Copyright): Likewise.
	(add_stmt_to_eh_lp_fn): Likewise.
	(add_stmt_to_eh_lp): Likewise.
	(record_stmt_eh_region): Likewise.
	(remove_stmt_from_eh_lp_fn): Likewise.
	(remove_stmt_from_eh_lp): Likewise.
	(lookup_stmt_eh_lp_fn): Likewise.
	(lookup_stmt_eh_lp): Likewise.
	(record_in_finally_tree): Likewise.
	(collect_finally_tree_1): Likewise.
	(collect_finally_tree): Likewise.
	(outside_finally_tree): Likewise.
	(replace_goto_queue_cond_clause): Likewise.
	(record_in_goto_queue_label): Likewise.
	(maybe_record_in_goto_queue): Likewise.
	(do_return_redirection): Likewise.
	(do_goto_redirection): Likewise.
	(emit_post_landing_pad): Likewise.
	(emit_resx): Likewise.
	(emit_eh_dispatch): Likewise.
	(eh_region_may_contain_throw): Likewise.
	(frob_into_branch_around): Likewise.
	(lower_try_finally_dup_block): Likewise.
	(lower_try_finally_fallthru_label): Likewise.
	(get_eh_else): Likewise.
	(honor_protect_cleanup_actions): Likewise.
	(lower_try_finally_nofallthru): Likewise.
	(lower_try_finally_onedest): Likewise.
	(lower_try_finally_copy): Likewise.
	(lower_try_finally_switch): Likewise.
	(decide_copy_try_finally): Likewise.
	(cleanup_is_dead_in): Likewise.
	(lower_try_finally): Likewise.
	(lower_catch): Likewise.
	(lower_eh_filter): Likewise.
	(lower_eh_must_not_throw): Likewise.
	(lower_cleanup): Likewise.
	(lower_eh_constructs_2): Likewise.
	(make_pass_lower_eh): Likewise.
	(make_eh_dispatch_edges): Likewise.
	(redirect_eh_edge_1): Likewise.
	(redirect_eh_edge): Likewise.
	(tree_could_trap_p): Likewise.
	(stmt_could_throw_1_p): Likewise.
	(tree_could_throw_p): Likewise.
	(stmt_can_throw_external): Likewise.
	(stmt_can_throw_internal): Likewise.
	(maybe_clean_eh_stmt_fn): Likewise.
	(maybe_clean_eh_stmt): Likewise.
	(maybe_clean_or_replace_eh_stmt): Likewise.
	(maybe_duplicate_eh_stmt_fn): Likewise.
	(same_handler_p): Likewise.
	(optimize_double_finally): Likewise.
	(refactor_eh_r): Likewise.
	(make_pass_refactor_eh): Likewise.
	(lower_resx): Likewise.
	(optimize_clobbers): Likewise.
	(sink_clobbers): Likewise.
	(lower_eh_dispatch): Likewise.
	(mark_reachable_handlers): Likewise.
	(unsplit_eh): Likewise.
	(cleanup_empty_eh_merge_phis): Likewise.
	(cleanup_empty_eh_unsplit): Likewise.
	(cleanup_empty_eh): Likewise.
	(make_pass_cleanup_eh): Likewise.
	(verify_eh_edges): Likewise.
	* tree-eh.h (add_stmt_to_eh_lp): Likewise.
	(remove_stmt_from_eh_lp_fn): Likewise.
	(remove_stmt_from_eh_lp): Likewise.
	(lookup_stmt_eh_lp_fn): Likewise.
	(lookup_stmt_eh_lp): Likewise.
	(make_eh_dispatch_edges): Likewise.
	(make_eh_edges): Likewise.
	(redirect_eh_dispatch_edge): Likewise.
	(stmt_could_throw_p): Likewise.
	(stmt_can_throw_external): Likewise.
	(stmt_can_throw_internal): Likewise.
	(maybe_clean_eh_stmt_fn): Likewise.
	(maybe_clean_eh_stmt): Likewise.
	(maybe_clean_or_replace_eh_stmt): Likewise.
	(maybe_duplicate_eh_stmt_fn): Likewise.
	(maybe_duplicate_eh_stmt): Likewise.
	(verify_eh_edges): Likewise.
	(verify_eh_dispatch_edge): Likewise.
	* tree-emutls.c (gen_emutls_addr): Likewise.
	(lower_emutls_1): Likewise.
	(lower_emutls_stmt): Likewise.
	* tree-if-conv.c (ifc_temp_var): Likewise.
	(parse_predicate): Likewise.
	(bb_with_exit_edge_p): Likewise.
	(if_convertible_phi_p): Likewise.
	(memrefs_read_or_written_unconditionally): Likewise.
	(write_memrefs_written_at_least_once): Likewise.
	(ifcvt_memrefs_wont_trap): Likewise.
	(ifcvt_could_trap_p): Likewise.
	(ifcvt_can_use_mask_load_store): Likewise.
	(if_convertible_gimple_assign_stmt_p): Likewise.
	(predicate_bbs): Likewise.
	(find_phi_replacement_condition): Likewise.
	(predicate_scalar_phi): Likewise.
	(predicate_all_scalar_phis): Likewise.
	(predicate_mem_writes): Likewise.
	(version_loop_for_if_conversion): Likewise.
	* tree-inline.c (copy_decl_maybe_to_var): Likewise.
	(remap_ssa_name): Likewise.
	(remap_gimple_seq): Likewise.
	(copy_gimple_bind): Likewise.
	(remap_eh_region_tree_nr): Likewise.
	(remap_gimple_stmt): Likewise.
	(copy_bb): Likewise.
	(update_ssa_across_abnormal_edges): Likewise.
	(copy_edges_for_bb): Likewise.
	(copy_phis_for_bb): Likewise.
	(maybe_move_debug_stmts_to_successors): Likewise.
	(copy_cfg_body): Likewise.
	(copy_debug_stmts): Likewise.
	(self_inlining_addr_expr): Likewise.
	(insert_init_debug_bind): Likewise.
	(insert_init_stmt): Likewise.
	(setup_one_parameter): Likewise.
	(inline_forbidden_p_stmt): Likewise.
	(inline_forbidden_p): Likewise.
	(estimate_operator_cost): Likewise.
	(add_local_variables): Likewise.
	(expand_call_inline): Likewise.
	(gimple_expand_calls_inline): Likewise.
	(fold_marked_statements): Likewise.
	(mark_local_labels_stmt): Likewise.
	(replace_locals_stmt): Likewise.
	(tree_function_versioning): Likewise.
	* tree-inline.h (tree): Likewise.
	(void): Likewise.
	(estimate_num_insns): Likewise.
	* tree-into-ssa.c (marked_for_renaming): Likewise.
	(rewrite_uses_p): Likewise.
	(set_rewrite_uses): Likewise.
	(register_defs_p): Likewise.
	(initialize_flags_in_bb): Likewise.
	(add_new_name_mapping): Likewise.
	(find_def_blocks_for): Likewise.
	(insert_phi_nodes_for): Likewise.
	(get_reaching_def): Likewise.
	(rewrite_debug_stmt_uses): Likewise.
	(rewrite_stmt): Likewise.
	(rewrite_add_phi_arguments): Likewise.
	(maybe_replace_use_in_debug_stmt): Likewise.
	(maybe_register_def): Likewise.
	(rewrite_update_phi_arguments): Likewise.
	(make_pass_build_ssa): Likewise.
	(mark_def_interesting): Likewise.
	(prepare_block_for_update): Likewise.
	(prepare_use_sites_for): Likewise.
	(prepare_def_site_for): Likewise.
	(delete_update_ssa): Likewise.
	(mark_virtual_operand_for_renaming): Likewise.
	* tree-into-ssa.h (create_new_def_for): Likewise.
	(mark_virtual_phi_result_for_renaming): Likewise.
	* tree-loop-distribution.c (Copyright): Likewise.
	(dot_rdg): Likewise.
	(create_edge_for_control_dependence): Likewise.
	(create_rdg_cd_edges): Likewise.
	(create_rdg_vertices): Likewise.
	(stmts_from_loop): Likewise.
	(build_rdg): Likewise.
	(ssa_name_has_uses_outside_loop_p): Likewise.
	(generate_loops_for_partition): Likewise.
	(generate_memset_builtin): Likewise.
	(generate_memcpy_builtin): Likewise.
	(destroy_loop): Likewise.
	(classify_partition): Likewise.
	(similar_memory_accesses): Likewise.
	(rdg_build_partitions): Likewise.
	(pgcmp): Likewise.
	(distribute_loop): Likewise.
	* tree-nested.c (get_chain_field): Likewise.
	(init_tmp_var): Likewise.
	(save_tmp_var): Likewise.
	(walk_function): Likewise.
	(convert_nonlocal_reference_stmt): Likewise.
	(convert_local_reference_stmt): Likewise.
	(convert_nl_goto_reference): Likewise.
	(convert_nl_goto_receiver): Likewise.
	(convert_tramp_reference_op): Likewise.
	(convert_tramp_reference_stmt): Likewise.
	(convert_gimple_call): Likewise.
	(finalize_nesting_tree_1): Likewise.
	* tree-nrv.c (finalize_nrv_r): Likewise.
	(make_pass_nrv): Likewise.
	(dest_safe_for_nrv_p): Likewise.
	* tree-object-size.c (pass_through_call): Likewise.
	(addr_object_size): Likewise.
	(alloc_object_size): Likewise.
	(cond_expr_object_size): Likewise.
	(expr_object_size): Likewise.
	(merge_object_sizes): Likewise.
	(plus_stmt_object_size): Likewise.
	(collect_object_sizes_for): Likewise.
	(check_for_plus_in_loops_1): Likewise.
	(check_for_plus_in_loops): Likewise.
	(fini_object_sizes): Likewise.
	* tree-outof-ssa.c (ssa_is_replaceable_p): Likewise.
	(set_location_for_edge): Likewise.
	(eliminate_build): Likewise.
	(eliminate_phi): Likewise.
	(remove_gimple_phi_args): Likewise.
	(eliminate_useless_phis): Likewise.
	(rewrite_trees): Likewise.
	(maybe_renumber_stmts_bb): Likewise.
	(trivially_conflicts_p): Likewise.
	(insert_backedge_copies): Likewise.
	* tree-outof-ssa.h (get_rtx_for_ssa_name): Likewise.
	(get_gimple_for_ssa_name): Likewise.
	* tree-parloops.c (printf): Likewise.
	(return): Likewise.
	(take_address_of): Likewise.
	(eliminate_local_variables_stmt): Likewise.
	(separate_decls_in_region_name): Likewise.
	(separate_decls_in_region_stmt): Likewise.
	(create_phi_for_local_result): Likewise.
	(create_call_for_reduction_1): Likewise.
	(create_loads_for_reductions): Likewise.
	(create_final_loads_for_reduction): Likewise.
	(create_stores_for_reduction): Likewise.
	(create_loads_and_stores_for_name): Likewise.
	(separate_decls_in_region): Likewise.
	(transform_to_exit_first_loop): Likewise.
	(create_parallel_loop): Likewise.
	(gen_parallel_loop): Likewise.
	(loop_has_vector_phi_nodes): Likewise.
	(gather_scalar_reductions): Likewise.
	(try_create_reduction_list): Likewise.
	* tree-pass.h (void): Likewise.
	(ipa_opt_pass_d): Likewise.
	(execute_all_ipa_stmt_fixups): Likewise.
	* tree-phinodes.c (GTY): Likewise.
	(ideal_phi_node_len): Likewise.
	(make_phi_node): Likewise.
	(reserve_phi_args_for_new_edge): Likewise.
	(add_phi_node_to_bb): Likewise.
	(create_phi_node): Likewise.
	(remove_phi_node): Likewise.
	(remove_phi_nodes): Likewise.
	* tree-phinodes.h (release_phi_node): Likewise.
	(add_phi_node_to_bb): Likewise.
	(add_phi_arg): Likewise.
	(degenerate_phi_result): Likewise.
	(gimple_phi_arg_imm_use_ptr): Likewise.
	(phi_arg_index_from_use): Likewise.
	* tree-predcom.c (computations): Likewise.
	(valid_initializer_p): Likewise.
	(find_looparound_phi): Likewise.
	(add_looparound_copies): Likewise.
	(determine_roots): Likewise.
	(replace_ref_with): Likewise.
	(initialize_root_vars): Likewise.
	(initialize_root_vars_lm): Likewise.
	(execute_load_motion): Likewise.
	(single_nonlooparound_use): Likewise.
	(remove_stmt): Likewise.
	(base_names_in_chain_on): Likewise.
	(eliminate_temp_copies): Likewise.
	(chain_can_be_combined_p): Likewise.
	(find_use_stmt): Likewise.
	(may_reassociate_p): Likewise.
	(find_associative_operation_root): Likewise.
	(find_common_use_stmt): Likewise.
	(combinable_refs_p): Likewise.
	(remove_name_from_operation): Likewise.
	(reassociate_to_the_same_stmt): Likewise.
	(stmt_combining_refs): Likewise.
	(combine_chains): Likewise.
	* tree-profile.c (gimple_gen_edge_profiler): Likewise.
	(gimple_gen_interval_profiler): Likewise.
	(gimple_gen_pow2_profiler): Likewise.
	(gimple_gen_one_value_profiler): Likewise.
	(gimple_gen_ic_profiler): Likewise.
	(gimple_gen_ic_func_profiler): Likewise.
	(gimple_gen_time_profiler): Likewise.
	(gimple_gen_average_profiler): Likewise.
	(gimple_gen_ior_profiler): Likewise.
	(tree_profiling): Likewise.
	* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop):
	Likewise.
	(get_scalar_evolution): Likewise.
	(add_to_evolution_1): Likewise.
	(add_to_evolution): Likewise.
	(get_loop_exit_condition): Likewise.
	(follow_ssa_edge_binary): Likewise.
	(follow_ssa_edge_expr): Likewise.
	(follow_ssa_edge_in_rhs): Likewise.
	(backedge_phi_arg_p): Likewise.
	(follow_ssa_edge_in_condition_phi_branch): Likewise.
	(follow_ssa_edge_in_condition_phi): Likewise.
	(follow_ssa_edge_inner_loop_phi): Likewise.
	(simplify_peeled_chrec): Likewise.
	(analyze_evolution_in_loop): Likewise.
	(analyze_initial_condition): Likewise.
	(interpret_loop_phi): Likewise.
	(interpret_condition_phi): Likewise.
	(interpret_rhs_expr): Likewise.
	(interpret_expr): Likewise.
	(analyze_scalar_evolution_1): Likewise.
	(loop_closed_phi_def): Likewise.
	(scev_const_prop): Likewise.
	* tree-scalar-evolution.h (number_of_latch_executions): Likewise.
	* tree-sra.c (representatives): Likewise.
	(get_ssa_base_param): Likewise.
	(create_access_1): Likewise.
	(disqualify_base_of_expr): Likewise.
	(build_access_from_expr_1): Likewise.
	(single_non_eh_succ): Likewise.
	(disqualify_if_bad_bb_terminating_stmt): Likewise.
	(build_accesses_from_assign): Likewise.
	(asm_visit_addr): Likewise.
	(scan_function): Likewise.
	(build_ref_for_offset): Likewise.
	(generate_subtree_copies): Likewise.
	(init_subtree_with_zero): Likewise.
	(sra_modify_expr): Likewise.
	(load_assign_lhs_subreplacements): Likewise.
	(contains_vce_or_bfcref_p): Likewise.
	(sra_modify_assign): Likewise.
	(sra_modify_function_body): Likewise.
	(ptr_parm_has_direct_uses): Likewise.
	(get_adjustment_for_base): Likewise.
	(replace_removed_params_ssa_names): Likewise.
	(sra_ipa_modify_assign): Likewise.
	(ipa_sra_modify_function_body): Likewise.
	(sra_ipa_reset_debug_stmts): Likewise.
	(convert_callers): Likewise.
	* tree-ssa-alias.c (ref_may_alias_global_p): Likewise.
	(ao_ref_init_from_ptr_and_size): Likewise.
	(refs_output_dependent_p): Likewise.
	(ref_maybe_used_by_call_p_1): Likewise.
	(ref_maybe_used_by_call_p): Likewise.
	(ref_maybe_used_by_stmt_p): Likewise.
	(call_may_clobber_ref_p_1): Likewise.
	(call_may_clobber_ref_p): Likewise.
	(stmt_may_clobber_ref_p_1): Likewise.
	(stmt_may_clobber_ref_p): Likewise.
	(stmt_kills_ref_p_1): Likewise.
	(stmt_kills_ref_p): Likewise.
	(maybe_skip_until): Likewise.
	(get_continuation_for_phi_1): Likewise.
	(walk_non_aliased_vuses): Likewise.
	(walk_aliased_vdefs_1): Likewise.
	* tree-ssa-alias.h (ref_maybe_used_by_stmt_p): Likewise.
	(stmt_may_clobber_global_p): Likewise.
	(stmt_may_clobber_ref_p): Likewise.
	(stmt_may_clobber_ref_p_1): Likewise.
	(call_may_clobber_ref_p): Likewise.
	(stmt_kills_ref_p): Likewise.
	(get_continuation_for_phi): Likewise.
	* tree-ssa-ccp.c (get_default_value): Likewise.
	(get_value_for_expr): Likewise.
	(likely_value): Likewise.
	(ccp_initialize): Likewise.
	(ccp_lattice_meet): Likewise.
	(valueize_op): Likewise.
	(bit_value_binop): Likewise.
	(bit_value_assume_aligned): Likewise.
	(insert_clobber_before_stack_restore): Likewise.
	(insert_clobbers_for_var): Likewise.
	(ccp_fold_stmt): Likewise.
	(visit_assignment): Likewise.
	(visit_cond_stmt): Likewise.
	(optimize_stack_restore): Likewise.
	(optimize_unreachable): Likewise.
	* tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise.
	(create_outofssa_var_map): Likewise.
	(coalesce_partitions): Likewise.
	* tree-ssa-copy.c (stmt_may_generate_copy): Likewise.
	(dump_copy_of): Likewise.
	(copy_prop_visit_assignment): Likewise.
	(copy_prop_visit_cond_stmt): Likewise.
	(copy_prop_visit_stmt): Likewise.
	(init_copy_prop): Likewise.
	* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Likewise.
	* tree-ssa-dce.c (Copyright): Likewise.
	(mark_stmt_necessary): Likewise.
	(mark_operand_necessary): Likewise.
	(mark_last_stmt_necessary): Likewise.
	(find_obviously_necessary_stmts): Likewise.
	(mark_aliased_reaching_defs_necessary_1): Likewise.
	(mark_all_reaching_defs_necessary_1): Likewise.
	(mark_all_reaching_defs_necessary): Likewise.
	(propagate_necessity): Likewise.
	(remove_dead_phis): Likewise.
	(forward_edge_to_pdom): Likewise.
	(remove_dead_stmt): Likewise.
	(eliminate_unnecessary_stmts): Likewise.
	* tree-ssa-dom.c (Copyright): Likewise.
	(target): Likewise.
	(remove): Likewise.
	(lookup_avail_expr): Likewise.
	(initialize_hash_element): Likewise.
	(iterative_hash_hashable_expr): Likewise.
	(print_expr_hash_elt): Likewise.
	(free_all_edge_infos): Likewise.
	(make_pass_dominator): Likewise.
	(restore_vars_to_original_value): Likewise.
	(record_equivalences_from_phis): Likewise.
	(record_equivalences_from_incoming_edge): Likewise.
	(loop_depth_of_name): Likewise.
	(record_equality): Likewise.
	(simple_iv_increment_p): Likewise.
	(cprop_into_successor_phis): Likewise.
	(record_edge_info): Likewise.
	(eliminate_redundant_computations): Likewise.
	(record_equivalences_from_stmt): Likewise.
	(cprop_operand): Likewise.
	(optimize_stmt): Likewise.
	(avail_expr_hash): Likewise.
	(remove_stmt_or_phi): Likewise.
	(get_rhs_or_phi_arg): Likewise.
	(get_lhs_or_phi_result): Likewise.
	(propagate_rhs_into_lhs): Likewise.
	(eliminate_const_or_copy): Likewise.
	(eliminate_degenerate_phis_1): Likewise.
	* tree-ssa-dom.h (simple_iv_increment_p): Likewise.
	* tree-ssa-dse.c (dse_possible_dead_store_p): Likewise.
	(dse_optimize_stmt): Likewise.
	* tree-ssa-forwprop.c (get_prop_dest_stmt): Likewise.
	(get_prop_source_stmt): Likewise.
	(remove_prop_source_from_use): Likewise.
	(rhs_to_tree): Likewise.
	(combine_cond_expr_cond): Likewise.
	(forward_propagate_into_comparison_1): Likewise.
	(forward_propagate_into_comparison): Likewise.
	(forward_propagate_into_cond): Likewise.
	(combine_cond_exprs): Likewise.
	(forward_propagate_addr_expr_1): Likewise.
	(forward_propagate_addr_expr): Likewise.
	(forward_propagate_comparison): Likewise.
	(simplify_conversion_from_bitmask): Likewise.
	(simplify_not_neg_expr): Likewise.
	(simplify_gimple_switch_label_vec): Likewise.
	(simplify_gimple_switch): Likewise.
	(constant_pointer_difference): Likewise.
	(simplify_builtin_call): Likewise.
	(truth_valued_ssa_name): Likewise.
	(lookup_logical_inverted_value): Likewise.
	(defcodefor_name): Likewise.
	(simplify_bitwise_binary_boolean): Likewise.
	(simplify_bitwise_binary): Likewise.
	(simplify_rotate): Likewise.
	(associate_plusminus): Likewise.
	(associate_pointerplus_align): Likewise.
	(associate_pointerplus_diff): Likewise.
	(associate_pointerplus): Likewise.
	(combine_conversions): Likewise.
	(simplify_vce): Likewise.
	(simplify_bitfield_ref): Likewise.
	(simplify_permutation): Likewise.
	(simplify_vector_constructor): Likewise.
	(simplify_mult): Likewise.
	* tree-ssa-ifcombine.c (bb_no_side_effects_p): Likewise.
	(same_phi_args_p): Likewise.
	(get_name_for_bit_test): Likewise.
	(recognize_single_bit_test): Likewise.
	(recognize_bits_test): Likewise.
	(ifcombine_ifandif): Likewise.
	(tree_ssa_ifcombine_bb): Likewise.
	* tree-ssa-live.c (clear_unused_block_pointer): Likewise.
	(remove_unused_locals): Likewise.
	(set_var_live_on_entry): Likewise.
	(calculate_live_on_exit): Likewise.
	(verify_live_on_entry): Likewise.
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Likewise.
	(do_while_loop_p): Likewise.
	* tree-ssa-loop-im.c (if): Likewise.
	(ref_indep_loop_p): Likewise.
	(init_lim_data): Likewise.
	(free_lim_aux_data): Likewise.
	(clear_lim_data): Likewise.
	(outermost_invariant_loop): Likewise.
	(add_dependency): Likewise.
	(outermost_indep_loop): Likewise.
	(simple_mem_ref_in_stmt): Likewise.
	(mem_ref_in_stmt): Likewise.
	(extract_true_false_args_from_phi): Likewise.
	(determine_max_movement): Likewise.
	(set_level): Likewise.
	(set_profitable_level): Likewise.
	(nonpure_call_p): Likewise.
	(rewrite_reciprocal): Likewise.
	(rewrite_bittest): Likewise.
	(force_move_till_op): Likewise.
	(mem_ref_alloc): Likewise.
	(mark_ref_stored): Likewise.
	(execute_sm_if_changed): Likewise.
	(execute_sm): Likewise.
	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Likewise.
	(tree_estimate_loop_size): Likewise.
	(remove_exits_and_undefined_stmts): Likewise.
	(unloop_loops): Likewise.
	(try_unroll_loop_completely): Likewise.
	(propagate_into_all_uses): Likewise.
	(propagate_constants_for_unrolling): Likewise.
	* tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise.
	(name_info): Likewise.
	(stmt_after_ip_normal_pos): Likewise.
	(stmt_after_inc_pos): Likewise.
	(get_iv): Likewise.
	(find_bivs): Likewise.
	(mark_bivs): Likewise.
	(find_givs_in_stmt_scev): Likewise.
	(find_induction_variables): Likewise.
	(find_interesting_uses_op): Likewise.
	(extract_cond_operands): Likewise.
	(expr_invariant_in_loop_p): Likewise.
	(may_be_nonaddressable_p): Likewise.
	(find_interesting_uses_address): Likewise.
	(find_invariants_stmt): Likewise.
	(find_interesting_uses_outside): Likewise.
	(find_depends): Likewise.
	(add_old_iv_candidates): Likewise.
	(computation_cost): Likewise.
	(determine_common_wider_type): Likewise.
	(get_use_type): Likewise.
	(get_loop_invariant_expr_id): Likewise.
	(determine_use_iv_cost_address): Likewise.
	(expr_equal_p): Likewise.
	(difference_cannot_overflow_p): Likewise.
	(determine_set_costs): Likewise.
	(rewrite_use_nonlinear_expr): Likewise.
	(adjust_iv_update_pos): Likewise.
	(remove_unused_ivs): Likewise.
	(loop_body_includes_call): Likewise.
	* tree-ssa-loop-manip.c (create_iv): Likewise.
	(add_exit_phi): Likewise.
	(find_uses_to_rename_use): Likewise.
	(find_uses_to_rename_bb): Likewise.
	(check_loop_closed_ssa_use): Likewise.
	(verify_loop_closed_ssa): Likewise.
	(split_loop_exit_edge): Likewise.
	(ip_normal_pos): Likewise.
	(standard_iv_increment_position): Likewise.
	(tree_transform_and_unroll_loop): Likewise.
	(rewrite_phi_with_iv): Likewise.
	(canonicalize_loop_ivs): Likewise.
	* tree-ssa-loop-niter.c (determine_value_range): Likewise.
	(bound_difference): Likewise.
	(expand_simple_operations): Likewise.
	(simplify_using_initial_conditions): Likewise.
	(loop_only_exit_p): Likewise.
	(number_of_iterations_exit): Likewise.
	(finite_loop_p): Likewise.
	(chain_of_csts_start): Likewise.
	(get_base_for): Likewise.
	(get_val_for): Likewise.
	(loop_niter_by_eval): Likewise.
	(find_loop_niter_by_eval): Likewise.
	(derive_constant_upper_bound_ops): Likewise.
	(do_warn_aggressive_loop_optimizations): Likewise.
	(record_estimate): Likewise.
	(record_nonwrapping_iv): Likewise.
	(idx_infer_loop_bounds): Likewise.
	(infer_loop_bounds_from_ref): Likewise.
	(infer_loop_bounds_from_array): Likewise.
	(infer_loop_bounds_from_pointer_arith): Likewise.
	(infer_loop_bounds_from_undefined): Likewise.
	(maybe_lower_iteration_bound): Likewise.
	(estimate_numbers_of_iterations): Likewise.
	(stmt_dominates_stmt_p): Likewise.
	(nowrap_type_p): Likewise.
	* tree-ssa-loop-niter.h (stmt_dominates_stmt_p): Likewise.
	(scev_probably_wraps_p): Likewise.
	* tree-ssa-loop-prefetch.c (then): Likewise.
	(find_or_create_group): Likewise.
	(release_mem_refs): Likewise.
	(idx_analyze_ref): Likewise.
	(analyze_ref): Likewise.
	(gather_memory_references): Likewise.
	(issue_prefetch_ref): Likewise.
	(emit_mfence_after_loop): Likewise.
	* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Likewise.
	(simplify_using_entry_checks): Likewise.
	(tree_unswitch_single_loop): Likewise.
	* tree-ssa-loop.h (tree_num_loop_insns): Likewise.
	* tree-ssa-math-opts.c (Copyright): Likewise.
	(compute_merit): Likewise.
	(insert_reciprocals): Likewise.
	(replace_reciprocal): Likewise.
	(execute_cse_reciprocals_1): Likewise.
	(make_pass_cse_reciprocals): Likewise.
	(execute_cse_sincos_1): Likewise.
	(powi_as_mults_1): Likewise.
	(powi_as_mults): Likewise.
	(build_and_insert_call): Likewise.
	(build_and_insert_binop): Likewise.
	(build_and_insert_ref): Likewise.
	(build_and_insert_cast): Likewise.
	(gimple_expand_builtin_cabs): Likewise.
	(do_shift_rotate): Likewise.
	(verify_symbolic_number_p): Likewise.
	(find_bswap_1): Likewise.
	(find_bswap): Likewise.
	(make_pass_optimize_bswap): Likewise.
	(is_widening_mult_rhs_p): Likewise.
	(is_widening_mult_p): Likewise.
	(convert_mult_to_widen): Likewise.
	(convert_plusminus_to_widen): Likewise.
	(convert_mult_to_fma): Likewise.
	* tree-ssa-operands.c (alloc_use): Likewise.
	(add_use_op): Likewise.
	(finalize_ssa_defs): Likewise.
	(cleanup_build_arrays): Likewise.
	(append_vuse): Likewise.
	(add_virtual_operand): Likewise.
	(mark_address_taken): Likewise.
	(get_mem_ref_operands): Likewise.
	(get_tmr_operands): Likewise.
	(maybe_add_call_vops): Likewise.
	(get_asm_stmt_operands): Likewise.
	(get_expr_operands): Likewise.
	(parse_ssa_operands): Likewise.
	(build_ssa_operands): Likewise.
	(verify_ssa_operands): Likewise.
	(free_stmt_operands): Likewise.
	(update_stmt_operands): Likewise.
	(debug_immediate_uses_for): Likewise.
	(unlink_stmt_vdef): Likewise.
	(has_zero_uses_1): Likewise.
	* tree-ssa-operands.h (verify_ssa_operands): Likewise.
	(free_stmt_operands): Likewise.
	(update_stmt_operands): Likewise.
	(swap_ssa_operands): Likewise.
	(unlink_stmt_vdef): Likewise.
	* tree-ssa-phiopt.c (tree_ssa_cs_elim): Likewise.
	(single_non_singleton_phi_for_edges): Likewise.
	(tree_ssa_phiopt_worker): Likewise.
	(replace_phi_edge_with_variable): Likewise.
	(conditional_replacement): Likewise.
	(rhs_is_fed_for_value_replacement): Likewise.
	(operand_equal_for_value_replacement): Likewise.
	(value_replacement): Likewise.
	(minmax_replacement): Likewise.
	(abs_replacement): Likewise.
	(neg_replacement): Likewise.
	(add_or_mark_expr): Likewise.
	(cond_store_replacement): Likewise.
	(cond_if_else_store_replacement_1): Likewise.
	(cond_if_else_store_replacement): Likewise.
	(local_mem_dependence): Likewise.
	(hoist_adjacent_loads): Likewise.
	* tree-ssa-phiprop.c (phivn_valid_p): Likewise.
	(phiprop_insert_phi): Likewise.
	(propagate_with_phi): Likewise.
	* tree-ssa-pre.c (translate_vuse_through_block): Likewise.
	(phi_translate_1): Likewise.
	(value_dies_in_block_x): Likewise.
	(prune_clobbered_mems): Likewise.
	(create_expression_by_pieces): Likewise.
	(insert_into_preds_of_block): Likewise.
	(do_regular_insertion): Likewise.
	(compute_avail): Likewise.
	(eliminate_insert): Likewise.
	(eliminate): Likewise.
	(fini_eliminate): Likewise.
	(mark_operand_necessary): Likewise.
	(remove_dead_inserted_code): Likewise.
	* tree-ssa-propagate.c (block): Likewise.
	(reexamined): Likewise.
	(add_ssa_edge): Likewise.
	(add_control_edge): Likewise.
	(simulate_stmt): Likewise.
	(process_ssa_edge_worklist): Likewise.
	(simulate_block): Likewise.
	(valid_gimple_call_p): Likewise.
	(move_ssa_defining_stmt_for_defs): Likewise.
	(update_gimple_call): Likewise.
	(update_call_from_tree): Likewise.
	(ssa_propagate): Likewise.
	(stmt_makes_single_store): Likewise.
	(replace_uses_in): Likewise.
	(substitute_and_fold): Likewise.
	(may_propagate_copy): Likewise.
	(propagate_tree_value_into_stmt): Likewise.
	* tree-ssa-propagate.h (prop_set_simulate_again): Likewise.
	(prop_simulate_again_p): Likewise.
	* tree-ssa-reassoc.c (reassoc_remove_stmt): Likewise.
	(phi_rank): Likewise.
	(loop_carried_phi): Likewise.
	(get_rank): Likewise.
	(sort_by_operand_rank): Likewise.
	(add_repeat_to_ops_vec): Likewise.
	(get_unary_op): Likewise.
	(eliminate_using_constants): Likewise.
	(oecount_cmp): Likewise.
	(stmt_is_power_of_op): Likewise.
	(decrement_power): Likewise.
	(propagate_op_to_single_use): Likewise.
	(zero_one_operation): Likewise.
	(reassoc_stmt_dominates_stmt_p): Likewise.
	(insert_stmt_after): Likewise.
	(build_and_add_sum): Likewise.
	(undistribute_ops_list): Likewise.
	(eliminate_redundant_comparison): Likewise.
	(optimize_ops_list): Likewise.
	(update_range_test): Likewise.
	(optimize_range_tests): Likewise.
	(final_range_test_p): Likewise.
	(suitable_cond_bb): Likewise.
	(no_side_effect_bb): Likewise.
	(get_ops): Likewise.
	(update_ops): Likewise.
	(maybe_optimize_range_tests): Likewise.
	(is_phi_for_stmt): Likewise.
	(remove_visited_stmt_chain): Likewise.
	(swap_ops_for_binary_stmt): Likewise.
	(find_insert_point): Likewise.
	(rewrite_expr_tree): Likewise.
	(get_reassociation_width): Likewise.
	(rewrite_expr_tree_parallel): Likewise.
	(linearize_expr): Likewise.
	(get_single_immediate_use): Likewise.
	(negate_value): Likewise.
	(should_break_up_subtract): Likewise.
	(break_up_subtract): Likewise.
	(acceptable_pow_call): Likewise.
	(linearize_expr_tree): Likewise.
	(repropagate_negates): Likewise.
	(break_up_subtract_bb): Likewise.
	(compare_repeat_factors): Likewise.
	(attempt_builtin_powi): Likewise.
	(transform_stmt_to_copy): Likewise.
	(reassociate_bb): Likewise.
	* tree-ssa-sccvn.c (vn_get_expr_for): Likewise.
	(ao_ref_init_from_vn_reference): Likewise.
	(copy_reference_ops_from_call): Likewise.
	(vn_reference_maybe_forwprop_address): Likewise.
	(valueize_shared_reference_ops_from_ref): Likewise.
	(vn_reference_lookup_3): Likewise.
	(init_vn_nary_op_from_op): Likewise.
	(vn_nary_length_from_stmt): Likewise.
	(vn_nary_op_lookup): Likewise.
	(vn_nary_op_insert): Likewise.
	(vn_phi_eq): Likewise.
	(vn_phi_lookup): Likewise.
	(mark_use_processed): Likewise.
	(visit_copy): Likewise.
	(visit_nary_op): Likewise.
	(visit_reference_op_call): Likewise.
	(visit_reference_op_load): Likewise.
	(visit_reference_op_store): Likewise.
	(expr_has_constants): Likewise.
	(valueize_expr): Likewise.
	(simplify_binary_expression): Likewise.
	(simplify_unary_expression): Likewise.
	(visit_use): Likewise.
	(compare_ops): Likewise.
	(DFS): Likewise.
	* tree-ssa-sccvn.h (sizeof_vn_nary_op): Likewise.
	(vn_constant_eq_with_type): Likewise.
	* tree-ssa-sink.c (find_bb_for_arg): Likewise.
	(all_immediate_uses_same_place): Likewise.
	(nearest_common_dominator_of_uses): Likewise.
	(select_best_block): Likewise.
	(statement_sink_location): Likewise.
	(sink_code_in_bb): Likewise.
	* tree-ssa-strlen.c (literal): Likewise.
	(tree_map_base_eq): Likewise.
	(get_string_length): Likewise.
	(find_equal_ptrs): Likewise.
	(adjust_last_stmt): Likewise.
	(handle_builtin_strlen): Likewise.
	(handle_builtin_strchr): Likewise.
	(handle_builtin_strcpy): Likewise.
	(handle_builtin_memcpy): Likewise.
	(handle_builtin_strcat): Likewise.
	(handle_pointer_plus): Likewise.
	(handle_char_store): Likewise.
	(strlen_optimize_stmt): Likewise.
	(do_invalidate): Likewise.
	* tree-ssa-structalias.c (new_var_info): Likewise.
	(get_call_vi): Likewise.
	(lookup_call_use_vi): Likewise.
	(lookup_call_clobber_vi): Likewise.
	(get_call_use_vi): Likewise.
	(get_function_part_constraint): Likewise.
	(handle_rhs_call): Likewise.
	(handle_lhs_call): Likewise.
	(handle_const_call): Likewise.
	(handle_pure_call): Likewise.
	(get_fi_for_callee): Likewise.
	(find_func_aliases_for_builtin_call): Likewise.
	(find_func_aliases_for_call): Likewise.
	(find_func_aliases): Likewise.
	(process_ipa_clobber): Likewise.
	(find_func_clobbers): Likewise.
	(compute_points_to_sets): Likewise.
	(ipa_pta_execute): Likewise.
	* tree-ssa-tail-merge.c (stmt_local_def): Likewise.
	(gsi_advance_fw_nondebug_nonlocal): Likewise.
	(update_dep_bb): Likewise.
	(same_succ_hash): Likewise.
	(inverse_flags): Likewise.
	(release_last_vdef): Likewise.
	(gimple_operand_equal_value_p): Likewise.
	(gsi_advance_bw_nondebug_nonlocal): Likewise.
	(find_duplicate): Likewise.
	(same_phi_alternatives_1): Likewise.
	(bb_has_non_vop_phi): Likewise.
	(find_clusters): Likewise.
	(vop_phi): Likewise.
	(replace_block_by): Likewise.
	(apply_clusters): Likewise.
	(update_debug_stmt): Likewise.
	(update_debug_stmts): Likewise.
	* tree-ssa-ter.c (finished_with_expr): Likewise.
	(ter_is_replaceable_p): Likewise.
	(find_ssaname): Likewise.
	(find_replaceable_in_bb): Likewise.
	* tree-ssa-threadedge.c (potentially_threadable_block): Likewise.
	(lhs_of_dominating_assert): Likewise.
	(record_temporary_equivalences_from_phis): Likewise.
	(invalidate_equivalences): Likewise.
	(record_temporary_equivalences_from_stmts_at_dest): Likewise.
	(dummy_simplify): Likewise.
	(simplify_control_stmt_condition): Likewise.
	(propagate_threaded_block_debug_into): Likewise.
	(thread_around_empty_blocks): Likewise.
	(thread_through_normal_block): Likewise.
	(thread_across_edge): Likewise.
	* tree-ssa-threadedge.h (thread_across_edge): Likewise.
	* tree-ssa-threadupdate.c (copy_phi_arg_into_existing_phi): Likewise.
	(copy_phi_args): Likewise.
	(phi_args_equal_on_edges): Likewise.
	(bb_ends_with_multiway_branch): Likewise.
	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
	(uncprop_into_successor_phis): Likewise.
	* tree-ssa-uninit.c (warn_uninit): Likewise.
	(warn_uninitialized_vars): Likewise.
	(can_skip_redundant_opnd): Likewise.
	(convert_control_dep_chain_into_preds): Likewise.
	(find_predicates): Likewise.
	(collect_phi_def_edges): Likewise.
	(find_def_preds): Likewise.
	(find_matching_predicate_in_rest_chains): Likewise.
	(prune_uninit_phi_opnds_in_unrealizable_paths): Likewise.
	(use_pred_not_overlap_with_undef_path_pred): Likewise.
	(simplify_pred): Likewise.
	(simplify_preds_4): Likewise.
	(push_to_worklist): Likewise.
	(get_pred_info_from_cmp): Likewise.
	(is_degenerated_phi): Likewise.
	(normalize_one_pred_1): Likewise.
	(normalize_one_pred): Likewise.
	(normalize_one_pred_chain): Likewise.
	(normalize_preds): Likewise.
	(is_use_properly_guarded): Likewise.
	(find_uninit_use): Likewise.
	(warn_uninitialized_phi): Likewise.
	(gate_warn_uninitialized): Likewise.
	* tree-ssa.c (ssa_redirect_edge): Likewise.
	(flush_pending_stmts): Likewise.
	(insert_debug_temp_for_var_def): Likewise.
	(insert_debug_temps_for_defs): Likewise.
	(reset_debug_uses): Likewise.
	(release_defs_bitset): Likewise.
	(verify_ssa_name): Likewise.
	(verify_def): Likewise.
	(verify_use): Likewise.
	(verify_ssa): Likewise.
	(execute_update_addresses_taken): Likewise.
	* tree-ssa.h (gimple_replace_ssa_lhs): Likewise.
	(reset_debug_uses): Likewise.
	* tree-ssanames.c (ssanames_print_statistics): Likewise.
	(get_ptr_info): Likewise.
	(duplicate_ssa_name_range_info): Likewise.
	(duplicate_ssa_name_fn): Likewise.
	* tree-ssanames.h (make_ssa_name_fn): Likewise.
	(copy_ssa_name_fn): Likewise.
	(duplicate_ssa_name_fn): Likewise.
	(release_defs): Likewise.
	(make_ssa_name): Likewise.
	(copy_ssa_name): Likewise.
	(release_ssa_name): Likewise.
	* tree-stdarg.c (va_list_counter_bump): Likewise.
	(check_all_va_list_escapes): Likewise.
	* tree-switch-conversion.c (hoist_edge_and_branch_if_true): Likewise.
	(case_bit_test_cmp): Likewise.
	(emit_case_bit_tests): Likewise.
	(check_final_bb): Likewise.
	(gather_default_values): Likewise.
	(build_constructors): Likewise.
	(constructor_contains_same_values_p): Likewise.
	(array_value_type): Likewise.
	(build_one_array): Likewise.
	(build_arrays): Likewise.
	(gen_def_assigns): Likewise.
	(fix_phi_nodes): Likewise.
	(gen_inbound_check): Likewise.
	(process_switch): Likewise.
	* tree-tailcall.c (suitable_for_tail_call_opt_p): Likewise.
	(independent_of_stmt_p): Likewise.
	(propagate_through_phis): Likewise.
	(find_tail_calls): Likewise.
	(adjust_return_value_with_ops): Likewise.
	(update_accumulator_with_ops): Likewise.
	(adjust_return_value): Likewise.
	(eliminate_tail_call): Likewise.
	(optimize_tail_call): Likewise.
	(create_tailcall_accumulator): Likewise.
	(tree_optimize_tail_calls_1): Likewise.
	* tree-vect-data-refs.c (vect_lanes_optab_supported_p): Likewise.
	(vect_analyze_data_ref_dependence): Likewise.
	(vect_slp_analyze_data_ref_dependence): Likewise.
	(vect_compute_data_ref_alignment): Likewise.
	(vect_verify_datarefs_alignment): Likewise.
	(vector_alignment_reachable_p): Likewise.
	(vect_get_data_access_cost): Likewise.
	(vect_peeling_hash_get_lowest_cost): Likewise.
	(vect_enhance_data_refs_alignment): Likewise.
	(vect_analyze_group_access): Likewise.
	(vect_analyze_data_ref_access): Likewise.
	(vect_prune_runtime_alias_test_list): Likewise.
	(vect_check_gather): Likewise.
	(vect_analyze_data_refs): Likewise.
	(vect_get_new_vect_var): Likewise.
	(vect_create_addr_base_for_vector_ref): Likewise.
	(vect_create_data_ref_ptr): Likewise.
	(bump_vector_ptr): Likewise.
	(vect_store_lanes_supported): Likewise.
	(vect_permute_store_chain): Likewise.
	(vect_setup_realignment): Likewise.
	(vect_load_lanes_supported): Likewise.
	(vect_permute_load_chain): Likewise.
	(vect_transform_grouped_load): Likewise.
	(vect_record_grouped_load_vectors): Likewise.
	(vect_supportable_dr_alignment): Likewise.
	* tree-vect-generic.c (expand_vector_divmod): Likewise.
	(expand_vector_condition): Likewise.
	(optimize_vector_constructor): Likewise.
	(vector_element): Likewise.
	(lower_vec_perm): Likewise.
	(expand_vector_operations_1): Likewise.
	* tree-vect-loop-manip.c (rename_variables_in_bb): Likewise.
	(adjust_debug_stmts_now): Likewise.
	(adjust_debug_stmts): Likewise.
	(slpeel_update_phi_nodes_for_guard1): Likewise.
	(slpeel_update_phi_nodes_for_guard2): Likewise.
	(slpeel_make_loop_iterate_ntimes): Likewise.
	(slpeel_duplicate_current_defs_from_edges): Likewise.
	(slpeel_tree_duplicate_loop_to_edge_cfg): Likewise.
	(slpeel_add_loop_guard): Likewise.
	(slpeel_can_duplicate_loop_p): Likewise.
	(set_prologue_iterations): Likewise.
	(slpeel_tree_peel_loop_to_edge): Likewise.
	(find_loop_location): Likewise.
	(vect_can_advance_ivs_p): Likewise.
	(vect_update_ivs_after_vectorizer): Likewise.
	(vect_gen_niters_for_prolog_loop): Likewise.
	(vect_create_cond_for_align_checks): Likewise.
	(vect_loop_versioning): Likewise.
	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
	(vect_analyze_scalar_cycles_1): Likewise.
	(vect_analyze_scalar_cycles): Likewise.
	(new_loop_vec_info): Likewise.
	(destroy_loop_vec_info): Likewise.
	(vect_analyze_loop_form): Likewise.
	(vect_analyze_loop_operations): Likewise.
	(reduction_code_for_scalar_code): Likewise.
	(report_vect_op): Likewise.
	(vect_is_slp_reduction): Likewise.
	(vect_is_simple_reduction_1): Likewise.
	(vect_is_simple_reduction): Likewise.
	(vect_get_single_scalar_iteration_cost): Likewise.
	(vect_model_reduction_cost): Likewise.
	(vect_model_induction_cost): Likewise.
	(get_initial_def_for_induction): Likewise.
	(get_initial_def_for_reduction): Likewise.
	(vect_create_epilog_for_reduction): Likewise.
	(vectorizable_reduction): Likewise.
	(vect_min_worthwhile_factor): Likewise.
	(vectorizable_induction): Likewise.
	(vectorizable_live_operation): Likewise.
	(vect_loop_kill_debug_uses): Likewise.
	(vect_generate_tmps_on_preheader): Likewise.
	(vect_transform_loop): Likewise.
	* tree-vect-patterns.c (Copyright): Likewise.
	(append_pattern_def_seq): Likewise.
	(new_pattern_def_seq): Likewise.
	(vect_same_loop_or_bb_p): Likewise.
	(vect_single_imm_use): Likewise.
	(type_conversion_p): Likewise.
	(vect_recog_temp_ssa_var): Likewise.
	(vect_recog_dot_prod_pattern): Likewise.
	(vect_handle_widen_op_by_const): Likewise.
	(vect_recog_widen_mult_pattern): Likewise.
	(vect_recog_pow_pattern): Likewise.
	(vect_recog_widen_sum_pattern): Likewise.
	(vect_operation_fits_smaller_type): Likewise.
	(vect_recog_over_widening_pattern): Likewise.
	(vect_recog_widen_shift_pattern): Likewise.
	(vect_recog_rotate_pattern): Likewise.
	(vect_recog_vector_vector_shift_pattern): Likewise.
	(vect_recog_divmod_pattern): Likewise.
	(vect_recog_mixed_size_cond_pattern): Likewise.
	(check_bool_pattern): Likewise.
	(adjust_bool_pattern_cast): Likewise.
	(adjust_bool_pattern): Likewise.
	(vect_recog_bool_pattern): Likewise.
	(vect_mark_pattern_stmts): Likewise.
	(vect_pattern_recog_1): Likewise.
	(vect_pattern_recog): Likewise.
	* tree-vect-slp.c (find_bb_location): Likewise.
	(vect_free_slp_instance): Likewise.
	(vect_create_new_slp_node): Likewise.
	(vect_free_oprnd_info): Likewise.
	(vect_get_place_in_interleaving_chain): Likewise.
	(vect_get_and_check_slp_defs): Likewise.
	(vect_build_slp_tree_1): Likewise.
	(vect_build_slp_tree): Likewise.
	(vect_print_slp_tree): Likewise.
	(vect_mark_slp_stmts): Likewise.
	(vect_mark_slp_stmts_relevant): Likewise.
	(vect_slp_rearrange_stmts): Likewise.
	(vect_supported_load_permutation_p): Likewise.
	(vect_find_first_load_in_slp_instance): Likewise.
	(vect_find_last_store_in_slp_instance): Likewise.
	(vect_analyze_slp_cost_1): Likewise.
	(vect_analyze_slp_cost): Likewise.
	(vect_analyze_slp_instance): Likewise.
	(vect_analyze_slp): Likewise.
	(vect_detect_hybrid_slp_stmts): Likewise.
	(new_bb_vec_info): Likewise.
	(destroy_bb_vec_info): Likewise.
	(vect_slp_analyze_node_operations): Likewise.
	(vect_bb_slp_scalar_cost): Likewise.
	(vect_slp_analyze_bb): Likewise.
	(vect_get_constant_vectors): Likewise.
	(vect_get_slp_vect_defs): Likewise.
	(vect_get_slp_defs): Likewise.
	(vect_create_mask_and_perm): Likewise.
	(vect_transform_slp_perm_load): Likewise.
	(vect_schedule_slp_instance): Likewise.
	(vect_remove_slp_scalar_calls): Likewise.
	(vect_schedule_slp): Likewise.
	(vect_slp_transform_bb): Likewise.
	* tree-vect-stmts.c (stmt_in_inner_loop_p): Likewise.
	(create_vector_array): Likewise.
	(read_vector_array): Likewise.
	(write_vector_array): Likewise.
	(create_array_ref): Likewise.
	(vect_mark_relevant): Likewise.
	(vect_stmt_relevant_p): Likewise.
	(exist_non_indexing_operands_for_use_p): Likewise.
	(process_use): Likewise.
	(vect_mark_stmts_to_be_vectorized): Likewise.
	(vect_cost_group_size): Likewise.
	(vect_model_store_cost): Likewise.
	(vect_get_store_cost): Likewise.
	(vect_model_load_cost): Likewise.
	(vect_get_load_cost): Likewise.
	(vect_init_vector_1): Likewise.
	(vect_init_vector): Likewise.
	(vect_get_vec_def_for_operand): Likewise.
	(vect_get_vec_def_for_stmt_copy): Likewise.
	(vect_get_vec_defs_for_stmt_copy): Likewise.
	(vect_get_vec_defs): Likewise.
	(vect_finish_stmt_generation): Likewise.
	(vectorizable_function): Likewise.
	(vectorizable_mask_load_store): Likewise.
	(vectorizable_call): Likewise.
	(vectorizable_simd_clone_call): Likewise.
	(vect_gen_widened_results_half): Likewise.
	(vect_get_loop_based_defs): Likewise.
	(vect_create_vectorized_demotion_stmts): Likewise.
	(vect_create_vectorized_promotion_stmts): Likewise.
	(vectorizable_conversion): Likewise.
	(vectorizable_assignment): Likewise.
	(vect_supportable_shift): Likewise.
	(vectorizable_shift): Likewise.
	(vectorizable_operation): Likewise.
	(perm_mask_for_reverse): Likewise.
	(vectorizable_store): Likewise.
	(vect_gen_perm_mask): Likewise.
	(permute_vec_elements): Likewise.
	(hoist_defs_of_uses): Likewise.
	(vectorizable_load): Likewise.
	(vect_is_simple_cond): Likewise.
	(vectorizable_condition): Likewise.
	(vect_analyze_stmt): Likewise.
	(vect_transform_stmt): Likewise.
	(vect_remove_stores): Likewise.
	(free_stmt_vec_info_vec): Likewise.
	(free_stmt_vec_info): Likewise.
	(get_same_sized_vectype): Likewise.
	(vect_is_simple_use): Likewise.
	(vect_is_simple_use_1): Likewise.
	(supportable_widening_operation): Likewise.
	* tree-vectorizer.c (adjust_simduid_builtins): Likewise.
	(note_simd_array_uses): Likewise.
	(vect_destroy_datarefs): Likewise.
	(vect_loop_vectorized_call): Likewise.
	(fold_loop_vectorized_call): Likewise.
	(vectorize_loops): Likewise.
	* tree-vectorizer.h (Copyright): Likewise.
	(add_stmt_info_to_vec): Likewise.
	(loop_vec_info_for_loop): Likewise.
	(nested_in_vect_loop_p): Likewise.
	(vec_info_for_bb): Likewise.
	(vinfo_for_stmt): Likewise.
	(set_vinfo_for_stmt): Likewise.
	(get_earlier_stmt): Likewise.
	(is_pattern_stmt_p): Likewise.
	(unlimited_cost_model): Likewise.
	* tree-vrp.c (live_on_edge): Likewise.
	(is_overflow_infinity): Likewise.
	(usable_range_p): Likewise.
	(gimple_assign_nonnegative_warnv_p): Likewise.
	(gimple_call_nonnegative_warnv_p): Likewise.
	(gimple_stmt_nonnegative_warnv_p): Likewise.
	(gimple_assign_nonzero_warnv_p): Likewise.
	(gimple_stmt_nonzero_warnv_p): Likewise.
	(extract_range_from_unary_expr): Likewise.
	(extract_range_from_comparison): Likewise.
	(extract_range_basic): Likewise.
	(extract_range_from_assignment): Likewise.
	(debug_all_value_ranges): Likewise.
	(build_assert_expr_for): Likewise.
	(fp_predicate): Likewise.
	(register_edge_assert_for_2): Likewise.
	(register_edge_assert_for_1): Likewise.
	(register_edge_assert_for): Likewise.
	(compare_case_labels): Likewise.
	(find_assert_locations_1): Likewise.
	(find_assert_locations): Likewise.
	(process_assert_insertions_for): Likewise.
	(search_for_addr_array): Likewise.
	(check_all_array_refs): Likewise.
	(all_imm_uses_in_stmt_or_feed_cond): Likewise.
	(maybe_set_nonzero_bits): Likewise.
	(remove_range_assertions): Likewise.
	(vrp_initialize): Likewise.
	(vrp_valueize): Likewise.
	(vrp_evaluate_conditional_warnv_with_ops): Likewise.
	(vrp_evaluate_conditional): Likewise.
	(vrp_visit_cond_stmt): Likewise.
	(find_case_label_index): Likewise.
	(find_case_label_range): Likewise.
	(find_case_label_ranges): Likewise.
	(vrp_visit_switch_stmt): Likewise.
	(vrp_meet): Likewise.
	(vrp_visit_phi_node): Likewise.
	(simplify_truth_ops_using_ranges): Likewise.
	(simplify_div_or_mod_using_ranges): Likewise.
	(simplify_abs_using_ranges): Likewise.
	(range_fits_type_p): Likewise.
	(simplify_cond_using_ranges): Likewise.
	(simplify_switch_using_ranges): Likewise.
	(simplify_conversion_using_ranges): Likewise.
	(simplify_float_conversion_using_ranges): Likewise.
	(simplify_internal_call_using_ranges): Likewise.
	(simplify_stmt_using_ranges): Likewise.
	(fold_predicate_in): Likewise.
	(vrp_fold_stmt): Likewise.
	(identify_jump_threads): Likewise.
	* tree.c (find_decls_types_in_node): Likewise.
	* tree.h (opts_for_fn): Likewise.
	* tsan.c (get_memory_access_decl): Likewise.
	(instrument_expr): Likewise.
	(instrument_builtin_call): Likewise.
	(instrument_gimple): Likewise.
	(instrument_func_entry): Likewise.
	(instrument_func_exit): Likewise.
	* ubsan.c (ubsan_expand_null_ifn): Likewise.
	(instrument_member_call): Likewise.
	(instrument_mem_ref): Likewise.
	(instrument_null): Likewise.
	(instrument_si_overflow): Likewise.
	(instrument_bool_enum_load): Likewise.
	* value-prof.c (gimple_alloc_histogram_value): Likewise.
	(histogram_eq): Likewise.
	(set_histogram_value): Likewise.
	(gimple_histogram_value): Likewise.
	(gimple_add_histogram_value): Likewise.
	(gimple_remove_histogram_value): Likewise.
	(stream_out_histogram_value): Likewise.
	(stream_in_histogram_value): Likewise.
	(dump_histograms_for_stmt): Likewise.
	(gimple_remove_stmt_histograms): Likewise.
	(gimple_duplicate_stmt_histograms): Likewise.
	(verify_histograms): Likewise.
	(free_histograms): Likewise.
	(gimple_value_profile_transformations): Likewise.
	(gimple_divmod_fixed_value): Likewise.
	(gimple_divmod_fixed_value_transform): Likewise.
	(gimple_mod_pow2): Likewise.
	(gimple_mod_pow2_value_transform): Likewise.
	(gimple_mod_subtract): Likewise.
	(gimple_mod_subtract_transform): Likewise.
	(find_func_by_profile_id): Likewise.
	(check_ic_target): Likewise.
	(gimple_ic): Likewise.
	(gimple_ic_transform): Likewise.
	(interesting_stringop_to_profile_p): Likewise.
	(gimple_stringop_fixed_value): Likewise.
	(gimple_stringops_transform): Likewise.
	(stringop_block_profile): Likewise.
	(gimple_divmod_values_to_profile): Likewise.
	(gimple_indirect_call_to_profile): Likewise.
	(gimple_stringops_values_to_profile): Likewise.
	* value-prof.h (Copyright): Likewise.
	(gimple_histogram_value): Likewise.
	(gimple_histogram_value_of_type): Likewise.
	(gimple_add_histogram_value): Likewise.
	(dump_histograms_for_stmt): Likewise.
	(gimple_remove_histogram_value): Likewise.
	(gimple_remove_stmt_histograms): Likewise.
	(gimple_duplicate_stmt_histograms): Likewise.
	(gimple_move_stmt_histograms): Likewise.
	(stringop_block_profile): Likewise.
	(gimple_ic): Likewise.
	(stream_in_histogram_value): Likewise.
	* vtable-verify.c (find_or_create_vtbl_map_node): Likewise.
	(var_is_used_for_virtual_call_p): Likewise.
	(verify_bb_vtables): Likewise.

gcc/c-family/

	Patch autogenerated by rename_gimple.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 6a01b854f462cd86b84173b0c45db90f11c00359

	* c-gimplify.c (add_block_to_enclosing): Replace "gimple" typedef with
	"gimple_stmt *".

gcc/cp/

	Patch autogenerated by rename_gimple.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 6a01b854f462cd86b84173b0c45db90f11c00359

	* cp-gimplify.c (gimplify_must_not_throw_expr): Replace "gimple"
	typedef with "gimple_stmt *".

gcc/java/

	Patch autogenerated by rename_gimple.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 6a01b854f462cd86b84173b0c45db90f11c00359

	* java-gimplify.c (java_gimplify_block): Replace "gimple" typedef with
	"gimple_stmt *".
---
 gcc/asan.c                            |   36 +-
 gcc/builtins.c                        |   10 +-
 gcc/builtins.h                        |    2 +-
 gcc/c-family/c-gimplify.c             |    4 +-
 gcc/calls.c                           |    2 +-
 gcc/calls.h                           |    2 +-
 gcc/cfgexpand.c                       |   46 +-
 gcc/cfgexpand.h                       |    2 +-
 gcc/cfgloop.c                         |    2 +-
 gcc/cfgloop.h                         |    2 +-
 gcc/cfgloopmanip.c                    |    4 +-
 gcc/cgraph.c                          |   32 +-
 gcc/cgraph.h                          |   24 +-
 gcc/cgraphbuild.c                     |   12 +-
 gcc/cgraphclones.c                    |    8 +-
 gcc/cgraphunit.c                      |   12 +-
 gcc/config/aarch64/aarch64-builtins.c |    4 +-
 gcc/config/alpha/alpha.c              |   14 +-
 gcc/config/i386/i386.c                |   14 +-
 gcc/config/rs6000/rs6000.c            |    4 +-
 gcc/cp/cp-gimplify.c                  |    2 +-
 gcc/dumpfile.c                        |    4 +-
 gcc/dumpfile.h                        |    4 +-
 gcc/except.h                          |    2 +-
 gcc/expr.c                            |   28 +-
 gcc/expr.h                            |    2 +-
 gcc/fold-const.c                      |    2 +-
 gcc/fold-const.h                      |    2 +-
 gcc/gimple-builder.c                  |   26 +-
 gcc/gimple-builder.h                  |   16 +-
 gcc/gimple-fold.c                     |   58 +-
 gcc/gimple-fold.h                     |    8 +-
 gcc/gimple-iterator.c                 |   36 +-
 gcc/gimple-iterator.h                 |   22 +-
 gcc/gimple-low.c                      |   30 +-
 gcc/gimple-low.h                      |    2 +-
 gcc/gimple-pretty-print.c             |  104 ++--
 gcc/gimple-pretty-print.h             |    8 +-
 gcc/gimple-ssa-isolate-paths.c        |   14 +-
 gcc/gimple-ssa-strength-reduction.c   |   92 +--
 gcc/gimple-ssa.h                      |   14 +-
 gcc/gimple-streamer-in.c              |   10 +-
 gcc/gimple-streamer-out.c             |    8 +-
 gcc/gimple-walk.c                     |   18 +-
 gcc/gimple-walk.h                     |   12 +-
 gcc/gimple.c                          |  284 ++++-----
 gcc/gimple.h                          | 1030 ++++++++++++++++-----------------
 gcc/gimplify-me.c                     |    4 +-
 gcc/gimplify-me.h                     |    2 +-
 gcc/gimplify.c                        |  100 ++--
 gcc/gimplify.h                        |   12 +-
 gcc/graphite-poly.c                   |    8 +-
 gcc/graphite-scop-detection.c         |   20 +-
 gcc/graphite-sese-to-poly.c           |  168 +++---
 gcc/internal-fn.c                     |   40 +-
 gcc/internal-fn.h                     |    2 +-
 gcc/ipa-inline-analysis.c             |   40 +-
 gcc/ipa-inline.c                      |    4 +-
 gcc/ipa-profile.c                     |    2 +-
 gcc/ipa-prop.c                        |   80 +--
 gcc/ipa-prop.h                        |    6 +-
 gcc/ipa-pure-const.c                  |   12 +-
 gcc/ipa-ref.c                         |   10 +-
 gcc/ipa-ref.h                         |   12 +-
 gcc/ipa-split.c                       |   40 +-
 gcc/java/java-gimplify.c              |    2 +-
 gcc/lto-streamer-in.c                 |   16 +-
 gcc/lto-streamer-out.c                |    6 +-
 gcc/omp-low.c                         |  248 ++++----
 gcc/passes.c                          |    4 +-
 gcc/predict.c                         |   32 +-
 gcc/profile.c                         |    8 +-
 gcc/sese.c                            |   18 +-
 gcc/sese.h                            |    8 +-
 gcc/ssa-iterators.h                   |   42 +-
 gcc/stmt.c                            |    4 +-
 gcc/tracer.c                          |    4 +-
 gcc/trans-mem.c                       |  114 ++--
 gcc/trans-mem.h                       |    2 +-
 gcc/tree-affine.c                     |    2 +-
 gcc/tree-call-cdce.c                  |   50 +-
 gcc/tree-cfg.c                        |  232 ++++----
 gcc/tree-cfg.h                        |   22 +-
 gcc/tree-cfgcleanup.c                 |   28 +-
 gcc/tree-cfgcleanup.h                 |    2 +-
 gcc/tree-chrec.c                      |   10 +-
 gcc/tree-chrec.h                      |    6 +-
 gcc/tree-complex.c                    |   34 +-
 gcc/tree-core.h                       |    4 +-
 gcc/tree-data-ref.c                   |   14 +-
 gcc/tree-data-ref.h                   |    8 +-
 gcc/tree-dfa.c                        |   14 +-
 gcc/tree-dfa.h                        |    2 +-
 gcc/tree-eh.c                         |  196 +++----
 gcc/tree-eh.h                         |   38 +-
 gcc/tree-emutls.c                     |    8 +-
 gcc/tree-if-conv.c                    |   34 +-
 gcc/tree-inline.c                     |   84 +--
 gcc/tree-inline.h                     |    6 +-
 gcc/tree-into-ssa.c                   |   62 +-
 gcc/tree-into-ssa.h                   |    4 +-
 gcc/tree-loop-distribution.c          |   62 +-
 gcc/tree-nested.c                     |   32 +-
 gcc/tree-nrv.c                        |    8 +-
 gcc/tree-object-size.c                |   28 +-
 gcc/tree-outof-ssa.c                  |   26 +-
 gcc/tree-outof-ssa.h                  |    4 +-
 gcc/tree-parloops.c                   |   52 +-
 gcc/tree-pass.h                       |    6 +-
 gcc/tree-phinodes.c                   |   18 +-
 gcc/tree-phinodes.h                   |   14 +-
 gcc/tree-predcom.c                    |   62 +-
 gcc/tree-profile.c                    |   32 +-
 gcc/tree-scalar-evolution.c           |   72 +--
 gcc/tree-scalar-evolution.h           |    2 +-
 gcc/tree-sra.c                        |   62 +-
 gcc/tree-ssa-alias.c                  |   38 +-
 gcc/tree-ssa-alias.h                  |   14 +-
 gcc/tree-ssa-ccp.c                    |   46 +-
 gcc/tree-ssa-coalesce.c               |   10 +-
 gcc/tree-ssa-copy.c                   |   14 +-
 gcc/tree-ssa-copyrename.c             |    2 +-
 gcc/tree-ssa-dce.c                    |   40 +-
 gcc/tree-ssa-dom.c                    |   82 +--
 gcc/tree-ssa-dom.h                    |    2 +-
 gcc/tree-ssa-dse.c                    |   10 +-
 gcc/tree-ssa-forwprop.c               |  152 ++---
 gcc/tree-ssa-ifcombine.c              |   20 +-
 gcc/tree-ssa-live.c                   |   18 +-
 gcc/tree-ssa-loop-ch.c                |    6 +-
 gcc/tree-ssa-loop-im.c                |   70 +--
 gcc/tree-ssa-loop-ivcanon.c           |   20 +-
 gcc/tree-ssa-loop-ivopts.c            |   68 +--
 gcc/tree-ssa-loop-manip.c             |   32 +-
 gcc/tree-ssa-loop-niter.c             |   56 +-
 gcc/tree-ssa-loop-niter.h             |    4 +-
 gcc/tree-ssa-loop-prefetch.c          |   16 +-
 gcc/tree-ssa-loop-unswitch.c          |    8 +-
 gcc/tree-ssa-loop.h                   |    2 +-
 gcc/tree-ssa-math-opts.c              |   90 +--
 gcc/tree-ssa-operands.c               |   42 +-
 gcc/tree-ssa-operands.h               |   10 +-
 gcc/tree-ssa-phiopt.c                 |   86 +--
 gcc/tree-ssa-phiprop.c                |   18 +-
 gcc/tree-ssa-pre.c                    |   52 +-
 gcc/tree-ssa-propagate.c              |   46 +-
 gcc/tree-ssa-propagate.h              |   14 +-
 gcc/tree-ssa-reassoc.c                |  176 +++---
 gcc/tree-ssa-sccvn.c                  |   58 +-
 gcc/tree-ssa-sccvn.h                  |    8 +-
 gcc/tree-ssa-sink.c                   |   22 +-
 gcc/tree-ssa-strlen.c                 |   42 +-
 gcc/tree-ssa-structalias.c            |   44 +-
 gcc/tree-ssa-tail-merge.c             |   40 +-
 gcc/tree-ssa-ter.c                    |   12 +-
 gcc/tree-ssa-threadedge.c             |   46 +-
 gcc/tree-ssa-threadedge.h             |    4 +-
 gcc/tree-ssa-threadupdate.c           |   10 +-
 gcc/tree-ssa-uncprop.c                |    4 +-
 gcc/tree-ssa-uninit.c                 |   78 +--
 gcc/tree-ssa.c                        |   40 +-
 gcc/tree-ssa.h                        |    4 +-
 gcc/tree-ssanames.c                   |    8 +-
 gcc/tree-ssanames.h                   |   16 +-
 gcc/tree-stdarg.c                     |   12 +-
 gcc/tree-switch-conversion.c          |   48 +-
 gcc/tree-tailcall.c                   |   30 +-
 gcc/tree-vect-data-refs.c             |  100 ++--
 gcc/tree-vect-generic.c               |   22 +-
 gcc/tree-vect-loop-manip.c            |   62 +-
 gcc/tree-vect-loop.c                  |  174 +++---
 gcc/tree-vect-patterns.c              |  194 +++----
 gcc/tree-vect-slp.c                   |  124 ++--
 gcc/tree-vect-stmts.c                 |  244 ++++----
 gcc/tree-vectorizer.c                 |   22 +-
 gcc/tree-vectorizer.h                 |  116 ++--
 gcc/tree-vrp.c                        |  142 ++---
 gcc/tree.c                            |    4 +-
 gcc/tree.h                            |    4 +-
 gcc/tsan.c                            |   12 +-
 gcc/ubsan.c                           |   20 +-
 gcc/value-prof.c                      |   96 +--
 gcc/value-prof.h                      |   26 +-
 gcc/vtable-verify.c                   |   10 +-
 184 files changed, 3823 insertions(+), 3823 deletions(-)

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

* [PATCH 3/3] Introduce gimple_switch and use it in various places
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
  2014-05-02 21:54                   ` [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *" David Malcolm
@ 2014-05-02 21:54                   ` David Malcolm
  2014-05-09  6:54                     ` Jeff Law
  2014-05-02 21:54                   ` [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *" David Malcolm
                                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-02 21:54 UTC (permalink / raw)
  To: GCC Patches
  Cc: Jeff Law, Richard Biener, Richard Sandiford, Andrew MacLeod,
	David Malcolm

gcc/
	* gimple.h (gimple_switch): New subclass of gimple_stmt_with_ops,
	adding the invariant that stmt->code == GIMPLE_SWITCH.
	(is_a_helper <gimple_switch *>::test): New.
	(is_a_helper <const gimple_switch *>::test): New.
	(gimple_try): Likewise.

	* coretypes.h (gimple_switch): Add forward declaration here.

	* gdbhooks.py (build_pretty_printer): Add gimple_switch,
	using the gimple printer.

	* gimple.c (gimple_build_switch_nlabels): Return a gimple_switch
	rather than just a gimple.
	(gimple_build_switch): Likewise.
	* gimple.h (gimple_build_switch_nlabels): Likewise.
	(gimple_build_switch): Likewise.

	* gimple.h (gimple_switch_num_labels): Update type-signature to
	require a gimple_switch rather than just a gimple.
	(gimple_switch_set_num_labels): Likewise.
	(gimple_switch_set_index): Likewise.
	(gimple_switch_label): Likewise.
	(gimple_switch_set_label): Likewise.
	(gimple_switch_default_label): Likewise.
	(gimple_switch_set_default_label): Likewise.
	* expr.h (expand_case): Likewise.
	* gimple-pretty-print.c (dump_gimple_call): Likewise.
	* stmt.c (compute_cases_per_edge): Likewise.
	(expand_case): Likewise.
	* tree-cfg.h (group_case_labels_stmt): Likewise.
	* tree-cfg.c (make_gimple_switch_edges): Likewise.
	(find_taken_edge_switch_expr) Likewise.
	(find_case_label_for_value) Likewise.
	(get_cases_for_edge): Likewise.
	(group_case_labels_stmt): Likewise.
	(verify_gimple_switch): Likewise.
	* tree-eh.c (verify_norecord_switch_expr): Likewise.
	* tree-eh.c (lower_eh_constructs_2): Likewise.
	* tree-loop-distribution.c (generate_loops_for_partition): Likewise.
	* tree-ssa-dom.c (record_edge_info): Likewise.
	* tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise.
	(simplify_gimple_switch): Likewise.
	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
	(collect_switch_conv_info): Likewise.
	(build_constructors): Likewise.
	(array_value_type): Likewise.
	(build_one_array): Likewise.
	(build_arrays): Likewise.
	(gen_inbound_check): Likewise.
	* tree-vrp.c (find_switch_asserts): Likewise.
	(find_case_label_range): Likewise.
	(find_case_label_ranges): Likewise.
	(vrp_visit_switch_stmt): Likewise.
	(simplify_switch_using_ranges): Likewise.

	* tree-vrp.c (switch_update): Strengthen field "stmt" from being
	merely a gimple_stmt * to being a gimple_switch *.

	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to
	gimple_switch in regions where the stmt code has been tested as
	GIMPLE_SWITCH.
	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
	* tree-cfg.c (make_edges): Likewise.
	(end_recording_case_labels): Likewise.
	(cleanup_dead_labels): Likewise.
	(cleanup_dead_labels): Likewise.
	(group_case_labels): Likewise.
	(find_taken_edge): Likewise.
	(find_case_label_for_value): Likewise.
	(verify_gimple_stmt): Likewise.
	(gimple_verify_flow_info): Likewise.
	(gimple_redirect_edge_and_branch): Likewise.
	* tree-inline.c (estimate_num_insns): Likewise.
	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
	* tree-switch-conversion.c (do_switchconv): Likewise.
	* tree-vrp.c  (find_assert_locations_1): Likewise.
	(vrp_visit_stmt): Likewise.
	(simplify_stmt_using_ranges): Likewise.

	* ipa-inline-analysis.c (set_switch_stmt_execution_predicate):
	Introduce local "lastg" as a generic gimple, so that local "last"
	can be of type gimple_switch once lastg's code has been verified.

	* omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle
	the GIMPLE_SWITCH case.

	* tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch
	argument, since the caller (find_taken_edge) has checked that
	last_stmt is a switch.

	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Add
	gimple_switch class.
	(GIMPLE_SWITCH): Update signatures of accessor functions to reflect
	above gimple_stmt to gimple_switch changes.
---
 gcc/cfgexpand.c              |  2 +-
 gcc/coretypes.h              |  5 ++++
 gcc/doc/gimple.texi          | 34 ++++++++++++++-----------
 gcc/expr.h                   |  2 +-
 gcc/gdbhooks.py              |  4 ++-
 gcc/gimple-pretty-print.c    |  4 +--
 gcc/gimple.c                 | 11 +++++----
 gcc/gimple.h                 | 44 ++++++++++++++++++++++++++-------
 gcc/ipa-inline-analysis.c    |  7 +++---
 gcc/omp-low.c                |  5 ++--
 gcc/stmt.c                   |  4 +--
 gcc/tree-cfg.c               | 59 ++++++++++++++++++++++----------------------
 gcc/tree-cfg.h               |  2 +-
 gcc/tree-eh.c                |  5 ++--
 gcc/tree-inline.c            | 21 +++++++++-------
 gcc/tree-loop-distribution.c |  5 ++--
 gcc/tree-ssa-dom.c           |  8 +++---
 gcc/tree-ssa-forwprop.c      |  6 ++---
 gcc/tree-ssa-uncprop.c       |  8 +++---
 gcc/tree-switch-conversion.c | 18 +++++++-------
 gcc/tree-vrp.c               | 24 +++++++++---------
 21 files changed, 162 insertions(+), 116 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 00d0db2..992521c 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3161,7 +3161,7 @@ expand_gimple_stmt_1 (gimple_stmt *stmt)
     case GIMPLE_PREDICT:
       break;
     case GIMPLE_SWITCH:
-      expand_case (stmt);
+      expand_case (as_a <gimple_switch *> (stmt));
       break;
     case GIMPLE_ASM:
       expand_asm_stmt (stmt);
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index c48f146..6aeb2b6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -64,6 +64,11 @@ typedef const union tree_node *const_tree;
 class gimple_stmt;
 typedef gimple_stmt *gimple_seq;
 struct gimple_stmt_iterator;
+
+/* Forward declarations of gimple subclasses.
+   Keep this in the same order as the corresponding codes in gimple.def.  */
+class gimple_switch;
+
 union section;
 typedef union section section;
 struct gcc_options;
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 6fc4360..311c586 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -311,12 +311,14 @@ kinds, along with their relationships to @code{GSS_} values (layouts) and
      |   |    (no GSS layout)
      |   |
      |   + gimple_stmt_with_ops
-     |   |        layout: GSS_WITH_OPS
-     |   |        Used for 5 codes: GIMPLE_COND
-     |   |                          GIMPLE_DEBUG
-     |   |                          GIMPLE_GOTO
-     |   |                          GIMPLE_LABEL
-     |   |                          GIMPLE_SWITCH
+     |   |   |    layout: GSS_WITH_OPS
+     |   |   |    Used for 4 codes: GIMPLE_COND
+     |   |   |                      GIMPLE_DEBUG
+     |   |   |                      GIMPLE_GOTO
+     |   |   |                      GIMPLE_LABEL
+     |   |   |
+     |   |   + gimple_switch
+     |   |            code: GIMPLE_SWITCH
      |   |
      |   + gimple_stmt_with_memory_ops_base
      |       |    layout: GSS_WITH_MEM_OPS_BASE
@@ -2252,7 +2254,7 @@ Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
 @subsection @code{GIMPLE_SWITCH}
 @cindex @code{GIMPLE_SWITCH}
 
-@deftypefn {GIMPLE function} gimple_stmt *gimple_build_switch (tree index, @
+@deftypefn {GIMPLE function} gimple_switch *gimple_build_switch (tree index, @
 tree default_label, @code{VEC}(tree,heap) *args)
 Build a @code{GIMPLE_SWITCH} statement.  @code{INDEX} is the index variable
 to switch on, and @code{DEFAULT_LABEL} represents the default label.
@@ -2260,44 +2262,46 @@ to switch on, and @code{DEFAULT_LABEL} represents the default label.
 non-default case labels.  Each label is a tree of code @code{CASE_LABEL_EXPR}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (gimple_stmt *g)
+@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (@
+const gimple_switch *g)
 Return the number of labels associated with the switch statement
 @code{G}.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gimple_switch_set_num_labels (@
-gimple_stmt *g, unsigned nlabels)
+gimple_switch *g, unsigned nlabels)
 Set @code{NLABELS} to be the number of labels for the switch statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_index (gimple_stmt *g)
+@deftypefn {GIMPLE function} tree gimple_switch_index (const gimple_switch *g)
 Return the index variable used by the switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple_stmt *g, @
+@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple_switch *g, @
 tree index)
 Set @code{INDEX} to be the index variable for switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_label (gimple_stmt *g, @
+@deftypefn {GIMPLE function} tree gimple_switch_label (const gimple_switch *g, @
 unsigned index)
 Return the label numbered @code{INDEX}. The default label is 0, followed
 by any labels in a switch statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple_stmt *g, @
+@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple_switch *g, @
 unsigned index, tree label)
 Set the label number @code{INDEX} to @code{LABEL}. 0 is always the default
 label.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_default_label (gimple_stmt *g)
+@deftypefn {GIMPLE function} tree gimple_switch_default_label (@
+const gimple_switch *g)
 Return the default label for a switch statement.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gimple_switch_set_default_label (@
-gimple_stmt *g, tree label)
+gimple_switch *g, tree label)
 Set the default label for a switch statement.
 @end deftypefn
 
diff --git a/gcc/expr.h b/gcc/expr.h
index 73a32f7..807dad5 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -777,7 +777,7 @@ rtx get_personality_function (tree);
 /* In stmt.c */
 
 /* Expand a GIMPLE_SWITCH statement.  */
-extern void expand_case (gimple_stmt *);
+extern void expand_case (gimple_switch *);
 
 /* Like expand_case but special-case for SJLJ exception dispatching.  */
 extern void expand_sjlj_dispatch_table (rtx, vec<tree> );
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 2bc67f0..f5171f3 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -454,7 +454,9 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
-    pp.add_printer_for_types(['gimple_stmt *'],
+    pp.add_printer_for_types(['gimple_stmt *',
+                              # Keep this in the same order as gimple.def:
+                              'gimple_switch *'],
                              'gimple',
                              GimplePrinter)
     pp.add_printer_for_types(['basic_block', 'basic_block_def *'],
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 268b43bb..03ad971 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -775,7 +775,7 @@ dump_gimple_call (pretty_printer *buffer, gimple_stmt *gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_switch (pretty_printer *buffer, gimple_stmt *gs, int spc, int flags)
+dump_gimple_switch (pretty_printer *buffer, gimple_switch *gs, int spc, int flags)
 {
   unsigned int i;
 
@@ -2126,7 +2126,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple_stmt *gs, int spc, int flags)
       break;
 
     case GIMPLE_SWITCH:
-      dump_gimple_switch (buffer, gs, spc, flags);
+      dump_gimple_switch (buffer, as_a <gimple_switch *> (gs), spc, flags);
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index bc8d757..9701f49 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -714,13 +714,14 @@ gimple_build_resx (int region)
    NLABELS is the number of labels in the switch excluding the default.
    DEFAULT_LABEL is the default label for the switch statement.  */
 
-gimple_stmt *
+gimple_switch *
 gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
 {
   /* nlabels + 1 default label + 1 index.  */
   gcc_checking_assert (default_label);
-  gimple_stmt *p = gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
-				    1 + 1 + nlabels);
+  gimple_switch *p =
+    as_a <gimple_switch *> (gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK,
+						   1 + 1 + nlabels));
   gimple_switch_set_index (p, index);
   gimple_switch_set_default_label (p, default_label);
   return p;
@@ -732,12 +733,12 @@ gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
    DEFAULT_LABEL is the default label
    ARGS is a vector of labels excluding the default.  */
 
-gimple_stmt *
+gimple_switch *
 gimple_build_switch (tree index, tree default_label, vec<tree> args)
 {
   unsigned i, nlabels = args.length ();
 
-  gimple_stmt *p = gimple_build_switch_nlabels (nlabels, index, default_label);
+  gimple_switch *p = gimple_build_switch_nlabels (nlabels, index, default_label);
 
   /* Copy the labels from the vector to the switch statement.  */
   for (i = 0; i < nlabels; i++)
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 4cc88f0..0bf8853 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -764,6 +764,16 @@ enum gimple_statement_structure_enum {
 };
 #undef DEFGSSTRUCT
 
+/* A statement with the invariant that
+      stmt->code == GIMPLE_SWITCH
+   i.e. a switch statement.  */
+
+struct GTY((tag("GSS_WITH_OPS")))
+  gimple_switch : public gimple_stmt_with_ops
+{
+  /* no additional fields; this uses the layout for GSS_WITH_OPS. */
+};
+
 template <>
 template <>
 inline bool
@@ -951,6 +961,14 @@ is_a_helper <gimple_phi *>::test (gimple_stmt *gs)
 template <>
 template <>
 inline bool
+is_a_helper <gimple_switch *>::test (gimple_stmt *gs)
+{
+  return gs->code == GIMPLE_SWITCH;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <gimple_transaction *>::test (gimple_stmt *gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
@@ -1143,6 +1161,14 @@ is_a_helper <const gimple_phi *>::test (const gimple_stmt *gs)
 template <>
 template <>
 inline bool
+is_a_helper <const gimple_switch *>::test (const gimple_stmt *gs)
+{
+  return gs->code == GIMPLE_SWITCH;
+}
+
+template <>
+template <>
+inline bool
 is_a_helper <const gimple_transaction *>::test (const gimple_stmt *gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
@@ -1193,8 +1219,8 @@ gimple_try *gimple_build_try (gimple_seq, gimple_seq,
 			      enum gimple_try_flags);
 gimple_stmt *gimple_build_wce (gimple_seq);
 gimple_stmt *gimple_build_resx (int);
-gimple_stmt *gimple_build_switch_nlabels (unsigned, tree, tree);
-gimple_stmt *gimple_build_switch (tree, tree, vec<tree> );
+gimple_switch *gimple_build_switch_nlabels (unsigned, tree, tree);
+gimple_switch *gimple_build_switch (tree, tree, vec<tree> );
 gimple_stmt *gimple_build_eh_dispatch (int);
 gimple_stmt *gimple_build_debug_bind_stat (tree, tree, gimple_stmt *MEM_STAT_DECL);
 #define gimple_build_debug_bind(var,val,stmt)			\
@@ -3942,7 +3968,7 @@ gimple_eh_dispatch_set_region (gimple_stmt *gs, int region)
 /* Return the number of labels associated with the switch statement GS.  */
 
 static inline unsigned
-gimple_switch_num_labels (const gimple_stmt *gs)
+gimple_switch_num_labels (const gimple_switch *gs)
 {
   unsigned num_ops;
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
@@ -3955,7 +3981,7 @@ gimple_switch_num_labels (const gimple_stmt *gs)
 /* Set NLABELS to be the number of labels for the switch statement GS.  */
 
 static inline void
-gimple_switch_set_num_labels (gimple_stmt *g, unsigned nlabels)
+gimple_switch_set_num_labels (gimple_switch *g, unsigned nlabels)
 {
   GIMPLE_CHECK (g, GIMPLE_SWITCH);
   gimple_set_num_ops (g, nlabels + 1);
@@ -3985,7 +4011,7 @@ gimple_switch_index_ptr (const gimple_stmt *gs)
 /* Set INDEX to be the index variable for switch statement GS.  */
 
 static inline void
-gimple_switch_set_index (gimple_stmt *gs, tree index)
+gimple_switch_set_index (gimple_switch *gs, tree index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index));
@@ -3997,7 +4023,7 @@ gimple_switch_set_index (gimple_stmt *gs, tree index)
    labels in a switch statement.  */
 
 static inline tree
-gimple_switch_label (const gimple_stmt *gs, unsigned index)
+gimple_switch_label (const gimple_switch *gs, unsigned index)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1);
@@ -4007,7 +4033,7 @@ gimple_switch_label (const gimple_stmt *gs, unsigned index)
 /* Set the label number INDEX to LABEL.  0 is always the default label.  */
 
 static inline void
-gimple_switch_set_label (gimple_stmt *gs, unsigned index, tree label)
+gimple_switch_set_label (gimple_switch *gs, unsigned index, tree label)
 {
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1
@@ -4019,7 +4045,7 @@ gimple_switch_set_label (gimple_stmt *gs, unsigned index, tree label)
 /* Return the default label for a switch statement.  */
 
 static inline tree
-gimple_switch_default_label (const gimple_stmt *gs)
+gimple_switch_default_label (const gimple_switch *gs)
 {
   tree label = gimple_switch_label (gs, 0);
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
@@ -4029,7 +4055,7 @@ gimple_switch_default_label (const gimple_stmt *gs)
 /* Set the default label for a switch statement.  */
 
 static inline void
-gimple_switch_set_default_label (gimple_stmt *gs, tree label)
+gimple_switch_set_default_label (gimple_switch *gs, tree label)
 {
   gcc_checking_assert (!CASE_LOW (label) && !CASE_HIGH (label));
   gimple_switch_set_label (gs, 0, label);
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index d4ecc09..35517c8 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -1801,7 +1801,7 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
 				     struct inline_summary *summary,
 				     basic_block bb)
 {
-  gimple_stmt *last;
+  gimple_stmt *lastg;
   tree op;
   int index;
   struct agg_position_info aggpos;
@@ -1810,9 +1810,10 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
   size_t n;
   size_t case_idx;
 
-  last = last_stmt (bb);
-  if (!last || gimple_code (last) != GIMPLE_SWITCH)
+  lastg = last_stmt (bb);
+  if (!lastg || gimple_code (lastg) != GIMPLE_SWITCH)
     return;
+  gimple_switch *last = as_a <gimple_switch *> (lastg);
   op = gimple_switch_index (last);
   if (!unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos))
     return;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index f402d50..b6c845b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10462,10 +10462,11 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch *switch_stmt = as_a <gimple_switch *> (stmt);
 	unsigned int i;
-	for (i = 0; i < gimple_switch_num_labels (stmt); ++i)
+	for (i = 0; i < gimple_switch_num_labels (switch_stmt); ++i)
 	  {
-	    tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+	    tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 	    n = splay_tree_lookup (all_labels, (splay_tree_key) lab);
 	    if (n && diagnose_sb_0 (gsi_p, context, (gimple_stmt *) n->value))
 	      break;
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 32dffaa..c1ae362 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1130,7 +1130,7 @@ reset_out_edges_aux (basic_block bb)
    STMT. Record this information in the aux field of the edge.  */
 
 static inline void
-compute_cases_per_edge (gimple_stmt *stmt)
+compute_cases_per_edge (gimple_switch *stmt)
 {
   basic_block bb = gimple_bb (stmt);
   reset_out_edges_aux (bb);
@@ -1152,7 +1152,7 @@ compute_cases_per_edge (gimple_stmt *stmt)
    Generate the code to test it and jump to the right place.  */
 
 void
-expand_case (gimple_stmt *stmt)
+expand_case (gimple_switch *stmt)
 {
   tree minval = NULL_TREE, maxval = NULL_TREE, range = NULL_TREE;
   rtx default_label = NULL_RTX;
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 22621d2..e75c3b4 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -150,7 +150,7 @@ static void make_blocks (gimple_seq);
 static void make_edges (void);
 static void assign_discriminators (void);
 static void make_cond_expr_edges (basic_block);
-static void make_gimple_switch_edges (basic_block);
+static void make_gimple_switch_edges (gimple_switch *, basic_block);
 static bool make_goto_expr_edges (basic_block);
 static void make_gimple_asm_edges (basic_block);
 static edge gimple_redirect_edge_and_branch (edge, basic_block);
@@ -169,8 +169,8 @@ static bool gimple_can_merge_blocks_p (basic_block, basic_block);
 static void remove_bb (basic_block);
 static edge find_taken_edge_computed_goto (basic_block, tree);
 static edge find_taken_edge_cond_expr (basic_block, tree);
-static edge find_taken_edge_switch_expr (basic_block, tree);
-static tree find_case_label_for_value (gimple_stmt *, tree);
+static edge find_taken_edge_switch_expr (gimple_switch *, basic_block, tree);
+static tree find_case_label_for_value (gimple_switch *, tree);
 
 void
 init_empty_tree_cfg_for_function (struct function *fn)
@@ -769,7 +769,7 @@ make_edges (void)
 	      fallthru = false;
 	      break;
 	    case GIMPLE_SWITCH:
-	      make_gimple_switch_edges (bb);
+	      make_gimple_switch_edges (as_a <gimple_switch *> (last), bb);
 	      fallthru = false;
 	      break;
 	    case GIMPLE_RESX:
@@ -1094,7 +1094,7 @@ end_recording_case_labels (void)
 	{
 	  gimple_stmt *stmt = last_stmt (bb);
 	  if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	    group_case_labels_stmt (stmt);
+	    group_case_labels_stmt (as_a <gimple_switch *> (stmt));
 	}
     }
   BITMAP_FREE (touched_switch_bbs);
@@ -1106,7 +1106,7 @@ end_recording_case_labels (void)
    Otherwise return NULL.  */
 
 static tree
-get_cases_for_edge (edge e, gimple_stmt *t)
+get_cases_for_edge (edge e, gimple_switch *t)
 {
   void **slot;
   size_t i, n;
@@ -1145,9 +1145,8 @@ get_cases_for_edge (edge e, gimple_stmt *t)
 /* Create the edges for a GIMPLE_SWITCH starting at block BB.  */
 
 static void
-make_gimple_switch_edges (basic_block bb)
+make_gimple_switch_edges (gimple_switch *entry, basic_block bb)
 {
-  gimple_stmt *entry = last_stmt (bb);
   size_t i, n;
 
   n = gimple_switch_num_labels (entry);
@@ -1398,12 +1397,13 @@ cleanup_dead_labels (void)
 
 	case GIMPLE_SWITCH:
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    gimple_switch *switch_stmt = as_a <gimple_switch *> (stmt);
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Replace all destination labels.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree case_label = gimple_switch_label (stmt, i);
+		tree case_label = gimple_switch_label (switch_stmt, i);
 		label = CASE_LABEL (case_label);
 		new_label = main_block_label (label);
 		if (new_label != label)
@@ -1500,7 +1500,7 @@ cleanup_dead_labels (void)
    Eg. three separate entries 1: 2: 3: become one entry 1..3:  */
 
 void
-group_case_labels_stmt (gimple_stmt *stmt)
+group_case_labels_stmt (gimple_switch *stmt)
 {
   int old_size = gimple_switch_num_labels (stmt);
   int i, j, new_size = old_size;
@@ -1588,7 +1588,7 @@ group_case_labels (void)
     {
       gimple_stmt *stmt = last_stmt (bb);
       if (stmt && gimple_code (stmt) == GIMPLE_SWITCH)
-	group_case_labels_stmt (stmt);
+	group_case_labels_stmt (as_a <gimple_switch *> (stmt));
     }
 }
 
@@ -2053,8 +2053,8 @@ find_taken_edge (basic_block bb, tree val)
   if (gimple_code (stmt) == GIMPLE_COND)
     return find_taken_edge_cond_expr (bb, val);
 
-  if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return find_taken_edge_switch_expr (bb, val);
+  if (gimple_switch *switch_stmt = dyn_cast <gimple_switch *> (stmt))
+    return find_taken_edge_switch_expr (switch_stmt, bb, val);
 
   if (computed_goto_p (stmt))
     {
@@ -2113,14 +2113,13 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
    NULL if any edge may be taken.  */
 
 static edge
-find_taken_edge_switch_expr (basic_block bb, tree val)
+find_taken_edge_switch_expr (gimple_switch *switch_stmt, basic_block bb,
+			     tree val)
 {
   basic_block dest_bb;
   edge e;
-  gimple_stmt *switch_stmt;
   tree taken_case;
 
-  switch_stmt = last_stmt (bb);
   taken_case = find_case_label_for_value (switch_stmt, val);
   dest_bb = label_to_block (CASE_LABEL (taken_case));
 
@@ -2135,7 +2134,7 @@ find_taken_edge_switch_expr (basic_block bb, tree val)
    sorted: We can do a binary search for a case matching VAL.  */
 
 static tree
-find_case_label_for_value (gimple_stmt *switch_stmt, tree val)
+find_case_label_for_value (gimple_switch *switch_stmt, tree val)
 {
   size_t low, high, n = gimple_switch_num_labels (switch_stmt);
   tree default_case = gimple_switch_default_label (switch_stmt);
@@ -4262,7 +4261,7 @@ verify_gimple_goto (gimple_stmt *stmt)
    is a problem, otherwise false.  */
 
 static bool
-verify_gimple_switch (gimple_stmt *stmt)
+verify_gimple_switch (gimple_switch *stmt)
 {
   unsigned int i, n;
   tree elt, prev_upper_bound = NULL_TREE;
@@ -4444,7 +4443,7 @@ verify_gimple_stmt (gimple_stmt *stmt)
       return verify_gimple_goto (stmt);
 
     case GIMPLE_SWITCH:
-      return verify_gimple_switch (stmt);
+      return verify_gimple_switch (as_a <gimple_switch *> (stmt));
 
     case GIMPLE_RETURN:
       return verify_gimple_return (stmt);
@@ -5177,26 +5176,27 @@ gimple_verify_flow_info (void)
 
 	case GIMPLE_SWITCH:
 	  {
+	    gimple_switch *switch_stmt = as_a <gimple_switch *> (stmt);
 	    tree prev;
 	    edge e;
 	    size_t i, n;
 
-	    n = gimple_switch_num_labels (stmt);
+	    n = gimple_switch_num_labels (switch_stmt);
 
 	    /* Mark all the destination basic blocks.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 		gcc_assert (!label_bb->aux || label_bb->aux == (void *)1);
 		label_bb->aux = (void *)1;
 	      }
 
 	    /* Verify that the case labels are sorted.  */
-	    prev = gimple_switch_label (stmt, 0);
+	    prev = gimple_switch_label (switch_stmt, 0);
 	    for (i = 1; i < n; ++i)
 	      {
-		tree c = gimple_switch_label (stmt, i);
+		tree c = gimple_switch_label (switch_stmt, i);
 		if (!CASE_LOW (c))
 		  {
 		    error ("found default case not at the start of "
@@ -5242,7 +5242,7 @@ gimple_verify_flow_info (void)
 	    /* Check that we have all of them.  */
 	    for (i = 0; i < n; ++i)
 	      {
-		tree lab = CASE_LABEL (gimple_switch_label (stmt, i));
+		tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i));
 		basic_block label_bb = label_to_block (lab);
 
 		if (label_bb->aux != (void *)2)
@@ -5430,8 +5430,9 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 
     case GIMPLE_SWITCH:
       {
+	gimple_switch *switch_stmt = as_a <gimple_switch *> (stmt);
 	tree label = gimple_block_label (dest);
-        tree cases = get_cases_for_edge (e, stmt);
+        tree cases = get_cases_for_edge (e, switch_stmt);
 
 	/* If we have a list of cases associated with E, then use it
 	   as it's a lot faster than walking the entire case vector.  */
@@ -5452,7 +5453,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	       to move all the cases associated with E to E2.  */
 	    if (e2)
 	      {
-		tree cases2 = get_cases_for_edge (e2, stmt);
+		tree cases2 = get_cases_for_edge (e2, switch_stmt);
 
 		CASE_CHAIN (last) = CASE_CHAIN (cases2);
 		CASE_CHAIN (cases2) = first;
@@ -5461,11 +5462,11 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest)
 	  }
 	else
 	  {
-	    size_t i, n = gimple_switch_num_labels (stmt);
+	    size_t i, n = gimple_switch_num_labels (switch_stmt);
 
 	    for (i = 0; i < n; i++)
 	      {
-		tree elt = gimple_switch_label (stmt, i);
+		tree elt = gimple_switch_label (switch_stmt, i);
 		if (label_to_block (CASE_LABEL (elt)) == e->dest)
 		  CASE_LABEL (elt) = label;
 	      }
diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index 347b55e..39fd302 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -32,7 +32,7 @@ extern void end_recording_case_labels (void);
 extern basic_block label_to_block_fn (struct function *, tree);
 #define label_to_block(t) (label_to_block_fn (cfun, t))
 extern void cleanup_dead_labels (void);
-extern void group_case_labels_stmt (gimple_stmt *);
+extern void group_case_labels_stmt (gimple_switch *);
 extern void group_case_labels (void);
 extern void replace_uses_by (tree, tree);
 extern basic_block single_noncomplex_succ (basic_block bb);
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index 08e23ef..44bfd0c3 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -713,7 +713,8 @@ maybe_record_in_goto_queue (struct leh_state *state, gimple_stmt *stmt)
    of the labels will leave outer GIMPLE_TRY_FINALLY nodes. Verify this.  */
 
 static void
-verify_norecord_switch_expr (struct leh_state *state, gimple_stmt *switch_expr)
+verify_norecord_switch_expr (struct leh_state *state,
+			     gimple_switch *switch_expr)
 {
   struct leh_tf_state *tf = state->tf;
   size_t i, n;
@@ -2057,7 +2058,7 @@ lower_eh_constructs_2 (struct leh_state *state, gimple_stmt_iterator *gsi)
       break;
 
     case GIMPLE_SWITCH:
-      verify_norecord_switch_expr (state, stmt);
+      verify_norecord_switch_expr (state, as_a <gimple_switch *> (stmt));
       break;
 
     case GIMPLE_TRY:
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index ce4b0fb..32ae17a 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3813,15 +3813,18 @@ estimate_num_insns (gimple_stmt *stmt, eni_weights *weights)
       break;
 
     case GIMPLE_SWITCH:
-      /* Take into account cost of the switch + guess 2 conditional jumps for
-         each case label.
-
-	 TODO: once the switch expansion logic is sufficiently separated, we can
-	 do better job on estimating cost of the switch.  */
-      if (weights->time_based)
-        cost = floor_log2 (gimple_switch_num_labels (stmt)) * 2;
-      else
-        cost = gimple_switch_num_labels (stmt) * 2;
+      {
+	gimple_switch *switch_stmt = as_a <gimple_switch *> (stmt);
+	/* Take into account cost of the switch + guess 2 conditional jumps for
+	   each case label.
+
+	   TODO: once the switch expansion logic is sufficiently separated, we can
+	   do better job on estimating cost of the switch.  */
+	if (weights->time_based)
+	  cost = floor_log2 (gimple_switch_num_labels (switch_stmt)) * 2;
+	else
+	  cost = gimple_switch_num_labels (switch_stmt) * 2;
+      }
       break;
 
     case GIMPLE_CALL:
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 41a5559..7eca65a 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -685,10 +685,11 @@ generate_loops_for_partition (struct loop *loop, partition_t partition,
 		  gimple_cond_make_false (stmt);
 		  update_stmt (stmt);
 		}
-	      else if (gimple_code (stmt) == GIMPLE_SWITCH)
+	      else if (gimple_switch *switch_stmt =
+		         dyn_cast <gimple_switch *> (stmt))
 		{
 		  gimple_switch_set_index
-		      (stmt, CASE_LOW (gimple_switch_label (stmt, 1)));
+		      (switch_stmt, CASE_LOW (gimple_switch_label (switch_stmt, 1)));
 		  update_stmt (stmt);
 		}
 	      else
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 7f5b4bb..244d79d 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1784,21 +1784,21 @@ record_edge_info (basic_block bb)
       gimple_stmt *stmt = gsi_stmt (gsi);
       location_t loc = gimple_location (stmt);
 
-      if (gimple_code (stmt) == GIMPLE_SWITCH)
+      if (gimple_switch *switch_stmt = dyn_cast <gimple_switch *> (stmt))
 	{
-	  tree index = gimple_switch_index (stmt);
+	  tree index = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (index) == SSA_NAME)
 	    {
 	      int i;
-              int n_labels = gimple_switch_num_labels (stmt);
+              int n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 	      edge e;
 	      edge_iterator ei;
 
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block target_bb = label_to_block (CASE_LABEL (label));
 		  if (CASE_HIGH (label)
 		      || !CASE_LOW (label)
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 793f0fa..893a62c 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1284,7 +1284,7 @@ simplify_not_neg_expr (gimple_stmt_iterator *gsi_p)
    have values outside the range of the new type.  */
 
 static void
-simplify_gimple_switch_label_vec (gimple_stmt *stmt, tree index_type)
+simplify_gimple_switch_label_vec (gimple_switch *stmt, tree index_type)
 {
   unsigned int branch_num = gimple_switch_num_labels (stmt);
   auto_vec<tree> labels (branch_num);
@@ -1354,7 +1354,7 @@ simplify_gimple_switch_label_vec (gimple_stmt *stmt, tree index_type)
    the condition which we may be able to optimize better.  */
 
 static bool
-simplify_gimple_switch (gimple_stmt *stmt)
+simplify_gimple_switch (gimple_switch *stmt)
 {
   /* The optimization that we really care about is removing unnecessary
      casts.  That will let us do much better in propagating the inferred
@@ -3809,7 +3809,7 @@ pass_forwprop::execute (function *fun)
 	      }
 
 	    case GIMPLE_SWITCH:
-	      changed = simplify_gimple_switch (stmt);
+	      changed = simplify_gimple_switch (as_a <gimple_switch *> (stmt));
 	      break;
 
 	    case GIMPLE_COND:
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c
index 50ae88f..9b07967 100644
--- a/gcc/tree-ssa-uncprop.c
+++ b/gcc/tree-ssa-uncprop.c
@@ -171,14 +171,14 @@ associate_equivalences_with_edges (void)
       /* For a SWITCH_EXPR, a case label which represents a single
 	 value and which is the only case label which reaches the
 	 target block creates an equivalence.  */
-      else if (gimple_code (stmt) == GIMPLE_SWITCH)
+      else if (gimple_switch *switch_stmt = dyn_cast <gimple_switch *> (stmt))
 	{
-	  tree cond = gimple_switch_index (stmt);
+	  tree cond = gimple_switch_index (switch_stmt);
 
 	  if (TREE_CODE (cond) == SSA_NAME
 	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
 	    {
-	      int i, n_labels = gimple_switch_num_labels (stmt);
+	      int i, n_labels = gimple_switch_num_labels (switch_stmt);
 	      tree *info = XCNEWVEC (tree, last_basic_block_for_fn (cfun));
 
 	      /* Walk over the case label vector.  Record blocks
@@ -186,7 +186,7 @@ associate_equivalences_with_edges (void)
 		 a single value.  */
 	      for (i = 0; i < n_labels; i++)
 		{
-		  tree label = gimple_switch_label (stmt, i);
+		  tree label = gimple_switch_label (switch_stmt, i);
 		  basic_block bb = label_to_block (CASE_LABEL (label));
 
 		  if (CASE_HIGH (label)
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index a831a64..909355c 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -299,7 +299,7 @@ case_bit_test_cmp (const void *p1, const void *p2)
     node targets.  */
 
 static void
-emit_case_bit_tests (gimple_stmt *swtch, tree index_expr,
+emit_case_bit_tests (gimple_switch *swtch, tree index_expr,
 		     tree minval, tree range)
 {
   struct case_bit_test test[MAX_CASE_BIT_TESTS];
@@ -609,7 +609,7 @@ struct switch_conv_info
 /* Collect information about GIMPLE_SWITCH statement SWTCH into INFO.  */
 
 static void
-collect_switch_conv_info (gimple_stmt *swtch, struct switch_conv_info *info)
+collect_switch_conv_info (gimple_switch *swtch, struct switch_conv_info *info)
 {
   unsigned int branch_num = gimple_switch_num_labels (swtch);
   tree min_case, max_case;
@@ -853,7 +853,7 @@ gather_default_values (tree default_case, struct switch_conv_info *info)
    order of phi nodes.  SWTCH is the switch statement being converted.  */
 
 static void
-build_constructors (gimple_stmt *swtch, struct switch_conv_info *info)
+build_constructors (gimple_switch *swtch, struct switch_conv_info *info)
 {
   unsigned i, branch_num = gimple_switch_num_labels (swtch);
   tree pos = info->range_min;
@@ -945,7 +945,7 @@ constructor_contains_same_values_p (vec<constructor_elt, va_gc> *vec)
    all the constants.  */
 
 static tree
-array_value_type (gimple_stmt *swtch, tree type, int num,
+array_value_type (gimple_switch *swtch, tree type, int num,
 		  struct switch_conv_info *info)
 {
   unsigned int i, len = vec_safe_length (info->constructors[num]);
@@ -1022,7 +1022,7 @@ array_value_type (gimple_stmt *swtch, tree type, int num,
    new array.  */
 
 static void
-build_one_array (gimple_stmt *swtch, int num, tree arr_index_type, gimple_stmt *phi,
+build_one_array (gimple_switch *swtch, int num, tree arr_index_type, gimple_stmt *phi,
 		 tree tidx, struct switch_conv_info *info)
 {
   tree name, cst;
@@ -1088,7 +1088,7 @@ build_one_array (gimple_stmt *swtch, int num, tree arr_index_type, gimple_stmt *
    them.  */
 
 static void
-build_arrays (gimple_stmt *swtch, struct switch_conv_info *info)
+build_arrays (gimple_switch *swtch, struct switch_conv_info *info)
 {
   tree arr_index_type;
   tree tidx, sub, utype;
@@ -1209,7 +1209,7 @@ fix_phi_nodes (edge e1f, edge e2f, basic_block bbf,
 */
 
 static void
-gen_inbound_check (gimple_stmt *swtch, struct switch_conv_info *info)
+gen_inbound_check (gimple_switch *swtch, struct switch_conv_info *info)
 {
   tree label_decl1 = create_artificial_label (UNKNOWN_LOCATION);
   tree label_decl2 = create_artificial_label (UNKNOWN_LOCATION);
@@ -1329,7 +1329,7 @@ gen_inbound_check (gimple_stmt *swtch, struct switch_conv_info *info)
    conversion failed.  */
 
 static const char *
-process_switch (gimple_stmt *swtch)
+process_switch (gimple_switch *swtch)
 {
   struct switch_conv_info info;
 
@@ -1467,7 +1467,7 @@ pass_convert_switch::execute (function *fun)
 	    putc ('\n', dump_file);
 	  }
 
-	failure_reason = process_switch (stmt);
+	failure_reason = process_switch (as_a <gimple_switch *> (stmt));
 	if (! failure_reason)
 	  {
 	    if (dump_file)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index b8db7a3..9252219 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -168,7 +168,7 @@ static bool values_propagated;
 static int *vr_phi_edge_counts;
 
 typedef struct {
-  gimple_stmt *stmt;
+  gimple_switch *stmt;
   tree vec;
 } switch_update;
 
@@ -5616,7 +5616,7 @@ compare_case_labels (const void *p1, const void *p2)
    list of assertions for the corresponding operands.  */
 
 static bool
-find_switch_asserts (basic_block bb, gimple_stmt *last)
+find_switch_asserts (basic_block bb, gimple_switch *last)
 {
   bool need_assert;
   gimple_stmt_iterator bsi;
@@ -5787,7 +5787,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
   if (last
       && gimple_code (last) == GIMPLE_SWITCH
       && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
-    need_assert |= find_switch_asserts (bb, last);
+    need_assert |= find_switch_asserts (bb, as_a <gimple_switch *> (last));
 
   /* Traverse all the statements in BB marking used names and looking
      for statements that may infer assertions for their used operands.  */
@@ -7269,7 +7269,7 @@ vrp_visit_cond_stmt (gimple_stmt *stmt, edge *taken_edge_p)
    returned. */
 
 static bool
-find_case_label_index (gimple_stmt *stmt, size_t start_idx, tree val, size_t *idx)
+find_case_label_index (gimple_switch *stmt, size_t start_idx, tree val, size_t *idx)
 {
   size_t n = gimple_switch_num_labels (stmt);
   size_t low, high;
@@ -7319,7 +7319,7 @@ find_case_label_index (gimple_stmt *stmt, size_t start_idx, tree val, size_t *id
    Returns true if the default label is not needed. */
 
 static bool
-find_case_label_range (gimple_stmt *stmt, tree min, tree max, size_t *min_idx,
+find_case_label_range (gimple_switch *stmt, tree min, tree max, size_t *min_idx,
 		       size_t *max_idx)
 {
   size_t i, j;
@@ -7375,7 +7375,7 @@ find_case_label_range (gimple_stmt *stmt, tree min, tree max, size_t *min_idx,
    Returns true if the default label is not needed.  */
 
 static bool
-find_case_label_ranges (gimple_stmt *stmt, value_range_t *vr, size_t *min_idx1,
+find_case_label_ranges (gimple_switch *stmt, value_range_t *vr, size_t *min_idx1,
 			size_t *max_idx1, size_t *min_idx2,
 			size_t *max_idx2)
 {
@@ -7453,7 +7453,7 @@ find_case_label_ranges (gimple_stmt *stmt, value_range_t *vr, size_t *min_idx1,
    SSA_PROP_VARYING.  */
 
 static enum ssa_prop_result
-vrp_visit_switch_stmt (gimple_stmt *stmt, edge *taken_edge_p)
+vrp_visit_switch_stmt (gimple_switch *stmt, edge *taken_edge_p)
 {
   tree op, val;
   value_range_t *vr;
@@ -7568,8 +7568,8 @@ vrp_visit_stmt (gimple_stmt *stmt, edge *taken_edge_p, tree *output_p)
     return vrp_visit_assignment_or_call (stmt, output_p);
   else if (gimple_code (stmt) == GIMPLE_COND)
     return vrp_visit_cond_stmt (stmt, taken_edge_p);
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return vrp_visit_switch_stmt (stmt, taken_edge_p);
+  else if (gimple_switch *switch_stmt = dyn_cast <gimple_switch *> (stmt))
+    return vrp_visit_switch_stmt (switch_stmt, taken_edge_p);
 
   /* All other statements produce nothing of interest for VRP, so mark
      their outputs varying and prevent further simulation.  */
@@ -9020,7 +9020,7 @@ simplify_cond_using_ranges (gimple_stmt *stmt)
    argument.  */
 
 static bool
-simplify_switch_using_ranges (gimple_stmt *stmt)
+simplify_switch_using_ranges (gimple_switch *stmt)
 {
   tree op = gimple_switch_index (stmt);
   value_range_t *vr;
@@ -9414,8 +9414,8 @@ simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
     }
   else if (gimple_code (stmt) == GIMPLE_COND)
     return simplify_cond_using_ranges (stmt);
-  else if (gimple_code (stmt) == GIMPLE_SWITCH)
-    return simplify_switch_using_ranges (stmt);
+  else if (gimple_switch *switch_stmt = dyn_cast <gimple_switch *> (stmt))
+    return simplify_switch_using_ranges (switch_stmt);
   else if (is_gimple_call (stmt)
 	   && gimple_call_internal_p (stmt))
     return simplify_internal_call_using_ranges (gsi, stmt);
-- 
1.8.5.3

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

* [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *"
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
  2014-05-02 21:54                   ` [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *" David Malcolm
  2014-05-02 21:54                   ` [PATCH 3/3] Introduce gimple_switch and use it in various places David Malcolm
@ 2014-05-02 21:54                   ` David Malcolm
  2014-05-09  6:49                     ` Jeff Law
  2014-05-05  8:22                   ` [PATCH 0/3] Compile-time gimple checking, without typedefs Richard Biener
  2014-05-09  6:43                   ` Jeff Law
  4 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-02 21:54 UTC (permalink / raw)
  To: GCC Patches
  Cc: Jeff Law, Richard Biener, Richard Sandiford, Andrew MacLeod,
	David Malcolm

gcc/
	* coretypes.h (gimple): Drop typedef.
	(const_gimple): Likewise.
	(gimple_seq): Convert from being a "gimple" to a "gimple_stmt *".

	* gimple.h (gimple_statement_base): Rename to...
	(gimple_stmt): ...this.
	(gimple_statement_with_ops_base): Rename to...
	(gimple_stmt_with_ops_base): ...this.
	(gimple_statement_with_ops): Rename to...
	(gimple_stmt_with_ops): ...this.
        (gimple_statement_with_memory_ops_base): Rename to...
	(gimple_stmt_with_memory_ops_base): ...this.
        (gimple_statement_with_memory_ops): Rename to...
	(gimple_stmt_with_memory_ops): ...this.
        (gimple_statement_call): Rename to...
        (gimple_call): ...this.
        (gimple_statement_omp): Rename to...
        (gimple_omp): ...this.
        (gimple_statement_bind): Rename to...
        (gimple_bind): ...this.
        (gimple_statement_catch): Rename to...
        (gimple_catch): ...this.
        (gimple_statement_eh_filter): Rename to...
        (gimple_eh_filter): ...this.
        (gimple_statement_eh_else): Rename to...
        (gimple_eh_else): ...this.
        (gimple_statement_eh_mnt): Rename to...
        (gimple_eh_mnt): ...this.
        (gimple_statement_phi): Rename to...
        (gimple_phi): ...this.
        (gimple_statement_eh_ctrl): Rename to...
        (gimple_eh_ctrl): ...this.
        (gimple_statement_resx): Rename to...
        (gimple_resx): ...this.
        (gimple_statement_eh_dispatch): Rename to...
        (gimple_eh_dispatch): ...this.
        (gimple_statement_try): Rename to...
        (gimple_try): ...this.
        (gimple_statement_wce): Rename to...
        (gimple_wce): ...this.
        (gimple_statement_asm): Rename to...
        (gimple_asm): ...this.
        (gimple_statement_omp_critical): Rename to...
        (gimple_omp_critical): ...this.
        (gimple_statement_omp_for): Rename to...
        (gimple_omp_for): ...this.
        (gimple_statement_omp_parallel_layout): Rename to...
        (gimple_omp_parallel_layout): ...this.
        (gimple_statement_omp_taskreg): Rename to...
        (gimple_omp_taskreg): ...this.
        (gimple_statement_omp_parallel): Rename to...
        (gimple_omp_parallel): ...this.
        (gimple_statement_omp_target): Rename to...
        (gimple_omp_target): ...this.
        (gimple_statement_omp_task): Rename to...
        (gimple_omp_task): ...this.
        (gimple_statement_omp_sections): Rename to...
        (gimple_omp_sections): ...this.
        (gimple_statement_omp_continue): Rename to...
        (gimple_omp_continue): ...this.
        (gimple_statement_omp_single_layout): Rename to...
        (gimple_omp_single_layout): ...this.
        (gimple_statement_omp_single): Rename to...
        (gimple_omp_single): ...this.
        (gimple_statement_omp_teams): Rename to...
        (gimple_omp_teams): ...this.
        (gimple_statement_omp_atomic_load): Rename to...
        (gimple_omp_atomic_load): ...this.
        (gimple_statement_omp_atomic_store_layout): Rename to...
        (gimple_omp_atomic_store_layout): ...this.
        (gimple_statement_omp_atomic_store): Rename to...
        (gimple_omp_atomic_store): ...this.
        (gimple_statement_omp_return): Rename to...
        (gimple_omp_return): ...this.
        (gimple_statement_transaction): Rename to...
        (gimple_transaction): ...this.

        (is_a_helper <gimple_statement_asm *>::test): Rename to...
        (is_a_helper <gimple_asm *>::test): ...this.
        (is_a_helper <gimple_statement_bind *>::test): Rename to...
        (is_a_helper <gimple_bind *>::test): ...this.
        (is_a_helper <gimple_statement_call *>::test): Rename to...
        (is_a_helper <gimple_call *>::test): ...this.
        (is_a_helper <gimple_statement_catch *>::test): Rename to...
        (is_a_helper <gimple_catch *>::test): ...this.
        (is_a_helper <gimple_statement_resx *>::test): Rename to...
        (is_a_helper <gimple_resx *>::test): ...this.
        (is_a_helper <gimple_statement_eh_dispatch *>::test): Rename to...
        (is_a_helper <gimple_eh_dispatch *>::test): ...this.
        (is_a_helper <gimple_statement_eh_else *>::test): Rename to...
        (is_a_helper <gimple_eh_else *>::test): ...this.
        (is_a_helper <gimple_statement_eh_filter *>::test): Rename to...
        (is_a_helper <gimple_eh_filter *>::test): ...this.
        (is_a_helper <gimple_statement_eh_mnt *>::test): Rename to...
        (is_a_helper <gimple_eh_mnt *>::test): ...this.
        (is_a_helper <gimple_statement_omp_atomic_load *>::test): Rename to...
        (is_a_helper <gimple_omp_atomic_load *>::test): ...this.
        (is_a_helper <gimple_statement_omp_atomic_store *>::test): Rename to...
        (is_a_helper <gimple_omp_atomic_store *>::test): ...this.
        (is_a_helper <gimple_statement_omp_return *>::test): Rename to...
        (is_a_helper <gimple_omp_return *>::test): ...this.
        (is_a_helper <gimple_statement_omp_continue *>::test): Rename to...
        (is_a_helper <gimple_omp_continue *>::test): ...this.
        (is_a_helper <gimple_statement_omp_critical *>::test): Rename to...
        (is_a_helper <gimple_omp_critical *>::test): ...this.
        (is_a_helper <gimple_statement_omp_for *>::test): Rename to...
        (is_a_helper <gimple_omp_for *>::test): ...this.
        (is_a_helper <gimple_statement_omp_taskreg *>::test): Rename to...
        (is_a_helper <gimple_omp_taskreg *>::test): ...this.
        (is_a_helper <gimple_statement_omp_parallel *>::test): Rename to...
        (is_a_helper <gimple_omp_parallel *>::test): ...this.
        (is_a_helper <gimple_statement_omp_target *>::test): Rename to...
        (is_a_helper <gimple_omp_target *>::test): ...this.
        (is_a_helper <gimple_statement_omp_sections *>::test): Rename to...
        (is_a_helper <gimple_omp_sections *>::test): ...this.
        (is_a_helper <gimple_statement_omp_single *>::test): Rename to...
        (is_a_helper <gimple_omp_single *>::test): ...this.
        (is_a_helper <gimple_statement_omp_teams *>::test): Rename to...
        (is_a_helper <gimple_omp_teams *>::test): ...this.
        (is_a_helper <gimple_statement_omp_task *>::test): Rename to...
        (is_a_helper <gimple_omp_task *>::test): ...this.
        (is_a_helper <gimple_statement_phi *>::test): Rename to...
        (is_a_helper <gimple_phi *>::test): ...this.
        (is_a_helper <gimple_statement_transaction *>::test): Rename to...
        (is_a_helper <gimple_transaction *>::test): ...this.
        (is_a_helper <gimple_statement_try *>::test): Rename to...
        (is_a_helper <gimple_try *>::test): ...this.
        (is_a_helper <gimple_statement_wce *>::test): Rename to...
        (is_a_helper <gimple_wce *>::test): ...this.
        (is_a_helper <gimple_statement_with_ops *>::test): Rename to...
        (is_a_helper <gimple_stmt_with_ops *>::test): ...this.
        (is_a_helper <gimple_statement_with_memory_ops *>::test): Rename to...
        (is_a_helper <gimple_stmt_with_memory_ops *>::test): ...this.

        (is_a_helper <const gimple_statement_asm *>::test): Rename to...
        (is_a_helper <const gimple_asm *>::test): ...this.
        (is_a_helper <const gimple_statement_bind *>::test): Rename to...
        (is_a_helper <const gimple_bind *>::test): ...this.
        (is_a_helper <const gimple_statement_call *>::test): Rename to...
        (is_a_helper <const gimple_call *>::test): ...this.
        (is_a_helper <const gimple_statement_catch *>::test): Rename to...
        (is_a_helper <const gimple_catch *>::test): ...this.
        (is_a_helper <const gimple_statement_resx *>::test): Rename to...
        (is_a_helper <const gimple_resx *>::test): ...this.
        (is_a_helper <const gimple_statement_eh_dispatch *>::test): Rename to...
        (is_a_helper <const gimple_eh_dispatch *>::test): ...this.
        (is_a_helper <const gimple_statement_eh_filter *>::test): Rename to...
        (is_a_helper <const gimple_eh_filter *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_atomic_load *>::test): Rename to...
        (is_a_helper <const gimple_omp_atomic_load *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_atomic_store *>::test): Rename to...
        (is_a_helper <const gimple_omp_atomic_store *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_return *>::test): Rename to...
        (is_a_helper <const gimple_omp_return *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_continue *>::test): Rename to...
        (is_a_helper <const gimple_omp_continue *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_critical *>::test): Rename to...
        (is_a_helper <const gimple_omp_critical *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_for *>::test): Rename to...
        (is_a_helper <const gimple_omp_for *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_taskreg *>::test): Rename to...
        (is_a_helper <const gimple_omp_taskreg *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_parallel *>::test): Rename to...
        (is_a_helper <const gimple_omp_parallel *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_target *>::test): Rename to...
        (is_a_helper <const gimple_omp_target *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_sections *>::test): Rename to...
        (is_a_helper <const gimple_omp_sections *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_single *>::test): Rename to...
        (is_a_helper <const gimple_omp_single *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_teams *>::test): Rename to...
        (is_a_helper <const gimple_omp_teams *>::test): ...this.
        (is_a_helper <const gimple_statement_omp_task *>::test): Rename to...
        (is_a_helper <const gimple_omp_task *>::test): ...this.
        (is_a_helper <const gimple_statement_phi *>::test): Rename to...
        (is_a_helper <const gimple_phi *>::test): ...this.
        (is_a_helper <const gimple_statement_transaction *>::test): Rename to...
        (is_a_helper <const gimple_transaction *>::test): ...this.
        (is_a_helper <const gimple_statement_with_ops *>::test): Rename to...
        (is_a_helper <const gimple_stmt_with_ops *>::test): ...this.
        (is_a_helper <const gimple_statement_with_memory_ops *>::test): Rename to...
        (is_a_helper <const gimple_stmt_with_memory_ops *>::test): ...this.

	(gimple_build_try): Update for renaming of gimple statement types.
	(gimple_use_ops): Likewise.
	(gimple_set_use_ops): Likewise.
	(gimple_vuse): Likewise.
	(gimple_vuse_ptr): Likewise.
	(gimple_vdef_ptr): Likewise.
	(gimple_set_vuse): Likewise.
	(gimple_set_vdef): Likewise.
	(gimple_omp_return_set_lhs): Likewise.
	(gimple_omp_return_lhs): Likewise.
	(gimple_omp_return_lhs_ptr): Likewise.
	(gimple_call_internal_fn): Likewise.
	(gimple_call_fntype): Likewise.
	(gimple_call_set_fntype): Likewise.
	(gimple_call_set_internal_fn): Likewise.
	(gimple_call_use_set): Likewise.
	(gimple_call_clobber_set): Likewise.
	(gimple_bind_vars): Likewise.
	(gimple_bind_set_vars): Likewise.
	(gimple_bind_append_vars): Likewise.
	(gimple_bind_body_ptr): Likewise.
	(gimple_bind_set_body): Likewise.
	(gimple_bind_add_stmt): Likewise.
	(gimple_bind_add_seq): Likewise.
	(gimple_bind_block): Likewise.
	(gimple_bind_set_block): Likewise.
	(gimple_asm_ninputs): Likewise.
	(gimple_asm_noutputs): Likewise.
	(gimple_asm_nclobbers): Likewise.
	(gimple_asm_nlabels): Likewise.
	(gimple_asm_input_op): Likewise.
	(gimple_asm_input_op_ptr): Likewise.
	(gimple_asm_set_input_op): Likewise.
	(gimple_asm_output_op): Likewise.
	(gimple_asm_output_op_ptr): Likewise.
	(gimple_asm_set_output_op): Likewise.
	(gimple_asm_clobber_op): Likewise.
	(gimple_asm_set_clobber_op): Likewise.
	(gimple_asm_label_op): Likewise.
	(gimple_asm_set_label_op): Likewise.
	(gimple_asm_string): Likewise.
	(gimple_catch_types): Likewise.
	(gimple_catch_types_ptr): Likewise.
	(gimple_catch_handler_ptr): Likewise.
	(gimple_catch_set_types): Likewise.
	(gimple_catch_set_handler): Likewise.
	(gimple_eh_filter_types): Likewise.
	(gimple_eh_filter_types_ptr): Likewise.
        (gimple_eh_filter_failure_ptr)
	(gimple_eh_filter_set_types): Likewise.
	(gimple_eh_filter_set_failure): Likewise.
	(gimple_eh_must_not_throw_fndecl): Likewise.
	(gimple_eh_must_not_throw_set_fndecl): Likewise.
	(gimple_eh_else_n_body_ptr): Likewise.
	(gimple_eh_else_e_body_ptr): Likewise.
	(gimple_eh_else_set_n_body): Likewise.
	(gimple_eh_else_set_e_body): Likewise.
	(gimple_try_eval_ptr): Likewise.
	(gimple_try_cleanup_ptr): Likewise.
	(gimple_try_set_eval): Likewise.
	(gimple_try_set_cleanup): Likewise.
	(gimple_wce_cleanup_ptr): Likewise.
	(gimple_wce_set_cleanup): Likewise.
	(gimple_phi_capacity): Likewise.
	(gimple_phi_num_args): Likewise.
	(gimple_phi_result): Likewise.
	(gimple_phi_result_ptr): Likewise.
	(gimple_phi_set_result): Likewise.
	(gimple_phi_arg): Likewise.
	(gimple_phi_set_arg): Likewise.
        (gimple_resx_region): Likewise.
	(gimple_resx_set_region): Likewise.
	(gimple_eh_dispatch_region): Likewise.
	(gimple_eh_dispatch_set_region): Likewise.
	(gimple_omp_body_ptr): Likewise.
	(gimple_omp_set_body): Likewise.
	(gimple_omp_critical_name): Likewise.
	(gimple_omp_critical_name_ptr): Likewise.
        (gimple_omp_critical_set_name): Likewise.
	(gimple_omp_for_clauses): Likewise.
	(gimple_omp_for_clauses_ptr): Likewise.
	(gimple_omp_for_set_clauses): Likewise.
	(gimple_omp_for_collapse): Likewise.
	(gimple_omp_for_index): Likewise.
	(gimple_omp_for_index_ptr): Likewise.
	(gimple_omp_for_set_index): Likewise.
	(gimple_omp_for_initial): Likewise.
	(gimple_omp_for_initial_ptr): Likewise.
	(gimple_omp_for_set_initial): Likewise.
	(gimple_omp_for_final): Likewise.
	(gimple_omp_for_final_ptr): Likewise.
	(gimple_omp_for_set_final): Likewise.
	(gimple_omp_for_incr): 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_parallel_clauses): Likewise.
	(gimple_omp_parallel_clauses_ptr): Likewise.
	(gimple_omp_parallel_set_clauses): Likewise.
	(gimple_omp_parallel_child_fn): Likewise.
	(gimple_omp_parallel_child_fn_ptr): Likewise.
	(gimple_omp_parallel_set_child_fn): Likewise.
	(gimple_omp_parallel_data_arg): Likewise.
	(gimple_omp_parallel_data_arg_ptr): Likewise.
	(gimple_omp_parallel_set_data_arg): Likewise.
	(gimple_omp_task_clauses): Likewise.
	(gimple_omp_task_clauses_ptr): Likewise.
	(gimple_omp_task_set_clauses): Likewise.
	(gimple_omp_task_child_fn): Likewise.
	(gimple_omp_task_child_fn_ptr): Likewise.
	(gimple_omp_task_set_child_fn): Likewise.
	(gimple_omp_task_data_arg): Likewise.
	(gimple_omp_task_data_arg_ptr): Likewise.
	(gimple_omp_task_set_data_arg): Likewise.
	(gimple_omp_taskreg_clauses): Likewise.
	(gimple_omp_taskreg_clauses_ptr): Likewise.
	(gimple_omp_taskreg_set_clauses): Likewise.
	(gimple_omp_taskreg_child_fn): Likewise.
	(gimple_omp_taskreg_child_fn_ptr): Likewise.
	(gimple_omp_taskreg_set_child_fn): Likewise.
	(gimple_omp_taskreg_data_arg): Likewise.
	(gimple_omp_taskreg_data_arg_ptr): Likewise.
	(gimple_omp_taskreg_set_data_arg): Likewise.
	(gimple_omp_task_copy_fn): Likewise.
	(gimple_omp_task_copy_fn_ptr): Likewise.
	(gimple_omp_task_set_copy_fn): Likewise.
	(gimple_omp_task_arg_size): Likewise.
	(gimple_omp_task_arg_size_ptr): Likewise.
	(gimple_omp_task_set_arg_size): Likewise.
	(gimple_omp_task_arg_align): Likewise.
	(gimple_omp_task_arg_align_ptr): Likewise.
	(gimple_omp_task_set_arg_align): Likewise.
	(gimple_omp_single_clauses): Likewise.
	(gimple_omp_single_clauses_ptr): Likewise.
	(gimple_omp_single_set_clauses): Likewise.
	(gimple_omp_target_clauses): Likewise.
	(gimple_omp_target_clauses_ptr): Likewise.
	(gimple_omp_target_set_clauses): Likewise.
	(gimple_omp_target_child_fn): Likewise.
	(gimple_omp_target_child_fn_ptr): Likewise.
	(gimple_omp_target_set_child_fn): Likewise.
	(gimple_omp_target_data_arg): Likewise.
	(gimple_omp_target_data_arg_ptr): Likewise.
	(gimple_omp_target_set_data_arg): Likewise.
	(gimple_omp_teams_clauses): Likewise.
	(gimple_omp_teams_clauses_ptr): Likewise.
	(gimple_omp_teams_set_clauses): Likewise.
	(gimple_omp_sections_clauses): Likewise.
	(gimple_omp_sections_clauses_ptr): Likewise.
	(gimple_omp_sections_set_clauses): Likewise.
	(gimple_omp_sections_control): Likewise.
	(gimple_omp_sections_control_ptr): Likewise.
	(gimple_omp_sections_set_control): Likewise.
	(gimple_omp_for_set_cond): Likewise.
	(gimple_omp_for_cond): Likewise.
	(gimple_omp_atomic_store_set_val): Likewise.
	(gimple_omp_atomic_store_val): Likewise.
	(gimple_omp_atomic_store_val_ptr): Likewise.
	(gimple_omp_atomic_load_set_lhs): Likewise.
	(gimple_omp_atomic_load_lhs): Likewise.
	(gimple_omp_atomic_load_lhs_ptr): Likewise.
	(gimple_omp_atomic_load_set_rhs): Likewise.
	(gimple_omp_atomic_load_rhs): Likewise.
	(gimple_omp_atomic_load_rhs_ptr): Likewise.
	(gimple_omp_continue_control_def): Likewise.
	(gimple_omp_continue_control_def_ptr): Likewise.
	(gimple_omp_continue_set_control_def): Likewise.
	(gimple_omp_continue_control_use): Likewise.
	(gimple_omp_continue_control_use_ptr): Likewise.
	(gimple_omp_continue_set_control_use): Likewise.
	(gimple_transaction_body_ptr): Likewise.
	(gimple_transaction_label): Likewise.
	(gimple_transaction_label_ptr): Likewise.
        (gimple_transaction_set_body): Likewise.
        (gimple_transaction_set_label): Likewise.

	* gsstruct.def: Update for renamings of the gimple statement classes.

	* system.h (CONST_CAST_GIMPLE): Update for renaming of
	"gimple_statement_base" to "gimple_stmt".

	* target.def (DEFHOOK_UNDOC): Remove "const_gimple" in favor of
	"const gimple_stmt *".

	* ggc.h (ggc_alloc_cleared_gimple_statement_stat): Rename to...
	(ggc_alloc_cleared_gimple_stmt_stat): ...this, updating for renaming
	of gimple statement type.

	* gimple-pretty-print.h (debug): Update for renaming of
	"gimple_statement_base" to "gimple_stmt".
	* gimple-pretty-print.c (debug): Likewise.

	* gimple-ssa.h (gimple_vuse_op): Update for renaming of
	"gimple_statement_with_memory_ops" to "gimple_stmt_with_memory_ops".
	(gimple_vdef_op): Likewise.

	* gimple.c (gimple_alloc_stat): Update for renaming of gimple
	statement types.
	(gimple_build_asm_1): Likewise.
	(gimple_build_try): Likewise.
	(gimple_build_resx): Likewise.
	(gimple_build_eh_dispatch): Likewise.
	(gimple_build_omp_for): Likewise.
	(gimple_copy): Likewise.

	* gimple-streamer-in.c (input_gimple_stmt): Update for renaming of
	"gimple_statement_asm" to "gimple_asm".

	* gimplify.c (gimplify_cleanup_point_expr): Likewise for
	"gimple_statement_try" to "gimple_try".

	* tree-dfa.c (dump_dfa_stats): Likewise for "gimple_statement_phi"
	to "gimple_phi".

	* tree-phinodes.c (phinodes_print_statistics): Likewise.
	(allocate_phi_node): Likewise.
	(ideal_phi_node_len): Likewise.
	(make_phi_node): Likewise.
	(release_phi_node): Likewise.
	(resize_phi_node): Likewise.
	(reserve_phi_args_for_new_edge): Likewise.
	(remove_phi_arg_num): Likewise.
	(remove_phi_args): Likewise.

	* tree-ssa-ccp.c (gimple_htab): Likewise for renaming of
	"gimple_statement_base" to "gimple_stmt".

	* gdbhooks.py (build_pretty_printer): Update to reflect above changes.

	* doc/gimple.texi: Update to reflect the above changes, and those
	in the automated patch that follows.

gcc/testsuite/
	* g++.dg/plugin/selfassign.c (get_real_ref_rhs): Replace "gimple"
	typedef with "gimple_stmt *".
	(get_non_ssa_expr): Likewise.
	(compare_and_warn): Likewise.
	(warn_self_assign): Likewise.

	* gcc.dg/plugin/selfassign.c (get_real_ref_rhs): Likewise.
	(get_non_ssa_expr): Likewise.
	(compare_and_warn): Likewise.
	(warn_self_assign): Likewise.
---
 gcc/coretypes.h                          |   5 +-
 gcc/doc/gimple.texi                      | 808 +++++++++++++++++-------------
 gcc/gdbhooks.py                          |   2 +-
 gcc/ggc.h                                |   6 +-
 gcc/gimple-pretty-print.c                |   4 +-
 gcc/gimple-pretty-print.h                |   4 +-
 gcc/gimple-ssa.h                         |   8 +-
 gcc/gimple-streamer-in.c                 |   2 +-
 gcc/gimple.c                             |  28 +-
 gcc/gimple.h                             | 830 +++++++++++++++----------------
 gcc/gimplify.c                           |   2 +-
 gcc/gsstruct.def                         |  52 +-
 gcc/system.h                             |   2 +-
 gcc/target.def                           |   2 +-
 gcc/testsuite/g++.dg/plugin/selfassign.c |   8 +-
 gcc/testsuite/gcc.dg/plugin/selfassign.c |   8 +-
 gcc/tree-dfa.c                           |   2 +-
 gcc/tree-phinodes.c                      |  34 +-
 gcc/tree-ssa-ccp.c                       |   2 +-
 19 files changed, 972 insertions(+), 837 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index d70fb11..c48f146 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -61,9 +61,8 @@ typedef const struct rtvec_def *const_rtvec;
 union tree_node;
 typedef union tree_node *tree;
 typedef const union tree_node *const_tree;
-typedef struct gimple_statement_base *gimple;
-typedef const struct gimple_statement_base *const_gimple;
-typedef gimple gimple_seq;
+class gimple_stmt;
+typedef gimple_stmt *gimple_seq;
 struct gimple_stmt_iterator;
 union section;
 typedef union section section;
diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 1e5473d..6fc4360 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -92,8 +92,8 @@ groups: a header describing the instruction and its locations,
 and a variable length body with all the operands. Tuples are
 organized into a hierarchy with 3 main classes of tuples.
 
-@subsection @code{gimple_statement_base} (gsbase)
-@cindex gimple_statement_base
+@subsection @code{gimple_stmt} (gsbase)
+@cindex gimple_stmt
 
 This is the root of the hierarchy, it holds basic information
 needed by most GIMPLE statements. There are some fields that
@@ -192,12 +192,12 @@ Lexical block holding this statement.  Also used for debug
 information generation.
 @end itemize
 
-@subsection @code{gimple_statement_with_ops}
-@cindex gimple_statement_with_ops
+@subsection @code{gimple_stmt_with_ops}
+@cindex gimple_stmt_with_ops
 
 This tuple is actually split in two:
-@code{gimple_statement_with_ops_base} and
-@code{gimple_statement_with_ops}. This is needed to accommodate the
+@code{gimple_stmt_with_ops_base} and
+@code{gimple_stmt_with_ops}. This is needed to accommodate the
 way the operand vector is allocated. The operand vector is
 defined to be an array of 1 element. So, to allocate a dynamic
 number of operands, the memory allocator (@code{gimple_alloc}) simply
@@ -205,11 +205,11 @@ allocates enough memory to hold the structure itself plus @code{N
 - 1} operands which run ``off the end'' of the structure. For
 example, to allocate space for a tuple with 3 operands,
 @code{gimple_alloc} reserves @code{sizeof (struct
-gimple_statement_with_ops) + 2 * sizeof (tree)} bytes.
+gimple_stmt_with_ops) + 2 * sizeof (tree)} bytes.
 
 On the other hand, several fields in this tuple need to be shared
-with the @code{gimple_statement_with_memory_ops} tuple. So, these
-common fields are placed in @code{gimple_statement_with_ops_base} which
+with the @code{gimple_stmt_with_memory_ops} tuple. So, these
+common fields are placed in @code{gimple_stmt_with_ops_base} which
 is then inherited from the other two tuples.
 
 
@@ -223,7 +223,7 @@ is then inherited from the other two tuples.
 
 @itemize @bullet
 @item @code{gsbase}
-Inherited from @code{struct gimple_statement_base}.
+Inherited from @code{struct gimple_stmt}.
 
 @item @code{def_ops}
 Array of pointers into the operand array indicating all the slots that
@@ -239,14 +239,14 @@ Similar to @code{def_ops} but for variables read by the statement.
 Array of trees with @code{num_ops} slots.
 @end itemize
 
-@subsection @code{gimple_statement_with_memory_ops}
+@subsection @code{gimple_stmt_with_memory_ops}
 
-This tuple is essentially identical to @code{gimple_statement_with_ops},
+This tuple is essentially identical to @code{gimple_stmt_with_ops},
 except that it contains 4 additional fields to hold vectors
 related memory stores and loads.  Similar to the previous case,
 the structure is split in two to accommodate for the operand
-vector (@code{gimple_statement_with_memory_ops_base} and
-@code{gimple_statement_with_memory_ops}).
+vector (@code{gimple_stmt_with_memory_ops_base} and
+@code{gimple_stmt_with_memory_ops}).
 
 
 @multitable {@code{vdef_ops}}	{80 + 8 * @code{num_ops} bytes}
@@ -300,17 +300,17 @@ kinds, along with their relationships to @code{GSS_} values (layouts) and
 @code{GIMPLE_} values (codes):
 
 @smallexample
-   gimple_statement_base
+   gimple_stmt
      |    layout: GSS_BASE
      |    used for 4 codes: GIMPLE_ERROR_MARK
      |                      GIMPLE_NOP
      |                      GIMPLE_OMP_SECTIONS_SWITCH
      |                      GIMPLE_PREDICT
      |
-     + gimple_statement_with_ops_base
+     + gimple_stmt_with_ops_base
      |   |    (no GSS layout)
      |   |
-     |   + gimple_statement_with_ops
+     |   + gimple_stmt_with_ops
      |   |        layout: GSS_WITH_OPS
      |   |        Used for 5 codes: GIMPLE_COND
      |   |                          GIMPLE_DEBUG
@@ -318,104 +318,104 @@ kinds, along with their relationships to @code{GSS_} values (layouts) and
      |   |                          GIMPLE_LABEL
      |   |                          GIMPLE_SWITCH
      |   |
-     |   + gimple_statement_with_memory_ops_base
+     |   + gimple_stmt_with_memory_ops_base
      |       |    layout: GSS_WITH_MEM_OPS_BASE
      |       |
-     |       + gimple_statement_with_memory_ops
+     |       + gimple_stmt_with_memory_ops
      |       |        layout: GSS_WITH_MEM_OPS.
      |       |        used for codes GIMPLE_ASSIGN and GIMPLE_RETURN.
      |       |
-     |       + gimple_statement_call
+     |       + gimple_call
      |       |        layout: GSS_CALL, code: GIMPLE_CALL
      |       |
-     |       + gimple_statement_asm
+     |       + gimple_asm
      |       |        layout: GSS_ASM, code: GIMPLE_ASM
      |       |
-     |       + gimple_statement_transaction
+     |       + gimple_transaction
      |                layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
      |
-     + gimple_statement_omp
+     + gimple_omp
      |   |    layout: GSS_OMP.  Used for code GIMPLE_OMP_SECTION
      |   |
-     |   + gimple_statement_omp_critical
+     |   + gimple_omp_critical
      |   |        layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
      |   |
-     |   + gimple_statement_omp_for
+     |   + gimple_omp_for
      |   |        layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
      |   |
-     |   + gimple_statement_omp_parallel_layout
+     |   + gimple_omp_parallel_layout
      |   |   |    layout: GSS_OMP_PARALLEL_LAYOUT
      |   |   |
-     |   |   + gimple_statement_omp_taskreg
+     |   |   + gimple_omp_taskreg
      |   |   |   |
-     |   |   |   + gimple_statement_omp_parallel
+     |   |   |   + gimple_omp_parallel
      |   |   |   |        code: GIMPLE_OMP_PARALLEL
      |   |   |   |
-     |   |   |   + gimple_statement_omp_task
+     |   |   |   + gimple_omp_task
      |   |   |            code: GIMPLE_OMP_TASK
      |   |   |
-     |   |   + gimple_statement_omp_target
+     |   |   + gimple_omp_target
      |   |            code: GIMPLE_OMP_TARGET
      |   |
-     |   + gimple_statement_omp_sections
+     |   + gimple_omp_sections
      |   |        layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
      |   |
-     |   + gimple_statement_omp_single_layout
+     |   + gimple_omp_single_layout
      |       |    layout: GSS_OMP_SINGLE_LAYOUT
      |       |
-     |       + gimple_statement_omp_single
+     |       + gimple_omp_single
      |       |        code: GIMPLE_OMP_SINGLE
      |       |
-     |       + gimple_statement_omp_teams
+     |       + gimple_omp_teams
      |                code: GIMPLE_OMP_TEAMS
      |
-     + gimple_statement_bind
+     + gimple_bind
      |        layout: GSS_BIND, code: GIMPLE_BIND
      |
-     + gimple_statement_catch
+     + gimple_catch
      |        layout: GSS_CATCH, code: GIMPLE_CATCH
      |
-     + gimple_statement_eh_filter
+     + gimple_eh_filter
      |        layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER
      |
-     + gimple_statement_eh_else
+     + gimple_eh_else
      |        layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE
      |
-     + gimple_statement_eh_mnt
+     + gimple_eh_mnt
      |        layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW
      |
-     + gimple_statement_phi
+     + gimple_phi
      |        layout: GSS_PHI, code: GIMPLE_PHI
      |
-     + gimple_statement_eh_ctrl
+     + gimple_eh_ctrl
      |   |    layout: GSS_EH_CTRL
      |   |
-     |   + gimple_statement_resx
+     |   + gimple_resx
      |   |        code: GIMPLE_RESX
      |   |
-     |   + gimple_statement_eh_dispatch
+     |   + gimple_eh_dispatch
      |            code: GIMPLE_EH_DISPATCH
      |
-     + gimple_statement_try
+     + gimple_try
      |        layout: GSS_TRY, code: GIMPLE_TRY
      |
-     + gimple_statement_wce
+     + gimple_wce
      |        layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR
      |
-     + gimple_statement_omp_continue
+     + gimple_omp_continue
      |        layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE
      |
-     + gimple_statement_omp_atomic_load
+     + gimple_omp_atomic_load
      |        layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD
      |
-     + gimple_statement_omp_atomic_store_layout
+     + gimple_omp_atomic_store_layout
          |    layout: GSS_OMP_ATOMIC_STORE_LAYOUT,
          |    code: GIMPLE_OMP_ATOMIC_STORE
          |
-         + gimple_statement_omp_atomic_store
+         + gimple_omp_atomic_store
          |        code: GIMPLE_OMP_ATOMIC_STORE
          |
-         + gimple_statement_omp_return
+         + gimple_omp_return
                   code: GIMPLE_OMP_RETURN
 @end smallexample
 
@@ -706,15 +706,15 @@ the code of a given statement, its operand vector will be at
 different offsets from the base of the structure.  To access
 tuple operands use the following accessors
 
-@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple_stmt *g)
 Returns the number of operands in statement G.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
+@deftypefn {GIMPLE function} tree gimple_op (gimple_stmt *g, unsigned i)
 Returns operand @code{I} from statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple_stmt *g)
 Returns a pointer into the operand vector for statement @code{G}.  This
 is computed using an internal table called @code{gimple_ops_offset_}[].
 This table is indexed by the gimple code of @code{G}.
@@ -790,15 +790,15 @@ program is running (and which is valid in all functions).
 
 @subsection Statement validation
 
-@deftypefn {GIMPLE function} bool is_gimple_assign (gimple g)
+@deftypefn {GIMPLE function} bool is_gimple_assign (gimple_stmt *g)
 Return true if the code of g is @code{GIMPLE_ASSIGN}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool is_gimple_call (gimple g)
+@deftypefn {GIMPLE function} bool is_gimple_call (gimple_stmt *g)
 Return true if the code of g is @code{GIMPLE_CALL}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool is_gimple_debug (gimple g)
+@deftypefn {GIMPLE function} bool is_gimple_debug (gimple_stmt *g)
 Return true if the code of g is @code{GIMPLE_DEBUG}.
 @end deftypefn
 
@@ -807,12 +807,12 @@ Return true if g is a @code{GIMPLE_ASSIGN} that performs a type cast
 operation.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_debug_bind_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_debug_bind_p (gimple_stmt *g)
 Return true if g is a @code{GIMPLE_DEBUG} that binds the value of an
 expression to a variable.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool is_gimple_omp (gimple g)
+@deftypefn {GIMPLE function} bool is_gimple_omp (gimple_stmt *g)
 Return true if g is any of the OpenMP codes.
 @end deftypefn
 
@@ -826,19 +826,19 @@ of the GIMPLE instructions.
 @subsection Common accessors
 The following are common accessors for gimple statements.
 
-@deftypefn {GIMPLE function} {enum gimple_code} gimple_code (gimple g)
+@deftypefn {GIMPLE function} {enum gimple_code} gimple_code (gimple_stmt *g)
 Return the code for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} basic_block gimple_bb (gimple g)
+@deftypefn {GIMPLE function} basic_block gimple_bb (gimple_stmt *g)
 Return the basic block to which statement @code{G} belongs to.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_block (gimple g)
+@deftypefn {GIMPLE function} tree gimple_block (gimple_stmt *g)
 Return the lexical scope block holding statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_expr_type (gimple stmt)
+@deftypefn {GIMPLE function} tree gimple_expr_type (gimple_stmt *stmt)
 Return the type of the main expression computed by @code{STMT}. Return
 @code{void_type_node} if @code{STMT} computes nothing. This will only return
 something meaningful for @code{GIMPLE_ASSIGN}, @code{GIMPLE_COND} and
@@ -846,7 +846,8 @@ something meaningful for @code{GIMPLE_ASSIGN}, @code{GIMPLE_COND} and
 @code{void_type_node}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {enum tree_code} gimple_expr_code (gimple stmt)
+@deftypefn {GIMPLE function} {enum tree_code} gimple_expr_code (@
+gimple_stmt *stmt)
 Return the tree code for the expression computed by @code{STMT}.  This
 is only meaningful for @code{GIMPLE_CALL}, @code{GIMPLE_ASSIGN} and
 @code{GIMPLE_COND}.  If @code{STMT} is @code{GIMPLE_CALL}, it will return @code{CALL_EXPR}.
@@ -855,139 +856,153 @@ For @code{GIMPLE_ASSIGN} it returns the code of the operation performed
 by the @code{RHS} of the assignment.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_block (gimple g, tree block)
+@deftypefn {GIMPLE function} void gimple_set_block (gimple_stmt *g, tree block)
 Set the lexical scope block of @code{G} to @code{BLOCK}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} location_t gimple_locus (gimple g)
+@deftypefn {GIMPLE function} location_t gimple_locus (gimple_stmt *g)
 Return locus information for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_locus (gimple g, location_t locus)
+@deftypefn {GIMPLE function} void gimple_set_locus (gimple_stmt *g, @
+location_t locus)
 Set locus information for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_locus_empty_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_locus_empty_p (gimple_stmt *g)
 Return true if @code{G} does not have locus information.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_no_warning_p (gimple stmt)
+@deftypefn {GIMPLE function} bool gimple_no_warning_p (gimple_stmt *stmt)
 Return true if no warnings should be emitted for statement @code{STMT}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_visited (gimple stmt, bool visited_p)
+@deftypefn {GIMPLE function} void gimple_set_visited (gimple_stmt *stmt, @
+bool visited_p)
 Set the visited status on statement @code{STMT} to @code{VISITED_P}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_visited_p (gimple stmt)
+@deftypefn {GIMPLE function} bool gimple_visited_p (gimple_stmt *stmt)
 Return the visited status on statement @code{STMT}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_plf (gimple stmt, enum plf_mask plf, bool val_p)
+@deftypefn {GIMPLE function} void gimple_set_plf (gimple_stmt *stmt, @
+enum plf_mask plf, bool val_p)
 Set pass local flag @code{PLF} on statement @code{STMT} to @code{VAL_P}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {unsigned int} gimple_plf (gimple stmt, enum plf_mask plf)
+@deftypefn {GIMPLE function} {unsigned int} gimple_plf (gimple_stmt *stmt, @
+enum plf_mask plf)
 Return the value of pass local flag @code{PLF} on statement @code{STMT}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_has_ops (gimple g)
+@deftypefn {GIMPLE function} bool gimple_has_ops (gimple_stmt *g)
 Return true if statement @code{G} has register or memory operands.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_has_mem_ops (gimple g)
+@deftypefn {GIMPLE function} bool gimple_has_mem_ops (gimple_stmt *g)
 Return true if statement @code{G} has memory operands.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_num_ops (gimple_stmt *g)
 Return the number of operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_ops (gimple_stmt *g)
 Return the array of operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_op (gimple g, unsigned i)
+@deftypefn {GIMPLE function} tree gimple_op (gimple_stmt *g, unsigned i)
 Return operand @code{I} for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_op_ptr (gimple g, unsigned i)
+@deftypefn {GIMPLE function} {tree *} gimple_op_ptr (gimple_stmt *g, unsigned i)
 Return a pointer to operand @code{I} for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_op (gimple g, unsigned i, tree op)
+@deftypefn {GIMPLE function} void gimple_set_op (gimple_stmt *g, unsigned i, @
+tree op)
 Set operand @code{I} of statement @code{G} to @code{OP}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bitmap gimple_addresses_taken (gimple stmt)
+@deftypefn {GIMPLE function} bitmap gimple_addresses_taken (gimple_stmt *stmt)
 Return the set of symbols that have had their address taken by
 @code{STMT}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {struct def_optype_d *} gimple_def_ops (gimple g)
+@deftypefn {GIMPLE function} {struct def_optype_d *} gimple_def_ops (@
+gimple_stmt *g)
 Return the set of @code{DEF} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_def_ops (gimple g, struct def_optype_d *def)
+@deftypefn {GIMPLE function} void gimple_set_def_ops (gimple_stmt *g, @
+struct def_optype_d *def)
 Set @code{DEF} to be the set of @code{DEF} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {struct use_optype_d *} gimple_use_ops (gimple g)
+@deftypefn {GIMPLE function} {struct use_optype_d *} gimple_use_ops (@
+gimple_stmt *g)
 Return the set of @code{USE} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_use_ops (gimple g, struct use_optype_d *use)
+@deftypefn {GIMPLE function} void gimple_set_use_ops (gimple_stmt *g, @
+struct use_optype_d *use)
 Set @code{USE} to be the set of @code{USE} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vuse_ops (gimple g)
+@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vuse_ops (@
+gimple_stmt *g)
 Return the set of @code{VUSE} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_vuse_ops (gimple g, struct voptype_d *ops)
+@deftypefn {GIMPLE function} void gimple_set_vuse_ops (gimple_stmt *g, @
+struct voptype_d *ops)
 Set @code{OPS} to be the set of @code{VUSE} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vdef_ops (gimple g)
+@deftypefn {GIMPLE function} {struct voptype_d *} gimple_vdef_ops (@
+gimple_stmt *g)
 Return the set of @code{VDEF} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_vdef_ops (gimple g, struct voptype_d *ops)
+@deftypefn {GIMPLE function} void gimple_set_vdef_ops (gimple_stmt *g, @
+struct voptype_d *ops)
 Set @code{OPS} to be the set of @code{VDEF} operands for statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bitmap gimple_loaded_syms (gimple g)
+@deftypefn {GIMPLE function} bitmap gimple_loaded_syms (gimple_stmt *g)
 Return the set of symbols loaded by statement @code{G}.  Each element of
 the set is the @code{DECL_UID} of the corresponding symbol.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bitmap gimple_stored_syms (gimple g)
+@deftypefn {GIMPLE function} bitmap gimple_stored_syms (gimple_stmt *g)
 Return the set of symbols stored by statement @code{G}.  Each element of
 the set is the @code{DECL_UID} of the corresponding symbol.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_modified_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_modified_p (gimple_stmt *g)
 Return true if statement @code{G} has operands and the modified field
 has been set.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_has_volatile_ops (gimple stmt)
+@deftypefn {GIMPLE function} bool gimple_has_volatile_ops (gimple_stmt *stmt)
 Return true if statement @code{STMT} contains volatile operands.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_set_has_volatile_ops (gimple stmt, bool volatilep)
+@deftypefn {GIMPLE function} void gimple_set_has_volatile_ops (@
+gimple_stmt *stmt, bool volatilep)
 Return true if statement @code{STMT} contains volatile operands.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void update_stmt (gimple s)
+@deftypefn {GIMPLE function} void update_stmt (gimple_stmt *s)
 Mark statement @code{S} as modified, and update it.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void update_stmt_if_modified (gimple s)
+@deftypefn {GIMPLE function} void update_stmt_if_modified (gimple_stmt *s)
 Update statement @code{S} if it has been marked modified.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_copy (gimple stmt)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_copy (gimple_stmt *stmt)
 Return a deep copy of statement @code{STMT}.
 @end deftypefn
 
@@ -1031,7 +1046,8 @@ Return a deep copy of statement @code{STMT}.
 @subsection @code{GIMPLE_ASM}
 @cindex @code{GIMPLE_ASM}
 
-@deftypefn {GIMPLE function} gimple gimple_build_asm (const char *string, ninputs, noutputs, nclobbers, ...)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_asm (@
+const char *string, ninputs, noutputs, nclobbers, ...)
 Build a @code{GIMPLE_ASM} statement.  This statement is used for
 building in-line assembly constructs.  @code{STRING} is the assembly
 code.  @code{NINPUT} is the number of register inputs.  @code{NOUTPUT} is the
@@ -1040,58 +1056,64 @@ registers.  The rest of the arguments trees for each input,
 output, and clobbered registers.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_build_asm_vec (const char *, VEC(tree,gc) *, VEC(tree,gc) *, VEC(tree,gc) *)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_asm_vec (@
+const char *, VEC(tree,gc) *, VEC(tree,gc) *, VEC(tree,gc) *)
 Identical to gimple_build_asm, but the arguments are passed in
 VECs.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_asm_ninputs (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_asm_ninputs (gimple_stmt *g)
 Return the number of input operands for @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_asm_noutputs (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_asm_noutputs (gimple_stmt *g)
 Return the number of output operands for @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_asm_nclobbers (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_asm_nclobbers (gimple_stmt *g)
 Return the number of clobber operands for @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_asm_input_op (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_asm_input_op (gimple_stmt *g, @
+unsigned index)
 Return input operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_asm_set_input_op (gimple g, unsigned index, tree in_op)
+@deftypefn {GIMPLE function} void gimple_asm_set_input_op (gimple_stmt *g, @
+unsigned index, tree in_op)
 Set @code{IN_OP} to be input operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_asm_output_op (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_asm_output_op (gimple_stmt *g, @
+unsigned index)
 Return output operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_asm_set_output_op (gimple g, @
+@deftypefn {GIMPLE function} void gimple_asm_set_output_op (gimple_stmt *g, @
 unsigned index, tree out_op)
 Set @code{OUT_OP} to be output operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_asm_clobber_op (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_asm_clobber_op (gimple_stmt *g, @
+unsigned index)
 Return clobber operand @code{INDEX} of @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_asm_set_clobber_op (gimple g, unsigned index, tree clobber_op)
+@deftypefn {GIMPLE function} void gimple_asm_set_clobber_op (gimple_stmt *g, @
+unsigned index, tree clobber_op)
 Set @code{CLOBBER_OP} to be clobber operand @code{INDEX} in @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {const char *} gimple_asm_string (gimple g)
+@deftypefn {GIMPLE function} {const char *} gimple_asm_string (gimple_stmt *g)
 Return the string representing the assembly instruction in
 @code{GIMPLE_ASM} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_asm_volatile_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_asm_volatile_p (gimple_stmt *g)
 Return true if @code{G} is an asm statement marked volatile.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_asm_set_volatile (gimple g)
+@deftypefn {GIMPLE function} void gimple_asm_set_volatile (gimple_stmt *g)
 Mark asm statement @code{G} as volatile.
 @end deftypefn
 
@@ -1099,7 +1121,8 @@ Mark asm statement @code{G} as volatile.
 @subsection @code{GIMPLE_ASSIGN}
 @cindex @code{GIMPLE_ASSIGN}
 
-@deftypefn {GIMPLE function} gimple gimple_build_assign (tree lhs, tree rhs)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_assign (tree lhs, @
+tree rhs)
 Build a @code{GIMPLE_ASSIGN} statement.  The left-hand side is an lvalue
 passed in lhs.  The right-hand side can be either a unary or
 binary tree expression.  The expression tree rhs will be
@@ -1113,7 +1136,8 @@ operands in separate trees, it is better to use
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} gimple gimplify_assign (tree dst, tree src, gimple_seq *seq_p)
+@deftypefn {GIMPLE function} gimple_stmt *gimplify_assign (tree dst, tree src, @
+gimple_seq *seq_p)
 Build a new @code{GIMPLE_ASSIGN} tuple and append it to the end of
 @code{*SEQ_P}.
 @end deftypefn
@@ -1124,7 +1148,7 @@ case they will be converted to a gimple operand if necessary.
 
 This function returns the newly created @code{GIMPLE_ASSIGN} tuple.
 
-@deftypefn {GIMPLE function} gimple gimple_build_assign_with_ops @
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_assign_with_ops @
 (enum tree_code subcode, tree lhs, tree op1, tree op2)
 This function is similar to @code{gimple_build_assign}, but is used to
 build a @code{GIMPLE_ASSIGN} statement when the operands of the
@@ -1137,73 +1161,79 @@ are the operands.  If op2 is null, subcode must be a @code{tree_code}
 for a unary expression.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {enum tree_code} gimple_assign_rhs_code (gimple g)
+@deftypefn {GIMPLE function} {enum tree_code} gimple_assign_rhs_code (@
+gimple_stmt *g)
 Return the code of the expression computed on the @code{RHS} of
 assignment statement @code{G}.
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} {enum gimple_rhs_class} gimple_assign_rhs_class (gimple g)
+@deftypefn {GIMPLE function} {enum gimple_rhs_class} gimple_assign_rhs_class (@
+gimple_stmt *g)
 Return the gimple rhs class of the code for the expression
 computed on the rhs of assignment statement @code{G}.  This will never
 return @code{GIMPLE_INVALID_RHS}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_assign_lhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_assign_lhs (gimple_stmt *g)
 Return the @code{LHS} of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_assign_lhs_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_assign_lhs_ptr (gimple_stmt *g)
 Return a pointer to the @code{LHS} of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_assign_rhs1 (gimple g)
+@deftypefn {GIMPLE function} tree gimple_assign_rhs1 (gimple_stmt *g)
 Return the first operand on the @code{RHS} of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs1_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs1_ptr (gimple_stmt *g)
 Return the address of the first operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_assign_rhs2 (gimple g)
+@deftypefn {GIMPLE function} tree gimple_assign_rhs2 (gimple_stmt *g)
 Return the second operand on the @code{RHS} of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs2_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs2_ptr (gimple_stmt *g)
 Return the address of the second operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_assign_rhs3 (gimple g)
+@deftypefn {GIMPLE function} tree gimple_assign_rhs3 (gimple_stmt *g)
 Return the third operand on the @code{RHS} of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs3_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_assign_rhs3_ptr (gimple_stmt *g)
 Return the address of the third operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_assign_set_lhs (gimple g, tree lhs)
+@deftypefn {GIMPLE function} void gimple_assign_set_lhs (gimple_stmt *g, @
+tree lhs)
 Set @code{LHS} to be the @code{LHS} operand of assignment statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_assign_set_rhs1 (gimple g, tree rhs)
+@deftypefn {GIMPLE function} void gimple_assign_set_rhs1 (gimple_stmt *g, @
+tree rhs)
 Set @code{RHS} to be the first operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_assign_set_rhs2 (gimple g, tree rhs)
+@deftypefn {GIMPLE function} void gimple_assign_set_rhs2 (gimple_stmt *g, @
+tree rhs)
 Set @code{RHS} to be the second operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_assign_set_rhs3 (gimple g, tree rhs)
+@deftypefn {GIMPLE function} void gimple_assign_set_rhs3 (gimple_stmt *g, @
+tree rhs)
 Set @code{RHS} to be the third operand on the @code{RHS} of assignment
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple s)
+@deftypefn {GIMPLE function} bool gimple_assign_cast_p (const_gimple_stmt *s)
 Return true if @code{S} is a type-cast assignment.
 @end deftypefn
 
@@ -1212,49 +1242,56 @@ Return true if @code{S} is a type-cast assignment.
 @subsection @code{GIMPLE_BIND}
 @cindex @code{GIMPLE_BIND}
 
-@deftypefn {GIMPLE function} gimple gimple_build_bind (tree vars, gimple_seq body)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_bind (tree vars, @
+gimple_seq body)
 Build a @code{GIMPLE_BIND} statement with a list of variables in @code{VARS}
 and a body of statements in sequence @code{BODY}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_bind_vars (gimple g)
+@deftypefn {GIMPLE function} tree gimple_bind_vars (gimple_stmt *g)
 Return the variables declared in the @code{GIMPLE_BIND} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_set_vars (gimple g, tree vars)
+@deftypefn {GIMPLE function} void gimple_bind_set_vars (gimple_stmt *g, @
+tree vars)
 Set @code{VARS} to be the set of variables declared in the @code{GIMPLE_BIND}
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_append_vars (gimple g, tree vars)
+@deftypefn {GIMPLE function} void gimple_bind_append_vars (gimple_stmt *g, @
+tree vars)
 Append @code{VARS} to the set of variables declared in the @code{GIMPLE_BIND}
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_bind_body (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_bind_body (gimple_stmt *g)
 Return the GIMPLE sequence contained in the @code{GIMPLE_BIND} statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_set_body (gimple g, gimple_seq seq)
+@deftypefn {GIMPLE function} void gimple_bind_set_body (gimple_stmt *g, @
+gimple_seq seq)
 Set @code{SEQ} to be sequence contained in the @code{GIMPLE_BIND} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_add_stmt (gimple gs, gimple stmt)
+@deftypefn {GIMPLE function} void gimple_bind_add_stmt (gimple_stmt *gs, @
+gimple_stmt *stmt)
 Append a statement to the end of a @code{GIMPLE_BIND}'s body.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_add_seq (gimple gs, gimple_seq seq)
+@deftypefn {GIMPLE function} void gimple_bind_add_seq (gimple_stmt *gs, @
+gimple_seq seq)
 Append a sequence of statements to the end of a @code{GIMPLE_BIND}'s
 body.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_bind_block (gimple g)
+@deftypefn {GIMPLE function} tree gimple_bind_block (gimple_stmt *g)
 Return the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND} statement
 @code{G}. This is analogous to the @code{BIND_EXPR_BLOCK} field in trees.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_bind_set_block (gimple g, tree block)
+@deftypefn {GIMPLE function} void gimple_bind_set_block (gimple_stmt *g, @
+tree block)
 Set @code{BLOCK} to be the @code{TREE_BLOCK} node associated with @code{GIMPLE_BIND}
 statement @code{G}.
 @end deftypefn
@@ -1264,7 +1301,8 @@ statement @code{G}.
 @subsection @code{GIMPLE_CALL}
 @cindex @code{GIMPLE_CALL}
 
-@deftypefn {GIMPLE function} gimple gimple_build_call (tree fn, unsigned nargs, ...)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_call (tree fn, @
+unsigned nargs, ...)
 Build a @code{GIMPLE_CALL} statement to function @code{FN}.  The argument @code{FN}
 must be either a @code{FUNCTION_DECL} or a gimple call address as
 determined by @code{is_gimple_call_addr}.  @code{NARGS} are the number of
@@ -1274,7 +1312,8 @@ operand is validated with @code{is_gimple_operand}).
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} gimple gimple_build_call_from_tree (tree call_expr)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_call_from_tree (@
+tree call_expr)
 Build a @code{GIMPLE_CALL} from a @code{CALL_EXPR} node.  The arguments and the
 function are taken from the expression directly.  This routine
 assumes that @code{call_expr} is already in GIMPLE form.  That is, its
@@ -1283,98 +1322,105 @@ simplification.  All the call flags in @code{call_expr} are copied over
 to the new @code{GIMPLE_CALL}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_build_call_vec (tree fn, @code{VEC}(tree, heap) *args)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_call_vec (tree fn, @
+@code{VEC}(tree, heap) *args)
 Identical to @code{gimple_build_call} but the arguments are stored in a
 @code{VEC}().
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_lhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_call_lhs (gimple_stmt *g)
 Return the @code{LHS} of call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_call_lhs_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_call_lhs_ptr (gimple_stmt *g)
 Return a pointer to the @code{LHS} of call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_set_lhs (gimple g, tree lhs)
+@deftypefn {GIMPLE function} void gimple_call_set_lhs (gimple_stmt *g, tree lhs)
 Set @code{LHS} to be the @code{LHS} operand of call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_fn (gimple g)
+@deftypefn {GIMPLE function} tree gimple_call_fn (gimple_stmt *g)
 Return the tree node representing the function called by call
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_set_fn (gimple g, tree fn)
+@deftypefn {GIMPLE function} void gimple_call_set_fn (gimple_stmt *g, tree fn)
 Set @code{FN} to be the function called by call statement @code{G}.  This has
 to be a gimple value specifying the address of the called
 function.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_fndecl (gimple g)
+@deftypefn {GIMPLE_STMT *function} tree gimple_call_fndecl (gimple_stmt *g)
 If a given @code{GIMPLE_CALL}'s callee is a @code{FUNCTION_DECL}, return it.
 Otherwise return @code{NULL}.  This function is analogous to
 @code{get_callee_fndecl} in @code{GENERIC}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_set_fndecl (gimple g, tree fndecl)
+@deftypefn {GIMPLE function} tree gimple_call_set_fndecl (gimple_stmt *g, @
+tree fndecl)
 Set the called function to @code{FNDECL}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_return_type (gimple g)
+@deftypefn {GIMPLE function} tree gimple_call_return_type (gimple_stmt *g)
 Return the type returned by call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_chain (gimple g)
+@deftypefn {GIMPLE function} tree gimple_call_chain (gimple_stmt *g)
 Return the static chain for call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_set_chain (gimple g, tree chain)
+@deftypefn {GIMPLE function} void gimple_call_set_chain (gimple_stmt *g, @
+tree chain)
 Set @code{CHAIN} to be the static chain for call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_call_num_args (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_call_num_args (gimple_stmt *g)
 Return the number of arguments used by call statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_call_arg (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_call_arg (gimple_stmt *g, @
+unsigned index)
 Return the argument at position @code{INDEX} for call statement @code{G}.  The
 first argument is 0.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_call_arg_ptr (gimple g, unsigned index)
+@deftypefn {GIMPLE function} {tree *} gimple_call_arg_ptr (gimple_stmt *g, @
+unsigned index)
 Return a pointer to the argument at position @code{INDEX} for call
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_set_arg (gimple g, unsigned index, tree arg)
+@deftypefn {GIMPLE function} void gimple_call_set_arg (gimple_stmt *g, @
+unsigned index, tree arg)
 Set @code{ARG} to be the argument at position @code{INDEX} for call statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_set_tail (gimple s)
+@deftypefn {GIMPLE function} void gimple_call_set_tail (gimple_stmt *s)
 Mark call statement @code{S} as being a tail call (i.e., a call just
 before the exit of a function). These calls are candidate for
 tail call optimization.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_call_tail_p (gimple s)
+@deftypefn {GIMPLE function} bool gimple_call_tail_p (gimple_stmt *s)
 Return true if @code{GIMPLE_CALL} @code{S} is marked as a tail call.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_call_mark_uninlinable (gimple s)
+@deftypefn {GIMPLE function} void gimple_call_mark_uninlinable (gimple_stmt *s)
 Mark @code{GIMPLE_CALL} @code{S} as being uninlinable.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_call_cannot_inline_p (gimple s)
+@deftypefn {GIMPLE function} bool gimple_call_cannot_inline_p (gimple_stmt *s)
 Return true if @code{GIMPLE_CALL} @code{S} cannot be inlined.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_call_noreturn_p (gimple s)
+@deftypefn {GIMPLE function} bool gimple_call_noreturn_p (gimple_stmt *s)
 Return true if @code{S} is a noreturn call.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_call_copy_skip_args (gimple stmt, bitmap args_to_skip)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_call_copy_skip_args (@
+gimple_stmt *stmt, bitmap args_to_skip)
 Build a @code{GIMPLE_CALL} identical to @code{STMT} but skipping the arguments
 in the positions marked by the set @code{ARGS_TO_SKIP}.
 @end deftypefn
@@ -1384,31 +1430,34 @@ in the positions marked by the set @code{ARGS_TO_SKIP}.
 @subsection @code{GIMPLE_CATCH}
 @cindex @code{GIMPLE_CATCH}
 
-@deftypefn {GIMPLE function} gimple gimple_build_catch (tree types, gimple_seq handler)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_catch (tree types, @
+gimple_seq handler)
 Build a @code{GIMPLE_CATCH} statement.  @code{TYPES} are the tree types this
 catch handles.  @code{HANDLER} is a sequence of statements with the code
 for the handler.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_catch_types (gimple g)
+@deftypefn {GIMPLE function} tree gimple_catch_types (gimple_stmt *g)
 Return the types handled by @code{GIMPLE_CATCH} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_catch_types_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_catch_types_ptr (gimple_stmt *g)
 Return a pointer to the types handled by @code{GIMPLE_CATCH} statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_catch_handler (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_catch_handler (gimple_stmt *g)
 Return the GIMPLE sequence representing the body of the handler
 of @code{GIMPLE_CATCH} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_catch_set_types (gimple g, tree t)
+@deftypefn {GIMPLE function} void gimple_catch_set_types (gimple_stmt *g, @
+tree t)
 Set @code{T} to be the set of types handled by @code{GIMPLE_CATCH} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_catch_set_handler (gimple g, gimple_seq handler)
+@deftypefn {GIMPLE function} void gimple_catch_set_handler (gimple_stmt *g, @
+gimple_seq handler)
 Set @code{HANDLER} to be the body of @code{GIMPLE_CATCH} @code{G}.
 @end deftypefn
 
@@ -1417,7 +1466,8 @@ Set @code{HANDLER} to be the body of @code{GIMPLE_CATCH} @code{G}.
 @subsection @code{GIMPLE_COND}
 @cindex @code{GIMPLE_COND}
 
-@deftypefn {GIMPLE function} gimple gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs, tree t_label, tree f_label)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_cond (@
+enum tree_code pred_code, tree lhs, tree rhs, tree t_label, tree f_label)
 Build a @code{GIMPLE_COND} statement.  @code{A} @code{GIMPLE_COND} statement compares
 @code{LHS} and @code{RHS} and if the condition in @code{PRED_CODE} is true, jump to
 the label in @code{t_label}, otherwise jump to the label in @code{f_label}.
@@ -1426,66 +1476,70 @@ the label in @code{t_label}, otherwise jump to the label in @code{f_label}.
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} gimple gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_cond_from_tree (@
+tree cond, tree t_label, tree f_label)
 Build a @code{GIMPLE_COND} statement from the conditional expression
 tree @code{COND}.  @code{T_LABEL} and @code{F_LABEL} are as in @code{gimple_build_cond}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {enum tree_code} gimple_cond_code (gimple g)
+@deftypefn {GIMPLE function} {enum tree_code} gimple_cond_code (gimple_stmt *g)
 Return the code of the predicate computed by conditional
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_set_code (gimple g, enum tree_code code)
+@deftypefn {GIMPLE function} void gimple_cond_set_code (gimple_stmt *g, @
+enum tree_code code)
 Set @code{CODE} to be the predicate code for the conditional statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_cond_lhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_cond_lhs (gimple_stmt *g)
 Return the @code{LHS} of the predicate computed by conditional statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_set_lhs (gimple g, tree lhs)
+@deftypefn {GIMPLE function} void gimple_cond_set_lhs (gimple_stmt *g, tree lhs)
 Set @code{LHS} to be the @code{LHS} operand of the predicate computed by
 conditional statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_cond_rhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_cond_rhs (gimple_stmt *g)
 Return the @code{RHS} operand of the predicate computed by conditional
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_set_rhs (gimple g, tree rhs)
+@deftypefn {GIMPLE function} void gimple_cond_set_rhs (gimple_stmt *g, tree rhs)
 Set @code{RHS} to be the @code{RHS} operand of the predicate computed by
 conditional statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_cond_true_label (gimple g)
+@deftypefn {GIMPLE function} tree gimple_cond_true_label (gimple_stmt *g)
 Return the label used by conditional statement @code{G} when its
 predicate evaluates to true.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_set_true_label (gimple g, tree label)
+@deftypefn {GIMPLE function} void gimple_cond_set_true_label (gimple_stmt *g, @
+tree label)
 Set @code{LABEL} to be the label used by conditional statement @code{G} when
 its predicate evaluates to true.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_set_false_label (gimple g, tree label)
+@deftypefn {GIMPLE function} void gimple_cond_set_false_label (gimple_stmt *g, @
+tree label)
 Set @code{LABEL} to be the label used by conditional statement @code{G} when
 its predicate evaluates to false.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_cond_false_label (gimple g)
+@deftypefn {GIMPLE function} tree gimple_cond_false_label (gimple_stmt *g)
 Return the label used by conditional statement @code{G} when its
 predicate evaluates to false.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_make_false (gimple g)
+@deftypefn {GIMPLE function} void gimple_cond_make_false (gimple_stmt *g)
 Set the conditional @code{COND_STMT} to be of the form 'if (1 == 0)'.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_cond_make_true (gimple g)
+@deftypefn {GIMPLE function} void gimple_cond_make_true (gimple_stmt *g)
 Set the conditional @code{COND_STMT} to be of the form 'if (1 == 1)'.
 @end deftypefn
 
@@ -1494,7 +1548,8 @@ Set the conditional @code{COND_STMT} to be of the form 'if (1 == 1)'.
 @cindex @code{GIMPLE_DEBUG}
 @cindex @code{GIMPLE_DEBUG_BIND}
 
-@deftypefn {GIMPLE function} gimple gimple_build_debug_bind (tree var, tree value, gimple stmt)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_debug_bind (tree var, @
+tree value, gimple_stmt *stmt)
 Build a @code{GIMPLE_DEBUG} statement with @code{GIMPLE_DEBUG_BIND} of
 @code{subcode}.  The effect of this statement is to tell debug
 information generation machinery that the value of user variable
@@ -1533,35 +1588,41 @@ Block and location information for the newly-created stmt are
 taken from @code{stmt}, if given.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_debug_bind_get_var (gimple stmt)
+@deftypefn {GIMPLE function} tree gimple_debug_bind_get_var (gimple_stmt *stmt)
 Return the user variable @var{var} that is bound at @code{stmt}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_debug_bind_get_value (gimple stmt)
+@deftypefn {GIMPLE function} tree gimple_debug_bind_get_value (@
+gimple_stmt *stmt)
 Return the value expression that is bound to a user variable at
 @code{stmt}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_debug_bind_get_value_ptr (gimple stmt)
+@deftypefn {GIMPLE function} {tree *} gimple_debug_bind_get_value_ptr (@
+gimple_stmt *stmt)
 Return a pointer to the value expression that is bound to a user
 variable at @code{stmt}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_debug_bind_set_var (gimple stmt, tree var)
+@deftypefn {GIMPLE function} void gimple_debug_bind_set_var (@
+gimple_stmt *stmt, tree var)
 Modify the user variable bound at @code{stmt} to @var{var}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_debug_bind_set_value (gimple stmt, tree var)
+@deftypefn {GIMPLE function} void gimple_debug_bind_set_value (@
+gimple_stmt *stmt, tree var)
 Modify the value bound to the user variable bound at @code{stmt} to
 @var{value}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_debug_bind_reset_value (gimple stmt)
+@deftypefn {GIMPLE function} void gimple_debug_bind_reset_value (@
+gimple_stmt *stmt)
 Modify the value bound to the user variable bound at @code{stmt} so
 that the variable becomes unbound.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_debug_bind_has_value_p (gimple stmt)
+@deftypefn {GIMPLE function} bool gimple_debug_bind_has_value_p (@
+gimple_stmt *stmt)
 Return @code{TRUE} if @code{stmt} binds a user variable to a value,
 and @code{FALSE} if it unbinds the variable.
 @end deftypefn
@@ -1570,39 +1631,46 @@ and @code{FALSE} if it unbinds the variable.
 @subsection @code{GIMPLE_EH_FILTER}
 @cindex @code{GIMPLE_EH_FILTER}
 
-@deftypefn {GIMPLE function} gimple gimple_build_eh_filter (tree types, gimple_seq failure)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_eh_filter (@
+tree types, gimple_seq failure)
 Build a @code{GIMPLE_EH_FILTER} statement.  @code{TYPES} are the filter's
 types.  @code{FAILURE} is a sequence with the filter's failure action.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_eh_filter_types (gimple g)
+@deftypefn {GIMPLE function} tree gimple_eh_filter_types (gimple_stmt *g)
 Return the types handled by @code{GIMPLE_EH_FILTER} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_eh_filter_types_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_eh_filter_types_ptr (@
+gimple_stmt *g)
 Return a pointer to the types handled by @code{GIMPLE_EH_FILTER}
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_eh_filter_failure (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_eh_filter_failure (@
+gimple_stmt *g)
 Return the sequence of statement to execute when @code{GIMPLE_EH_FILTER}
 statement fails.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_eh_filter_set_types (gimple g, tree types)
+@deftypefn {GIMPLE function} void gimple_eh_filter_set_types (gimple_stmt *g, @
+tree types)
 Set @code{TYPES} to be the set of types handled by @code{GIMPLE_EH_FILTER} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_eh_filter_set_failure (gimple g, gimple_seq failure)
+@deftypefn {GIMPLE function} void gimple_eh_filter_set_failure (@
+gimple_stmt *g, gimple_seq failure)
 Set @code{FAILURE} to be the sequence of statements to execute on
 failure for @code{GIMPLE_EH_FILTER} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_eh_filter_must_not_throw (gimple g)
+@deftypefn {GIMPLE function} bool gimple_eh_filter_must_not_throw (@
+gimple_stmt *g)
 Return the @code{EH_FILTER_MUST_NOT_THROW} flag.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_eh_filter_set_must_not_throw (gimple g, bool mntp)
+@deftypefn {GIMPLE function} void gimple_eh_filter_set_must_not_throw (@
+gimple_stmt *g, bool mntp)
 Set the @code{EH_FILTER_MUST_NOT_THROW} flag.
 @end deftypefn
 
@@ -1611,30 +1679,32 @@ Set the @code{EH_FILTER_MUST_NOT_THROW} flag.
 @subsection @code{GIMPLE_LABEL}
 @cindex @code{GIMPLE_LABEL}
 
-@deftypefn {GIMPLE function} gimple gimple_build_label (tree label)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_label (tree label)
 Build a @code{GIMPLE_LABEL} statement with corresponding to the tree
 label, @code{LABEL}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_label_label (gimple g)
+@deftypefn {GIMPLE function} tree gimple_label_label (gimple_stmt *g)
 Return the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_label_set_label (gimple g, tree label)
+@deftypefn {GIMPLE function} void gimple_label_set_label (gimple_stmt *g, @
+tree label)
 Set @code{LABEL} to be the @code{LABEL_DECL} node used by @code{GIMPLE_LABEL}
 statement @code{G}.
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} gimple gimple_build_goto (tree dest)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_goto (tree dest)
 Build a @code{GIMPLE_GOTO} statement to label @code{DEST}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_goto_dest (gimple g)
+@deftypefn {GIMPLE function} tree gimple_goto_dest (gimple_stmt *g)
 Return the destination of the unconditional jump @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_goto_set_dest (gimple g, tree dest)
+@deftypefn {GIMPLE function} void gimple_goto_set_dest (gimple_stmt *g, @
+tree dest)
 Set @code{DEST} to be the destination of the unconditional jump @code{G}.
 @end deftypefn
 
@@ -1643,11 +1713,11 @@ Set @code{DEST} to be the destination of the unconditional jump @code{G}.
 @subsection @code{GIMPLE_NOP}
 @cindex @code{GIMPLE_NOP}
 
-@deftypefn {GIMPLE function} gimple gimple_build_nop (void)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_nop (void)
 Build a @code{GIMPLE_NOP} statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_nop_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_nop_p (gimple_stmt *g)
 Returns @code{TRUE} if statement @code{G} is a @code{GIMPLE_NOP}.
 @end deftypefn
 
@@ -1655,25 +1725,28 @@ Returns @code{TRUE} if statement @code{G} is a @code{GIMPLE_NOP}.
 @subsection @code{GIMPLE_OMP_ATOMIC_LOAD}
 @cindex @code{GIMPLE_OMP_ATOMIC_LOAD}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_atomic_load (tree lhs, tree rhs)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_atomic_load (@
+tree lhs, tree rhs)
 Build a @code{GIMPLE_OMP_ATOMIC_LOAD} statement.  @code{LHS} is the left-hand
 side of the assignment.  @code{RHS} is the right-hand side of the
 assignment.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
+@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_lhs (@
+gimple_stmt *g, tree lhs)
 Set the @code{LHS} of an atomic load.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_lhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_lhs (gimple_stmt *g)
 Get the @code{LHS} of an atomic load.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
+@deftypefn {GIMPLE function} void gimple_omp_atomic_load_set_rhs (@
+gimple_stmt *g, tree rhs)
 Set the @code{RHS} of an atomic set.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_rhs (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_atomic_load_rhs (gimple_stmt *g)
 Get the @code{RHS} of an atomic set.
 @end deftypefn
 
@@ -1682,16 +1755,18 @@ Get the @code{RHS} of an atomic set.
 @subsection @code{GIMPLE_OMP_ATOMIC_STORE}
 @cindex @code{GIMPLE_OMP_ATOMIC_STORE}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_atomic_store (tree val)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_atomic_store (@
+tree val)
 Build a @code{GIMPLE_OMP_ATOMIC_STORE} statement. @code{VAL} is the value to be
 stored.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_atomic_store_set_val (gimple g, tree val)
+@deftypefn {GIMPLE function} void gimple_omp_atomic_store_set_val (@
+gimple_stmt *g, tree val)
 Set the value being stored in an atomic store.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_atomic_store_val (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_atomic_store_val (gimple_stmt *g)
 Return the value being stored in an atomic store.
 @end deftypefn
 
@@ -1699,36 +1774,43 @@ Return the value being stored in an atomic store.
 @subsection @code{GIMPLE_OMP_CONTINUE}
 @cindex @code{GIMPLE_OMP_CONTINUE}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_continue (tree control_def, tree control_use)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_continue (@
+tree control_def, tree control_use)
 Build a @code{GIMPLE_OMP_CONTINUE} statement.  @code{CONTROL_DEF} is the
 definition of the control variable.  @code{CONTROL_USE} is the use of
 the control variable.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def (@
+gimple_stmt *s)
 Return the definition of the control variable on a
 @code{GIMPLE_OMP_CONTINUE} in @code{S}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def_ptr (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_control_def_ptr (@
+gimple_stmt *s)
 Same as above, but return the pointer.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_def (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_def (@
+gimple_stmt *s)
 Set the control variable definition for a @code{GIMPLE_OMP_CONTINUE}
 statement in @code{S}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use (@
+gimple_stmt *s)
 Return the use of the control variable on a @code{GIMPLE_OMP_CONTINUE}
 in @code{S}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use_ptr (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_control_use_ptr (@
+gimple_stmt *s)
 Same as above, but return the pointer.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_use (gimple s)
+@deftypefn {GIMPLE function} tree gimple_omp_continue_set_control_use (@
+gimple_stmt *s)
 Set the control variable use for a @code{GIMPLE_OMP_CONTINUE} statement
 in @code{S}.
 @end deftypefn
@@ -1738,22 +1820,25 @@ in @code{S}.
 @subsection @code{GIMPLE_OMP_CRITICAL}
 @cindex @code{GIMPLE_OMP_CRITICAL}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_critical (gimple_seq body, tree name)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_critical (@
+gimple_seq body, tree name)
 Build a @code{GIMPLE_OMP_CRITICAL} statement. @code{BODY} is the sequence of
 statements for which only one thread can execute.  @code{NAME} is an
 optional identifier for this critical block.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_critical_name (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_critical_name (gimple_stmt *g)
 Return the name associated with @code{OMP_CRITICAL} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_critical_name_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_critical_name_ptr (@
+gimple_stmt *g)
 Return a pointer to the name associated with @code{OMP} critical
 statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_critical_set_name (gimple g, tree name)
+@deftypefn {GIMPLE function} void gimple_omp_critical_set_name (@
+gimple_stmt *g, tree name)
 Set @code{NAME} to be the name associated with @code{OMP} critical statement @code{G}.
 @end deftypefn
 
@@ -1761,7 +1846,8 @@ Set @code{NAME} to be the name associated with @code{OMP} critical statement @co
 @subsection @code{GIMPLE_OMP_FOR}
 @cindex @code{GIMPLE_OMP_FOR}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_for (gimple_seq body, @
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_for (@
+gimple_seq body, @
 tree clauses, tree index, tree initial, tree final, tree incr, @
 gimple_seq pre_body, enum tree_code omp_for_cond)
 Build a @code{GIMPLE_OMP_FOR} statement. @code{BODY} is sequence of statements
@@ -1774,81 +1860,91 @@ final value of @code{INDEX}.  OMP_FOR_COND is the predicate used to
 compare @code{INDEX} and @code{FINAL}.  @code{INCR} is the increment expression.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_for_clauses (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_for_clauses (gimple_stmt *g)
 Return the clauses associated with @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_for_clauses_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_for_clauses_ptr (@
+gimple_stmt *g)
 Return a pointer to the @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_clauses (gimple g, tree clauses)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_clauses (@
+gimple_stmt *g, tree clauses)
 Set @code{CLAUSES} to be the list of clauses associated with @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_for_index (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_for_index (gimple_stmt *g)
 Return the index variable for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_for_index_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_for_index_ptr (gimple_stmt *g)
 Return a pointer to the index variable for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_index (gimple g, tree index)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_index (@
+gimple_stmt *g, tree index)
 Set @code{INDEX} to be the index variable for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_for_initial (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_for_initial (gimple_stmt *g)
 Return the initial value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_for_initial_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_for_initial_ptr (@
+gimple_stmt *g)
 Return a pointer to the initial value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_initial (gimple g, tree initial)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_initial (gimple_stmt *g, @
+tree initial)
 Set @code{INITIAL} to be the initial value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_for_final (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_for_final (gimple_stmt *g)
 Return the final value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_for_final_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_for_final_ptr (gimple_stmt *g)
 turn a pointer to the final value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_final (gimple g, tree final)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_final (gimple_stmt *g, @
+tree final)
 Set @code{FINAL} to be the final value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_for_incr (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_for_incr (gimple_stmt *g)
 Return the increment value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_for_incr_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_for_incr_ptr (gimple_stmt *g)
 Return a pointer to the increment value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_incr (gimple g, tree incr)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_incr (gimple_stmt *g, @
+tree incr)
 Set @code{INCR} to be the increment value for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_omp_for_pre_body (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_omp_for_pre_body (gimple_stmt *g)
 Return the sequence of statements to execute before the @code{OMP_FOR}
 statement @code{G} starts.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_pre_body (gimple g, gimple_seq pre_body)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_pre_body (gimple_stmt *g, @
+gimple_seq pre_body)
 Set @code{PRE_BODY} to be the sequence of statements to execute before
 the @code{OMP_FOR} statement @code{G} starts.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_for_set_cond (gimple g, enum tree_code cond)
+@deftypefn {GIMPLE function} void gimple_omp_for_set_cond (gimple_stmt *g, @
+enum tree_code cond)
 Set @code{COND} to be the condition code for @code{OMP_FOR} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {enum tree_code} gimple_omp_for_cond (gimple g)
+@deftypefn {GIMPLE function} {enum tree_code} gimple_omp_for_cond (@
+gimple_stmt *g)
 Return the condition code associated with @code{OMP_FOR} @code{G}.
 @end deftypefn
 
@@ -1857,7 +1953,8 @@ Return the condition code associated with @code{OMP_FOR} @code{G}.
 @subsection @code{GIMPLE_OMP_MASTER}
 @cindex @code{GIMPLE_OMP_MASTER}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_master (gimple_seq body)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_master (@
+gimple_seq body)
 Build a @code{GIMPLE_OMP_MASTER} statement. @code{BODY} is the sequence of
 statements to be executed by just the master.
 @end deftypefn
@@ -1867,7 +1964,8 @@ statements to be executed by just the master.
 @subsection @code{GIMPLE_OMP_ORDERED}
 @cindex @code{GIMPLE_OMP_ORDERED}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_ordered (gimple_seq body)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_ordered (@
+gimple_seq body)
 Build a @code{GIMPLE_OMP_ORDERED} statement.
 @end deftypefn
 
@@ -1879,8 +1977,8 @@ executed in sequence.
 @subsection @code{GIMPLE_OMP_PARALLEL}
 @cindex @code{GIMPLE_OMP_PARALLEL}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_parallel (gimple_seq @
-body, tree clauses, tree child_fn, tree data_arg)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_parallel (@
+gimple_seq body, tree clauses, tree child_fn, tree data_arg)
 Build a @code{GIMPLE_OMP_PARALLEL} statement.
 @end deftypefn
 
@@ -1889,61 +1987,70 @@ Build a @code{GIMPLE_OMP_PARALLEL} statement.
 the function created for the parallel threads to execute.
 @code{DATA_ARG} are the shared data argument(s).
 
-@deftypefn {GIMPLE function} bool gimple_omp_parallel_combined_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_omp_parallel_combined_p (@
+gimple_stmt *g)
 Return true if @code{OMP} parallel statement @code{G} has the
 @code{GF_OMP_PARALLEL_COMBINED} flag set.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_parallel_set_combined_p (gimple g)
+@deftypefn {GIMPLE function} void gimple_omp_parallel_set_combined_p (@
+gimple_stmt *g)
 Set the @code{GF_OMP_PARALLEL_COMBINED} field in @code{OMP} parallel statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_omp_body (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_omp_body (gimple_stmt *g)
 Return the body for the @code{OMP} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_set_body (gimple g, gimple_seq body)
+@deftypefn {GIMPLE function} void gimple_omp_set_body (gimple_stmt *g, @
+gimple_seq body)
 Set @code{BODY} to be the body for the @code{OMP} statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_parallel_clauses (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_parallel_clauses (gimple_stmt *g)
 Return the clauses associated with @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_clauses_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_clauses_ptr (@
+gimple_stmt *g)
 Return a pointer to the clauses associated with @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_parallel_set_clauses (gimple g, tree clauses)
+@deftypefn {GIMPLE function} void gimple_omp_parallel_set_clauses (@
+gimple_stmt *g, tree clauses)
 Set @code{CLAUSES} to be the list of clauses associated with
 @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_parallel_child_fn (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_parallel_child_fn (gimple_stmt *g)
 Return the child function used to hold the body of @code{OMP_PARALLEL}
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_child_fn_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_child_fn_ptr (@
+gimple_stmt *g)
 Return a pointer to the child function used to hold the body of
 @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_parallel_set_child_fn (gimple g, tree child_fn)
+@deftypefn {GIMPLE function} void gimple_omp_parallel_set_child_fn (@
+gimple_stmt *g, tree child_fn)
 Set @code{CHILD_FN} to be the child function for @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_parallel_data_arg (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_parallel_data_arg (gimple_stmt *g)
 Return the artificial argument used to send variables and values
 from the parent to the children threads in @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_data_arg_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_parallel_data_arg_ptr (@
+gimple_stmt *g)
 Return a pointer to the data argument for @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_parallel_set_data_arg (gimple g, tree data_arg)
+@deftypefn {GIMPLE function} void gimple_omp_parallel_set_data_arg (@
+gimple_stmt *g, tree data_arg)
 Set @code{DATA_ARG} to be the data argument for @code{OMP_PARALLEL} @code{G}.
 @end deftypefn
 
@@ -1952,17 +2059,17 @@ Set @code{DATA_ARG} to be the data argument for @code{OMP_PARALLEL} @code{G}.
 @subsection @code{GIMPLE_OMP_RETURN}
 @cindex @code{GIMPLE_OMP_RETURN}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_return (bool wait_p)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_return (bool wait_p)
 Build a @code{GIMPLE_OMP_RETURN} statement. @code{WAIT_P} is true if this is a
 non-waiting return.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_return_set_nowait (gimple s)
+@deftypefn {GIMPLE function} void gimple_omp_return_set_nowait (gimple_stmt *s)
 Set the nowait flag on @code{GIMPLE_OMP_RETURN} statement @code{S}.
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} bool gimple_omp_return_nowait_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_omp_return_nowait_p (gimple_stmt *g)
 Return true if @code{OMP} return statement @code{G} has the
 @code{GF_OMP_RETURN_NOWAIT} flag set.
 @end deftypefn
@@ -1971,18 +2078,19 @@ Return true if @code{OMP} return statement @code{G} has the
 @subsection @code{GIMPLE_OMP_SECTION}
 @cindex @code{GIMPLE_OMP_SECTION}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_section (gimple_seq body)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_section (@
+gimple_seq body)
 Build a @code{GIMPLE_OMP_SECTION} statement for a sections statement.
 @end deftypefn
 
 @code{BODY} is the sequence of statements in the section.
 
-@deftypefn {GIMPLE function} bool gimple_omp_section_last_p (gimple g)
+@deftypefn {GIMPLE function} bool gimple_omp_section_last_p (gimple_stmt *g)
 Return true if @code{OMP} section statement @code{G} has the
 @code{GF_OMP_SECTION_LAST} flag set.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_section_set_last (gimple g)
+@deftypefn {GIMPLE function} void gimple_omp_section_set_last (gimple_stmt *g)
 Set the @code{GF_OMP_SECTION_LAST} flag on @code{G}.
 @end deftypefn
 
@@ -1990,7 +2098,8 @@ Set the @code{GF_OMP_SECTION_LAST} flag on @code{G}.
 @subsection @code{GIMPLE_OMP_SECTIONS}
 @cindex @code{GIMPLE_OMP_SECTIONS}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_sections (gimple_seq body, tree clauses)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_sections (@
+gimple_seq body, tree clauses)
 Build a @code{GIMPLE_OMP_SECTIONS} statement. @code{BODY} is a sequence of
 section statements.  @code{CLAUSES} are any of the @code{OMP} sections
 construct's clauses: private, firstprivate, lastprivate,
@@ -1998,34 +2107,39 @@ reduction, and nowait.
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_sections_switch (void)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_sections_switch (@
+void)
 Build a @code{GIMPLE_OMP_SECTIONS_SWITCH} statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_sections_control (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_sections_control (gimple_stmt *g)
 Return the control variable associated with the
 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_control_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_control_ptr (@
+gimple_stmt *g)
 Return a pointer to the clauses associated with the
 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_sections_set_control (gimple g, tree control)
+@deftypefn {GIMPLE function} void gimple_omp_sections_set_control (@
+gimple_stmt *g, tree control)
 Set @code{CONTROL} to be the set of clauses associated with the
 @code{GIMPLE_OMP_SECTIONS} in @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_sections_clauses (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_sections_clauses (gimple_stmt *g)
 Return the clauses associated with @code{OMP_SECTIONS} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_clauses_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_sections_clauses_ptr (@
+gimple_stmt *g)
 Return a pointer to the clauses associated with @code{OMP_SECTIONS} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_sections_set_clauses (gimple g, tree clauses)
+@deftypefn {GIMPLE function} void gimple_omp_sections_set_clauses (@
+gimple_stmt *g, tree clauses)
 Set @code{CLAUSES} to be the set of clauses associated with @code{OMP_SECTIONS}
 @code{G}.
 @end deftypefn
@@ -2035,22 +2149,25 @@ Set @code{CLAUSES} to be the set of clauses associated with @code{OMP_SECTIONS}
 @subsection @code{GIMPLE_OMP_SINGLE}
 @cindex @code{GIMPLE_OMP_SINGLE}
 
-@deftypefn {GIMPLE function} gimple gimple_build_omp_single (gimple_seq body, tree clauses)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_omp_single (@
+gimple_seq body, tree clauses)
 Build a @code{GIMPLE_OMP_SINGLE} statement. @code{BODY} is the sequence of
 statements that will be executed once.  @code{CLAUSES} are any of the
 @code{OMP} single construct's clauses: private, firstprivate,
 copyprivate, nowait.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_omp_single_clauses (gimple g)
+@deftypefn {GIMPLE function} tree gimple_omp_single_clauses (gimple_stmt *g)
 Return the clauses associated with @code{OMP_SINGLE} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_omp_single_clauses_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_omp_single_clauses_ptr (@
+gimple_stmt *g)
 Return a pointer to the clauses associated with @code{OMP_SINGLE} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_omp_single_set_clauses (gimple g, tree clauses)
+@deftypefn {GIMPLE function} void gimple_omp_single_set_clauses (@
+gimple_stmt *g, tree clauses)
 Set @code{CLAUSES} to be the clauses associated with @code{OMP_SINGLE} @code{G}.
 @end deftypefn
 
@@ -2059,34 +2176,37 @@ Set @code{CLAUSES} to be the clauses associated with @code{OMP_SINGLE} @code{G}.
 @subsection @code{GIMPLE_PHI}
 @cindex @code{GIMPLE_PHI}
 
-@deftypefn {GIMPLE function} unsigned gimple_phi_capacity (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_phi_capacity (gimple_stmt *g)
 Return the maximum number of arguments supported by @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_phi_num_args (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_phi_num_args (gimple_stmt *g)
 Return the number of arguments in @code{GIMPLE_PHI} @code{G}. This must always
 be exactly the number of incoming edges for the basic block
 holding @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_phi_result (gimple g)
+@deftypefn {GIMPLE function} tree gimple_phi_result (gimple_stmt *g)
 Return the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {tree *} gimple_phi_result_ptr (gimple g)
+@deftypefn {GIMPLE function} {tree *} gimple_phi_result_ptr (gimple_stmt *g)
 Return a pointer to the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_phi_set_result (gimple g, tree result)
+@deftypefn {GIMPLE function} void gimple_phi_set_result (gimple_stmt *g, @
+tree result)
 Set @code{RESULT} to be the @code{SSA} name created by @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {struct phi_arg_d *} gimple_phi_arg (gimple g, index)
+@deftypefn {GIMPLE function} {struct phi_arg_d *} gimple_phi_arg (@
+gimple_stmt *g, index)
 Return the @code{PHI} argument corresponding to incoming edge @code{INDEX} for
 @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_phi_set_arg (gimple g, index, struct phi_arg_d * phiarg)
+@deftypefn {GIMPLE function} void gimple_phi_set_arg (gimple_stmt *g, @
+index, struct phi_arg_d * phiarg)
 Set @code{PHIARG} to be the argument corresponding to incoming edge
 @code{INDEX} for @code{GIMPLE_PHI} @code{G}.
 @end deftypefn
@@ -2095,18 +2215,19 @@ Set @code{PHIARG} to be the argument corresponding to incoming edge
 @subsection @code{GIMPLE_RESX}
 @cindex @code{GIMPLE_RESX}
 
-@deftypefn {GIMPLE function} gimple gimple_build_resx (int region)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_resx (int region)
 Build a @code{GIMPLE_RESX} statement which is a statement.  This
 statement is a placeholder for _Unwind_Resume before we know if a
 function call or a branch is needed.  @code{REGION} is the exception
 region from which control is flowing.
 @end deftypefn
 
-@deftypefn {GIMPLE function} int gimple_resx_region (gimple g)
+@deftypefn {GIMPLE function} int gimple_resx_region (gimple_stmt *g)
 Return the region number for @code{GIMPLE_RESX} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_resx_set_region (gimple g, int region)
+@deftypefn {GIMPLE function} void gimple_resx_set_region (gimple_stmt *g, @
+int region)
 Set @code{REGION} to be the region number for @code{GIMPLE_RESX} @code{G}.
 @end deftypefn
 
@@ -2114,15 +2235,16 @@ Set @code{REGION} to be the region number for @code{GIMPLE_RESX} @code{G}.
 @subsection @code{GIMPLE_RETURN}
 @cindex @code{GIMPLE_RETURN}
 
-@deftypefn {GIMPLE function} gimple gimple_build_return (tree retval)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_return (tree retval)
 Build a @code{GIMPLE_RETURN} statement whose return value is retval.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_return_retval (gimple g)
+@deftypefn {GIMPLE function} tree gimple_return_retval (gimple_stmt *g)
 Return the return value for @code{GIMPLE_RETURN} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_return_set_retval (gimple g, tree retval)
+@deftypefn {GIMPLE function} void gimple_return_set_retval (gimple_stmt *g, @
+tree retval)
 Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
 @end deftypefn
 
@@ -2130,50 +2252,52 @@ Set @code{RETVAL} to be the return value for @code{GIMPLE_RETURN} @code{G}.
 @subsection @code{GIMPLE_SWITCH}
 @cindex @code{GIMPLE_SWITCH}
 
-@deftypefn {GIMPLE function} gimple gimple_build_switch (tree index, tree @
-default_label, @code{VEC}(tree,heap) *args)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_switch (tree index, @
+tree default_label, @code{VEC}(tree,heap) *args)
 Build a @code{GIMPLE_SWITCH} statement.  @code{INDEX} is the index variable
 to switch on, and @code{DEFAULT_LABEL} represents the default label.
 @code{ARGS} is a vector of @code{CASE_LABEL_EXPR} trees that contain the
 non-default case labels.  Each label is a tree of code @code{CASE_LABEL_EXPR}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (gimple g)
+@deftypefn {GIMPLE function} unsigned gimple_switch_num_labels (gimple_stmt *g)
 Return the number of labels associated with the switch statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_num_labels (gimple g, @
-unsigned nlabels)
+@deftypefn {GIMPLE function} void gimple_switch_set_num_labels (@
+gimple_stmt *g, unsigned nlabels)
 Set @code{NLABELS} to be the number of labels for the switch statement
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_index (gimple g)
+@deftypefn {GIMPLE function} tree gimple_switch_index (gimple_stmt *g)
 Return the index variable used by the switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple g, tree index)
+@deftypefn {GIMPLE function} void gimple_switch_set_index (gimple_stmt *g, @
+tree index)
 Set @code{INDEX} to be the index variable for switch statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_label (gimple g, unsigned index)
+@deftypefn {GIMPLE function} tree gimple_switch_label (gimple_stmt *g, @
+unsigned index)
 Return the label numbered @code{INDEX}. The default label is 0, followed
 by any labels in a switch statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple g, unsigned @
-index, tree label)
+@deftypefn {GIMPLE function} void gimple_switch_set_label (gimple_stmt *g, @
+unsigned index, tree label)
 Set the label number @code{INDEX} to @code{LABEL}. 0 is always the default
 label.
 @end deftypefn
 
-@deftypefn {GIMPLE function} tree gimple_switch_default_label (gimple g)
+@deftypefn {GIMPLE function} tree gimple_switch_default_label (gimple_stmt *g)
 Return the default label for a switch statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_switch_set_default_label (gimple g, @
-tree label)
+@deftypefn {GIMPLE function} void gimple_switch_set_default_label (@
+gimple_stmt *g, tree label)
 Set the default label for a switch statement.
 @end deftypefn
 
@@ -2182,7 +2306,7 @@ Set the default label for a switch statement.
 @subsection @code{GIMPLE_TRY}
 @cindex @code{GIMPLE_TRY}
 
-@deftypefn {GIMPLE function} gimple gimple_build_try (gimple_seq eval, @
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_try (gimple_seq eval, @
 gimple_seq cleanup, unsigned int kind)
 Build a @code{GIMPLE_TRY} statement.  @code{EVAL} is a sequence with the
 expression to evaluate.  @code{CLEANUP} is a sequence of statements to
@@ -2192,36 +2316,39 @@ or @code{GIMPLE_TRY_FINALLY} if this statement denotes a try/finally
 construct.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {enum gimple_try_flags} gimple_try_kind (gimple g)
+@deftypefn {GIMPLE function} {enum gimple_try_flags} gimple_try_kind (@
+gimple_stmt *g)
 Return the kind of try block represented by @code{GIMPLE_TRY} @code{G}. This is
 either @code{GIMPLE_TRY_CATCH} or @code{GIMPLE_TRY_FINALLY}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_try_catch_is_cleanup (gimple g)
+@deftypefn {GIMPLE function} bool gimple_try_catch_is_cleanup (gimple_stmt *g)
 Return the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_try_eval (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_try_eval (gimple_stmt *g)
 Return the sequence of statements used as the body for @code{GIMPLE_TRY}
 @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_try_cleanup (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_try_cleanup (gimple_stmt *g)
 Return the sequence of statements used as the cleanup body for
 @code{GIMPLE_TRY} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_try_set_catch_is_cleanup (gimple g, @
-bool catch_is_cleanup)
+@deftypefn {GIMPLE function} void gimple_try_set_catch_is_cleanup (@
+gimple_stmt *g, bool catch_is_cleanup)
 Set the @code{GIMPLE_TRY_CATCH_IS_CLEANUP} flag.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_try_set_eval (gimple g, gimple_seq eval)
+@deftypefn {GIMPLE function} void gimple_try_set_eval (gimple_stmt *g, @
+gimple_seq eval)
 Set @code{EVAL} to be the sequence of statements to use as the body for
 @code{GIMPLE_TRY} @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_try_set_cleanup (gimple g, gimple_seq cleanup)
+@deftypefn {GIMPLE function} void gimple_try_set_cleanup (gimple_stmt *g, @
+gimple_seq cleanup)
 Set @code{CLEANUP} to be the sequence of statements to use as the
 cleanup body for @code{GIMPLE_TRY} @code{G}.
 @end deftypefn
@@ -2230,24 +2357,26 @@ cleanup body for @code{GIMPLE_TRY} @code{G}.
 @subsection @code{GIMPLE_WITH_CLEANUP_EXPR}
 @cindex @code{GIMPLE_WITH_CLEANUP_EXPR}
 
-@deftypefn {GIMPLE function} gimple gimple_build_wce (gimple_seq cleanup)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_build_wce (gimple_seq cleanup)
 Build a @code{GIMPLE_WITH_CLEANUP_EXPR} statement.  @code{CLEANUP} is the
 clean-up expression.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_seq gimple_wce_cleanup (gimple g)
+@deftypefn {GIMPLE function} gimple_seq gimple_wce_cleanup (gimple_stmt *g)
 Return the cleanup sequence for cleanup statement @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_wce_set_cleanup (gimple g, gimple_seq cleanup)
+@deftypefn {GIMPLE function} void gimple_wce_set_cleanup (gimple_stmt *g, @
+gimple_seq cleanup)
 Set @code{CLEANUP} to be the cleanup sequence for @code{G}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} bool gimple_wce_cleanup_eh_only (gimple g)
+@deftypefn {GIMPLE function} bool gimple_wce_cleanup_eh_only (gimple_stmt *g)
 Return the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_wce_set_cleanup_eh_only (gimple g, bool eh_only_p)
+@deftypefn {GIMPLE function} void gimple_wce_set_cleanup_eh_only (@
+gimple_stmt *g, bool eh_only_p)
 Set the @code{CLEANUP_EH_ONLY} flag for a @code{WCE} tuple.
 @end deftypefn
 
@@ -2274,7 +2403,8 @@ in the section entitled Sequence Iterators.
 
 Below is a list of functions to manipulate and query sequences.
 
-@deftypefn {GIMPLE function} void gimple_seq_add_stmt (gimple_seq *seq, gimple g)
+@deftypefn {GIMPLE function} void gimple_seq_add_stmt (gimple_seq *seq, @
+gimple_stmt *g)
 Link a gimple statement to the end of the sequence *@code{SEQ} if @code{G} is
 not @code{NULL}.  If *@code{SEQ} is @code{NULL}, allocate a sequence before linking.
 @end deftypefn
@@ -2294,19 +2424,21 @@ Reverse the order of the statements in the sequence @code{SEQ}.  Return
 @code{SEQ}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_seq_first (gimple_seq s)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_seq_first (gimple_seq s)
 Return the first statement in sequence @code{S}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gimple_seq_last (gimple_seq s)
+@deftypefn {GIMPLE function} gimple_stmt *gimple_seq_last (gimple_seq s)
 Return the last statement in sequence @code{S}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_seq_set_last (gimple_seq s, gimple last)
+@deftypefn {GIMPLE function} void gimple_seq_set_last (gimple_seq s, @
+gimple_stmt *last)
 Set the last statement in sequence @code{S} to the statement in @code{LAST}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gimple_seq_set_first (gimple_seq s, gimple first)
+@deftypefn {GIMPLE function} void gimple_seq_set_first (gimple_seq s, @
+gimple_stmt *first)
 Set the first statement in sequence @code{S} to the statement in @code{FIRST}.
 @end deftypefn
 
@@ -2352,7 +2484,7 @@ gimple_stmt_iterator gsi;
 
 for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
   @{
-    gimple g = gsi_stmt (gsi);
+    gimple_stmt *g = gsi_stmt (gsi);
     /* Do something with gimple statement @code{G}.  */
   @}
 @end smallexample
@@ -2424,7 +2556,7 @@ Advance the iterator to the next gimple statement.
 Advance the iterator to the previous gimple statement.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple gsi_stmt (gimple_stmt_iterator i)
+@deftypefn {GIMPLE function} gimple_stmt *gsi_stmt (gimple_stmt_iterator i)
 Return the current stmt.
 @end deftypefn
 
@@ -2433,7 +2565,8 @@ Return a block statement iterator that points to the first
 non-label statement in block @code{BB}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} {gimple *} gsi_stmt_ptr (gimple_stmt_iterator *i)
+@deftypefn {GIMPLE function} {gimple_stmt **} gsi_stmt_ptr (@
+gimple_stmt_iterator *i)
 Return a pointer to the current stmt.
 @end deftypefn
 
@@ -2460,7 +2593,8 @@ by iterator @code{I}.  @code{MODE} indicates what to do with the iterator
 after insertion (see @code{enum gsi_iterator_update} above).
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gsi_link_before (gimple_stmt_iterator *i, gimple g, enum gsi_iterator_update mode)
+@deftypefn {GIMPLE function} void gsi_link_before (gimple_stmt_iterator *i, @
+gimple_stmt *g, enum gsi_iterator_update mode)
 Links statement @code{G} before the statement pointed-to by iterator @code{I}.
 Updates iterator @code{I} according to @code{MODE}.
 @end deftypefn
@@ -2472,7 +2606,7 @@ Links sequence @code{SEQ} after the statement pointed-to by iterator @code{I}.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gsi_link_after (gimple_stmt_iterator *i, @
-gimple g, enum gsi_iterator_update mode)
+gimple_stmt *g, enum gsi_iterator_update mode)
 Links statement @code{G} after the statement pointed-to by iterator @code{I}.
 @code{MODE} is as in @code{gsi_insert_after}.
 @end deftypefn
@@ -2488,14 +2622,14 @@ Return this new sequence.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gsi_replace (gimple_stmt_iterator *i, @
-gimple stmt, bool update_eh_info)
+gimple_stmt *stmt, bool update_eh_info)
 Replace the statement pointed-to by @code{I} to @code{STMT}.  If @code{UPDATE_EH_INFO}
 is true, the exception handling information of the original
 statement is moved to the new statement.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gsi_insert_before (gimple_stmt_iterator *i, @
-gimple stmt, enum gsi_iterator_update mode)
+gimple_stmt *stmt, enum gsi_iterator_update mode)
 Insert statement @code{STMT} before the statement pointed-to by iterator
 @code{I}, update @code{STMT}'s basic block and scan it for new operands.  @code{MODE}
 specifies how to update iterator @code{I} after insertion (see enum
@@ -2508,7 +2642,7 @@ Like @code{gsi_insert_before}, but for all the statements in @code{SEQ}.
 @end deftypefn
 
 @deftypefn {GIMPLE function} void gsi_insert_after (gimple_stmt_iterator *i, @
-gimple stmt, enum gsi_iterator_update mode)
+gimple_stmt *stmt, enum gsi_iterator_update mode)
 Insert statement @code{STMT} after the statement pointed-to by iterator
 @code{I}, update @code{STMT}'s basic block and scan it for new operands.  @code{MODE}
 specifies how to update iterator @code{I} after insertion (see enum
@@ -2520,7 +2654,8 @@ gimple_seq seq, enum gsi_iterator_update mode)
 Like @code{gsi_insert_after}, but for all the statements in @code{SEQ}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_for_stmt (gimple stmt)
+@deftypefn {GIMPLE function} gimple_stmt_iterator gsi_for_stmt (@
+gimple_stmt *stmt)
 Finds iterator for @code{STMT}.
 @end deftypefn
 
@@ -2541,7 +2676,7 @@ basic_block bb)
 Move the statement at @code{FROM} to the end of basic block @code{BB}.
 @end deftypefn
 
-@deftypefn {GIMPLE function} void gsi_insert_on_edge (edge e, gimple stmt)
+@deftypefn {GIMPLE function} void gsi_insert_on_edge (edge e, gimple_stmt *stmt)
 Add @code{STMT} to the pending list of edge @code{E}.  No actual insertion is
 made until a call to @code{gsi_commit_edge_inserts}() is made.
 @end deftypefn
@@ -2552,7 +2687,8 @@ Add the sequence of statements in @code{SEQ} to the pending list of edge
 @code{gsi_commit_edge_inserts}() is made.
 @end deftypefn
 
-@deftypefn {GIMPLE function} basic_block gsi_insert_on_edge_immediate (edge e, gimple stmt)
+@deftypefn {GIMPLE function} basic_block gsi_insert_on_edge_immediate (@
+edge e, gimple_stmt *stmt)
 Similar to @code{gsi_insert_on_edge}+@code{gsi_commit_edge_inserts}.  If a new
 block has to be created, it is returned.
 @end deftypefn
@@ -2626,7 +2762,7 @@ The return value is that returned by the last call to
 @end deftypefn
 
 
-@deftypefn {GIMPLE function} tree walk_gimple_op (gimple stmt, @
+@deftypefn {GIMPLE function} tree walk_gimple_op (gimple_stmt *stmt, @
   walk_tree_fn callback_op, struct walk_stmt_info *wi)
 Use this function to walk the operands of statement @code{STMT}.  Every
 operand is walked via @code{walk_tree} with optional state information
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 85608dc..2bc67f0 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -454,7 +454,7 @@ def build_pretty_printer():
                              'tree', TreePrinter)
     pp.add_printer_for_types(['cgraph_node *'],
                              'cgraph_node', CGraphNodePrinter)
-    pp.add_printer_for_types(['gimple', 'gimple_statement_base *'],
+    pp.add_printer_for_types(['gimple_stmt *'],
                              'gimple',
                              GimplePrinter)
     pp.add_printer_for_types(['basic_block', 'basic_block_def *'],
diff --git a/gcc/ggc.h b/gcc/ggc.h
index 55f3fe9..6c8dc0e 100644
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -270,10 +270,10 @@ ggc_alloc_cleared_tree_node_stat (size_t s MEM_STAT_DECL)
   return (union tree_node *) ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
 }
 
-static inline struct gimple_statement_base *
-ggc_alloc_cleared_gimple_statement_stat (size_t s MEM_STAT_DECL)
+static inline struct gimple_stmt *
+ggc_alloc_cleared_gimple_stmt_stat (size_t s MEM_STAT_DECL)
 {
-  return (struct gimple_statement_base *)
+  return (struct gimple_stmt *)
     ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
 }
 
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 741cd92..24fd876 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -94,13 +94,13 @@ print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
 }
 
 DEBUG_FUNCTION void
-debug (gimple_statement_base &ref)
+debug (gimple_stmt &ref)
 {
   print_gimple_stmt (stderr, &ref, 0, 0);
 }
 
 DEBUG_FUNCTION void
-debug (gimple_statement_base *ptr)
+debug (gimple_stmt *ptr)
 {
   if (ptr)
     debug (*ptr);
diff --git a/gcc/gimple-pretty-print.h b/gcc/gimple-pretty-print.h
index 37db243..489e108 100644
--- a/gcc/gimple-pretty-print.h
+++ b/gcc/gimple-pretty-print.h
@@ -29,8 +29,8 @@ extern void debug_gimple_stmt (gimple);
 extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
-extern void debug (gimple_statement_base &ref);
-extern void debug (gimple_statement_base *ptr);
+extern void debug (gimple_stmt &ref);
+extern void debug (gimple_stmt *ptr);
 extern void print_gimple_expr (FILE *, gimple, int, int);
 extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
 extern void gimple_dump_bb (FILE *, basic_block, int, int);
diff --git a/gcc/gimple-ssa.h b/gcc/gimple-ssa.h
index 904f002..f048db1 100644
--- a/gcc/gimple-ssa.h
+++ b/gcc/gimple-ssa.h
@@ -108,8 +108,8 @@ static inline use_operand_p
 gimple_vuse_op (const_gimple g)
 {
   struct use_optype_d *ops;
-  const gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <const gimple_statement_with_memory_ops *> (g);
+  const gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <const gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL_USE_OPERAND_P;
   ops = mem_ops_stmt->use_ops;
@@ -124,8 +124,8 @@ gimple_vuse_op (const_gimple g)
 static inline def_operand_p
 gimple_vdef_op (gimple g)
 {
-  gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <gimple_statement_with_memory_ops *> (g);
+  gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL_DEF_OPERAND_P;
   if (mem_ops_stmt->vdef)
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index f7b5d01..a2d935b 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -137,7 +137,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
     case GIMPLE_ASM:
       {
 	/* FIXME lto.  Move most of this into a new gimple_asm_set_string().  */
-	gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm *> (stmt);
+	gimple_asm *asm_stmt = as_a <gimple_asm *> (stmt);
 	tree str;
 	asm_stmt->ni = streamer_read_uhwi (ib);
 	asm_stmt->no = streamer_read_uhwi (ib);
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 334d67a..3036b98 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -132,7 +132,7 @@ gimple_alloc_stat (enum gimple_code code, unsigned num_ops MEM_STAT_DECL)
       gimple_alloc_sizes[(int) kind] += size;
     }
 
-  stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT);
+  stmt = ggc_alloc_cleared_gimple_stmt_stat (size PASS_MEM_STAT);
   gimple_set_code (stmt, code);
   gimple_set_num_ops (stmt, num_ops);
 
@@ -537,14 +537,14 @@ static inline gimple
 gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs,
                     unsigned nclobbers, unsigned nlabels)
 {
-  gimple_statement_asm *p;
+  gimple_asm *p;
   int size = strlen (string);
 
   /* ASMs with labels cannot have outputs.  This should have been
      enforced by the front end.  */
   gcc_assert (nlabels == 0 || noutputs == 0);
 
-  p = as_a <gimple_statement_asm *> (
+  p = as_a <gimple_asm *> (
         gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK,
 			       ninputs + noutputs + nclobbers + nlabels));
 
@@ -664,14 +664,14 @@ gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body)
    KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on
    whether this is a try/catch or a try/finally respectively.  */
 
-gimple_statement_try *
+gimple_try *
 gimple_build_try (gimple_seq eval, gimple_seq cleanup,
     		  enum gimple_try_flags kind)
 {
-  gimple_statement_try *p;
+  gimple_try *p;
 
   gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
-  p = as_a <gimple_statement_try *> (gimple_alloc (GIMPLE_TRY, 0));
+  p = as_a <gimple_try *> (gimple_alloc (GIMPLE_TRY, 0));
   gimple_set_subcode (p, kind);
   if (eval)
     gimple_try_set_eval (p, eval);
@@ -701,8 +701,8 @@ gimple_build_wce (gimple_seq cleanup)
 gimple
 gimple_build_resx (int region)
 {
-  gimple_statement_resx *p =
-    as_a <gimple_statement_resx *> (
+  gimple_resx *p =
+    as_a <gimple_resx *> (
       gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0));
   p->region = region;
   return p;
@@ -751,8 +751,8 @@ gimple_build_switch (tree index, tree default_label, vec<tree> args)
 gimple
 gimple_build_eh_dispatch (int region)
 {
-  gimple_statement_eh_dispatch *p =
-    as_a <gimple_statement_eh_dispatch *> (
+  gimple_eh_dispatch *p =
+    as_a <gimple_eh_dispatch *> (
       gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
   p->region = region;
   return p;
@@ -828,8 +828,8 @@ gimple
 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
 		      gimple_seq pre_body)
 {
-  gimple_statement_omp_for *p =
-    as_a <gimple_statement_omp_for *> (gimple_alloc (GIMPLE_OMP_FOR, 0));
+  gimple_omp_for *p =
+    as_a <gimple_omp_for *> (gimple_alloc (GIMPLE_OMP_FOR, 0));
   if (body)
     gimple_omp_set_body (p, body);
   gimple_omp_for_set_clauses (p, clauses);
@@ -1663,8 +1663,8 @@ gimple_copy (gimple stmt)
 	  t = unshare_expr (gimple_omp_for_clauses (stmt));
 	  gimple_omp_for_set_clauses (copy, t);
 	  {
-	    gimple_statement_omp_for *omp_for_copy =
-	      as_a <gimple_statement_omp_for *> (copy);
+	    gimple_omp_for *omp_for_copy =
+	      as_a <gimple_omp_for *> (copy);
 	    omp_for_copy->iter =
 	      static_cast <struct gimple_omp_for_iter *> (
 		  ggc_internal_vec_alloc_stat (sizeof (struct gimple_omp_for_iter),
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 9df45de..ed8e7a4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -70,7 +70,7 @@ enum gimple_rhs_class
 };
 
 /* Specific flags for individual GIMPLE statements.  These flags are
-   always stored in gimple_statement_base.subcode and they may only be
+   always stored in gimple_stmt.subcode and they may only be
    defined for statement codes that do not use subcodes.
 
    Values for the masks can overlap as long as the overlapping values
@@ -136,7 +136,7 @@ enum plf_mask {
 
 struct GTY((desc ("gimple_statement_structure (&%h)"), tag ("GSS_BASE"),
 	    chain_next ("%h.next"), variable_size))
-  gimple_statement_base
+  gimple_stmt
 {
   /* [ WORD 1 ]
      Main identifying code for a tuple.  */
@@ -206,7 +206,7 @@ struct GTY((desc ("gimple_statement_structure (&%h)"), tag ("GSS_BASE"),
 
 /* This gimple subclass has no tag value.  */
 struct GTY(())
-  gimple_statement_with_ops_base : public gimple_statement_base
+  gimple_stmt_with_ops_base : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -222,7 +222,7 @@ struct GTY(())
 /* Statements that take register operands.  */
 
 struct GTY((tag("GSS_WITH_OPS")))
-  gimple_statement_with_ops : public gimple_statement_with_ops_base
+  gimple_stmt_with_ops : public gimple_stmt_with_ops_base
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -237,7 +237,7 @@ struct GTY((tag("GSS_WITH_OPS")))
 /* Base for statements that take both memory and register operands.  */
 
 struct GTY((tag("GSS_WITH_MEM_OPS_BASE")))
-  gimple_statement_with_memory_ops_base : public gimple_statement_with_ops_base
+  gimple_stmt_with_memory_ops_base : public gimple_stmt_with_ops_base
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -252,8 +252,8 @@ struct GTY((tag("GSS_WITH_MEM_OPS_BASE")))
 /* Statements that take both memory and register operands.  */
 
 struct GTY((tag("GSS_WITH_MEM_OPS")))
-  gimple_statement_with_memory_ops :
-    public gimple_statement_with_memory_ops_base
+  gimple_stmt_with_memory_ops :
+    public gimple_stmt_with_memory_ops_base
 {
   /* [ WORD 1-9 ] : base class */
 
@@ -268,7 +268,7 @@ struct GTY((tag("GSS_WITH_MEM_OPS")))
 /* Call statements that take both memory and register operands.  */
 
 struct GTY((tag("GSS_CALL")))
-  gimple_statement_call : public gimple_statement_with_memory_ops_base
+  gimple_call : public gimple_stmt_with_memory_ops_base
 {
   /* [ WORD 1-9 ] : base class */
 
@@ -293,7 +293,7 @@ struct GTY((tag("GSS_CALL")))
 /* OpenMP statements (#pragma omp).  */
 
 struct GTY((tag("GSS_OMP")))
-  gimple_statement_omp : public gimple_statement_base
+  gimple_omp : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -305,7 +305,7 @@ struct GTY((tag("GSS_OMP")))
 /* GIMPLE_BIND */
 
 struct GTY((tag("GSS_BIND")))
-  gimple_statement_bind : public gimple_statement_base
+  gimple_bind : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -314,7 +314,7 @@ struct GTY((tag("GSS_BIND")))
   tree vars;
 
   /* [ WORD 8 ]
-     This is different than the BLOCK field in gimple_statement_base,
+     This is different than the BLOCK field in gimple_stmt,
      which is analogous to TREE_BLOCK (i.e., the lexical block holding
      this statement).  This field is the equivalent of BIND_EXPR_BLOCK
      in tree land (i.e., the lexical scope defined by this bind).  See
@@ -329,7 +329,7 @@ struct GTY((tag("GSS_BIND")))
 /* GIMPLE_CATCH */
 
 struct GTY((tag("GSS_CATCH")))
-  gimple_statement_catch : public gimple_statement_base
+  gimple_catch : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -344,7 +344,7 @@ struct GTY((tag("GSS_CATCH")))
 /* GIMPLE_EH_FILTER */
 
 struct GTY((tag("GSS_EH_FILTER")))
-  gimple_statement_eh_filter : public gimple_statement_base
+  gimple_eh_filter : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -360,7 +360,7 @@ struct GTY((tag("GSS_EH_FILTER")))
 /* GIMPLE_EH_ELSE */
 
 struct GTY((tag("GSS_EH_ELSE")))
-  gimple_statement_eh_else : public gimple_statement_base
+  gimple_eh_else : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -371,7 +371,7 @@ struct GTY((tag("GSS_EH_ELSE")))
 /* GIMPLE_EH_MUST_NOT_THROW */
 
 struct GTY((tag("GSS_EH_MNT")))
-  gimple_statement_eh_mnt : public gimple_statement_base
+  gimple_eh_mnt : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -382,7 +382,7 @@ struct GTY((tag("GSS_EH_MNT")))
 /* GIMPLE_PHI */
 
 struct GTY((tag("GSS_PHI")))
-  gimple_statement_phi : public gimple_statement_base
+  gimple_phi : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -401,7 +401,7 @@ struct GTY((tag("GSS_PHI")))
 /* GIMPLE_RESX, GIMPLE_EH_DISPATCH */
 
 struct GTY((tag("GSS_EH_CTRL")))
-  gimple_statement_eh_ctrl : public gimple_statement_base
+  gimple_eh_ctrl : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -411,14 +411,14 @@ struct GTY((tag("GSS_EH_CTRL")))
 };
 
 struct GTY((tag("GSS_EH_CTRL")))
-  gimple_statement_resx : public gimple_statement_eh_ctrl
+  gimple_resx : public gimple_eh_ctrl
 {
   /* No extra fields; adds invariant:
        stmt->code == GIMPLE_RESX.  */
 };
 
 struct GTY((tag("GSS_EH_CTRL")))
-  gimple_statement_eh_dispatch : public gimple_statement_eh_ctrl
+  gimple_eh_dispatch : public gimple_eh_ctrl
 {
   /* No extra fields; adds invariant:
        stmt->code == GIMPLE_EH_DISPATH.  */
@@ -428,7 +428,7 @@ struct GTY((tag("GSS_EH_CTRL")))
 /* GIMPLE_TRY */
 
 struct GTY((tag("GSS_TRY")))
-  gimple_statement_try : public gimple_statement_base
+  gimple_try : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -458,7 +458,7 @@ enum gimple_try_flags
 /* GIMPLE_WITH_CLEANUP_EXPR */
 
 struct GTY((tag("GSS_WCE")))
-  gimple_statement_wce : public gimple_statement_base
+  gimple_wce : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -476,7 +476,7 @@ struct GTY((tag("GSS_WCE")))
 /* GIMPLE_ASM  */
 
 struct GTY((tag("GSS_ASM")))
-  gimple_statement_asm : public gimple_statement_with_memory_ops_base
+  gimple_asm : public gimple_stmt_with_memory_ops_base
 {
   /* [ WORD 1-9 ] : base class */
 
@@ -501,7 +501,7 @@ struct GTY((tag("GSS_ASM")))
 /* GIMPLE_OMP_CRITICAL */
 
 struct GTY((tag("GSS_OMP_CRITICAL")))
-  gimple_statement_omp_critical : public gimple_statement_omp
+  gimple_omp_critical : public gimple_omp
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -531,7 +531,7 @@ struct GTY(()) gimple_omp_for_iter {
 /* GIMPLE_OMP_FOR */
 
 struct GTY((tag("GSS_OMP_FOR")))
-  gimple_statement_omp_for : public gimple_statement_omp
+  gimple_omp_for : public gimple_omp
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -553,7 +553,7 @@ struct GTY((tag("GSS_OMP_FOR")))
 
 /* GIMPLE_OMP_PARALLEL, GIMPLE_OMP_TARGET */
 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
-  gimple_statement_omp_parallel_layout : public gimple_statement_omp
+  gimple_omp_parallel_layout : public gimple_omp
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -572,7 +572,7 @@ struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
 
 /* GIMPLE_OMP_PARALLEL or GIMPLE_TASK */
 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
-  gimple_statement_omp_taskreg : public gimple_statement_omp_parallel_layout
+  gimple_omp_taskreg : public gimple_omp_parallel_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_PARALLEL
@@ -582,14 +582,14 @@ struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
 
 /* GIMPLE_OMP_PARALLEL */
 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
-  gimple_statement_omp_parallel : public gimple_statement_omp_taskreg
+  gimple_omp_parallel : public gimple_omp_taskreg
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_PARALLEL.  */
 };
 
 struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
-  gimple_statement_omp_target : public gimple_statement_omp_parallel_layout
+  gimple_omp_target : public gimple_omp_parallel_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_TARGET.  */
@@ -598,7 +598,7 @@ struct GTY((tag("GSS_OMP_PARALLEL_LAYOUT")))
 /* GIMPLE_OMP_TASK */
 
 struct GTY((tag("GSS_OMP_TASK")))
-  gimple_statement_omp_task : public gimple_statement_omp_taskreg
+  gimple_omp_task : public gimple_omp_taskreg
 {
   /* [ WORD 1-10 ] : base class */
 
@@ -614,13 +614,13 @@ struct GTY((tag("GSS_OMP_TASK")))
 
 
 /* GIMPLE_OMP_SECTION */
-/* Uses struct gimple_statement_omp.  */
+/* Uses struct gimple_omp.  */
 
 
 /* GIMPLE_OMP_SECTIONS */
 
 struct GTY((tag("GSS_OMP_SECTIONS")))
-  gimple_statement_omp_sections : public gimple_statement_omp
+  gimple_omp_sections : public gimple_omp
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -635,11 +635,11 @@ struct GTY((tag("GSS_OMP_SECTIONS")))
 
 /* GIMPLE_OMP_CONTINUE.
 
-   Note: This does not inherit from gimple_statement_omp, because we
+   Note: This does not inherit from gimple_omp, because we
          do not need the body field.  */
 
 struct GTY((tag("GSS_OMP_CONTINUE")))
-  gimple_statement_omp_continue : public gimple_statement_base
+  gimple_omp_continue : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -653,7 +653,7 @@ struct GTY((tag("GSS_OMP_CONTINUE")))
 /* GIMPLE_OMP_SINGLE, GIMPLE_OMP_TEAMS */
 
 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
-  gimple_statement_omp_single_layout : public gimple_statement_omp
+  gimple_omp_single_layout : public gimple_omp
 {
   /* [ WORD 1-7 ] : base class */
 
@@ -662,14 +662,14 @@ struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
 };
 
 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
-  gimple_statement_omp_single : public gimple_statement_omp_single_layout
+  gimple_omp_single : public gimple_omp_single_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_SINGLE.  */
 };
 
 struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
-  gimple_statement_omp_teams : public gimple_statement_omp_single_layout
+  gimple_omp_teams : public gimple_omp_single_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_TEAMS.  */
@@ -677,11 +677,11 @@ struct GTY((tag("GSS_OMP_SINGLE_LAYOUT")))
 
 
 /* GIMPLE_OMP_ATOMIC_LOAD.
-   Note: This is based on gimple_statement_base, not g_s_omp, because g_s_omp
+   Note: This is based on gimple_stmt, not g_s_omp, because g_s_omp
    contains a sequence, which we don't need here.  */
 
 struct GTY((tag("GSS_OMP_ATOMIC_LOAD")))
-  gimple_statement_omp_atomic_load : public gimple_statement_base
+  gimple_omp_atomic_load : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -693,7 +693,7 @@ struct GTY((tag("GSS_OMP_ATOMIC_LOAD")))
    See note on GIMPLE_OMP_ATOMIC_LOAD.  */
 
 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
-  gimple_statement_omp_atomic_store_layout : public gimple_statement_base
+  gimple_omp_atomic_store_layout : public gimple_stmt
 {
   /* [ WORD 1-6 ] : base class */
 
@@ -702,16 +702,16 @@ struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
 };
 
 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
-  gimple_statement_omp_atomic_store :
-    public gimple_statement_omp_atomic_store_layout
+  gimple_omp_atomic_store :
+    public gimple_omp_atomic_store_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_ATOMIC_STORE.  */
 };
 
 struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
-  gimple_statement_omp_return :
-    public gimple_statement_omp_atomic_store_layout
+  gimple_omp_return :
+    public gimple_omp_atomic_store_layout
 {
     /* No extra fields; adds invariant:
          stmt->code == GIMPLE_OMP_RETURN.  */
@@ -746,7 +746,7 @@ struct GTY((tag("GSS_OMP_ATOMIC_STORE_LAYOUT")))
 #define GTMA_HAS_NO_INSTRUMENTATION	(1u << 7)
 
 struct GTY((tag("GSS_TRANSACTION")))
-  gimple_statement_transaction : public gimple_statement_with_memory_ops_base
+  gimple_transaction : public gimple_stmt_with_memory_ops_base
 {
   /* [ WORD 1-9 ] : base class */
 
@@ -767,7 +767,7 @@ enum gimple_statement_structure_enum {
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_asm *>::test (gimple gs)
+is_a_helper <gimple_asm *>::test (gimple gs)
 {
   return gs->code == GIMPLE_ASM;
 }
@@ -775,7 +775,7 @@ is_a_helper <gimple_statement_asm *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_bind *>::test (gimple gs)
+is_a_helper <gimple_bind *>::test (gimple gs)
 {
   return gs->code == GIMPLE_BIND;
 }
@@ -783,7 +783,7 @@ is_a_helper <gimple_statement_bind *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_call *>::test (gimple gs)
+is_a_helper <gimple_call *>::test (gimple gs)
 {
   return gs->code == GIMPLE_CALL;
 }
@@ -791,7 +791,7 @@ is_a_helper <gimple_statement_call *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_catch *>::test (gimple gs)
+is_a_helper <gimple_catch *>::test (gimple gs)
 {
   return gs->code == GIMPLE_CATCH;
 }
@@ -799,7 +799,7 @@ is_a_helper <gimple_statement_catch *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_resx *>::test (gimple gs)
+is_a_helper <gimple_resx *>::test (gimple gs)
 {
   return gs->code == GIMPLE_RESX;
 }
@@ -807,7 +807,7 @@ is_a_helper <gimple_statement_resx *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_eh_dispatch *>::test (gimple gs)
+is_a_helper <gimple_eh_dispatch *>::test (gimple gs)
 {
   return gs->code == GIMPLE_EH_DISPATCH;
 }
@@ -815,7 +815,7 @@ is_a_helper <gimple_statement_eh_dispatch *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_eh_else *>::test (gimple gs)
+is_a_helper <gimple_eh_else *>::test (gimple gs)
 {
   return gs->code == GIMPLE_EH_ELSE;
 }
@@ -823,7 +823,7 @@ is_a_helper <gimple_statement_eh_else *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_eh_filter *>::test (gimple gs)
+is_a_helper <gimple_eh_filter *>::test (gimple gs)
 {
   return gs->code == GIMPLE_EH_FILTER;
 }
@@ -831,7 +831,7 @@ is_a_helper <gimple_statement_eh_filter *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_eh_mnt *>::test (gimple gs)
+is_a_helper <gimple_eh_mnt *>::test (gimple gs)
 {
   return gs->code == GIMPLE_EH_MUST_NOT_THROW;
 }
@@ -839,7 +839,7 @@ is_a_helper <gimple_statement_eh_mnt *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_atomic_load *>::test (gimple gs)
+is_a_helper <gimple_omp_atomic_load *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
 }
@@ -847,7 +847,7 @@ is_a_helper <gimple_statement_omp_atomic_load *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_atomic_store *>::test (gimple gs)
+is_a_helper <gimple_omp_atomic_store *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_ATOMIC_STORE;
 }
@@ -855,7 +855,7 @@ is_a_helper <gimple_statement_omp_atomic_store *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_return *>::test (gimple gs)
+is_a_helper <gimple_omp_return *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_RETURN;
 }
@@ -863,7 +863,7 @@ is_a_helper <gimple_statement_omp_return *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_continue *>::test (gimple gs)
+is_a_helper <gimple_omp_continue *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_CONTINUE;
 }
@@ -871,7 +871,7 @@ is_a_helper <gimple_statement_omp_continue *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_critical *>::test (gimple gs)
+is_a_helper <gimple_omp_critical *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_CRITICAL;
 }
@@ -879,7 +879,7 @@ is_a_helper <gimple_statement_omp_critical *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_for *>::test (gimple gs)
+is_a_helper <gimple_omp_for *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_FOR;
 }
@@ -887,7 +887,7 @@ is_a_helper <gimple_statement_omp_for *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_taskreg *>::test (gimple gs)
+is_a_helper <gimple_omp_taskreg *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
 }
@@ -895,7 +895,7 @@ is_a_helper <gimple_statement_omp_taskreg *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_parallel *>::test (gimple gs)
+is_a_helper <gimple_omp_parallel *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_PARALLEL;
 }
@@ -903,7 +903,7 @@ is_a_helper <gimple_statement_omp_parallel *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_target *>::test (gimple gs)
+is_a_helper <gimple_omp_target *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_TARGET;
 }
@@ -911,7 +911,7 @@ is_a_helper <gimple_statement_omp_target *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_sections *>::test (gimple gs)
+is_a_helper <gimple_omp_sections *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_SECTIONS;
 }
@@ -919,7 +919,7 @@ is_a_helper <gimple_statement_omp_sections *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_single *>::test (gimple gs)
+is_a_helper <gimple_omp_single *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_SINGLE;
 }
@@ -927,7 +927,7 @@ is_a_helper <gimple_statement_omp_single *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_teams *>::test (gimple gs)
+is_a_helper <gimple_omp_teams *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_TEAMS;
 }
@@ -935,7 +935,7 @@ is_a_helper <gimple_statement_omp_teams *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_omp_task *>::test (gimple gs)
+is_a_helper <gimple_omp_task *>::test (gimple gs)
 {
   return gs->code == GIMPLE_OMP_TASK;
 }
@@ -943,7 +943,7 @@ is_a_helper <gimple_statement_omp_task *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_phi *>::test (gimple gs)
+is_a_helper <gimple_phi *>::test (gimple gs)
 {
   return gs->code == GIMPLE_PHI;
 }
@@ -951,7 +951,7 @@ is_a_helper <gimple_statement_phi *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_transaction *>::test (gimple gs)
+is_a_helper <gimple_transaction *>::test (gimple gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
 }
@@ -959,7 +959,7 @@ is_a_helper <gimple_statement_transaction *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_try *>::test (gimple gs)
+is_a_helper <gimple_try *>::test (gimple gs)
 {
   return gs->code == GIMPLE_TRY;
 }
@@ -967,7 +967,7 @@ is_a_helper <gimple_statement_try *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_wce *>::test (gimple gs)
+is_a_helper <gimple_wce *>::test (gimple gs)
 {
   return gs->code == GIMPLE_WITH_CLEANUP_EXPR;
 }
@@ -975,7 +975,7 @@ is_a_helper <gimple_statement_wce *>::test (gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_asm *>::test (const_gimple gs)
+is_a_helper <const gimple_asm *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_ASM;
 }
@@ -983,7 +983,7 @@ is_a_helper <const gimple_statement_asm *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_bind *>::test (const_gimple gs)
+is_a_helper <const gimple_bind *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_BIND;
 }
@@ -991,7 +991,7 @@ is_a_helper <const gimple_statement_bind *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_call *>::test (const_gimple gs)
+is_a_helper <const gimple_call *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_CALL;
 }
@@ -999,7 +999,7 @@ is_a_helper <const gimple_statement_call *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_catch *>::test (const_gimple gs)
+is_a_helper <const gimple_catch *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_CATCH;
 }
@@ -1007,7 +1007,7 @@ is_a_helper <const gimple_statement_catch *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_resx *>::test (const_gimple gs)
+is_a_helper <const gimple_resx *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_RESX;
 }
@@ -1015,7 +1015,7 @@ is_a_helper <const gimple_statement_resx *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_eh_dispatch *>::test (const_gimple gs)
+is_a_helper <const gimple_eh_dispatch *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_EH_DISPATCH;
 }
@@ -1023,7 +1023,7 @@ is_a_helper <const gimple_statement_eh_dispatch *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_eh_filter *>::test (const_gimple gs)
+is_a_helper <const gimple_eh_filter *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_EH_FILTER;
 }
@@ -1031,7 +1031,7 @@ is_a_helper <const gimple_statement_eh_filter *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_atomic_load *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_atomic_load *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_ATOMIC_LOAD;
 }
@@ -1039,7 +1039,7 @@ is_a_helper <const gimple_statement_omp_atomic_load *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_atomic_store *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_atomic_store *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_ATOMIC_STORE;
 }
@@ -1047,7 +1047,7 @@ is_a_helper <const gimple_statement_omp_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 gimple_omp_return *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_RETURN;
 }
@@ -1055,7 +1055,7 @@ is_a_helper <const gimple_statement_omp_return *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_continue *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_continue *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_CONTINUE;
 }
@@ -1063,7 +1063,7 @@ is_a_helper <const gimple_statement_omp_continue *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_critical *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_critical *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_CRITICAL;
 }
@@ -1071,7 +1071,7 @@ is_a_helper <const gimple_statement_omp_critical *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_for *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_for *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_FOR;
 }
@@ -1079,7 +1079,7 @@ is_a_helper <const gimple_statement_omp_for *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_taskreg *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_taskreg *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_PARALLEL || gs->code == GIMPLE_OMP_TASK;
 }
@@ -1087,7 +1087,7 @@ is_a_helper <const gimple_statement_omp_taskreg *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_parallel *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_parallel *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_PARALLEL;
 }
@@ -1095,7 +1095,7 @@ is_a_helper <const gimple_statement_omp_parallel *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_target *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_target *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_TARGET;
 }
@@ -1103,7 +1103,7 @@ is_a_helper <const gimple_statement_omp_target *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_sections *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_sections *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_SECTIONS;
 }
@@ -1111,7 +1111,7 @@ is_a_helper <const gimple_statement_omp_sections *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_single *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_single *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_SINGLE;
 }
@@ -1119,7 +1119,7 @@ is_a_helper <const gimple_statement_omp_single *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_teams *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_teams *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_TEAMS;
 }
@@ -1127,7 +1127,7 @@ is_a_helper <const gimple_statement_omp_teams *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_omp_task *>::test (const_gimple gs)
+is_a_helper <const gimple_omp_task *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_OMP_TASK;
 }
@@ -1135,7 +1135,7 @@ is_a_helper <const gimple_statement_omp_task *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_phi *>::test (const_gimple gs)
+is_a_helper <const gimple_phi *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_PHI;
 }
@@ -1143,7 +1143,7 @@ is_a_helper <const gimple_statement_phi *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_transaction *>::test (const_gimple gs)
+is_a_helper <const gimple_transaction *>::test (const_gimple gs)
 {
   return gs->code == GIMPLE_TRANSACTION;
 }
@@ -1189,8 +1189,8 @@ gimple gimple_build_catch (tree, gimple_seq);
 gimple gimple_build_eh_filter (tree, gimple_seq);
 gimple gimple_build_eh_must_not_throw (tree);
 gimple gimple_build_eh_else (gimple_seq, gimple_seq);
-gimple_statement_try *gimple_build_try (gimple_seq, gimple_seq,
-					enum gimple_try_flags);
+gimple_try *gimple_build_try (gimple_seq, gimple_seq,
+			      enum gimple_try_flags);
 gimple gimple_build_wce (gimple_seq);
 gimple gimple_build_resx (int);
 gimple gimple_build_switch_nlabels (unsigned, tree, tree);
@@ -1647,7 +1647,7 @@ gimple_has_ops (const_gimple g)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_with_ops *>::test (const_gimple gs)
+is_a_helper <const gimple_stmt_with_ops *>::test (const_gimple gs)
 {
   return gimple_has_ops (gs);
 }
@@ -1655,7 +1655,7 @@ is_a_helper <const gimple_statement_with_ops *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_with_ops *>::test (gimple gs)
+is_a_helper <gimple_stmt_with_ops *>::test (gimple gs)
 {
   return gimple_has_ops (gs);
 }
@@ -1671,7 +1671,7 @@ gimple_has_mem_ops (const_gimple g)
 template <>
 template <>
 inline bool
-is_a_helper <const gimple_statement_with_memory_ops *>::test (const_gimple gs)
+is_a_helper <const gimple_stmt_with_memory_ops *>::test (const_gimple gs)
 {
   return gimple_has_mem_ops (gs);
 }
@@ -1679,7 +1679,7 @@ is_a_helper <const gimple_statement_with_memory_ops *>::test (const_gimple gs)
 template <>
 template <>
 inline bool
-is_a_helper <gimple_statement_with_memory_ops *>::test (gimple gs)
+is_a_helper <gimple_stmt_with_memory_ops *>::test (gimple gs)
 {
   return gimple_has_mem_ops (gs);
 }
@@ -1689,8 +1689,8 @@ is_a_helper <gimple_statement_with_memory_ops *>::test (gimple gs)
 static inline struct use_optype_d *
 gimple_use_ops (const_gimple g)
 {
-  const gimple_statement_with_ops *ops_stmt =
-    dyn_cast <const gimple_statement_with_ops *> (g);
+  const gimple_stmt_with_ops *ops_stmt =
+    dyn_cast <const gimple_stmt_with_ops *> (g);
   if (!ops_stmt)
     return NULL;
   return ops_stmt->use_ops;
@@ -1702,8 +1702,8 @@ gimple_use_ops (const_gimple g)
 static inline void
 gimple_set_use_ops (gimple g, struct use_optype_d *use)
 {
-  gimple_statement_with_ops *ops_stmt =
-    as_a <gimple_statement_with_ops *> (g);
+  gimple_stmt_with_ops *ops_stmt =
+    as_a <gimple_stmt_with_ops *> (g);
   ops_stmt->use_ops = use;
 }
 
@@ -1713,8 +1713,8 @@ gimple_set_use_ops (gimple g, struct use_optype_d *use)
 static inline tree
 gimple_vuse (const_gimple g)
 {
-  const gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <const gimple_statement_with_memory_ops *> (g);
+  const gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <const gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL_TREE;
   return mem_ops_stmt->vuse;
@@ -1725,8 +1725,8 @@ gimple_vuse (const_gimple g)
 static inline tree
 gimple_vdef (const_gimple g)
 {
-  const gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <const gimple_statement_with_memory_ops *> (g);
+  const gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <const gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL_TREE;
   return mem_ops_stmt->vdef;
@@ -1737,8 +1737,8 @@ gimple_vdef (const_gimple g)
 static inline tree *
 gimple_vuse_ptr (gimple g)
 {
-  gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <gimple_statement_with_memory_ops *> (g);
+  gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL;
   return &mem_ops_stmt->vuse;
@@ -1749,8 +1749,8 @@ gimple_vuse_ptr (gimple g)
 static inline tree *
 gimple_vdef_ptr (gimple g)
 {
-  gimple_statement_with_memory_ops *mem_ops_stmt =
-     dyn_cast <gimple_statement_with_memory_ops *> (g);
+  gimple_stmt_with_memory_ops *mem_ops_stmt =
+     dyn_cast <gimple_stmt_with_memory_ops *> (g);
   if (!mem_ops_stmt)
     return NULL;
   return &mem_ops_stmt->vdef;
@@ -1761,8 +1761,8 @@ gimple_vdef_ptr (gimple g)
 static inline void
 gimple_set_vuse (gimple g, tree vuse)
 {
-  gimple_statement_with_memory_ops *mem_ops_stmt =
-    as_a <gimple_statement_with_memory_ops *> (g);
+  gimple_stmt_with_memory_ops *mem_ops_stmt =
+    as_a <gimple_stmt_with_memory_ops *> (g);
   mem_ops_stmt->vuse = vuse;
 }
 
@@ -1771,8 +1771,8 @@ gimple_set_vuse (gimple g, tree vuse)
 static inline void
 gimple_set_vdef (gimple g, tree vdef)
 {
-  gimple_statement_with_memory_ops *mem_ops_stmt =
-    as_a <gimple_statement_with_memory_ops *> (g);
+  gimple_stmt_with_memory_ops *mem_ops_stmt =
+    as_a <gimple_stmt_with_memory_ops *> (g);
   mem_ops_stmt->vdef = vdef;
 }
 
@@ -1903,8 +1903,8 @@ gimple_omp_return_nowait_p (const_gimple g)
 static inline void
 gimple_omp_return_set_lhs (gimple g, tree lhs)
 {
-  gimple_statement_omp_return *omp_return_stmt =
-    as_a <gimple_statement_omp_return *> (g);
+  gimple_omp_return *omp_return_stmt =
+    as_a <gimple_omp_return *> (g);
   omp_return_stmt->val = lhs;
 }
 
@@ -1914,8 +1914,8 @@ gimple_omp_return_set_lhs (gimple g, tree lhs)
 static inline tree
 gimple_omp_return_lhs (const_gimple g)
 {
-  const gimple_statement_omp_return *omp_return_stmt =
-    as_a <const gimple_statement_omp_return *> (g);
+  const gimple_omp_return *omp_return_stmt =
+    as_a <const gimple_omp_return *> (g);
   return omp_return_stmt->val;
 }
 
@@ -1925,8 +1925,8 @@ gimple_omp_return_lhs (const_gimple g)
 static inline tree *
 gimple_omp_return_lhs_ptr (gimple g)
 {
-  gimple_statement_omp_return *omp_return_stmt =
-    as_a <gimple_statement_omp_return *> (g);
+  gimple_omp_return *omp_return_stmt =
+    as_a <gimple_omp_return *> (g);
   return &omp_return_stmt->val;
 }
 
@@ -2444,7 +2444,7 @@ static inline enum internal_fn
 gimple_call_internal_fn (const_gimple gs)
 {
   gcc_gimple_checking_assert (gimple_call_internal_p (gs));
-  return static_cast <const gimple_statement_call *> (gs)->u.internal_fn;
+  return static_cast <const gimple_call *> (gs)->u.internal_fn;
 }
 
 
@@ -2453,8 +2453,8 @@ gimple_call_internal_fn (const_gimple gs)
 static inline tree
 gimple_call_fntype (const_gimple gs)
 {
-  const gimple_statement_call *call_stmt =
-    as_a <const gimple_statement_call *> (gs);
+  const gimple_call *call_stmt =
+    as_a <const gimple_call *> (gs);
   if (gimple_call_internal_p (gs))
     return NULL_TREE;
   return call_stmt->u.fntype;
@@ -2465,7 +2465,7 @@ gimple_call_fntype (const_gimple gs)
 static inline void
 gimple_call_set_fntype (gimple gs, tree fntype)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call *> (gs);
+  gimple_call *call_stmt = as_a <gimple_call *> (gs);
   gcc_gimple_checking_assert (!gimple_call_internal_p (gs));
   call_stmt->u.fntype = fntype;
 }
@@ -2519,7 +2519,7 @@ gimple_call_set_fndecl (gimple gs, tree decl)
 static inline void
 gimple_call_set_internal_fn (gimple gs, enum internal_fn fn)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call *> (gs);
+  gimple_call *call_stmt = as_a <gimple_call *> (gs);
   gcc_gimple_checking_assert (gimple_call_internal_p (gs));
   call_stmt->u.internal_fn = fn;
 }
@@ -2797,7 +2797,7 @@ gimple_call_copy_flags (gimple dest_call, gimple orig_call)
 static inline struct pt_solution *
 gimple_call_use_set (gimple call)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call *> (call);
+  gimple_call *call_stmt = as_a <gimple_call *> (call);
   return &call_stmt->call_used;
 }
 
@@ -2808,7 +2808,7 @@ gimple_call_use_set (gimple call)
 static inline struct pt_solution *
 gimple_call_clobber_set (gimple call)
 {
-  gimple_statement_call *call_stmt = as_a <gimple_statement_call *> (call);
+  gimple_call *call_stmt = as_a <gimple_call *> (call);
   return &call_stmt->call_clobbered;
 }
 
@@ -3077,8 +3077,8 @@ gimple_goto_set_dest (gimple gs, tree dest)
 static inline tree
 gimple_bind_vars (const_gimple gs)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind *> (gs);
+  const gimple_bind *bind_stmt =
+    as_a <const gimple_bind *> (gs);
   return bind_stmt->vars;
 }
 
@@ -3089,7 +3089,7 @@ gimple_bind_vars (const_gimple gs)
 static inline void
 gimple_bind_set_vars (gimple gs, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   bind_stmt->vars = vars;
 }
 
@@ -3100,7 +3100,7 @@ gimple_bind_set_vars (gimple gs, tree vars)
 static inline void
 gimple_bind_append_vars (gimple gs, tree vars)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   bind_stmt->vars = chainon (bind_stmt->vars, vars);
 }
 
@@ -3108,7 +3108,7 @@ gimple_bind_append_vars (gimple gs, tree vars)
 static inline gimple_seq *
 gimple_bind_body_ptr (gimple gs)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   return &bind_stmt->body;
 }
 
@@ -3127,7 +3127,7 @@ gimple_bind_body (gimple gs)
 static inline void
 gimple_bind_set_body (gimple gs, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   bind_stmt->body = seq;
 }
 
@@ -3137,7 +3137,7 @@ gimple_bind_set_body (gimple gs, gimple_seq seq)
 static inline void
 gimple_bind_add_stmt (gimple gs, gimple stmt)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   gimple_seq_add_stmt (&bind_stmt->body, stmt);
 }
 
@@ -3147,7 +3147,7 @@ gimple_bind_add_stmt (gimple gs, gimple stmt)
 static inline void
 gimple_bind_add_seq (gimple gs, gimple_seq seq)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   gimple_seq_add_seq (&bind_stmt->body, seq);
 }
 
@@ -3158,8 +3158,8 @@ gimple_bind_add_seq (gimple gs, gimple_seq seq)
 static inline tree
 gimple_bind_block (const_gimple gs)
 {
-  const gimple_statement_bind *bind_stmt =
-    as_a <const gimple_statement_bind *> (gs);
+  const gimple_bind *bind_stmt =
+    as_a <const gimple_bind *> (gs);
   return bind_stmt->block;
 }
 
@@ -3170,7 +3170,7 @@ gimple_bind_block (const_gimple gs)
 static inline void
 gimple_bind_set_block (gimple gs, tree block)
 {
-  gimple_statement_bind *bind_stmt = as_a <gimple_statement_bind *> (gs);
+  gimple_bind *bind_stmt = as_a <gimple_bind *> (gs);
   gcc_gimple_checking_assert (block == NULL_TREE
 			      || TREE_CODE (block) == BLOCK);
   bind_stmt->block = block;
@@ -3182,8 +3182,8 @@ gimple_bind_set_block (gimple gs, tree block)
 static inline unsigned
 gimple_asm_ninputs (const_gimple gs)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   return asm_stmt->ni;
 }
 
@@ -3193,8 +3193,8 @@ gimple_asm_ninputs (const_gimple gs)
 static inline unsigned
 gimple_asm_noutputs (const_gimple gs)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   return asm_stmt->no;
 }
 
@@ -3204,8 +3204,8 @@ gimple_asm_noutputs (const_gimple gs)
 static inline unsigned
 gimple_asm_nclobbers (const_gimple gs)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   return asm_stmt->nc;
 }
 
@@ -3214,8 +3214,8 @@ gimple_asm_nclobbers (const_gimple gs)
 static inline unsigned
 gimple_asm_nlabels (const_gimple gs)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   return asm_stmt->nl;
 }
 
@@ -3224,8 +3224,8 @@ gimple_asm_nlabels (const_gimple gs)
 static inline tree
 gimple_asm_input_op (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni);
   return gimple_op (gs, index + asm_stmt->no);
 }
@@ -3235,8 +3235,8 @@ gimple_asm_input_op (const_gimple gs, unsigned index)
 static inline tree *
 gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni);
   return gimple_op_ptr (gs, index + asm_stmt->no);
 }
@@ -3247,7 +3247,7 @@ gimple_asm_input_op_ptr (const_gimple gs, unsigned index)
 static inline void
 gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm *> (gs);
+  gimple_asm *asm_stmt = as_a <gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->ni
 			      && TREE_CODE (in_op) == TREE_LIST);
   gimple_set_op (gs, index + asm_stmt->no, in_op);
@@ -3259,8 +3259,8 @@ gimple_asm_set_input_op (gimple gs, unsigned index, tree in_op)
 static inline tree
 gimple_asm_output_op (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no);
   return gimple_op (gs, index);
 }
@@ -3270,8 +3270,8 @@ gimple_asm_output_op (const_gimple gs, unsigned index)
 static inline tree *
 gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no);
   return gimple_op_ptr (gs, index);
 }
@@ -3282,7 +3282,7 @@ gimple_asm_output_op_ptr (const_gimple gs, unsigned index)
 static inline void
 gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm *> (gs);
+  gimple_asm *asm_stmt = as_a <gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->no
 			      && TREE_CODE (out_op) == TREE_LIST);
   gimple_set_op (gs, index, out_op);
@@ -3294,8 +3294,8 @@ gimple_asm_set_output_op (gimple gs, unsigned index, tree out_op)
 static inline tree
 gimple_asm_clobber_op (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nc);
   return gimple_op (gs, index + asm_stmt->ni + asm_stmt->no);
 }
@@ -3306,7 +3306,7 @@ gimple_asm_clobber_op (const_gimple gs, unsigned index)
 static inline void
 gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm *> (gs);
+  gimple_asm *asm_stmt = as_a <gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nc
 			      && TREE_CODE (clobber_op) == TREE_LIST);
   gimple_set_op (gs, index + asm_stmt->ni + asm_stmt->no, clobber_op);
@@ -3317,8 +3317,8 @@ gimple_asm_set_clobber_op (gimple gs, unsigned index, tree clobber_op)
 static inline tree
 gimple_asm_label_op (const_gimple gs, unsigned index)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nl);
   return gimple_op (gs, index + asm_stmt->ni + asm_stmt->nc);
 }
@@ -3328,7 +3328,7 @@ gimple_asm_label_op (const_gimple gs, unsigned index)
 static inline void
 gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
 {
-  gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm *> (gs);
+  gimple_asm *asm_stmt = as_a <gimple_asm *> (gs);
   gcc_gimple_checking_assert (index < asm_stmt->nl
 			      && TREE_CODE (label_op) == TREE_LIST);
   gimple_set_op (gs, index + asm_stmt->ni + asm_stmt->nc, label_op);
@@ -3340,8 +3340,8 @@ gimple_asm_set_label_op (gimple gs, unsigned index, tree label_op)
 static inline const char *
 gimple_asm_string (const_gimple gs)
 {
-  const gimple_statement_asm *asm_stmt =
-    as_a <const gimple_statement_asm *> (gs);
+  const gimple_asm *asm_stmt =
+    as_a <const gimple_asm *> (gs);
   return asm_stmt->string;
 }
 
@@ -3397,8 +3397,8 @@ gimple_asm_input_p (const_gimple gs)
 static inline tree
 gimple_catch_types (const_gimple gs)
 {
-  const gimple_statement_catch *catch_stmt =
-    as_a <const gimple_statement_catch *> (gs);
+  const gimple_catch *catch_stmt =
+    as_a <const gimple_catch *> (gs);
   return catch_stmt->types;
 }
 
@@ -3408,7 +3408,7 @@ gimple_catch_types (const_gimple gs)
 static inline tree *
 gimple_catch_types_ptr (gimple gs)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch *> (gs);
+  gimple_catch *catch_stmt = as_a <gimple_catch *> (gs);
   return &catch_stmt->types;
 }
 
@@ -3419,7 +3419,7 @@ gimple_catch_types_ptr (gimple gs)
 static inline gimple_seq *
 gimple_catch_handler_ptr (gimple gs)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch *> (gs);
+  gimple_catch *catch_stmt = as_a <gimple_catch *> (gs);
   return &catch_stmt->handler;
 }
 
@@ -3439,7 +3439,7 @@ gimple_catch_handler (gimple gs)
 static inline void
 gimple_catch_set_types (gimple gs, tree t)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch *> (gs);
+  gimple_catch *catch_stmt = as_a <gimple_catch *> (gs);
   catch_stmt->types = t;
 }
 
@@ -3449,7 +3449,7 @@ gimple_catch_set_types (gimple gs, tree t)
 static inline void
 gimple_catch_set_handler (gimple gs, gimple_seq handler)
 {
-  gimple_statement_catch *catch_stmt = as_a <gimple_statement_catch *> (gs);
+  gimple_catch *catch_stmt = as_a <gimple_catch *> (gs);
   catch_stmt->handler = handler;
 }
 
@@ -3459,8 +3459,8 @@ gimple_catch_set_handler (gimple gs, gimple_seq handler)
 static inline tree
 gimple_eh_filter_types (const_gimple gs)
 {
-  const gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <const gimple_statement_eh_filter *> (gs);
+  const gimple_eh_filter *eh_filter_stmt =
+    as_a <const gimple_eh_filter *> (gs);
   return eh_filter_stmt->types;
 }
 
@@ -3471,8 +3471,8 @@ gimple_eh_filter_types (const_gimple gs)
 static inline tree *
 gimple_eh_filter_types_ptr (gimple gs)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter *> (gs);
+  gimple_eh_filter *eh_filter_stmt =
+    as_a <gimple_eh_filter *> (gs);
   return &eh_filter_stmt->types;
 }
 
@@ -3483,8 +3483,8 @@ gimple_eh_filter_types_ptr (gimple gs)
 static inline gimple_seq *
 gimple_eh_filter_failure_ptr (gimple gs)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter *> (gs);
+  gimple_eh_filter *eh_filter_stmt =
+    as_a <gimple_eh_filter *> (gs);
   return &eh_filter_stmt->failure;
 }
 
@@ -3504,8 +3504,8 @@ gimple_eh_filter_failure (gimple gs)
 static inline void
 gimple_eh_filter_set_types (gimple gs, tree types)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter *> (gs);
+  gimple_eh_filter *eh_filter_stmt =
+    as_a <gimple_eh_filter *> (gs);
   eh_filter_stmt->types = types;
 }
 
@@ -3516,8 +3516,8 @@ gimple_eh_filter_set_types (gimple gs, tree types)
 static inline void
 gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
 {
-  gimple_statement_eh_filter *eh_filter_stmt =
-    as_a <gimple_statement_eh_filter *> (gs);
+  gimple_eh_filter *eh_filter_stmt =
+    as_a <gimple_eh_filter *> (gs);
   eh_filter_stmt->failure = failure;
 }
 
@@ -3526,7 +3526,7 @@ gimple_eh_filter_set_failure (gimple gs, gimple_seq failure)
 static inline tree
 gimple_eh_must_not_throw_fndecl (gimple gs)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_mnt *> (gs);
+  gimple_eh_mnt *eh_mnt_stmt = as_a <gimple_eh_mnt *> (gs);
   return eh_mnt_stmt->fndecl;
 }
 
@@ -3535,7 +3535,7 @@ gimple_eh_must_not_throw_fndecl (gimple gs)
 static inline void
 gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
 {
-  gimple_statement_eh_mnt *eh_mnt_stmt = as_a <gimple_statement_eh_mnt *> (gs);
+  gimple_eh_mnt *eh_mnt_stmt = as_a <gimple_eh_mnt *> (gs);
   eh_mnt_stmt->fndecl = decl;
 }
 
@@ -3544,8 +3544,8 @@ gimple_eh_must_not_throw_set_fndecl (gimple gs, tree decl)
 static inline gimple_seq *
 gimple_eh_else_n_body_ptr (gimple gs)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else *> (gs);
+  gimple_eh_else *eh_else_stmt =
+    as_a <gimple_eh_else *> (gs);
   return &eh_else_stmt->n_body;
 }
 
@@ -3558,8 +3558,8 @@ gimple_eh_else_n_body (gimple gs)
 static inline gimple_seq *
 gimple_eh_else_e_body_ptr (gimple gs)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else *> (gs);
+  gimple_eh_else *eh_else_stmt =
+    as_a <gimple_eh_else *> (gs);
   return &eh_else_stmt->e_body;
 }
 
@@ -3572,16 +3572,16 @@ gimple_eh_else_e_body (gimple gs)
 static inline void
 gimple_eh_else_set_n_body (gimple gs, gimple_seq seq)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else *> (gs);
+  gimple_eh_else *eh_else_stmt =
+    as_a <gimple_eh_else *> (gs);
   eh_else_stmt->n_body = seq;
 }
 
 static inline void
 gimple_eh_else_set_e_body (gimple gs, gimple_seq seq)
 {
-  gimple_statement_eh_else *eh_else_stmt =
-    as_a <gimple_statement_eh_else *> (gs);
+  gimple_eh_else *eh_else_stmt =
+    as_a <gimple_eh_else *> (gs);
   eh_else_stmt->e_body = seq;
 }
 
@@ -3627,7 +3627,7 @@ gimple_try_catch_is_cleanup (const_gimple gs)
 static inline gimple_seq *
 gimple_try_eval_ptr (gimple gs)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
+  gimple_try *try_stmt = as_a <gimple_try *> (gs);
   return &try_stmt->eval;
 }
 
@@ -3647,7 +3647,7 @@ gimple_try_eval (gimple gs)
 static inline gimple_seq *
 gimple_try_cleanup_ptr (gimple gs)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
+  gimple_try *try_stmt = as_a <gimple_try *> (gs);
   return &try_stmt->cleanup;
 }
 
@@ -3681,7 +3681,7 @@ gimple_try_set_catch_is_cleanup (gimple g, bool catch_is_cleanup)
 static inline void
 gimple_try_set_eval (gimple gs, gimple_seq eval)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
+  gimple_try *try_stmt = as_a <gimple_try *> (gs);
   try_stmt->eval = eval;
 }
 
@@ -3692,7 +3692,7 @@ gimple_try_set_eval (gimple gs, gimple_seq eval)
 static inline void
 gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
 {
-  gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
+  gimple_try *try_stmt = as_a <gimple_try *> (gs);
   try_stmt->cleanup = cleanup;
 }
 
@@ -3702,7 +3702,7 @@ gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
 static inline gimple_seq *
 gimple_wce_cleanup_ptr (gimple gs)
 {
-  gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
+  gimple_wce *wce_stmt = as_a <gimple_wce *> (gs);
   return &wce_stmt->cleanup;
 }
 
@@ -3721,7 +3721,7 @@ gimple_wce_cleanup (gimple gs)
 static inline void
 gimple_wce_set_cleanup (gimple gs, gimple_seq cleanup)
 {
-  gimple_statement_wce *wce_stmt = as_a <gimple_statement_wce *> (gs);
+  gimple_wce *wce_stmt = as_a <gimple_wce *> (gs);
   wce_stmt->cleanup = cleanup;
 }
 
@@ -3751,8 +3751,8 @@ gimple_wce_set_cleanup_eh_only (gimple gs, bool eh_only_p)
 static inline unsigned
 gimple_phi_capacity (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
-    as_a <const gimple_statement_phi *> (gs);
+  const gimple_phi *phi_stmt =
+    as_a <const gimple_phi *> (gs);
   return phi_stmt->capacity;
 }
 
@@ -3764,8 +3764,8 @@ gimple_phi_capacity (const_gimple gs)
 static inline unsigned
 gimple_phi_num_args (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
-    as_a <const gimple_statement_phi *> (gs);
+  const gimple_phi *phi_stmt =
+    as_a <const gimple_phi *> (gs);
   return phi_stmt->nargs;
 }
 
@@ -3775,8 +3775,8 @@ gimple_phi_num_args (const_gimple gs)
 static inline tree
 gimple_phi_result (const_gimple gs)
 {
-  const gimple_statement_phi *phi_stmt =
-    as_a <const gimple_statement_phi *> (gs);
+  const gimple_phi *phi_stmt =
+    as_a <const gimple_phi *> (gs);
   return phi_stmt->result;
 }
 
@@ -3785,7 +3785,7 @@ gimple_phi_result (const_gimple gs)
 static inline tree *
 gimple_phi_result_ptr (gimple gs)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi *> (gs);
+  gimple_phi *phi_stmt = as_a <gimple_phi *> (gs);
   return &phi_stmt->result;
 }
 
@@ -3794,7 +3794,7 @@ gimple_phi_result_ptr (gimple gs)
 static inline void
 gimple_phi_set_result (gimple gs, tree result)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi *> (gs);
+  gimple_phi *phi_stmt = as_a <gimple_phi *> (gs);
   phi_stmt->result = result;
   if (result && TREE_CODE (result) == SSA_NAME)
     SSA_NAME_DEF_STMT (result) = gs;
@@ -3807,7 +3807,7 @@ gimple_phi_set_result (gimple gs, tree result)
 static inline struct phi_arg_d *
 gimple_phi_arg (gimple gs, unsigned index)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi *> (gs);
+  gimple_phi *phi_stmt = as_a <gimple_phi *> (gs);
   gcc_gimple_checking_assert (index <= phi_stmt->capacity);
   return &(phi_stmt->args[index]);
 }
@@ -3818,7 +3818,7 @@ gimple_phi_arg (gimple gs, unsigned index)
 static inline void
 gimple_phi_set_arg (gimple gs, unsigned index, struct phi_arg_d * phiarg)
 {
-  gimple_statement_phi *phi_stmt = as_a <gimple_statement_phi *> (gs);
+  gimple_phi *phi_stmt = as_a <gimple_phi *> (gs);
   gcc_gimple_checking_assert (index <= phi_stmt->nargs);
   phi_stmt->args[index] = *phiarg;
 }
@@ -3905,8 +3905,8 @@ gimple_phi_arg_has_location (gimple gs, size_t i)
 static inline int
 gimple_resx_region (const_gimple gs)
 {
-  const gimple_statement_resx *resx_stmt =
-    as_a <const gimple_statement_resx *> (gs);
+  const gimple_resx *resx_stmt =
+    as_a <const gimple_resx *> (gs);
   return resx_stmt->region;
 }
 
@@ -3915,7 +3915,7 @@ gimple_resx_region (const_gimple gs)
 static inline void
 gimple_resx_set_region (gimple gs, int region)
 {
-  gimple_statement_resx *resx_stmt = as_a <gimple_statement_resx *> (gs);
+  gimple_resx *resx_stmt = as_a <gimple_resx *> (gs);
   resx_stmt->region = region;
 }
 
@@ -3924,8 +3924,8 @@ gimple_resx_set_region (gimple gs, int region)
 static inline int
 gimple_eh_dispatch_region (const_gimple gs)
 {
-  const gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <const gimple_statement_eh_dispatch *> (gs);
+  const gimple_eh_dispatch *eh_dispatch_stmt =
+    as_a <const gimple_eh_dispatch *> (gs);
   return eh_dispatch_stmt->region;
 }
 
@@ -3934,8 +3934,8 @@ gimple_eh_dispatch_region (const_gimple gs)
 static inline void
 gimple_eh_dispatch_set_region (gimple gs, int region)
 {
-  gimple_statement_eh_dispatch *eh_dispatch_stmt =
-    as_a <gimple_statement_eh_dispatch *> (gs);
+  gimple_eh_dispatch *eh_dispatch_stmt =
+    as_a <gimple_eh_dispatch *> (gs);
   eh_dispatch_stmt->region = region;
 }
 
@@ -4221,7 +4221,7 @@ get_lineno (const_gimple stmt)
 static inline gimple_seq *
 gimple_omp_body_ptr (gimple gs)
 {
-  return &static_cast <gimple_statement_omp *> (gs)->body;
+  return &static_cast <gimple_omp *> (gs)->body;
 }
 
 /* Return the body for the OMP statement GS.  */
@@ -4237,7 +4237,7 @@ gimple_omp_body (gimple gs)
 static inline void
 gimple_omp_set_body (gimple gs, gimple_seq body)
 {
-  static_cast <gimple_statement_omp *> (gs)->body = body;
+  static_cast <gimple_omp *> (gs)->body = body;
 }
 
 
@@ -4246,8 +4246,8 @@ gimple_omp_set_body (gimple gs, gimple_seq body)
 static inline tree
 gimple_omp_critical_name (const_gimple gs)
 {
-  const gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <const gimple_statement_omp_critical *> (gs);
+  const gimple_omp_critical *omp_critical_stmt =
+    as_a <const gimple_omp_critical *> (gs);
   return omp_critical_stmt->name;
 }
 
@@ -4257,8 +4257,8 @@ gimple_omp_critical_name (const_gimple gs)
 static inline tree *
 gimple_omp_critical_name_ptr (gimple gs)
 {
-  gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <gimple_statement_omp_critical *> (gs);
+  gimple_omp_critical *omp_critical_stmt =
+    as_a <gimple_omp_critical *> (gs);
   return &omp_critical_stmt->name;
 }
 
@@ -4268,8 +4268,8 @@ gimple_omp_critical_name_ptr (gimple gs)
 static inline void
 gimple_omp_critical_set_name (gimple gs, tree name)
 {
-  gimple_statement_omp_critical *omp_critical_stmt =
-    as_a <gimple_statement_omp_critical *> (gs);
+  gimple_omp_critical *omp_critical_stmt =
+    as_a <gimple_omp_critical *> (gs);
   omp_critical_stmt->name = name;
 }
 
@@ -4350,8 +4350,8 @@ gimple_omp_for_set_combined_into_p (gimple g, bool combined_p)
 static inline tree
 gimple_omp_for_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   return omp_for_stmt->clauses;
 }
 
@@ -4361,8 +4361,8 @@ gimple_omp_for_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_for_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   return &omp_for_stmt->clauses;
 }
 
@@ -4372,8 +4372,8 @@ gimple_omp_for_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_for_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   omp_for_stmt->clauses = clauses;
 }
 
@@ -4383,8 +4383,8 @@ gimple_omp_for_set_clauses (gimple gs, tree clauses)
 static inline size_t
 gimple_omp_for_collapse (gimple gs)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   return omp_for_stmt->collapse;
 }
 
@@ -4394,8 +4394,8 @@ gimple_omp_for_collapse (gimple gs)
 static inline tree
 gimple_omp_for_index (const_gimple gs, size_t i)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].index;
 }
@@ -4406,8 +4406,8 @@ gimple_omp_for_index (const_gimple gs, size_t i)
 static inline tree *
 gimple_omp_for_index_ptr (gimple gs, size_t i)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].index;
 }
@@ -4418,8 +4418,8 @@ gimple_omp_for_index_ptr (gimple gs, size_t i)
 static inline void
 gimple_omp_for_set_index (gimple gs, size_t i, tree index)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].index = index;
 }
@@ -4430,8 +4430,8 @@ gimple_omp_for_set_index (gimple gs, size_t i, tree index)
 static inline tree
 gimple_omp_for_initial (const_gimple gs, size_t i)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].initial;
 }
@@ -4442,8 +4442,8 @@ gimple_omp_for_initial (const_gimple gs, size_t i)
 static inline tree *
 gimple_omp_for_initial_ptr (gimple gs, size_t i)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].initial;
 }
@@ -4454,8 +4454,8 @@ gimple_omp_for_initial_ptr (gimple gs, size_t i)
 static inline void
 gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].initial = initial;
 }
@@ -4466,8 +4466,8 @@ gimple_omp_for_set_initial (gimple gs, size_t i, tree initial)
 static inline tree
 gimple_omp_for_final (const_gimple gs, size_t i)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].final;
 }
@@ -4478,8 +4478,8 @@ gimple_omp_for_final (const_gimple gs, size_t i)
 static inline tree *
 gimple_omp_for_final_ptr (gimple gs, size_t i)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].final;
 }
@@ -4490,8 +4490,8 @@ gimple_omp_for_final_ptr (gimple gs, size_t i)
 static inline void
 gimple_omp_for_set_final (gimple gs, size_t i, tree final)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].final = final;
 }
@@ -4502,8 +4502,8 @@ gimple_omp_for_set_final (gimple gs, size_t i, tree final)
 static inline tree
 gimple_omp_for_incr (const_gimple gs, size_t i)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].incr;
 }
@@ -4514,8 +4514,8 @@ gimple_omp_for_incr (const_gimple gs, size_t i)
 static inline tree *
 gimple_omp_for_incr_ptr (gimple gs, size_t i)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return &omp_for_stmt->iter[i].incr;
 }
@@ -4526,8 +4526,8 @@ gimple_omp_for_incr_ptr (gimple gs, size_t i)
 static inline void
 gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].incr = incr;
 }
@@ -4539,8 +4539,8 @@ gimple_omp_for_set_incr (gimple gs, size_t i, tree incr)
 static inline gimple_seq *
 gimple_omp_for_pre_body_ptr (gimple gs)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   return &omp_for_stmt->pre_body;
 }
 
@@ -4561,8 +4561,8 @@ gimple_omp_for_pre_body (gimple gs)
 static inline void
 gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   omp_for_stmt->pre_body = pre_body;
 }
 
@@ -4572,8 +4572,8 @@ gimple_omp_for_set_pre_body (gimple gs, gimple_seq pre_body)
 static inline tree
 gimple_omp_parallel_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <const gimple_statement_omp_parallel *> (gs);
+  const gimple_omp_parallel *omp_parallel_stmt =
+    as_a <const gimple_omp_parallel *> (gs);
   return omp_parallel_stmt->clauses;
 }
 
@@ -4583,8 +4583,8 @@ gimple_omp_parallel_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_parallel_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   return &omp_parallel_stmt->clauses;
 }
 
@@ -4595,8 +4595,8 @@ gimple_omp_parallel_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   omp_parallel_stmt->clauses = clauses;
 }
 
@@ -4606,8 +4606,8 @@ gimple_omp_parallel_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_parallel_child_fn (const_gimple gs)
 {
-  const gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <const gimple_statement_omp_parallel *> (gs);
+  const gimple_omp_parallel *omp_parallel_stmt =
+    as_a <const gimple_omp_parallel *> (gs);
   return omp_parallel_stmt->child_fn;
 }
 
@@ -4617,8 +4617,8 @@ gimple_omp_parallel_child_fn (const_gimple gs)
 static inline tree *
 gimple_omp_parallel_child_fn_ptr (gimple gs)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   return &omp_parallel_stmt->child_fn;
 }
 
@@ -4628,8 +4628,8 @@ gimple_omp_parallel_child_fn_ptr (gimple gs)
 static inline void
 gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   omp_parallel_stmt->child_fn = child_fn;
 }
 
@@ -4640,8 +4640,8 @@ gimple_omp_parallel_set_child_fn (gimple gs, tree child_fn)
 static inline tree
 gimple_omp_parallel_data_arg (const_gimple gs)
 {
-  const gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <const gimple_statement_omp_parallel *> (gs);
+  const gimple_omp_parallel *omp_parallel_stmt =
+    as_a <const gimple_omp_parallel *> (gs);
   return omp_parallel_stmt->data_arg;
 }
 
@@ -4651,8 +4651,8 @@ gimple_omp_parallel_data_arg (const_gimple gs)
 static inline tree *
 gimple_omp_parallel_data_arg_ptr (gimple gs)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   return &omp_parallel_stmt->data_arg;
 }
 
@@ -4662,8 +4662,8 @@ gimple_omp_parallel_data_arg_ptr (gimple gs)
 static inline void
 gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
 {
-  gimple_statement_omp_parallel *omp_parallel_stmt =
-    as_a <gimple_statement_omp_parallel *> (gs);
+  gimple_omp_parallel *omp_parallel_stmt =
+    as_a <gimple_omp_parallel *> (gs);
   omp_parallel_stmt->data_arg = data_arg;
 }
 
@@ -4673,8 +4673,8 @@ gimple_omp_parallel_set_data_arg (gimple gs, tree data_arg)
 static inline tree
 gimple_omp_task_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->clauses;
 }
 
@@ -4684,8 +4684,8 @@ gimple_omp_task_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_task_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->clauses;
 }
 
@@ -4696,8 +4696,8 @@ gimple_omp_task_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->clauses = clauses;
 }
 
@@ -4707,8 +4707,8 @@ gimple_omp_task_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_task_child_fn (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->child_fn;
 }
 
@@ -4718,8 +4718,8 @@ gimple_omp_task_child_fn (const_gimple gs)
 static inline tree *
 gimple_omp_task_child_fn_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->child_fn;
 }
 
@@ -4729,8 +4729,8 @@ gimple_omp_task_child_fn_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->child_fn = child_fn;
 }
 
@@ -4741,8 +4741,8 @@ gimple_omp_task_set_child_fn (gimple gs, tree child_fn)
 static inline tree
 gimple_omp_task_data_arg (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->data_arg;
 }
 
@@ -4752,8 +4752,8 @@ gimple_omp_task_data_arg (const_gimple gs)
 static inline tree *
 gimple_omp_task_data_arg_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->data_arg;
 }
 
@@ -4763,8 +4763,8 @@ gimple_omp_task_data_arg_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->data_arg = data_arg;
 }
 
@@ -4774,8 +4774,8 @@ gimple_omp_task_set_data_arg (gimple gs, tree data_arg)
 static inline tree
 gimple_omp_taskreg_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <const gimple_statement_omp_taskreg *> (gs);
+  const gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <const gimple_omp_taskreg *> (gs);
   return omp_taskreg_stmt->clauses;
 }
 
@@ -4785,8 +4785,8 @@ gimple_omp_taskreg_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_taskreg_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   return &omp_taskreg_stmt->clauses;
 }
 
@@ -4797,8 +4797,8 @@ gimple_omp_taskreg_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   omp_taskreg_stmt->clauses = clauses;
 }
 
@@ -4808,8 +4808,8 @@ gimple_omp_taskreg_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_taskreg_child_fn (const_gimple gs)
 {
-  const gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <const gimple_statement_omp_taskreg *> (gs);
+  const gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <const gimple_omp_taskreg *> (gs);
   return omp_taskreg_stmt->child_fn;
 }
 
@@ -4819,8 +4819,8 @@ gimple_omp_taskreg_child_fn (const_gimple gs)
 static inline tree *
 gimple_omp_taskreg_child_fn_ptr (gimple gs)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   return &omp_taskreg_stmt->child_fn;
 }
 
@@ -4830,8 +4830,8 @@ gimple_omp_taskreg_child_fn_ptr (gimple gs)
 static inline void
 gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   omp_taskreg_stmt->child_fn = child_fn;
 }
 
@@ -4842,8 +4842,8 @@ gimple_omp_taskreg_set_child_fn (gimple gs, tree child_fn)
 static inline tree
 gimple_omp_taskreg_data_arg (const_gimple gs)
 {
-  const gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <const gimple_statement_omp_taskreg *> (gs);
+  const gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <const gimple_omp_taskreg *> (gs);
   return omp_taskreg_stmt->data_arg;
 }
 
@@ -4853,8 +4853,8 @@ gimple_omp_taskreg_data_arg (const_gimple gs)
 static inline tree *
 gimple_omp_taskreg_data_arg_ptr (gimple gs)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   return &omp_taskreg_stmt->data_arg;
 }
 
@@ -4864,8 +4864,8 @@ gimple_omp_taskreg_data_arg_ptr (gimple gs)
 static inline void
 gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
 {
-  gimple_statement_omp_taskreg *omp_taskreg_stmt =
-    as_a <gimple_statement_omp_taskreg *> (gs);
+  gimple_omp_taskreg *omp_taskreg_stmt =
+    as_a <gimple_omp_taskreg *> (gs);
   omp_taskreg_stmt->data_arg = data_arg;
 }
 
@@ -4875,8 +4875,8 @@ gimple_omp_taskreg_set_data_arg (gimple gs, tree data_arg)
 static inline tree
 gimple_omp_task_copy_fn (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->copy_fn;
 }
 
@@ -4886,8 +4886,8 @@ gimple_omp_task_copy_fn (const_gimple gs)
 static inline tree *
 gimple_omp_task_copy_fn_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->copy_fn;
 }
 
@@ -4897,8 +4897,8 @@ gimple_omp_task_copy_fn_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->copy_fn = copy_fn;
 }
 
@@ -4908,8 +4908,8 @@ gimple_omp_task_set_copy_fn (gimple gs, tree copy_fn)
 static inline tree
 gimple_omp_task_arg_size (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->arg_size;
 }
 
@@ -4919,8 +4919,8 @@ gimple_omp_task_arg_size (const_gimple gs)
 static inline tree *
 gimple_omp_task_arg_size_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->arg_size;
 }
 
@@ -4930,8 +4930,8 @@ gimple_omp_task_arg_size_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->arg_size = arg_size;
 }
 
@@ -4941,8 +4941,8 @@ gimple_omp_task_set_arg_size (gimple gs, tree arg_size)
 static inline tree
 gimple_omp_task_arg_align (const_gimple gs)
 {
-  const gimple_statement_omp_task *omp_task_stmt =
-    as_a <const gimple_statement_omp_task *> (gs);
+  const gimple_omp_task *omp_task_stmt =
+    as_a <const gimple_omp_task *> (gs);
   return omp_task_stmt->arg_align;
 }
 
@@ -4952,8 +4952,8 @@ gimple_omp_task_arg_align (const_gimple gs)
 static inline tree *
 gimple_omp_task_arg_align_ptr (gimple gs)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   return &omp_task_stmt->arg_align;
 }
 
@@ -4963,8 +4963,8 @@ gimple_omp_task_arg_align_ptr (gimple gs)
 static inline void
 gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
 {
-  gimple_statement_omp_task *omp_task_stmt =
-    as_a <gimple_statement_omp_task *> (gs);
+  gimple_omp_task *omp_task_stmt =
+    as_a <gimple_omp_task *> (gs);
   omp_task_stmt->arg_align = arg_align;
 }
 
@@ -4974,8 +4974,8 @@ gimple_omp_task_set_arg_align (gimple gs, tree arg_align)
 static inline tree
 gimple_omp_single_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_single *omp_single_stmt =
-    as_a <const gimple_statement_omp_single *> (gs);
+  const gimple_omp_single *omp_single_stmt =
+    as_a <const gimple_omp_single *> (gs);
   return omp_single_stmt->clauses;
 }
 
@@ -4985,8 +4985,8 @@ gimple_omp_single_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_single_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_single *omp_single_stmt =
-    as_a <gimple_statement_omp_single *> (gs);
+  gimple_omp_single *omp_single_stmt =
+    as_a <gimple_omp_single *> (gs);
   return &omp_single_stmt->clauses;
 }
 
@@ -4996,8 +4996,8 @@ gimple_omp_single_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_single_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_single *omp_single_stmt =
-    as_a <gimple_statement_omp_single *> (gs);
+  gimple_omp_single *omp_single_stmt =
+    as_a <gimple_omp_single *> (gs);
   omp_single_stmt->clauses = clauses;
 }
 
@@ -5007,8 +5007,8 @@ gimple_omp_single_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_target_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target *> (gs);
+  const gimple_omp_target *omp_target_stmt =
+    as_a <const gimple_omp_target *> (gs);
   return omp_target_stmt->clauses;
 }
 
@@ -5018,8 +5018,8 @@ gimple_omp_target_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_target_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   return &omp_target_stmt->clauses;
 }
 
@@ -5029,8 +5029,8 @@ gimple_omp_target_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_target_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   omp_target_stmt->clauses = clauses;
 }
 
@@ -5061,8 +5061,8 @@ gimple_omp_target_set_kind (gimple g, int kind)
 static inline tree
 gimple_omp_target_child_fn (const_gimple gs)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target *> (gs);
+  const gimple_omp_target *omp_target_stmt =
+    as_a <const gimple_omp_target *> (gs);
   return omp_target_stmt->child_fn;
 }
 
@@ -5072,8 +5072,8 @@ gimple_omp_target_child_fn (const_gimple gs)
 static inline tree *
 gimple_omp_target_child_fn_ptr (gimple gs)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   return &omp_target_stmt->child_fn;
 }
 
@@ -5083,8 +5083,8 @@ gimple_omp_target_child_fn_ptr (gimple gs)
 static inline void
 gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   omp_target_stmt->child_fn = child_fn;
 }
 
@@ -5095,8 +5095,8 @@ gimple_omp_target_set_child_fn (gimple gs, tree child_fn)
 static inline tree
 gimple_omp_target_data_arg (const_gimple gs)
 {
-  const gimple_statement_omp_target *omp_target_stmt =
-    as_a <const gimple_statement_omp_target *> (gs);
+  const gimple_omp_target *omp_target_stmt =
+    as_a <const gimple_omp_target *> (gs);
   return omp_target_stmt->data_arg;
 }
 
@@ -5106,8 +5106,8 @@ gimple_omp_target_data_arg (const_gimple gs)
 static inline tree *
 gimple_omp_target_data_arg_ptr (gimple gs)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   return &omp_target_stmt->data_arg;
 }
 
@@ -5117,8 +5117,8 @@ gimple_omp_target_data_arg_ptr (gimple gs)
 static inline void
 gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
 {
-  gimple_statement_omp_target *omp_target_stmt =
-    as_a <gimple_statement_omp_target *> (gs);
+  gimple_omp_target *omp_target_stmt =
+    as_a <gimple_omp_target *> (gs);
   omp_target_stmt->data_arg = data_arg;
 }
 
@@ -5128,8 +5128,8 @@ gimple_omp_target_set_data_arg (gimple gs, tree data_arg)
 static inline tree
 gimple_omp_teams_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_teams *omp_teams_stmt =
-    as_a <const gimple_statement_omp_teams *> (gs);
+  const gimple_omp_teams *omp_teams_stmt =
+    as_a <const gimple_omp_teams *> (gs);
   return omp_teams_stmt->clauses;
 }
 
@@ -5139,8 +5139,8 @@ gimple_omp_teams_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_teams_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_teams *omp_teams_stmt =
-    as_a <gimple_statement_omp_teams *> (gs);
+  gimple_omp_teams *omp_teams_stmt =
+    as_a <gimple_omp_teams *> (gs);
   return &omp_teams_stmt->clauses;
 }
 
@@ -5150,8 +5150,8 @@ gimple_omp_teams_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_teams_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_teams *omp_teams_stmt =
-    as_a <gimple_statement_omp_teams *> (gs);
+  gimple_omp_teams *omp_teams_stmt =
+    as_a <gimple_omp_teams *> (gs);
   omp_teams_stmt->clauses = clauses;
 }
 
@@ -5161,8 +5161,8 @@ gimple_omp_teams_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_sections_clauses (const_gimple gs)
 {
-  const gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <const gimple_statement_omp_sections *> (gs);
+  const gimple_omp_sections *omp_sections_stmt =
+    as_a <const gimple_omp_sections *> (gs);
   return omp_sections_stmt->clauses;
 }
 
@@ -5172,8 +5172,8 @@ gimple_omp_sections_clauses (const_gimple gs)
 static inline tree *
 gimple_omp_sections_clauses_ptr (gimple gs)
 {
-  gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <gimple_statement_omp_sections *> (gs);
+  gimple_omp_sections *omp_sections_stmt =
+    as_a <gimple_omp_sections *> (gs);
   return &omp_sections_stmt->clauses;
 }
 
@@ -5184,8 +5184,8 @@ gimple_omp_sections_clauses_ptr (gimple gs)
 static inline void
 gimple_omp_sections_set_clauses (gimple gs, tree clauses)
 {
-  gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <gimple_statement_omp_sections *> (gs);
+  gimple_omp_sections *omp_sections_stmt =
+    as_a <gimple_omp_sections *> (gs);
   omp_sections_stmt->clauses = clauses;
 }
 
@@ -5196,8 +5196,8 @@ gimple_omp_sections_set_clauses (gimple gs, tree clauses)
 static inline tree
 gimple_omp_sections_control (const_gimple gs)
 {
-  const gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <const gimple_statement_omp_sections *> (gs);
+  const gimple_omp_sections *omp_sections_stmt =
+    as_a <const gimple_omp_sections *> (gs);
   return omp_sections_stmt->control;
 }
 
@@ -5208,8 +5208,8 @@ gimple_omp_sections_control (const_gimple gs)
 static inline tree *
 gimple_omp_sections_control_ptr (gimple gs)
 {
-  gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <gimple_statement_omp_sections *> (gs);
+  gimple_omp_sections *omp_sections_stmt =
+    as_a <gimple_omp_sections *> (gs);
   return &omp_sections_stmt->control;
 }
 
@@ -5220,8 +5220,8 @@ gimple_omp_sections_control_ptr (gimple gs)
 static inline void
 gimple_omp_sections_set_control (gimple gs, tree control)
 {
-  gimple_statement_omp_sections *omp_sections_stmt =
-    as_a <gimple_statement_omp_sections *> (gs);
+  gimple_omp_sections *omp_sections_stmt =
+    as_a <gimple_omp_sections *> (gs);
   omp_sections_stmt->control = control;
 }
 
@@ -5231,8 +5231,8 @@ gimple_omp_sections_set_control (gimple gs, tree control)
 static inline void
 gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
 {
-  gimple_statement_omp_for *omp_for_stmt =
-    as_a <gimple_statement_omp_for *> (gs);
+  gimple_omp_for *omp_for_stmt =
+    as_a <gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (TREE_CODE_CLASS (cond) == tcc_comparison
 			      && i < omp_for_stmt->collapse);
   omp_for_stmt->iter[i].cond = cond;
@@ -5244,8 +5244,8 @@ gimple_omp_for_set_cond (gimple gs, size_t i, enum tree_code cond)
 static inline enum tree_code
 gimple_omp_for_cond (const_gimple gs, size_t i)
 {
-  const gimple_statement_omp_for *omp_for_stmt =
-    as_a <const gimple_statement_omp_for *> (gs);
+  const gimple_omp_for *omp_for_stmt =
+    as_a <const gimple_omp_for *> (gs);
   gcc_gimple_checking_assert (i < omp_for_stmt->collapse);
   return omp_for_stmt->iter[i].cond;
 }
@@ -5256,8 +5256,8 @@ gimple_omp_for_cond (const_gimple gs, size_t i)
 static inline void
 gimple_omp_atomic_store_set_val (gimple g, tree val)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store *> (g);
+  gimple_omp_atomic_store *omp_atomic_store_stmt =
+    as_a <gimple_omp_atomic_store *> (g);
   omp_atomic_store_stmt->val = val;
 }
 
@@ -5267,8 +5267,8 @@ gimple_omp_atomic_store_set_val (gimple g, tree val)
 static inline tree
 gimple_omp_atomic_store_val (const_gimple g)
 {
-  const gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <const gimple_statement_omp_atomic_store *> (g);
+  const gimple_omp_atomic_store *omp_atomic_store_stmt =
+    as_a <const gimple_omp_atomic_store *> (g);
   return omp_atomic_store_stmt->val;
 }
 
@@ -5278,8 +5278,8 @@ gimple_omp_atomic_store_val (const_gimple g)
 static inline tree *
 gimple_omp_atomic_store_val_ptr (gimple g)
 {
-  gimple_statement_omp_atomic_store *omp_atomic_store_stmt =
-    as_a <gimple_statement_omp_atomic_store *> (g);
+  gimple_omp_atomic_store *omp_atomic_store_stmt =
+    as_a <gimple_omp_atomic_store *> (g);
   return &omp_atomic_store_stmt->val;
 }
 
@@ -5289,8 +5289,8 @@ gimple_omp_atomic_store_val_ptr (gimple g)
 static inline void
 gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load *> (g);
+  gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <gimple_omp_atomic_load *> (g);
   omp_atomic_load_stmt->lhs = lhs;
 }
 
@@ -5300,8 +5300,8 @@ gimple_omp_atomic_load_set_lhs (gimple g, tree lhs)
 static inline tree
 gimple_omp_atomic_load_lhs (const_gimple g)
 {
-  const gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <const gimple_statement_omp_atomic_load *> (g);
+  const gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <const gimple_omp_atomic_load *> (g);
   return omp_atomic_load_stmt->lhs;
 }
 
@@ -5311,8 +5311,8 @@ gimple_omp_atomic_load_lhs (const_gimple g)
 static inline tree *
 gimple_omp_atomic_load_lhs_ptr (gimple g)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load *> (g);
+  gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <gimple_omp_atomic_load *> (g);
   return &omp_atomic_load_stmt->lhs;
 }
 
@@ -5322,8 +5322,8 @@ gimple_omp_atomic_load_lhs_ptr (gimple g)
 static inline void
 gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load *> (g);
+  gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <gimple_omp_atomic_load *> (g);
   omp_atomic_load_stmt->rhs = rhs;
 }
 
@@ -5333,8 +5333,8 @@ gimple_omp_atomic_load_set_rhs (gimple g, tree rhs)
 static inline tree
 gimple_omp_atomic_load_rhs (const_gimple g)
 {
-  const gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <const gimple_statement_omp_atomic_load *> (g);
+  const gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <const gimple_omp_atomic_load *> (g);
   return omp_atomic_load_stmt->rhs;
 }
 
@@ -5344,8 +5344,8 @@ gimple_omp_atomic_load_rhs (const_gimple g)
 static inline tree *
 gimple_omp_atomic_load_rhs_ptr (gimple g)
 {
-  gimple_statement_omp_atomic_load *omp_atomic_load_stmt =
-    as_a <gimple_statement_omp_atomic_load *> (g);
+  gimple_omp_atomic_load *omp_atomic_load_stmt =
+    as_a <gimple_omp_atomic_load *> (g);
   return &omp_atomic_load_stmt->rhs;
 }
 
@@ -5355,8 +5355,8 @@ gimple_omp_atomic_load_rhs_ptr (gimple g)
 static inline tree
 gimple_omp_continue_control_def (const_gimple g)
 {
-  const gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <const gimple_statement_omp_continue *> (g);
+  const gimple_omp_continue *omp_continue_stmt =
+    as_a <const gimple_omp_continue *> (g);
   return omp_continue_stmt->control_def;
 }
 
@@ -5365,8 +5365,8 @@ gimple_omp_continue_control_def (const_gimple g)
 static inline tree *
 gimple_omp_continue_control_def_ptr (gimple g)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue *> (g);
+  gimple_omp_continue *omp_continue_stmt =
+    as_a <gimple_omp_continue *> (g);
   return &omp_continue_stmt->control_def;
 }
 
@@ -5375,8 +5375,8 @@ gimple_omp_continue_control_def_ptr (gimple g)
 static inline void
 gimple_omp_continue_set_control_def (gimple g, tree def)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue *> (g);
+  gimple_omp_continue *omp_continue_stmt =
+    as_a <gimple_omp_continue *> (g);
   omp_continue_stmt->control_def = def;
 }
 
@@ -5386,8 +5386,8 @@ gimple_omp_continue_set_control_def (gimple g, tree def)
 static inline tree
 gimple_omp_continue_control_use (const_gimple g)
 {
-  const gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <const gimple_statement_omp_continue *> (g);
+  const gimple_omp_continue *omp_continue_stmt =
+    as_a <const gimple_omp_continue *> (g);
   return omp_continue_stmt->control_use;
 }
 
@@ -5397,8 +5397,8 @@ gimple_omp_continue_control_use (const_gimple g)
 static inline tree *
 gimple_omp_continue_control_use_ptr (gimple g)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue *> (g);
+  gimple_omp_continue *omp_continue_stmt =
+    as_a <gimple_omp_continue *> (g);
   return &omp_continue_stmt->control_use;
 }
 
@@ -5408,8 +5408,8 @@ gimple_omp_continue_control_use_ptr (gimple g)
 static inline void
 gimple_omp_continue_set_control_use (gimple g, tree use)
 {
-  gimple_statement_omp_continue *omp_continue_stmt =
-    as_a <gimple_statement_omp_continue *> (g);
+  gimple_omp_continue *omp_continue_stmt =
+    as_a <gimple_omp_continue *> (g);
   omp_continue_stmt->control_use = use;
 }
 
@@ -5418,8 +5418,8 @@ gimple_omp_continue_set_control_use (gimple g, tree use)
 static inline gimple_seq *
 gimple_transaction_body_ptr (gimple gs)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction *> (gs);
+  gimple_transaction *transaction_stmt =
+    as_a <gimple_transaction *> (gs);
   return &transaction_stmt->body;
 }
 
@@ -5436,16 +5436,16 @@ gimple_transaction_body (gimple gs)
 static inline tree
 gimple_transaction_label (const_gimple gs)
 {
-  const gimple_statement_transaction *transaction_stmt =
-    as_a <const gimple_statement_transaction *> (gs);
+  const gimple_transaction *transaction_stmt =
+    as_a <const gimple_transaction *> (gs);
   return transaction_stmt->label;
 }
 
 static inline tree *
 gimple_transaction_label_ptr (gimple gs)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction *> (gs);
+  gimple_transaction *transaction_stmt =
+    as_a <gimple_transaction *> (gs);
   return &transaction_stmt->label;
 }
 
@@ -5463,8 +5463,8 @@ gimple_transaction_subcode (const_gimple gs)
 static inline void
 gimple_transaction_set_body (gimple gs, gimple_seq body)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction *> (gs);
+  gimple_transaction *transaction_stmt =
+    as_a <gimple_transaction *> (gs);
   transaction_stmt->body = body;
 }
 
@@ -5473,8 +5473,8 @@ gimple_transaction_set_body (gimple gs, gimple_seq body)
 static inline void
 gimple_transaction_set_label (gimple gs, tree label)
 {
-  gimple_statement_transaction *transaction_stmt =
-    as_a <gimple_statement_transaction *> (gs);
+  gimple_transaction *transaction_stmt =
+    as_a <gimple_transaction *> (gs);
   transaction_stmt->label = label;
 }
 
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 008a252..f1e6e91 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -5173,7 +5173,7 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p)
 	    }
 	  else
 	    {
-	      gimple_statement_try *gtry;
+	      gimple_try *gtry;
 	      gimple_seq seq;
 	      enum gimple_try_flags kind;
 
diff --git a/gcc/gsstruct.def b/gcc/gsstruct.def
index c061dce..c1f3dd7 100644
--- a/gcc/gsstruct.def
+++ b/gcc/gsstruct.def
@@ -25,29 +25,29 @@ along with GCC; see the file COPYING3.  If not see
    Each enum value should correspond with a single member of the union
    gimple_statement_d.  */
 
-DEFGSSTRUCT(GSS_BASE, gimple_statement_base, false)
-DEFGSSTRUCT(GSS_WITH_OPS, gimple_statement_with_ops, true)
-DEFGSSTRUCT(GSS_WITH_MEM_OPS_BASE, gimple_statement_with_memory_ops_base, false)
-DEFGSSTRUCT(GSS_WITH_MEM_OPS, gimple_statement_with_memory_ops, true)
-DEFGSSTRUCT(GSS_CALL, gimple_statement_call, true)
-DEFGSSTRUCT(GSS_ASM, gimple_statement_asm, true)
-DEFGSSTRUCT(GSS_BIND, gimple_statement_bind, false)
-DEFGSSTRUCT(GSS_PHI, gimple_statement_phi, false)
-DEFGSSTRUCT(GSS_TRY, gimple_statement_try, false)
-DEFGSSTRUCT(GSS_CATCH, gimple_statement_catch, false)
-DEFGSSTRUCT(GSS_EH_FILTER, gimple_statement_eh_filter, false)
-DEFGSSTRUCT(GSS_EH_MNT, gimple_statement_eh_mnt, false)
-DEFGSSTRUCT(GSS_EH_CTRL, gimple_statement_eh_ctrl, false)
-DEFGSSTRUCT(GSS_EH_ELSE, gimple_statement_eh_else, false)
-DEFGSSTRUCT(GSS_WCE, gimple_statement_wce, false)
-DEFGSSTRUCT(GSS_OMP, gimple_statement_omp, false)
-DEFGSSTRUCT(GSS_OMP_CRITICAL, gimple_statement_omp_critical, false)
-DEFGSSTRUCT(GSS_OMP_FOR, gimple_statement_omp_for, false)
-DEFGSSTRUCT(GSS_OMP_PARALLEL_LAYOUT, gimple_statement_omp_parallel_layout, false)
-DEFGSSTRUCT(GSS_OMP_TASK, gimple_statement_omp_task, false)
-DEFGSSTRUCT(GSS_OMP_SECTIONS, gimple_statement_omp_sections, false)
-DEFGSSTRUCT(GSS_OMP_SINGLE_LAYOUT, gimple_statement_omp_single_layout, false)
-DEFGSSTRUCT(GSS_OMP_CONTINUE, gimple_statement_omp_continue, false)
-DEFGSSTRUCT(GSS_OMP_ATOMIC_LOAD, gimple_statement_omp_atomic_load, false)
-DEFGSSTRUCT(GSS_OMP_ATOMIC_STORE_LAYOUT, gimple_statement_omp_atomic_store, false)
-DEFGSSTRUCT(GSS_TRANSACTION, gimple_statement_transaction, false)
+DEFGSSTRUCT(GSS_BASE, gimple_stmt, false)
+DEFGSSTRUCT(GSS_WITH_OPS, gimple_stmt_with_ops, true)
+DEFGSSTRUCT(GSS_WITH_MEM_OPS_BASE, gimple_stmt_with_memory_ops_base, false)
+DEFGSSTRUCT(GSS_WITH_MEM_OPS, gimple_stmt_with_memory_ops, true)
+DEFGSSTRUCT(GSS_CALL, gimple_call, true)
+DEFGSSTRUCT(GSS_ASM, gimple_asm, true)
+DEFGSSTRUCT(GSS_BIND, gimple_bind, false)
+DEFGSSTRUCT(GSS_PHI, gimple_phi, false)
+DEFGSSTRUCT(GSS_TRY, gimple_try, false)
+DEFGSSTRUCT(GSS_CATCH, gimple_catch, false)
+DEFGSSTRUCT(GSS_EH_FILTER, gimple_eh_filter, false)
+DEFGSSTRUCT(GSS_EH_MNT, gimple_eh_mnt, false)
+DEFGSSTRUCT(GSS_EH_CTRL, gimple_eh_ctrl, false)
+DEFGSSTRUCT(GSS_EH_ELSE, gimple_eh_else, false)
+DEFGSSTRUCT(GSS_WCE, gimple_wce, false)
+DEFGSSTRUCT(GSS_OMP, gimple_omp, false)
+DEFGSSTRUCT(GSS_OMP_CRITICAL, gimple_omp_critical, false)
+DEFGSSTRUCT(GSS_OMP_FOR, gimple_omp_for, false)
+DEFGSSTRUCT(GSS_OMP_PARALLEL_LAYOUT, gimple_omp_parallel_layout, false)
+DEFGSSTRUCT(GSS_OMP_TASK, gimple_omp_task, false)
+DEFGSSTRUCT(GSS_OMP_SECTIONS, gimple_omp_sections, false)
+DEFGSSTRUCT(GSS_OMP_SINGLE_LAYOUT, gimple_omp_single_layout, false)
+DEFGSSTRUCT(GSS_OMP_CONTINUE, gimple_omp_continue, false)
+DEFGSSTRUCT(GSS_OMP_ATOMIC_LOAD, gimple_omp_atomic_load, false)
+DEFGSSTRUCT(GSS_OMP_ATOMIC_STORE_LAYOUT, gimple_omp_atomic_store, false)
+DEFGSSTRUCT(GSS_TRANSACTION, gimple_transaction, false)
diff --git a/gcc/system.h b/gcc/system.h
index 892271f..872429e 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1013,7 +1013,7 @@ helper_const_non_const_cast (const char *p)
 #define CONST_CAST_TREE(X) CONST_CAST (union tree_node *, (X))
 #define CONST_CAST_RTX(X) CONST_CAST (struct rtx_def *, (X))
 #define CONST_CAST_BB(X) CONST_CAST (struct basic_block_def *, (X))
-#define CONST_CAST_GIMPLE(X) CONST_CAST (struct gimple_statement_base *, (X))
+#define CONST_CAST_GIMPLE(X) CONST_CAST (gimple_stmt *, (X))
 
 /* Activate certain diagnostics as warnings (not errors via the
    -Werror flag).  */
diff --git a/gcc/target.def b/gcc/target.def
index 3a64cd1..8cba30d 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -3488,7 +3488,7 @@ DEFHOOK_UNDOC
 "Perform architecture specific checking of statements gimplified\
  from @code{VA_ARG_EXPR}.  @var{stmt} is the statement.  Returns true if\
  the statement doesn't need to be checked for @code{va_list} references.",
- bool, (struct stdarg_info *ai, const_gimple stmt), NULL)
+ bool, (struct stdarg_info *ai, const gimple_stmt *stmt), NULL)
 
 /* This target hook allows the operating system to override the DECL
    that represents the external variable that contains the stack
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 59bb03a..5d5add8 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -64,7 +64,7 @@ get_real_ref_rhs (tree expr)
           if ((!vdecl || DECL_ARTIFICIAL (vdecl))
               && !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
             {
-              gimple def_stmt = SSA_NAME_DEF_STMT (expr);
+              gimple_stmt *def_stmt = SSA_NAME_DEF_STMT (expr);
               /* We are only interested in an assignment with a single
                  rhs operand because if it is not, the original assignment
                  will not possibly be a self-assignment.  */
@@ -169,7 +169,7 @@ get_non_ssa_expr (tree expr)
           if ((!vdecl || DECL_ARTIFICIAL (vdecl))
               && !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
             {
-              gimple def_stmt = SSA_NAME_DEF_STMT (expr);
+              gimple_stmt *def_stmt = SSA_NAME_DEF_STMT (expr);
               if (gimple_assign_single_p (def_stmt))
                 vdecl = gimple_assign_rhs1 (def_stmt);
             }
@@ -187,7 +187,7 @@ get_non_ssa_expr (tree expr)
    they are the same. If so, print a warning message about self-assignment.  */
 
 static void
-compare_and_warn (gimple stmt, tree lhs, tree rhs)
+compare_and_warn (gimple_stmt *stmt, tree lhs, tree rhs)
 {
   if (operand_equal_p (lhs, rhs, OEP_PURE_SAME))
     {
@@ -211,7 +211,7 @@ compare_and_warn (gimple stmt, tree lhs, tree rhs)
 /* Check and warn if STMT is a self-assign statement.  */
 
 static void
-warn_self_assign (gimple stmt)
+warn_self_assign (gimple_stmt *stmt)
 {
   tree rhs, lhs;
 
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index 4dad0c2..060d70e 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -64,7 +64,7 @@ get_real_ref_rhs (tree expr)
           if ((!vdecl || DECL_ARTIFICIAL (vdecl))
               && !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
             {
-              gimple def_stmt = SSA_NAME_DEF_STMT (expr);
+              gimple_stmt *def_stmt = SSA_NAME_DEF_STMT (expr);
               /* We are only interested in an assignment with a single
                  rhs operand because if it is not, the original assignment
                  will not possibly be a self-assignment.  */
@@ -169,7 +169,7 @@ get_non_ssa_expr (tree expr)
           if ((!vdecl || DECL_ARTIFICIAL (vdecl))
               && !gimple_nop_p (SSA_NAME_DEF_STMT (expr)))
             {
-              gimple def_stmt = SSA_NAME_DEF_STMT (expr);
+              gimple_stmt *def_stmt = SSA_NAME_DEF_STMT (expr);
               if (gimple_assign_single_p (def_stmt))
                 vdecl = gimple_assign_rhs1 (def_stmt);
             }
@@ -187,7 +187,7 @@ get_non_ssa_expr (tree expr)
    they are the same. If so, print a warning message about self-assignment.  */
 
 static void
-compare_and_warn (gimple stmt, tree lhs, tree rhs)
+compare_and_warn (gimple_stmt *stmt, tree lhs, tree rhs)
 {
   if (operand_equal_p (lhs, rhs, OEP_PURE_SAME))
     {
@@ -211,7 +211,7 @@ compare_and_warn (gimple stmt, tree lhs, tree rhs)
 /* Check and warn if STMT is a self-assign statement.  */
 
 static void
-warn_self_assign (gimple stmt)
+warn_self_assign (gimple_stmt *stmt)
 {
   tree rhs, lhs;
 
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index a1f2758..acdfc70 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -232,7 +232,7 @@ dump_dfa_stats (FILE *file)
   fprintf (file, fmt_str_1, "VDEF operands", dfa_stats.num_vdefs,
 	   SCALE (size), LABEL (size));
 
-  size = dfa_stats.num_phis * sizeof (struct gimple_statement_phi);
+  size = dfa_stats.num_phis * sizeof (struct gimple_phi);
   total += size;
   fprintf (file, fmt_str_1, "PHI nodes", dfa_stats.num_phis,
 	   SCALE (size), LABEL (size));
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 0be431e..6463dee 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -97,12 +97,12 @@ phinodes_print_statistics (void)
    happens to contain a PHI node with LEN arguments or more, return
    that one.  */
 
-static inline gimple_statement_phi *
+static inline gimple_phi *
 allocate_phi_node (size_t len)
 {
-  gimple_statement_phi *phi;
+  gimple_phi *phi;
   size_t bucket = NUM_BUCKETS - 2;
-  size_t size = sizeof (struct gimple_statement_phi)
+  size_t size = sizeof (struct gimple_phi)
 	        + (len - 1) * sizeof (struct phi_arg_d);
 
   if (free_phinode_count)
@@ -115,7 +115,7 @@ allocate_phi_node (size_t len)
       && gimple_phi_capacity ((*free_phinodes[bucket])[0]) >= len)
     {
       free_phinode_count--;
-      phi = as_a <gimple_statement_phi *> (free_phinodes[bucket]->pop ());
+      phi = as_a <gimple_phi *> (free_phinodes[bucket]->pop ());
       if (free_phinodes[bucket]->is_empty ())
 	vec_free (free_phinodes[bucket]);
       if (GATHER_STATISTICS)
@@ -123,7 +123,7 @@ allocate_phi_node (size_t len)
     }
   else
     {
-      phi = static_cast <gimple_statement_phi *> (
+      phi = static_cast <gimple_phi *> (
 	ggc_internal_alloc_stat (size MEM_STAT_INFO));
       if (GATHER_STATISTICS)
 	{
@@ -158,7 +158,7 @@ ideal_phi_node_len (int len)
     len = 2;
 
   /* Compute the number of bytes of the original request.  */
-  size = sizeof (struct gimple_statement_phi)
+  size = sizeof (struct gimple_phi)
 	 + (len - 1) * sizeof (struct phi_arg_d);
 
   /* Round it up to the next power of two.  */
@@ -176,7 +176,7 @@ ideal_phi_node_len (int len)
 static gimple
 make_phi_node (tree var, int len)
 {
-  gimple_statement_phi *phi;
+  gimple_phi *phi;
   int capacity, i;
 
   capacity = ideal_phi_node_len (len);
@@ -186,7 +186,7 @@ make_phi_node (tree var, int len)
   /* We need to clear the entire PHI node, including the argument
      portion, because we represent a "missing PHI argument" by placing
      NULL_TREE in PHI_ARG_DEF.  */
-  memset (phi, 0, (sizeof (struct gimple_statement_phi)
+  memset (phi, 0, (sizeof (struct gimple_phi)
 		   - sizeof (struct phi_arg_d)
 		   + sizeof (struct phi_arg_d) * len));
   phi->code = GIMPLE_PHI;
@@ -241,18 +241,18 @@ release_phi_node (gimple phi)
 /* Resize an existing PHI node.  The only way is up.  Return the
    possibly relocated phi.  */
 
-static gimple_statement_phi *
-resize_phi_node (gimple_statement_phi *phi, size_t len)
+static gimple_phi *
+resize_phi_node (gimple_phi *phi, size_t len)
 {
   size_t old_size, i;
-  gimple_statement_phi *new_phi;
+  gimple_phi *new_phi;
 
   gcc_assert (len > gimple_phi_capacity (phi));
 
   /* The garbage collector will not look at the PHI node beyond the
      first PHI_NUM_ARGS elements.  Therefore, all we have to copy is a
      portion of the PHI node currently in use.  */
-  old_size = sizeof (struct gimple_statement_phi)
+  old_size = sizeof (struct gimple_phi)
 	     + (gimple_phi_num_args (phi) - 1) * sizeof (struct phi_arg_d);
 
   new_phi = allocate_phi_node (len);
@@ -296,12 +296,12 @@ reserve_phi_args_for_new_edge (basic_block bb)
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple_statement_phi *stmt =
-	as_a <gimple_statement_phi *> (gsi_stmt (gsi));
+      gimple_phi *stmt =
+	as_a <gimple_phi *> (gsi_stmt (gsi));
 
       if (len > gimple_phi_capacity (stmt))
 	{
-	  gimple_statement_phi *new_phi = resize_phi_node (stmt, cap);
+	  gimple_phi *new_phi = resize_phi_node (stmt, cap);
 
 	  /* The result of the PHI is defined by this PHI node.  */
 	  SSA_NAME_DEF_STMT (gimple_phi_result (new_phi)) = new_phi;
@@ -397,7 +397,7 @@ add_phi_arg (gimple phi, tree def, edge e, source_location locus)
    is consistent with how we remove an edge from the edge vector.  */
 
 static void
-remove_phi_arg_num (gimple_statement_phi *phi, int i)
+remove_phi_arg_num (gimple_phi *phi, int i)
 {
   int num_elem = gimple_phi_num_args (phi);
 
@@ -436,7 +436,7 @@ remove_phi_args (edge e)
   gimple_stmt_iterator gsi;
 
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    remove_phi_arg_num (as_a <gimple_statement_phi *> (gsi_stmt (gsi)),
+    remove_phi_arg_num (as_a <gimple_phi *> (gsi_stmt (gsi)),
 			e->dest_idx);
 }
 
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 5e6b4d8..9ae8595 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1857,7 +1857,7 @@ evaluate_stmt (gimple stmt)
   return val;
 }
 
-typedef hash_table <pointer_hash <gimple_statement_base> > gimple_htab;
+typedef hash_table <pointer_hash <gimple_stmt> > gimple_htab;
 
 /* Given a BUILT_IN_STACK_SAVE value SAVED_VAL, insert a clobber of VAR before
    each matching BUILT_IN_STACK_RESTORE.  Mark visited phis in VISITED.  */
-- 
1.8.5.3

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
                                     ` (2 preceding siblings ...)
  2014-05-02 21:54                   ` [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *" David Malcolm
@ 2014-05-05  8:22                   ` Richard Biener
  2014-05-05 16:01                     ` Jeff Law
  2014-05-09  6:43                   ` Jeff Law
  4 siblings, 1 reply; 250+ messages in thread
From: Richard Biener @ 2014-05-05  8:22 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches, Jeff Law, Richard Sandiford, Andrew MacLeod

On Fri, May 2, 2014 at 11:56 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> This patch series demonstrates a way of reimplementing the 89-patch series:
>   "[PATCH 00/89] Compile-time gimple-checking"
>      http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01148.html
>
> whilst avoiding introducing a pair of "gimple_foo/const_gimple_foo" typedefs
> for each subclass.
>
> It eliminates the "gimple" and "const_gimple" typedefs,
> renaming "gimple_statement_base" to "gimple_stmt", giving types:
>   "gimple_stmt *" and "const gimple_stmt *"
> thoughout the middle-end.  The rest of the gimple statement classes are
> renamed, converting the various
>   gimple_statement_with_FOO
> to:
>   gimple_stmt_with_FOO
> and the remainder:
>   gimple_statement_SOME_SUBCLASS
> to just:
>   gimple_SOME_SUBCLASS
>
> The idea is then to reimplement the earlier patch series, porting many of
> these:
>   gimple_stmt *something
> to point to some more concrete subclass; I've done this for GIMPLE_SWITCH.

Thanks for doing this.

> It requires two patches that I've already posted separately:
>
>   (A): "[PATCH] gengtype: Support explicit pointers in template arguments":
>           http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00003.html
>        (which apparently will need reworking after wide-int is merged;
>         oh well).

I'll look at this after the wide-int merge (which hopefully happens soon...)

>   (B): "[PATCH 19/89] Const-correctness of gimple_call_builtin_p":
>           http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01194.html
>        (I have a separate bootstrap&regrtest in progress for just this one,
>         which appears to be pre-approved per Jeff's earlier comments).
>
> Of the 3 patches in the series itself:
>
>   Patch 1:
>     This one is handwritten: it renames the gimple statement classes in
>     their declarations, in the docs, in the selftests and renames explicit
>     uses of *subclasses*.
>
>   Patch 2:
>      This one is autogenerated: it does the mass conversion of "gimple" to
>      "gimple_stmt *" and "const_gimple" to "const gimple_stmt *" throughout
>      the code.
>
>      The conversion script is at:
>        https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/rename_gimple.py
>
>      It's not a real C++ parser, but it has some smarts for handling
>      awkward cases like:
>         gimple def0, def2;
>      which must become:
>         gimple_stmt *def0, *def2;
>                            ^ note the second '*' character.
>
>      You can see the selftests for the conversion script at:
>        https://github.com/davidmalcolm/gcc-refactoring-scripts/blob/master/test_rename_gimple.py
>
>   Patch 3:
>     This one is a port of the previously-posted:
>       "[PATCH 02/89] Introduce gimple_switch and use it in various places"
>          http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01154.html
>     to the new approach.  As per an earlier revision:
>       http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01549.html
>     it *eliminates* the
>       stmt->as_a_gimple_switch ()
>     and
>       stmt->dyn_cast_gimple_switch ()
>     casting methods from the base class in favor of direct usage of is-a.h:
>       as_a <gimple_switch *> (stmt)
>     and
>       dyn_cast <gimple_switch *> (stmt)
>
>     This version of the patch also eliminates the
>        gimple_switch / const_gimple_switch
>     typedefs from the initial patch series in favor of "gimple_switch"
>     being the name of the subclass.

I wonder if, when we intoduce a gimple namespace, we can write

 dyn_cast <switch *> (stmt)

by means of ADL?  Thus, imagine just doing

namespace gimple {

 ... gimple.h contents ...
}

using gimple::gimple;
... a few more? ...

typedef gimple::gimple gimple;

And then

  gimple *stmt;
  gimple::switch *s = dyn_cast <switch *> (stmt);

(yeah, awkward 'switch' reserved keyword as you say below ...)

Thus, for all the new explicit sub-types you introduce use the namespace
syntax.  Can ADL work in our favors here with the way dyn_cast and
friends work?  Thus, do we really need to write dyn_cast
<gimple::switch *> (stmt)?

No, I'm not asking you to do that now (but a limited form of a gimple namespace
would be nice to have - using the "old-style" 'gimple' type avoids changing too
much code I suppose).

Just sth that you don't run out of work ;)

> Hopefully porting this first patch in the series gives a sense of what
> the end-result would look like.
>
> There are a few possible variations on the names we could pick in this
> approach.
>
> I deliberately renamed "gimple" to "gimple_stmt" since IIRC Andrew MacLeod
> had suggested something like this, for the potential of making "gimple"
> be a namespace. That said, using namespaces may be controversial, and
> would need further gengtype support, which may be tricky (i.e. fully teach
> gengtype about C++ namespaces, which may be a gengtype hack too far).
> [I'd much prefer to avoid C++ namespaces in the core code, mostly because
> of gengtype].
>
> Also, AIUI, Andrew is looking at introducing concepts of gimple types and
> gimple expressions, so "gimple" may no longer imply a *statement*.
>
> Alternatively, we could make the base class be just "gimple" (which would
> be more consistent with the names of the accessor functions).

I strongly prefer to name it 'gimple', not 'gimple_stmt'.  Because it's less
to type, and because it will make all other types shorter as well.  And because
'gimple' _is_ a stmt right now, so gimple_stmt is redundant.  Same applies
to gimple_stmt_with_FOO, just make it gimple_with_FOO.

I understand the namespace issue, but we don't have a namespace right now.
Also gimple::gimple works just fine, no?

> There's also the "bargain basement" namespaces approach, where we don't
> have an implicit "gimple" namespace, but just *pretend* we do, and rename
> the base type to "stmt", with e.g. "gimple_statement_phi" becoming just
> "phi". ["gimple_switch" would need to become "switch_", say, to avoid the
> reserved word].

Ick (for the 'switch' case ... CamelCase anyone? :)).

> Successfully bootstrapped and regrtested on x86_64-unknown-linux-gnu
> (Fedora 20) (on top of the 2 dependent patches mentioned above; equal
> results compared to a control build of r209953.
>
> How does this look? (for trunk; after 4.9.1 is released).

Not looking at the exact patches right now.

Thanks,
Richard.

>
> David Malcolm (3):
>   Handwritten part of conversion of "gimple" to "gimple_stmt *"
>   Autogenerated part of conversion of "gimple" to "gimple_stmt *"
>   Introduce gimple_switch and use it in various places
>
>  gcc/asan.c                               |   36 +-
>  gcc/builtins.c                           |   10 +-
>  gcc/builtins.h                           |    2 +-
>  gcc/c-family/c-gimplify.c                |    4 +-
>  gcc/calls.c                              |    2 +-
>  gcc/calls.h                              |    2 +-
>  gcc/cfgexpand.c                          |   48 +-
>  gcc/cfgexpand.h                          |    2 +-
>  gcc/cfgloop.c                            |    2 +-
>  gcc/cfgloop.h                            |    2 +-
>  gcc/cfgloopmanip.c                       |    4 +-
>  gcc/cgraph.c                             |   32 +-
>  gcc/cgraph.h                             |   24 +-
>  gcc/cgraphbuild.c                        |   12 +-
>  gcc/cgraphclones.c                       |    8 +-
>  gcc/cgraphunit.c                         |   12 +-
>  gcc/config/aarch64/aarch64-builtins.c    |    4 +-
>  gcc/config/alpha/alpha.c                 |   14 +-
>  gcc/config/i386/i386.c                   |   14 +-
>  gcc/config/rs6000/rs6000.c               |    4 +-
>  gcc/coretypes.h                          |   10 +-
>  gcc/cp/cp-gimplify.c                     |    2 +-
>  gcc/doc/gimple.texi                      |  824 ++++++++------
>  gcc/dumpfile.c                           |    4 +-
>  gcc/dumpfile.h                           |    4 +-
>  gcc/except.h                             |    2 +-
>  gcc/expr.c                               |   28 +-
>  gcc/expr.h                               |    2 +-
>  gcc/fold-const.c                         |    2 +-
>  gcc/fold-const.h                         |    2 +-
>  gcc/gdbhooks.py                          |    4 +-
>  gcc/ggc.h                                |    6 +-
>  gcc/gimple-builder.c                     |   26 +-
>  gcc/gimple-builder.h                     |   16 +-
>  gcc/gimple-fold.c                        |   58 +-
>  gcc/gimple-fold.h                        |    8 +-
>  gcc/gimple-iterator.c                    |   36 +-
>  gcc/gimple-iterator.h                    |   22 +-
>  gcc/gimple-low.c                         |   30 +-
>  gcc/gimple-low.h                         |    2 +-
>  gcc/gimple-pretty-print.c                |  110 +-
>  gcc/gimple-pretty-print.h                |   12 +-
>  gcc/gimple-ssa-isolate-paths.c           |   14 +-
>  gcc/gimple-ssa-strength-reduction.c      |   92 +-
>  gcc/gimple-ssa.h                         |   22 +-
>  gcc/gimple-streamer-in.c                 |   12 +-
>  gcc/gimple-streamer-out.c                |    8 +-
>  gcc/gimple-walk.c                        |   18 +-
>  gcc/gimple-walk.h                        |   12 +-
>  gcc/gimple.c                             |  315 +++---
>  gcc/gimple.h                             | 1782 +++++++++++++++---------------
>  gcc/gimplify-me.c                        |    4 +-
>  gcc/gimplify-me.h                        |    2 +-
>  gcc/gimplify.c                           |  102 +-
>  gcc/gimplify.h                           |   12 +-
>  gcc/graphite-poly.c                      |    8 +-
>  gcc/graphite-scop-detection.c            |   20 +-
>  gcc/graphite-sese-to-poly.c              |  168 +--
>  gcc/gsstruct.def                         |   52 +-
>  gcc/internal-fn.c                        |   40 +-
>  gcc/internal-fn.h                        |    2 +-
>  gcc/ipa-inline-analysis.c                |   45 +-
>  gcc/ipa-inline.c                         |    4 +-
>  gcc/ipa-profile.c                        |    2 +-
>  gcc/ipa-prop.c                           |   80 +-
>  gcc/ipa-prop.h                           |    6 +-
>  gcc/ipa-pure-const.c                     |   12 +-
>  gcc/ipa-ref.c                            |   10 +-
>  gcc/ipa-ref.h                            |   12 +-
>  gcc/ipa-split.c                          |   40 +-
>  gcc/java/java-gimplify.c                 |    2 +-
>  gcc/lto-streamer-in.c                    |   16 +-
>  gcc/lto-streamer-out.c                   |    6 +-
>  gcc/omp-low.c                            |  253 ++---
>  gcc/passes.c                             |    4 +-
>  gcc/predict.c                            |   32 +-
>  gcc/profile.c                            |    8 +-
>  gcc/sese.c                               |   18 +-
>  gcc/sese.h                               |    8 +-
>  gcc/ssa-iterators.h                      |   42 +-
>  gcc/stmt.c                               |    4 +-
>  gcc/system.h                             |    2 +-
>  gcc/target.def                           |    2 +-
>  gcc/testsuite/g++.dg/plugin/selfassign.c |    8 +-
>  gcc/testsuite/gcc.dg/plugin/selfassign.c |    8 +-
>  gcc/tracer.c                             |    4 +-
>  gcc/trans-mem.c                          |  114 +-
>  gcc/trans-mem.h                          |    2 +-
>  gcc/tree-affine.c                        |    2 +-
>  gcc/tree-call-cdce.c                     |   50 +-
>  gcc/tree-cfg.c                           |  277 ++---
>  gcc/tree-cfg.h                           |   22 +-
>  gcc/tree-cfgcleanup.c                    |   28 +-
>  gcc/tree-cfgcleanup.h                    |    2 +-
>  gcc/tree-chrec.c                         |   10 +-
>  gcc/tree-chrec.h                         |    6 +-
>  gcc/tree-complex.c                       |   34 +-
>  gcc/tree-core.h                          |    4 +-
>  gcc/tree-data-ref.c                      |   14 +-
>  gcc/tree-data-ref.h                      |    8 +-
>  gcc/tree-dfa.c                           |   16 +-
>  gcc/tree-dfa.h                           |    2 +-
>  gcc/tree-eh.c                            |  199 ++--
>  gcc/tree-eh.h                            |   38 +-
>  gcc/tree-emutls.c                        |    8 +-
>  gcc/tree-if-conv.c                       |   34 +-
>  gcc/tree-inline.c                        |  105 +-
>  gcc/tree-inline.h                        |    6 +-
>  gcc/tree-into-ssa.c                      |   62 +-
>  gcc/tree-into-ssa.h                      |    4 +-
>  gcc/tree-loop-distribution.c             |   67 +-
>  gcc/tree-nested.c                        |   32 +-
>  gcc/tree-nrv.c                           |    8 +-
>  gcc/tree-object-size.c                   |   28 +-
>  gcc/tree-outof-ssa.c                     |   26 +-
>  gcc/tree-outof-ssa.h                     |    4 +-
>  gcc/tree-parloops.c                      |   52 +-
>  gcc/tree-pass.h                          |    6 +-
>  gcc/tree-phinodes.c                      |   52 +-
>  gcc/tree-phinodes.h                      |   14 +-
>  gcc/tree-predcom.c                       |   62 +-
>  gcc/tree-profile.c                       |   32 +-
>  gcc/tree-scalar-evolution.c              |   72 +-
>  gcc/tree-scalar-evolution.h              |    2 +-
>  gcc/tree-sra.c                           |   62 +-
>  gcc/tree-ssa-alias.c                     |   38 +-
>  gcc/tree-ssa-alias.h                     |   14 +-
>  gcc/tree-ssa-ccp.c                       |   48 +-
>  gcc/tree-ssa-coalesce.c                  |   10 +-
>  gcc/tree-ssa-copy.c                      |   14 +-
>  gcc/tree-ssa-copyrename.c                |    2 +-
>  gcc/tree-ssa-dce.c                       |   40 +-
>  gcc/tree-ssa-dom.c                       |   90 +-
>  gcc/tree-ssa-dom.h                       |    2 +-
>  gcc/tree-ssa-dse.c                       |   10 +-
>  gcc/tree-ssa-forwprop.c                  |  154 +--
>  gcc/tree-ssa-ifcombine.c                 |   20 +-
>  gcc/tree-ssa-live.c                      |   18 +-
>  gcc/tree-ssa-loop-ch.c                   |    6 +-
>  gcc/tree-ssa-loop-im.c                   |   70 +-
>  gcc/tree-ssa-loop-ivcanon.c              |   20 +-
>  gcc/tree-ssa-loop-ivopts.c               |   68 +-
>  gcc/tree-ssa-loop-manip.c                |   32 +-
>  gcc/tree-ssa-loop-niter.c                |   56 +-
>  gcc/tree-ssa-loop-niter.h                |    4 +-
>  gcc/tree-ssa-loop-prefetch.c             |   16 +-
>  gcc/tree-ssa-loop-unswitch.c             |    8 +-
>  gcc/tree-ssa-loop.h                      |    2 +-
>  gcc/tree-ssa-math-opts.c                 |   90 +-
>  gcc/tree-ssa-operands.c                  |   42 +-
>  gcc/tree-ssa-operands.h                  |   10 +-
>  gcc/tree-ssa-phiopt.c                    |   86 +-
>  gcc/tree-ssa-phiprop.c                   |   18 +-
>  gcc/tree-ssa-pre.c                       |   52 +-
>  gcc/tree-ssa-propagate.c                 |   46 +-
>  gcc/tree-ssa-propagate.h                 |   14 +-
>  gcc/tree-ssa-reassoc.c                   |  176 +--
>  gcc/tree-ssa-sccvn.c                     |   58 +-
>  gcc/tree-ssa-sccvn.h                     |    8 +-
>  gcc/tree-ssa-sink.c                      |   22 +-
>  gcc/tree-ssa-strlen.c                    |   42 +-
>  gcc/tree-ssa-structalias.c               |   44 +-
>  gcc/tree-ssa-tail-merge.c                |   40 +-
>  gcc/tree-ssa-ter.c                       |   12 +-
>  gcc/tree-ssa-threadedge.c                |   46 +-
>  gcc/tree-ssa-threadedge.h                |    4 +-
>  gcc/tree-ssa-threadupdate.c              |   10 +-
>  gcc/tree-ssa-uncprop.c                   |   12 +-
>  gcc/tree-ssa-uninit.c                    |   78 +-
>  gcc/tree-ssa.c                           |   40 +-
>  gcc/tree-ssa.h                           |    4 +-
>  gcc/tree-ssanames.c                      |    8 +-
>  gcc/tree-ssanames.h                      |   16 +-
>  gcc/tree-stdarg.c                        |   12 +-
>  gcc/tree-switch-conversion.c             |   50 +-
>  gcc/tree-tailcall.c                      |   30 +-
>  gcc/tree-vect-data-refs.c                |  100 +-
>  gcc/tree-vect-generic.c                  |   22 +-
>  gcc/tree-vect-loop-manip.c               |   62 +-
>  gcc/tree-vect-loop.c                     |  174 +--
>  gcc/tree-vect-patterns.c                 |  194 ++--
>  gcc/tree-vect-slp.c                      |  124 +--
>  gcc/tree-vect-stmts.c                    |  244 ++--
>  gcc/tree-vectorizer.c                    |   22 +-
>  gcc/tree-vectorizer.h                    |  116 +-
>  gcc/tree-vrp.c                           |  152 +--
>  gcc/tree.c                               |    4 +-
>  gcc/tree.h                               |    4 +-
>  gcc/tsan.c                               |   12 +-
>  gcc/ubsan.c                              |   20 +-
>  gcc/value-prof.c                         |   96 +-
>  gcc/value-prof.h                         |   26 +-
>  gcc/vtable-verify.c                      |   10 +-
>  193 files changed, 4851 insertions(+), 4670 deletions(-)
>
> --
> 1.8.5.3
>

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05  8:22                   ` [PATCH 0/3] Compile-time gimple checking, without typedefs Richard Biener
@ 2014-05-05 16:01                     ` Jeff Law
  2014-05-05 17:37                       ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-05 16:01 UTC (permalink / raw)
  To: Richard Biener, David Malcolm
  Cc: GCC Patches, Richard Sandiford, Andrew MacLeod

On 05/05/14 02:22, Richard Biener wrote:
>>
>> Also, AIUI, Andrew is looking at introducing concepts of gimple types and
>> gimple expressions, so "gimple" may no longer imply a *statement*.
>>
>> Alternatively, we could make the base class be just "gimple" (which would
>> be more consistent with the names of the accessor functions).
>
> I strongly prefer to name it 'gimple', not 'gimple_stmt'.  Because it's less
> to type, and because it will make all other types shorter as well.  And because
> 'gimple' _is_ a stmt right now, so gimple_stmt is redundant.  Same applies
> to gimple_stmt_with_FOO, just make it gimple_with_FOO.
>
> I understand the namespace issue, but we don't have a namespace right now.
> Also gimple::gimple works just fine, no?
But this approach is going to be inconsistent with Andrew's work, right? 
  ISTM we'd end up with something like...

So statements would be "gimple"
types would be "gimple_type"
expressions would be "gimple_expr"

It's a bit of bikeshedding, but I'd prefer "gimple_stmt".  If you really 
feel strongly about it, I'll go along without objection, but it seems 
wrong to me.


>
>> There's also the "bargain basement" namespaces approach, where we don't
>> have an implicit "gimple" namespace, but just *pretend* we do, and rename
>> the base type to "stmt", with e.g. "gimple_statement_phi" becoming just
>> "phi". ["gimple_switch" would need to become "switch_", say, to avoid the
>> reserved word].
>
> Ick (for the 'switch' case ... CamelCase anyone? :)).
:-)  Please, no....

Jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 16:01                     ` Jeff Law
@ 2014-05-05 17:37                       ` Richard Biener
  2014-05-05 18:39                         ` David Malcolm
  2014-05-05 19:44                         ` Jeff Law
  0 siblings, 2 replies; 250+ messages in thread
From: Richard Biener @ 2014-05-05 17:37 UTC (permalink / raw)
  To: Jeff Law; +Cc: David Malcolm, GCC Patches, Richard Sandiford, Andrew MacLeod

On Mon, May 5, 2014 at 6:01 PM, Jeff Law <law@redhat.com> wrote:
> On 05/05/14 02:22, Richard Biener wrote:
>>>
>>>
>>> Also, AIUI, Andrew is looking at introducing concepts of gimple types and
>>> gimple expressions, so "gimple" may no longer imply a *statement*.
>>>
>>> Alternatively, we could make the base class be just "gimple" (which would
>>> be more consistent with the names of the accessor functions).
>>
>>
>> I strongly prefer to name it 'gimple', not 'gimple_stmt'.  Because it's
>> less
>> to type, and because it will make all other types shorter as well.  And
>> because
>> 'gimple' _is_ a stmt right now, so gimple_stmt is redundant.  Same applies
>> to gimple_stmt_with_FOO, just make it gimple_with_FOO.
>>
>> I understand the namespace issue, but we don't have a namespace right now.
>> Also gimple::gimple works just fine, no?
>
> But this approach is going to be inconsistent with Andrew's work, right?
> ISTM we'd end up with something like...
>
> So statements would be "gimple"
> types would be "gimple_type"
> expressions would be "gimple_expr"

Well, I hope that Andrew doesn't do without a namespace (and I still
don't believe in what he tries to achieve without laying proper ground-work
throughout the compiler).  With a namespace gimple we can use
gimple::stmt.

> It's a bit of bikeshedding, but I'd prefer "gimple_stmt".  If you really
> feel strongly about it, I'll go along without objection, but it seems wrong
> to me.

Less typing.  But yes, it's bikeshedding.  Still gimple_stmt is
redundant information in almost all context.  'stmt' was opposed to
elsewhere so we settle on 'gimple' (which is already existing).
IMHO not changing things is the best bikeshedding argument.

>>
>>> There's also the "bargain basement" namespaces approach, where we don't
>>> have an implicit "gimple" namespace, but just *pretend* we do, and rename
>>> the base type to "stmt", with e.g. "gimple_statement_phi" becoming just
>>> "phi". ["gimple_switch" would need to become "switch_", say, to avoid the
>>> reserved word].
>>
>>
>> Ick (for the 'switch' case ... CamelCase anyone? :)).
>
> :-)  Please, no....

Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
(similar to stmt).

Richard.

> Jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 17:37                       ` Richard Biener
@ 2014-05-05 18:39                         ` David Malcolm
  2014-05-05 19:36                           ` Jeff Law
  2014-05-05 19:44                         ` Jeff Law
  1 sibling, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-05 18:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jeff Law, GCC Patches, Richard Sandiford, Andrew MacLeod

On Mon, 2014-05-05 at 19:37 +0200, Richard Biener wrote:
> On Mon, May 5, 2014 at 6:01 PM, Jeff Law <law@redhat.com> wrote:
> > On 05/05/14 02:22, Richard Biener wrote:
> >>>
> >>>
> >>> Also, AIUI, Andrew is looking at introducing concepts of gimple types and
> >>> gimple expressions, so "gimple" may no longer imply a *statement*.
> >>>
> >>> Alternatively, we could make the base class be just "gimple" (which would
> >>> be more consistent with the names of the accessor functions).
> >>
> >>
> >> I strongly prefer to name it 'gimple', not 'gimple_stmt'.  Because it's
> >> less
> >> to type, and because it will make all other types shorter as well.  And
> >> because
> >> 'gimple' _is_ a stmt right now, so gimple_stmt is redundant.  Same applies
> >> to gimple_stmt_with_FOO, just make it gimple_with_FOO.
> >>
> >> I understand the namespace issue, but we don't have a namespace right now.
> >> Also gimple::gimple works just fine, no?
> >
> > But this approach is going to be inconsistent with Andrew's work, right?
> > ISTM we'd end up with something like...
> >
> > So statements would be "gimple"
> > types would be "gimple_type"
> > expressions would be "gimple_expr"
> 
> Well, I hope that Andrew doesn't do without a namespace (and I still
> don't believe in what he tries to achieve without laying proper ground-work
> throughout the compiler).  With a namespace gimple we can use
> gimple::stmt.
> 
> > It's a bit of bikeshedding, but I'd prefer "gimple_stmt".  If you really
> > feel strongly about it, I'll go along without objection, but it seems wrong
> > to me.
> 
> Less typing.  But yes, it's bikeshedding.  Still gimple_stmt is
> redundant information in almost all context.  'stmt' was opposed to
> elsewhere so we settle on 'gimple' (which is already existing).
> IMHO not changing things is the best bikeshedding argument.
> 
> >>
> >>> There's also the "bargain basement" namespaces approach, where we don't
> >>> have an implicit "gimple" namespace, but just *pretend* we do, and rename
> >>> the base type to "stmt", with e.g. "gimple_statement_phi" becoming just
> >>> "phi". ["gimple_switch" would need to become "switch_", say, to avoid the
> >>> reserved word].
> >>
> >>
> >> Ick (for the 'switch' case ... CamelCase anyone? :)).
> >
> > :-)  Please, no....
> 
> Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> (similar to stmt).

FWIW I assumed the ick from Jeff was in relation to CamelCase.

Note that it's not just GIMPLE_SWITCH that has this problem when using
this naming convention; I believe the list of codes that would have
class names clashing with C++ keywords would be:

       GIMPLE_GOTO
       GIMPLE_SWITCH
       GIMPLE_RETURN
       GIMPLE_CATCH
       GIMPLE_TRY

IMHO, I think trying to eliminate vowels or similar would be confusing
(e.g. how does one respell "try"? [1]) and that standardizing on a
trailing underscore for all of these seems to me to be cleaner and
simpler.

But, yeah, we're in bikeshedding territory here :)

Dave

[1]  e.g. in patch 32 of the series which converts a dozen or so
"gimple" vars in tree-eh.c to be explicitly one of these.  "trie" would
make me think of a data structure, rather than a "try" statement, and,
errr.... "trigh" would make me think of Battlestar Galactica's XO :)

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 18:39                         ` David Malcolm
@ 2014-05-05 19:36                           ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-05 19:36 UTC (permalink / raw)
  To: David Malcolm, Richard Biener
  Cc: GCC Patches, Richard Sandiford, Andrew MacLeod

On 05/05/14 12:37, David Malcolm wrote:
>
> FWIW I assumed the ick from Jeff was in relation to CamelCase.
Yes.  That is a personal preference, of course.
>
> Note that it's not just GIMPLE_SWITCH that has this problem when using
> this naming convention; I believe the list of codes that would have
> class names clashing with C++ keywords would be:
>
>         GIMPLE_GOTO
>         GIMPLE_SWITCH
>         GIMPLE_RETURN
>         GIMPLE_CATCH
>         GIMPLE_TRY
>
> IMHO, I think trying to eliminate vowels or similar would be confusing
> (e.g. how does one respell "try"? [1]) and that standardizing on a
> trailing underscore for all of these seems to me to be cleaner and
> simpler.
Seems reasonable to me (trailing underscore).  Or we could keep the 
gimple_ prefix.

Jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 17:37                       ` Richard Biener
  2014-05-05 18:39                         ` David Malcolm
@ 2014-05-05 19:44                         ` Jeff Law
  2014-05-05 19:53                           ` Jakub Jelinek
  2014-05-05 19:56                           ` Trevor Saunders
  1 sibling, 2 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-05 19:44 UTC (permalink / raw)
  To: Richard Biener
  Cc: David Malcolm, GCC Patches, Richard Sandiford, Andrew MacLeod

On 05/05/14 11:37, Richard Biener wrote:
>
> Well, I hope that Andrew doesn't do without a namespace (and I still
> don't believe in what he tries to achieve without laying proper ground-work
> throughout the compiler).  With a namespace gimple we can use
> gimple::stmt.
namespaces, while nice, aren't going to solve all these issues.  While I 
think we can get a good separation between gimple and the rest of the 
world, I suspect namespaces aren't going to help much with the statement 
vs expression vs type issues.

Ultimately I suspect we're not going to have too many places where we 
can stick a "using namespace gimple-whatever", but time will tell.

> Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> (similar to stmt).
As David pointed out there's several others that map to keywords.  I'd 
rather set a standard here across the project so that we don't have 
folks using gto for goto, others using goto_, _goto, whatever.  While 
swtch works well, I don't think the other examples work nearly as well. 
  Thus some kind of prefix/suffix seems better to me (though I'm sure my 
eyes will bleed as a result of looking at those objects).

jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 19:44                         ` Jeff Law
@ 2014-05-05 19:53                           ` Jakub Jelinek
  2014-05-06  9:33                             ` Martin Jambor
  2014-05-06 19:00                             ` David Malcolm
  2014-05-05 19:56                           ` Trevor Saunders
  1 sibling, 2 replies; 250+ messages in thread
From: Jakub Jelinek @ 2014-05-05 19:53 UTC (permalink / raw)
  To: Jeff Law
  Cc: Richard Biener, David Malcolm, GCC Patches, Richard Sandiford,
	Andrew MacLeod

On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> On 05/05/14 11:37, Richard Biener wrote:
> >
> >Well, I hope that Andrew doesn't do without a namespace (and I still
> >don't believe in what he tries to achieve without laying proper ground-work
> >throughout the compiler).  With a namespace gimple we can use
> >gimple::stmt.
> namespaces, while nice, aren't going to solve all these issues.
> While I think we can get a good separation between gimple and the
> rest of the world, I suspect namespaces aren't going to help much
> with the statement vs expression vs type issues.
> 
> Ultimately I suspect we're not going to have too many places where
> we can stick a "using namespace gimple-whatever", but time will
> tell.
> 
> >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> >(similar to stmt).
> As David pointed out there's several others that map to keywords.
> I'd rather set a standard here across the project so that we don't
> have folks using gto for goto, others using goto_, _goto, whatever.
> While swtch works well, I don't think the other examples work nearly
> as well.  Thus some kind of prefix/suffix seems better to me (though
> I'm sure my eyes will bleed as a result of looking at those
> objects).

But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
gassign, gcall.

	Jakub

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 19:44                         ` Jeff Law
  2014-05-05 19:53                           ` Jakub Jelinek
@ 2014-05-05 19:56                           ` Trevor Saunders
  1 sibling, 0 replies; 250+ messages in thread
From: Trevor Saunders @ 2014-05-05 19:56 UTC (permalink / raw)
  To: Jeff Law
  Cc: Richard Biener, David Malcolm, GCC Patches, Richard Sandiford,
	Andrew MacLeod

[-- Attachment #1: Type: text/plain, Size: 1632 bytes --]

On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> On 05/05/14 11:37, Richard Biener wrote:
> >
> >Well, I hope that Andrew doesn't do without a namespace (and I still
> >don't believe in what he tries to achieve without laying proper ground-work
> >throughout the compiler).  With a namespace gimple we can use
> >gimple::stmt.
> namespaces, while nice, aren't going to solve all these issues.  While I
> think we can get a good separation between gimple and the rest of the world,
> I suspect namespaces aren't going to help much with the statement vs
> expression vs type issues.
> 
> Ultimately I suspect we're not going to have too many places where we can
> stick a "using namespace gimple-whatever", but time will tell.

yeah, gcc::gimple::stmt::switch seems a bit excessive ;)

> >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> >(similar to stmt).
> As David pointed out there's several others that map to keywords.  I'd
> rather set a standard here across the project so that we don't have folks
> using gto for goto, others using goto_, _goto, whatever.  While swtch works
> well, I don't think the other examples work nearly as well.  Thus some kind
> of prefix/suffix seems better to me (though I'm sure my eyes will bleed as a
> result of looking at those objects).

personally I've become desensitized to cammel case, but how about
switch_stmt, goto_stmt etc? imho its not that bad to be a little
explicit these are statement types, but yet its pretty short.

Trev

> 
> jeff

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 19:53                           ` Jakub Jelinek
@ 2014-05-06  9:33                             ` Martin Jambor
  2014-05-06 19:00                             ` David Malcolm
  1 sibling, 0 replies; 250+ messages in thread
From: Martin Jambor @ 2014-05-06  9:33 UTC (permalink / raw)
  To: gcc-patches

On Mon, May 05, 2014 at 09:53:49PM +0200, Jakub Jelinek wrote:
> On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> > On 05/05/14 11:37, Richard Biener wrote:
> > >
> > >Well, I hope that Andrew doesn't do without a namespace (and I still
> > >don't believe in what he tries to achieve without laying proper ground-work
> > >throughout the compiler).  With a namespace gimple we can use
> > >gimple::stmt.
> > namespaces, while nice, aren't going to solve all these issues.
> > While I think we can get a good separation between gimple and the
> > rest of the world, I suspect namespaces aren't going to help much
> > with the statement vs expression vs type issues.
> > 
> > Ultimately I suspect we're not going to have too many places where
> > we can stick a "using namespace gimple-whatever", but time will
> > tell.
> > 
> > >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> > >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> > >(similar to stmt).
> > As David pointed out there's several others that map to keywords.
> > I'd rather set a standard here across the project so that we don't
> > have folks using gto for goto, others using goto_, _goto, whatever.
> > While swtch works well, I don't think the other examples work nearly
> > as well.  Thus some kind of prefix/suffix seems better to me (though
> > I'm sure my eyes will bleed as a result of looking at those
> > objects).
> 
> But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
> gassign, gcall.
> 
> 	Jakub

My thoughts exactly.  (And I'd also leave the general statement type
called gimple.)

Martin

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-05 19:53                           ` Jakub Jelinek
  2014-05-06  9:33                             ` Martin Jambor
@ 2014-05-06 19:00                             ` David Malcolm
  2014-05-06 19:15                               ` Jeff Law
  1 sibling, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-06 19:00 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Jeff Law, Richard Biener, GCC Patches, Richard Sandiford, Andrew MacLeod

On Mon, 2014-05-05 at 21:53 +0200, Jakub Jelinek wrote:
> On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> > On 05/05/14 11:37, Richard Biener wrote:
> > >
> > >Well, I hope that Andrew doesn't do without a namespace (and I still
> > >don't believe in what he tries to achieve without laying proper ground-work
> > >throughout the compiler).  With a namespace gimple we can use
> > >gimple::stmt.
> > namespaces, while nice, aren't going to solve all these issues.
> > While I think we can get a good separation between gimple and the
> > rest of the world, I suspect namespaces aren't going to help much
> > with the statement vs expression vs type issues.
> > 
> > Ultimately I suspect we're not going to have too many places where
> > we can stick a "using namespace gimple-whatever", but time will
> > tell.
> > 
> > >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> > >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> > >(similar to stmt).
> > As David pointed out there's several others that map to keywords.
> > I'd rather set a standard here across the project so that we don't
> > have folks using gto for goto, others using goto_, _goto, whatever.
> > While swtch works well, I don't think the other examples work nearly
> > as well.  Thus some kind of prefix/suffix seems better to me (though
> > I'm sure my eyes will bleed as a result of looking at those
> > objects).
> 
> But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
> gassign, gcall.

FWIW, I like this: I think it's clear and concise, and I think it avoids
the need for namespaces. (I'd prefer not to have a namespace, due to
gengtype).

Given Richi's preference for the base class being "gimple", that could
give:

Existing           New
--------           ---
gimple             gimple *


gimple             gswitch *
  a GIMPLE_SWITCH


gimple             gcall *
  a GIMPLE_CALL

etc

with the various
  gimple_statement_with_FOO
becoming just
  gimple_with_FOO
e.g. "gimple_with_memory_ops"

How would you want subclasses for the OpenMP statements to be named?
e.g. replace "gimple_statement_omp" with gomp_" for e.g.
"gomp_for *"

or to "gimple_omp_", giving e.g. "gimple_omp_for *"

with the former (less verbose) approach giving the following names, I
think (showing the class hierarchy):

   gimple
     |    layout: GSS_BASE
     |    used for 4 codes: GIMPLE_ERROR_MARK
     |                      GIMPLE_NOP
     |                      GIMPLE_OMP_SECTIONS_SWITCH
     |                      GIMPLE_PREDICT
     |
     + gimple_with_ops_base
     |   |    (no GSS layout)
     |   |
     |   + gimple_with_ops
     |   |   |    layout: GSS_WITH_OPS
     |   |   |
     |   |   + gcond
     |   |   |     code: GIMPLE_COND
     |   |   |
     |   |   + gdebug
     |   |   |     code: GIMPLE_DEBUG
     |   |   |
     |   |   + ggoto
     |   |   |     code: GIMPLE_GOTO
     |   |   |
     |   |   + glabel
     |   |   |     code: GIMPLE_LABEL
     |   |   |
     |   |   + gswitch
     |   |         code: GIMPLE_SWITCH
     |   |
     |   + gimple_with_memory_ops_base
     |       |    layout: GSS_WITH_MEM_OPS_BASE
     |       |
     |       + gimple_with_memory_ops
     |       |   |    layout: GSS_WITH_MEM_OPS
     |       |   |
     |       |   + gassign
     |       |   |    code GIMPLE_ASSIGN
     |       |   |
     |       |   + greturn
     |       |        code GIMPLE_RETURN
     |       |
     |       + gcall
     |       |        layout: GSS_CALL, code: GIMPLE_CALL
     |       |
     |       + gasm
     |       |        layout: GSS_ASM, code: GIMPLE_ASM
     |       |
     |       + gtransaction
     |                layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
     |
     + gomp
     |   |    layout: GSS_OMP.  Used for code GIMPLE_OMP_SECTION
     |   |
     |   + gomp_critical
     |   |        layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
     |   |
     |   + gomp_for
     |   |        layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
     |   |
     |   + gomp_parallel_layout
     |   |   |    layout: GSS_OMP_PARALLEL_LAYOUT
     |   |   |
     |   |   + gomp_taskreg
     |   |   |   |
     |   |   |   + gomp_parallel
     |   |   |   |        code: GIMPLE_OMP_PARALLEL
     |   |   |   |
     |   |   |   + gomp_task
     |   |   |            code: GIMPLE_OMP_TASK
     |   |   |
     |   |   + gomp_target
     |   |            code: GIMPLE_OMP_TARGET
     |   |
     |   + gomp_sections
     |   |        layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
     |   |
     |   + gomp_single_layout
     |       |    layout: GSS_OMP_SINGLE_LAYOUT
     |       |
     |       + gomp_single
     |       |        code: GIMPLE_OMP_SINGLE
     |       |
     |       + gomp_teams
     |                code: GIMPLE_OMP_TEAMS
     |
     + gbind
     |        layout: GSS_BIND, code: GIMPLE_BIND
     |
     + gcatch
     |        layout: GSS_CATCH, code: GIMPLE_CATCH
     |
     + geh_filter
     |        layout: GSS_EH_FILTER, code: GIMPLE_EH_FILTER
     |
     + geh_else
     |        layout: GSS_EH_ELSE, code: GIMPLE_EH_ELSE
     |
     + geh_mnt
     |        layout: GSS_EH_MNT, code: GIMPLE_EH_MUST_NOT_THROW
     |
     + gphi
     |        layout: GSS_PHI, code: GIMPLE_PHI
     |
     + geh_ctrl
     |   |    layout: GSS_EH_CTRL
     |   |
     |   + gresx
     |   |        code: GIMPLE_RESX
     |   |
     |   + geh_dispatch
     |            code: GIMPLE_EH_DISPATCH
     |
     + gtry
     |        layout: GSS_TRY, code: GIMPLE_TRY
     |
     + gwce
     |        layout: GSS_WCE, code: GIMPLE_WITH_CLEANUP_EXPR
     |
     + gomp_continue
     |        layout: GSS_OMP_CONTINUE, code: GIMPLE_OMP_CONTINUE
     |
     + gomp_atomic_load
     |        layout: GSS_OMP_ATOMIC_LOAD, code: GIMPLE_OMP_ATOMIC_LOAD
     |
     + gomp_atomic_store_layout
         |    layout: GSS_OMP_ATOMIC_STORE_LAYOUT,
         |    code: GIMPLE_OMP_ATOMIC_STORE
         |
         + gomp_atomic_store
         |        code: GIMPLE_OMP_ATOMIC_STORE
         |
         + gomp_return
                  code: GIMPLE_OMP_RETURN





Dave

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-06 19:00                             ` David Malcolm
@ 2014-05-06 19:15                               ` Jeff Law
  2014-05-06 19:21                                 ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-06 19:15 UTC (permalink / raw)
  To: David Malcolm, Jakub Jelinek
  Cc: Richard Biener, GCC Patches, Richard Sandiford, Andrew MacLeod

On 05/06/14 12:58, David Malcolm wrote:
>> But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
>> gassign, gcall.
>
> FWIW, I like this: I think it's clear and concise, and I think it avoids
> the need for namespaces. (I'd prefer not to have a namespace, due to
> gengtype).
Then let's go with it.  g<foo> is as reasonable as anything else we're 
likely to come up with.

jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-06 19:15                               ` Jeff Law
@ 2014-05-06 19:21                                 ` Richard Biener
  0 siblings, 0 replies; 250+ messages in thread
From: Richard Biener @ 2014-05-06 19:21 UTC (permalink / raw)
  To: Jeff Law, David Malcolm, Jakub Jelinek
  Cc: GCC Patches, Richard Sandiford, Andrew MacLeod

On May 6, 2014 9:15:09 PM CEST, Jeff Law <law@redhat.com> wrote:
>On 05/06/14 12:58, David Malcolm wrote:
>>> But the prefix can be as short as e.g. "g" (for gimple), so gtry,
>ggoto,
>>> gassign, gcall.
>>
>> FWIW, I like this: I think it's clear and concise, and I think it
>avoids
>> the need for namespaces. (I'd prefer not to have a namespace, due to
>> gengtype).
>Then let's go with it.  g<foo> is as reasonable as anything else we're 
>likely to come up with.

Agreed.

Richard.

>jeff


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

* Committed: [PATCH 19/89] Const-correctness of gimple_call_builtin_p
  2014-04-21 16:57 ` [PATCH 19/89] Const-correctness of gimple_call_builtin_p David Malcolm
@ 2014-05-07 19:39   ` David Malcolm
  2014-05-09  6:34   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: David Malcolm @ 2014-05-07 19:39 UTC (permalink / raw)
  To: gcc-patches

On Mon, 2014-04-21 at 12:56 -0400, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_builtin_call_types_compatible_p): Accept a
> 	const_gimple, rather than a gimple.
> 	(gimple_call_builtin_p): Likewise, for the three variants.
> 
> 	* gimple.c (gimple_builtin_call_types_compatible_p): Likewise.
> 	(gimple_call_builtin_p): Likewise, for the three variants.
> ---
>  gcc/gimple.c | 8 ++++----
>  gcc/gimple.h | 8 ++++----
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/gcc/gimple.c b/gcc/gimple.c
> index 13c5a08..943fa7c 100644
> --- a/gcc/gimple.c
> +++ b/gcc/gimple.c
> @@ -2383,7 +2383,7 @@ validate_type (tree type1, tree type2)
>     a decl of a builtin function.  */
>  
>  bool
> -gimple_builtin_call_types_compatible_p (gimple stmt, tree fndecl)
> +gimple_builtin_call_types_compatible_p (const_gimple stmt, tree fndecl)
>  {
>    gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
>  
> @@ -2412,7 +2412,7 @@ gimple_builtin_call_types_compatible_p (gimple stmt, tree fndecl)
>  /* Return true when STMT is builtins call.  */
>  
>  bool
> -gimple_call_builtin_p (gimple stmt)
> +gimple_call_builtin_p (const_gimple stmt)
>  {
>    tree fndecl;
>    if (is_gimple_call (stmt)
> @@ -2425,7 +2425,7 @@ gimple_call_builtin_p (gimple stmt)
>  /* Return true when STMT is builtins call to CLASS.  */
>  
>  bool
> -gimple_call_builtin_p (gimple stmt, enum built_in_class klass)
> +gimple_call_builtin_p (const_gimple stmt, enum built_in_class klass)
>  {
>    tree fndecl;
>    if (is_gimple_call (stmt)
> @@ -2438,7 +2438,7 @@ gimple_call_builtin_p (gimple stmt, enum built_in_class klass)
>  /* Return true when STMT is builtins call to CODE of CLASS.  */
>  
>  bool
> -gimple_call_builtin_p (gimple stmt, enum built_in_function code)
> +gimple_call_builtin_p (const_gimple stmt, enum built_in_function code)
>  {
>    tree fndecl;
>    if (is_gimple_call (stmt)
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index a8a8d72..62f9756 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -1458,10 +1458,10 @@ extern tree gimple_unsigned_type (tree);
>  extern tree gimple_signed_type (tree);
>  extern alias_set_type gimple_get_alias_set (tree);
>  extern bool gimple_ior_addresses_taken (bitmap, gimple);
> -extern bool gimple_builtin_call_types_compatible_p (gimple, tree);
> -extern bool gimple_call_builtin_p (gimple);
> -extern bool gimple_call_builtin_p (gimple, enum built_in_class);
> -extern bool gimple_call_builtin_p (gimple, enum built_in_function);
> +extern bool gimple_builtin_call_types_compatible_p (const_gimple, tree);
> +extern bool gimple_call_builtin_p (const_gimple);
> +extern bool gimple_call_builtin_p (const_gimple, enum built_in_class);
> +extern bool gimple_call_builtin_p (const_gimple, enum built_in_function);
>  extern bool gimple_asm_clobbers_memory_p (const_gimple);
>  extern void dump_decl_set (FILE *, bitmap);
>  extern bool nonfreeing_call_p (gimple);

Succesfully bootstrapped&regtested on its own on
x86_64-unknown-linux-gnu (Fedora 20).

Committed to trunk as r210185 (this is just fixing const-correctness,
and so it falls under Jeff's preapproval for such fixes here:
  http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01240.html )


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

* Re: [PATCH 19/89] Const-correctness of gimple_call_builtin_p
  2014-04-21 16:57 ` [PATCH 19/89] Const-correctness of gimple_call_builtin_p David Malcolm
  2014-05-07 19:39   ` Committed: " David Malcolm
@ 2014-05-09  6:34   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09  6:34 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_builtin_call_types_compatible_p): Accept a
> 	const_gimple, rather than a gimple.
> 	(gimple_call_builtin_p): Likewise, for the three variants.
>
> 	* gimple.c (gimple_builtin_call_types_compatible_p): Likewise.
> 	(gimple_call_builtin_p): Likewise, for the three variants.
This is fine per my prior pre-approval of const-correctness changes of 
this nature.

Thanks,
Jeff

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

* Re: [PATCH 0/3] Compile-time gimple checking, without typedefs
  2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
                                     ` (3 preceding siblings ...)
  2014-05-05  8:22                   ` [PATCH 0/3] Compile-time gimple checking, without typedefs Richard Biener
@ 2014-05-09  6:43                   ` Jeff Law
  4 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09  6:43 UTC (permalink / raw)
  To: David Malcolm, GCC Patches
  Cc: Richard Biener, Richard Sandiford, Andrew MacLeod

On 05/02/14 15:56, David Malcolm wrote:
> This patch series demonstrates a way of reimplementing the 89-patch series:
>    "[PATCH 00/89] Compile-time gimple-checking"
>       http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01148.html
>
> whilst avoiding introducing a pair of "gimple_foo/const_gimple_foo" typedefs
> for each subclass.
>
> It eliminates the "gimple" and "const_gimple" typedefs,
> renaming "gimple_statement_base" to "gimple_stmt", giving types:
>    "gimple_stmt *" and "const gimple_stmt *"
> thoughout the middle-end.  The rest of the gimple statement classes are
> renamed, converting the various
>    gimple_statement_with_FOO
> to:
>    gimple_stmt_with_FOO
> and the remainder:
>    gimple_statement_SOME_SUBCLASS
> to just:
>    gimple_SOME_SUBCLASS
>
> The idea is then to reimplement the earlier patch series, porting many of
> these:
>    gimple_stmt *something
> to point to some more concrete subclass; I've done this for GIMPLE_SWITCH.
>
> It requires two patches that I've already posted separately:
>
>    (A): "[PATCH] gengtype: Support explicit pointers in template arguments":
>            http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00003.html
>         (which apparently will need reworking after wide-int is merged;
>          oh well).
So, wide-int has been merged, so time to get this patch dealt with.  As 
mentioned before, if it's just trivial changes, consider it 
pre-approved.  Else please get another review.  Obviously in both cases 
it needs to be posted to gcc-patches.

>
>    (B): "[PATCH 19/89] Const-correctness of gimple_call_builtin_p":
>            http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01194.html
>         (I have a separate bootstrap&regrtest in progress for just this one,
>          which appears to be pre-approved per Jeff's earlier comments).
Yes, this would meet the pre-approval criteria.  Just to be explicit, I 
approved it tonight anyway :-)

So it looks like Richi really wanted to keep the statements as "gimple" 
rather than gimple_stmt or somesuch.  So that presumably requires some 
reworking this patch series, but those should be strictly name changes, 
right?

jeff




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

* Re: [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *"
  2014-05-02 21:54                   ` [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *" David Malcolm
@ 2014-05-09  6:49                     ` Jeff Law
  2014-05-09 10:42                       ` Richard Biener
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-09  6:49 UTC (permalink / raw)
  To: David Malcolm, GCC Patches
  Cc: Richard Biener, Richard Sandiford, Andrew MacLeod

On 05/02/14 15:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple): Drop typedef.
> 	(const_gimple): Likewise.
> 	(gimple_seq): Convert from being a "gimple" to a "gimple_stmt *".
So instead, we just want to convert from "gimple" to "gimple *", right? 
  That was my understanding of where we left things last week.

That's going to mean a ton of trivial fixups to this patch.  With those 
fixes, this patch is approved.

jeff


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

* Re: [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *"
  2014-05-02 21:54                   ` [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *" David Malcolm
@ 2014-05-09  6:50                     ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09  6:50 UTC (permalink / raw)
  To: David Malcolm, GCC Patches
  Cc: Richard Biener, Richard Sandiford, Andrew MacLeod

On 05/02/14 15:56, David Malcolm wrote:
> This autogenerated patch is 1.2M in size, so I've uploaded it to:
> http://dmalcolm.fedorapeople.org/gcc/large-patches/e5a7d209a8789e6df9eccb9210d4a6dbe26d0fd4-0002-Autogenerated-part-of-conversion-of-gimple-to-gimple.patch
>
> to avoid being anti-social on the mailing list.
>
> ChangeLog follows (without the patch itself):
>
> gcc/
>
> 	Patch autogenerated by rename_gimple.py from
> 	https://github.com/davidmalcolm/gcc-refactoring-scripts
> 	revision 6a01b854f462cd86b84173b0c45db90f11c00359
So like the prior patch in this series, there's going to be a ton of 
trivial changes here too.  THe net result is this patch ultimately 
changes "gimple" to "gimple *", right?  If so, approved with that change.

jeff

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

* Re: [PATCH 3/3] Introduce gimple_switch and use it in various places
  2014-05-02 21:54                   ` [PATCH 3/3] Introduce gimple_switch and use it in various places David Malcolm
@ 2014-05-09  6:54                     ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09  6:54 UTC (permalink / raw)
  To: David Malcolm, GCC Patches
  Cc: Richard Biener, Richard Sandiford, Andrew MacLeod

On 05/02/14 15:56, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_switch): New subclass of gimple_stmt_with_ops,
> 	adding the invariant that stmt->code == GIMPLE_SWITCH.
> 	(is_a_helper <gimple_switch *>::test): New.
> 	(is_a_helper <const gimple_switch *>::test): New.
> 	(gimple_try): Likewise.
>
> 	* coretypes.h (gimple_switch): Add forward declaration here.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_switch,
> 	using the gimple printer.
>
> 	* gimple.c (gimple_build_switch_nlabels): Return a gimple_switch
> 	rather than just a gimple.
> 	(gimple_build_switch): Likewise.
> 	* gimple.h (gimple_build_switch_nlabels): Likewise.
> 	(gimple_build_switch): Likewise.
>
> 	* gimple.h (gimple_switch_num_labels): Update type-signature to
> 	require a gimple_switch rather than just a gimple.
> 	(gimple_switch_set_num_labels): Likewise.
> 	(gimple_switch_set_index): Likewise.
> 	(gimple_switch_label): Likewise.
> 	(gimple_switch_set_label): Likewise.
> 	(gimple_switch_default_label): Likewise.
> 	(gimple_switch_set_default_label): Likewise.
> 	* expr.h (expand_case): Likewise.
> 	* gimple-pretty-print.c (dump_gimple_call): Likewise.
> 	* stmt.c (compute_cases_per_edge): Likewise.
> 	(expand_case): Likewise.
> 	* tree-cfg.h (group_case_labels_stmt): Likewise.
> 	* tree-cfg.c (make_gimple_switch_edges): Likewise.
> 	(find_taken_edge_switch_expr) Likewise.
> 	(find_case_label_for_value) Likewise.
> 	(get_cases_for_edge): Likewise.
> 	(group_case_labels_stmt): Likewise.
> 	(verify_gimple_switch): Likewise.
> 	* tree-eh.c (verify_norecord_switch_expr): Likewise.
> 	* tree-eh.c (lower_eh_constructs_2): Likewise.
> 	* tree-loop-distribution.c (generate_loops_for_partition): Likewise.
> 	* tree-ssa-dom.c (record_edge_info): Likewise.
> 	* tree-ssa-forwprop.c (simplify_gimple_switch_label_vec): Likewise.
> 	(simplify_gimple_switch): Likewise.
> 	* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
> 	(collect_switch_conv_info): Likewise.
> 	(build_constructors): Likewise.
> 	(array_value_type): Likewise.
> 	(build_one_array): Likewise.
> 	(build_arrays): Likewise.
> 	(gen_inbound_check): Likewise.
> 	* tree-vrp.c (find_switch_asserts): Likewise.
> 	(find_case_label_range): Likewise.
> 	(find_case_label_ranges): Likewise.
> 	(vrp_visit_switch_stmt): Likewise.
> 	(simplify_switch_using_ranges): Likewise.
>
> 	* tree-vrp.c (switch_update): Strengthen field "stmt" from being
> 	merely a gimple_stmt * to being a gimple_switch *.
>
> 	* cfgexpand.c (expand_gimple_stmt_1): Add checked cast to
> 	gimple_switch in regions where the stmt code has been tested as
> 	GIMPLE_SWITCH.
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
> 	* tree-cfg.c (make_edges): Likewise.
> 	(end_recording_case_labels): Likewise.
> 	(cleanup_dead_labels): Likewise.
> 	(cleanup_dead_labels): Likewise.
> 	(group_case_labels): Likewise.
> 	(find_taken_edge): Likewise.
> 	(find_case_label_for_value): Likewise.
> 	(verify_gimple_stmt): Likewise.
> 	(gimple_verify_flow_info): Likewise.
> 	(gimple_redirect_edge_and_branch): Likewise.
> 	* tree-inline.c (estimate_num_insns): Likewise.
> 	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
> 	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Likewise.
> 	* tree-switch-conversion.c (do_switchconv): Likewise.
> 	* tree-vrp.c  (find_assert_locations_1): Likewise.
> 	(vrp_visit_stmt): Likewise.
> 	(simplify_stmt_using_ranges): Likewise.
>
> 	* ipa-inline-analysis.c (set_switch_stmt_execution_predicate):
> 	Introduce local "lastg" as a generic gimple, so that local "last"
> 	can be of type gimple_switch once lastg's code has been verified.
>
> 	* omp-low.c (diagnose_sb_2): Introduce switch_stmt local to handle
> 	the GIMPLE_SWITCH case.
>
> 	* tree-cfg.c (find_taken_edge_switch_expr): Add gimple_switch
> 	argument, since the caller (find_taken_edge) has checked that
> 	last_stmt is a switch.
>
> 	* doc/gimple.texi (Class hierarchy of GIMPLE statements): Add
> 	gimple_switch class.
> 	(GIMPLE_SWITCH): Update signatures of accessor functions to reflect
> 	above gimple_stmt to gimple_switch changes.
OK after the "gimple_stmt" to "gimple" change referenced in prior 
messages related to this patchkit.

jeff


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

* Re: [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *"
  2014-05-09  6:49                     ` Jeff Law
@ 2014-05-09 10:42                       ` Richard Biener
  0 siblings, 0 replies; 250+ messages in thread
From: Richard Biener @ 2014-05-09 10:42 UTC (permalink / raw)
  To: Jeff Law; +Cc: David Malcolm, GCC Patches, Richard Sandiford, Andrew MacLeod

On Fri, May 9, 2014 at 8:49 AM, Jeff Law <law@redhat.com> wrote:
> On 05/02/14 15:56, David Malcolm wrote:
>>
>> gcc/
>>         * coretypes.h (gimple): Drop typedef.
>>         (const_gimple): Likewise.
>>         (gimple_seq): Convert from being a "gimple" to a "gimple_stmt *".
>
> So instead, we just want to convert from "gimple" to "gimple *", right?
> That was my understanding of where we left things last week.

Yes.

Thanks,
Richard.

> That's going to mean a ton of trivial fixups to this patch.  With those
> fixes, this patch is approved.
>
> jeff
>
>

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

* Re: [PATCH 04/89] Introduce gimple_cond and use it in various places
  2014-04-21 16:56 ` [PATCH 04/89] Introduce gimple_cond and use it in various places David Malcolm
@ 2014-05-09 14:13   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 14:13 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_cond): New typedef.
> 	(const_gimple_cond): Likewise.
>
> 	* gimple.h (struct gimple_statement_cond): New subclass of
> 	gimple_statement_with_ops, adding the invariant that
> 	stmt->code == GIMPLE_COND.
> 	(gimple_statement_base::as_a_gimple_cond): New.
> 	(gimple_statement_base::dyn_cast_gimple_cond): New.
> 	(is_a_helper <gimple_statement_cond>::test): New.
> 	(gimple_build_cond): Return a gimple_cond, rather than just
> 	a gimple.
> 	(gimple_build_cond_from_tree): Likewise.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_cond and its
> 	variants, using the gimple printer.
>
> 	* cfgexpand.c (expand_gimple_cond): Require a gimple_cond rather
> 	than just a gimple.
> 	* gimple.h (gimple_cond_set_condition_from_tree): Likewise.
> 	(gimple_cond_true_p): Likewise.
> 	(gimple_cond_false_p): Likewise.
> 	(gimple_cond_set_condition): Likewise.
> 	* gimple.c (gimple_cond_set_condition_from_tree): Likewise.
> 	* gimple-fold.c (fold_gimple_cond): Likewise.
> 	* gimple-pretty-print.c (dump_gimple_cond): Likewise.
> 	* tree-ssa-dom.c (canonicalize_comparison): Likewise.
> 	* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond): Likewise.
> 	* tree-ssa-ifcombine.c (recognize_single_bit_test): Likewise.
> 	(recognize_bits_test): Likewise.
> 	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
> 	(thread_around_empty_blocks): Likewise.
> 	(thread_through_normal_block): Likewise.
> 	(thread_across_edge): Likewise.
> 	* tree-ssa-threadedge.h (thread_across_edge): Likewise.
> 	* tree-vrp.c (range_fits_type_p): Likewise.
>
> 	* cfgexpand.c (expand_gimple_basic_block): Add checked cast to
> 	gimple_cond in regions where a stmt is known to have code GIMPLE_COND.
> 	* gimple-fold.c (fold_stmt_1): Likewise.
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
> 	* tree-ssa-dom.c (optimize_stmt): Likewise.
> 	* tree-ssa-forwprop.c (ssa_forward_propagate_and_combine): Likewise.
> 	* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise.
> 	* tree-vrp.c (simplify_stmt_using_ranges): Likewise.
>
> 	* cfgloopmanip.c (create_empty_loop_on_edge): Update local to be a
> 	gimple_cond.
> 	* tree-vrp.c (identify_jump_threads): Likewise.
>
> 	* gimple.c (gimple_build_cond): Return a gimple_cond, rather than
> 	just a gimple.
> 	(gimple_build_cond_from_tree): Likewise.
>
> 	* tree-ssa-dom.c (class dom_opt_dom_walker): Strengthen type of
> 	field "m_dummy_cond" from a plain gimple to a gimple_cond.
>
> 	* tree-ssa-ifcombine.c (ifcombine_ifandif): Introduce locals
> 	inner_stmt and outer_stmt so that inner_cond and outer_cond can be
> 	of type gimple_cond once we know that we have code == GIMPLE_COND.
> 	* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Introduce local
> 	"last" so that stmt can be of type gimple_cond.
This is generally fine.  It needs minor tweaks due to the change in how 
we're handling const stuff, but otherwise it looks ready to go.

So, once you've flushed the queue of dependencies and reworked this to 
fit into the new world order, it's OK for the trunk.  Please post the 
final version for archival purposes.

jeff

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

* Re: [PATCH 05/89] Introduce gimple_assign and use it in various places
  2014-04-21 16:56 ` [PATCH 05/89] Introduce gimple_assign and use it in various places David Malcolm
@ 2014-05-09 14:16   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 14:16 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_assign): New typedef.
> 	(const_gimple_assign): New typedef.
>
> 	* gimple.h (struct gimple_statement_assign): New subclass of
> 	gimple_statement_with_memory_ops, adding the invariant that
> 	stmt->code == GIMPLE_ASSIGN.
> 	(gimple_statement_base::as_a_gimple_assign): New.
> 	(gimple_statement_base::dyn_cast_gimple_assign): New.
> 	(is_a_helper <gimple_statement_assign>::test): New.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_assign and its
> 	variants, using the gimple printer.
>
> 	* gimple-builder.c (build_assign): Return a gimple_assign rather
> 	than just a gimple from each of the overloaded variants.
> 	(build_type_cast): Likewise.
> 	* gimple-builder.h (build_assign): Likewise.
> 	(build_type_cast): Likewise.
> 	* gimple.c (gimple_build_assign_stat): Likewise.
> 	(gimple_build_assign_with_ops): Likewise.
> 	* gimple.h (gimple_build_assign_stat): Likewise.
> 	(gimple_build_assign_with_ops): Likewise.
>
> 	* asan.c (get_mem_ref_of_assignment): Require a const_gimple_assign
> 	rather than just a "const gimple" (the latter is not a
> 	"const_gimple").
> 	* gimple-pretty-print.c (dump_unary_rhs): Require a gimple_assign
> 	rather than just a gimple.
> 	(dump_binary_rhs): Likewise.
> 	(dump_ternary_rhs): Likewise.
> 	* tree-cfg.c (verify_gimple_assign_unary): Likewise.
> 	(verify_gimple_assign_binary): Likewise.
> 	(verify_gimple_assign_ternary): Likewise.
> 	(verify_gimple_assign_single): Likewise.
> 	(verify_gimple_assign): Likewise.
> 	* tree-ssa-sccvn.c (simplify_unary_expression): Likewise.
> 	(try_to_simplify): Likewise.
> 	* tree-tailcall.c (process_assignment): Likewise.
> 	* tree-vect-generic.c (expand_vector_operation): Likewise.
> 	* tree-vrp.c (extract_range_from_cond_expr): Likewise.
> 	(extract_range_from_assignment): Likewise.
>
> 	* asan.c (has_stmt_been_instrumented_p): Add checked cast to
> 	gimple_assign in regions where a stmt is known to have code
> 	GIMPLE_ASSIGN.
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Likewise.
> 	* tree-cfg.c (verify_gimple_stmt): Likewise.
> 	* tree-ssa-sccvn.c (visit_use): Likewise.
> 	* tree-tailcall.c (find_tail_calls): Likewise.
> 	* tree-vrp.c (vrp_visit_assignment_or_call): Likewise.
>
> 	* tree-vrp.c (simplify_stmt_for_jump_threading): Replace a check
> 	against GIMPLE_ASSIGN with a dyn_cast_gimple_assign, introducing
> 	a gimple_assign local.
>
> 	* tree-vect-generic.c (expand_vector_condition): Convert local to a
> 	gimple_assign, adding a checked cast when extracting from gsi, since
> 	this is only called when  underlying stmt has code GIMPLE_ASSIGN.
> 	(optimize_vector_constructor): Likewise.
> 	(lower_vec_perm): Likewise.
> 	(expand_vector_operations_1): Convert local to a gimple_assign,
> 	introducing a dyn_cast.
Similar to the gimple_cond patch.  Update for the changes in the 
prerequisites and it's good to go.   Please post final version for 
archival purposes.

jeff

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

* Re: [PATCH 06/89] Introduce gimple_label and use it in a few places
  2014-04-21 16:56 ` [PATCH 06/89] Introduce gimple_label and use it in a few places David Malcolm
@ 2014-05-09 14:18   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 14:18 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_label): New typedef.
> 	(const_gimple_label): New typedef.
>
> 	* gimple.h (struct gimple_statement_label): New subclass of
> 	gimple_statement_with_ops, adding the invariant that
> 	stmt->code == GIMPLE_LABEL.
> 	(gimple_statement_base::as_a_gimple_label): New.
> 	(gimple_statement_base::dyn_cast_gimple_label): New.
> 	(is_a_helper <gimple_statement_label>::test): New.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_label and its
> 	variants, reusing the gimple printer.
>
> 	* gimple-pretty-print.c (dump_gimple_label): Require a gimple_label
> 	rather than just a gimple.
> 	* tree-cfg.c (verify_gimple_label): Likewise.
>
> 	* gimple.c (gimple_build_label): Return a gimple_label rather than
> 	just a gimple.
> 	* gimple.h (gimple_build_label): Likewise.
>
> 	* gimplify.c (gimplify_case_label_expr): Update local to be a
> 	gimple_label.
> 	* tree-switch-conversion.c (gen_inbound_check): Likewise.
>
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
> 	gimple_label in regions where a stmt is known to have code
> 	GIMPLE_LABEL.
> 	* tree-cfg.c (verify_gimple_stmt): Likewise.
Same as prior patches for gimple_cond and gimple_assign.

jeff

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

* Re: [PATCH 07/89] Introduce gimple_debug and use it in a few places
  2014-04-21 16:57 ` [PATCH 07/89] Introduce gimple_debug and use it in a few places David Malcolm
@ 2014-05-09 14:18   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 14:18 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_debug): New typedef.
> 	(const_gimple_debug): New typedef.
>
> 	* gimple.h (struct gimple_statement_debug): New subclass of
> 	gimple_statement_with_ops, adding the invariant that
> 	stmt->code == GIMPLE_DEBUG.
> 	(gimple_statement_base::as_a_gimple_debug): New.
> 	(gimple_statement_base::dyn_cast_gimple_debug): New.
> 	(is_a_helper <gimple_statement_debug>::test): New.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_debug and its
> 	variants, using the gimple printer.
>
> 	* gimple-pretty-print.c (dump_gimple_debug): Require a gimple_debug
> 	rather than just a gimple.
> 	* tree-inline.c (copy_debug_stmt): Likewise.
>
> 	* tree-inline.h (struct copy_body_data): Strengthen field
> 	"debug_stmts" from a vec<gimple> to a vec<gimple_debug>.
>
> 	* gimple.c (gimple_build_debug_bind_stat): Return a gimple_debug
> 	rather than just a gimple.
> 	(gimple_build_debug_source_bind_stat): Likewise.
> 	* gimple.h (gimple_build_debug_bind_stat): Likewise.
> 	(gimple_build_debug_source_bind_stat): Likewise.
>
> 	* tree-inline.c (remap_gimple_stmt): Update locals to be a
> 	gimple_debug.
> 	(maybe_move_debug_stmts_to_successors): Likewise.
> 	(copy_debug_stmts): Likewise.
>
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
> 	gimple_debug in regions where a stmt is known to have code
> 	GIMPLE_DEBUG.
Same as prior patches.

jeff

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

* Re: [PATCH 08/89] Introduce gimple_phi and use it in various places
  2014-04-21 17:13 ` [PATCH 08/89] Introduce gimple_phi and use it in various places David Malcolm
@ 2014-05-09 18:29   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:29 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_phi): New typedef.
> 	(const_gimple_phi): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_phi): New.
> 	(gimple_statement_base::dyn_cast_gimple_phi): New.
>
> 	* gdbhooks.py (build_pretty_printer): Add gimple_phi and its
> 	variants, using the gimple printer.
>
> 	* gimple.h (gimple_vec): Eliminate thie typedef in the hope of using
> 	vecs of more concrete gimple subclasses as appropriate; also the
> 	comment is about to become misleading.
>
> 	* gimple.h (gimple_phi_capacity): Use const_gimple_phi typedef
> 	rather than spelling out the full type.
> 	(gimple_phi_num_args): Likewise.
> 	(gimple_phi_result): Likewise.
> 	(gimple_phi_result_ptr): Use gimple_phi typedef.
> 	(gimple_phi_set_result): Likewise.
> 	(gimple_phi_arg): Likewise.
> 	(gimple_phi_set_arg): Likewise.
> 	* tree-phinodes.c (allocate_phi_node): Likewise.
> 	(resize_phi_node): Likewise.
> 	(reserve_phi_args_for_new_edge): Likewise.
> 	(remove_phi_arg_num): Likewise.
>
> 	* gimple-pretty-print.c (dump_gimple_phi): Require a gimple_phi
> 	rather than just a gimple.
> 	* tree-into-ssa.c (mark_phi_for_rewrite): Likewise.
>
> 	* tree-phinodes.c (make_phi_node): Return a gimple_phi rather than
> 	just a gimple.
> 	(create_phi_node): Likewise.
> 	* tree-phinodes.h (create_phi_node): Likewise.
>
> 	* trans-mem.c (struct struct tm_log_entry): Replace use of
> 	now-removed gimple_vec with a plain vec<gimple>.
>
> 	* tree-into-ssa.c (phis_to_rewrite): Strengthen from a
> 	vec<gimple_vec> to a vec< vec<gimple_phi> >.
>
> 	* tree-into-ssa.c (insert_phi_nodes_for): Update local to be a
> 	gimple_phi.
> 	* tree-into-ssa.c (rewrite_update_phi_arguments): Strengthen local
> 	"phis" from a gimple_vec to a vec<gimple_phi>, and local "phi" to
> 	a gimple_phi.
> 	* tree-into-ssa.c (delete_update_ssa): Strengthen local
> 	"phis" from a gimple_vec to a vec<gimple_phi>.
>
> 	* gimple-pretty-print.c (pp_gimple_stmt_1): Add checked cast to
> 	gimple_phi in regions where a stmt is known to have code
> 	GIMPLE_PHI.
> 	* tree-into-ssa.c (mark_use_interesting): Likewise.
Same as prior patches in this set.  Just get the const/renaming stuff 
addressed and it's good to go.

jeff

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

* Re: [PATCH 11/89] tree-parloops.c: use gimple_phi in various places
  2014-04-21 16:56 ` [PATCH 11/89] tree-parloops.c: use gimple_phi in various places David Malcolm
@ 2014-05-09 18:31   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:31 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-parloops.c (struct reduction_info): Strengthen field "new_phi"
> 	from gimple to gimple_phi.
> 	(create_phi_for_local_result): Convert local "new_phi" to gimple_phi.
> 	(loop_has_vector_phi_nodes): Require a gimple_phi rather than a gimple.
> 	(gather_scalar_reductions): Convert to a gimple_phi_iterator and
> 	gimple_phi.
> 	(try_create_reduction_list): Likewise.
OK when prerequisites have gone in.

jeff

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

* Re: [PATCH 12/89] tree-predcom.c: use gimple_phi in various places
  2014-04-21 17:15 ` [PATCH 12/89] tree-predcom.c: use gimple_phi in various places David Malcolm
@ 2014-05-09 18:31   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:31 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-predcom.c (find_looparound_phi): Return a gimple_phi rather
> 	than just a gimple.
> 	(insert_looparound_copy): Require a gimple_phi rather than just a
> 	gimple.
> 	(add_looparound_copies): Convert local "phi" to be a gimple_phi.
> 	(initialize_root_vars): Likewise.
> 	(initialize_root_vars_lm): Likewise.
OK when prerequisites have gone in.
jeff

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

* Re: [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi
  2014-04-21 17:14 ` [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi David Malcolm
@ 2014-05-09 18:31   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:31 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-ssa-propagate.h (typedef ssa_prop_visit_phi_fn): Strengthen
> 	type of parameter from gimple to gimple_phi.
>
> 	* tree-complex.c (complex_visit_phi): Update signature of callback
> 	implementation accordingly.
> 	* tree-ssa-ccp.c (ccp_visit_phi_node): Likewise.
> 	* tree-ssa-copy.c (copy_prop_visit_phi_node): Likewise.
> 	* tree-vrp.c (vrp_visit_phi_node): Likewise.
>
> 	* tree-ssa-propagate.c (simulate_stmt): Add a checked cast to
> 	gimple_phi when invoking the ssa_prop_visit_phi callback.
OK when prerequisites have gone in.

jeff

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

* Re: [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places
  2014-04-21 16:57 ` [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places David Malcolm
@ 2014-05-09 18:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-ssa-loop-niter.c (chain_of_csts_start): Return a gimple_phi
> 	rather than a gimple.
> 	(get_base_for): Likewise; convert local "phi" to be a gimple_phi.
> 	(loop_niter_by_eval): Convert local "phi" to be a gimple_phi.
OK when prerequisites have gone in.
jeff

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

* Re: [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi
  2014-04-21 17:15 ` [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi David Malcolm
@ 2014-05-09 18:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-ssa-phiprop.c (phiprop_insert_phi): Strengthen types of
> 	parameter "phi" and local "new_phi" from gimple to gimple_phi.
OK when prerequisites have gone in.
jeff

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

* Re: [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places
  2014-04-21 17:14 ` [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places David Malcolm
@ 2014-05-09 18:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-ssa-loop-manip.c (add_exit_phi): Convert local "phi" to be a
> 	gimple_phi.
> 	(split_loop_exit_edge): Likewise for "phi" and "new_phi".
OK when prerequisites have gone in.
jeff

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

* Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places
  2014-04-21 16:56 ` [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places David Malcolm
@ 2014-05-09 18:34   ` Jeff Law
  2014-05-09 18:49     ` Impact of gimple renamings on reviews (was Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places) David Malcolm
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:34 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* tree-ssa-loop-ivopts.c (determine_biv_step): Require a gimple_phi.
> 	(find_bivs): Convert local "phi" into a gimple_phi.
> 	(mark_bivs): Likewise.
OK when prerequisites have gone in.

Actually that's true for #17 & #18 as well.

jeff

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

* Re: [PATCH 21/89] Introduce gimple_return
  2014-04-21 16:57 ` [PATCH 21/89] Introduce gimple_return David Malcolm
@ 2014-05-09 18:45   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:45 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_return): New typedef.
> 	(const_gimple_return): New typedef.
>
> 	* gimple.h (gimple_statement_return): New subclass of
> 	gimple_statement_with_memory_ops, adding the invariant that
> 	stmt->code == GIMPLE_RETURN.
> 	(gimple_statement_base::as_a_gimple_return): New.
> 	(gimple_statement_base::dyn_cast_gimple_return): New.
> 	(is_a_helper <gimple_statement_return>::test): New.
> 	(gimple_build_return): Return a gimple_return rather
> 	than a plain gimple.
>
> 	* gimple.c (gimple_build_return): Return a gimple_return rather
> 	than a plain gimple.
>
> 	* cgraphunit.c (expand_thunk): Convert local from a gimple to
> 	a gimple_return.
>
> 	* gimple-low.c (struct return_statements_t): Convert field "stmt"
> 	from a gimple to a gimple_return.
> 	(lower_gimple_return): Convert local from a gimple to a
> 	gimple_return.
>
> 	* gimple-pretty-print.c (dump_gimple_return): Require a
> 	gimple_return rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_return within
> 	case GIMPLE_RETURN of switch statement.
>
> 	* gimplify.c (gimplify_return_expr): Convert locals from
> 	gimple to gimple_return.
>
> 	* ipa-split.c (split_function): Likewise.
>
> 	* tree-cfg.c (verify_gimple_assign): Require a gimple_return
> 	rather than a plain gimple.
> 	(verify_gimple_stmt): Add checked cast to gimple_return within
> 	case GIMPLE_RETURN of switch statement.
>
> 	* tree-tailcall.c (adjust_return_value): Convert local from
> 	gimple to gimple_return.
OK after fixing up the naming/const stuff as discussed for prior patches.

That applies to 22-30.  Make sure to take care of the pretty printers 
per Trevor's comments as well.  He indicated those were missing in a 
couple of those patches.

More to follow ;-)

Jeff

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

* Impact of gimple renamings on reviews (was Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places)
  2014-05-09 18:34   ` Jeff Law
@ 2014-05-09 18:49     ` David Malcolm
  2014-05-09 18:57       ` Jeff Law
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-09 18:49 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Fri, 2014-05-09 at 12:34 -0600, Jeff Law wrote:
> On 04/21/14 10:56, David Malcolm wrote:
> > gcc/
> > 	* tree-ssa-loop-ivopts.c (determine_biv_step): Require a gimple_phi.
> > 	(find_bivs): Convert local "phi" into a gimple_phi.
> > 	(mark_bivs): Likewise.
> OK when prerequisites have gone in.
> 
> Actually that's true for #17 & #18 as well.

Jeff: thanks.  Note that I'm currently working on a grand renaming, as
per the subthread here:
 http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00346.html
so that all of these will be "gphi *" rather than "gimple_phi", with
analogous change to the other classnames in the rest of the patches.

So there's both
  (A) a shortening of:
        gimple_phi
      to
        gphi
and
  (B) a change in "pointerness" (eliminating the typedefs), to:
        gphi *

and these obviously affect the entire patch series, so what I would
commit is beginning to look rather different from what I've posted,
albeit with largely mechanical changes.

Are these patches going to need re-review when the renaming is done, or
are the changes sufficiently mechanical so as to be "grandfathered in"
from these reviews that you're doing; I'm slightly nervous about the
pointerness change, but bootstrap&regrtesting ought to catch typo issues
there when manually fixing up the later patches.

I hope that re-review isn't necessary, but I'm relatively new around
here so I wanted to doublecheck.

If re-review *is* required, maybe hold off on reviewing the rest of the
series until I've got the renaming done?

[In any case, this is all in a holding pattern for trunk until after
4.9.1]

Cheers
Dave


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

* Re: [PATCH 09/89] Introduce gimple_phi_iterator
  2014-04-21 17:14 ` [PATCH 09/89] Introduce gimple_phi_iterator David Malcolm
@ 2014-05-09 18:51   ` Jeff Law
  2014-05-14 16:18     ` gphi_iterator? (was Re: [PATCH 09/89] Introduce gimple_phi_iterator) David Malcolm
  0 siblings, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:51 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* gimple-iterator.h (struct gimple_phi_iterator): New subclass of
> 	gimple_stmt_iterator with identical layout, but adding...
> 	(gimple_phi_iterator::phi): ...new method, equivalent to
> 	gsi_stmt (), but casting the underlying gimple to gimple_phi,
> 	checking that code == GIMPLE_PHI in a checked build.
> 	(gsi_start_phis): Return a gimple_phi_iterator, rather than just a
> 	gimple_stmt_iterator.
>
> 	* tree-if-conv.c (bb_with_exit_edge_p): Require a gimple_phi rather
> 	than just a gimple.
> 	(if_convertible_phi_p): Likewise.
> 	* tree-phinodes.h (add_phi_node_to_bb): Likewise.
> 	* tree-ssa-phiprop.c (propagate_with_phi): Likewise.
>
> 	* tree-ssa-uninit.c (warn_uninitialized_phi): Require a gimple_phi
> 	and a vec<gimple_phi> *, rather than just a gimple and vec<gimple> *.
> 	(find_uninit_use): Likewise; add checked cast to gimple_phi when
> 	adding to worklist.
> 	(execute_late_warn_uninitialized): Strengthen types of various locals,
> 	"worklist" from vec<gimple> to vec<gimple_phi>, "gsi" to a
> 	gimple_phi_iterator, and "phi" and "cur_phi" to a gimple_phi.
>
> 	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Require a
> 	gimple_phi_iterator * rather than a gimple_stmt_iterator *;
> 	use it to strengthen local from a gimple to a gimple_phi.
>
> 	* cfgloop.c (find_subloop_latch_edge_by_ivs): Convert local from a
> 	gimple_stmt_iterator to a gimple_phi_iterator.  Use the iterator's
> 	"phi" method rather than gsi_stmt.  Use this checked cast to convert
> 	the type of related local from a plain gimple to a gimple_phi.
> 	* gimple-pretty-print.c (dump_phi_nodes): Likewise.
> 	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behaviour):
> 	Likewise.
> 	* sese.c (sese_add_exit_phis_edge): Likewise.
> 	* tree-cfg.c (reinstall_phi_args): Likewise.
> 	(gimple_make_forwarder_block): Likewise.
> 	(add_phi_args_after_copy_edge): Likewise.
> 	(gimple_lv_adjust_loop_header_phi): Likewise.
> 	* tree-cfgcleanup.c (phi_alternatives_equal): Likewise.
> 	(remove_forwarder_block_with_phi): Likewise.
> 	(merge_phi_nodes): Likewise.
> 	* tree-complex.c (update_phi_components): Likewise.
> 	* tree-if-conv.c (if_convertible_loop_p_1): Likewise.
> 	* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
> 	(copy_phis_for_bb): Likewise.
> 	* tree-into-ssa.c (rewrite_add_phi_arguments): Likewise.
> 	* tree-outof-ssa.c (eliminate_build): Likewise.
> 	(eliminate_useless_phis): Likewise.
> 	(rewrite_trees): Likewise.
> 	(insert_backedge_copies): Likewise.
> 	* tree-phinodes.c (reserve_phi_args_for_new_edge): Likewise.
> 	(remove_phi_args): Likewise.
> 	(remove_phi_nodes): Likewise.
> 	* tree-predcom.c (find_looparound_phi): Likewise.
> 	(eliminate_temp_copies): Likewise.
> 	* tree-scalar-evolution.c (loop_closed_phi_def): Likewise.
> 	(scev_const_prop): Likewise; also, add checked cast to phi.
> 	* tree-ssa-coalesce.c (coalesce_partitions): Likewise.
> 	* tree-ssa-dce.c (remove_dead_phis): Likewise.
> 	(forward_edge_to_pdom): Likewise.
> 	* tree-ssa-dom.c (record_equivalences_from_phis): Likewise.
> 	(cprop_into_successor_phis): Likewise.
> 	(propagate_rhs_into_lhs): Likewise.
> 	(eliminate_degenerate_phis_1): Likewise.
> 	* tree-ssa-ifcombine.c (same_phi_args_p): Likewise.
> 	* tree-ssa-live.c (calculate_live_on_exit): Likewise.
> 	(verify_live_on_entry): Likewise.
> 	* tree-ssa-loop-im.c
> 	(move_computations_dom_walker::before_dom_children): Likewise.
> 	* tree-ssa-loop-ivopts.c (find_bivs): Likewise.
> 	(mark_bivs): Likewise.
> 	(find_interesting_uses_outside): Likewise.
> 	(determine_set_costs): Likewise.
> 	* tree-ssa-loop-manip.c (split_loop_exit_edge): Likewise.
> 	(tree_transform_and_unroll_loop): Likewise.
> 	(rewrite_all_phi_nodes_with_iv): Likewise.
> 	(canonicalize_loop_ivs): Likewise.
> 	* tree-ssa-loop-niter.c (determine_value_range): Likewise.
> 	* tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise.
> 	* tree-ssa-phiprop.c (tree_ssa_phiprop): Likewise.
> 	* tree-ssa-reassoc.c (suitable_cond_bb): Likewise.
> 	* tree-ssa-tail-merge.c (same_phi_alternatives_1): Likewise.
> 	(vop_phi): Likewise.
> 	* tree-ssa-threadedge.c (record_temporary_equivalences_from_phis):
> 	Likewise.
> 	* tree-ssa-threadupdate.c (copy_phi_arg_into_existing_phi): Likewise.
> 	(copy_phi_args): Likewise.
> 	(phi_args_equal_on_edges): Likewise.
> 	* tree-ssa.c (ssa_redirect_edge): Likewise.
> 	(flush_pending_stmts): Likewise.
> 	* tree-switch-conversion.c (check_final_bb): Likewise.
> 	(gather_default_values): Likewise.
> 	(build_constructors): Likewise.
> 	(fix_phi_nodes): Likewise.
> 	* tree-tailcall.c (propagate_through_phis): Likewise.
> 	(add_successor_phi_arg): Likewise.
> 	* tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard1):
> 	Likewise.
> 	(slpeel_update_phi_nodes_for_guard2): Likewise.
> 	(slpeel_tree_peel_loop_to_edge): Likewise.
> 	(vect_can_advance_ivs_p): Likewise.
> 	(vect_update_ivs_after_vectorizer): Likewise.
> 	* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Likewise.
> 	* tree-vrp.c (find_assert_locations): Likewise.
> 	* value-prof.c (gimple_ic): Likewise.
>
> 	* omp-low.c (expand_parallel_call): Convert local to a gimple_phi.
OK once prerequisites have gone in.

Jeff

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

* Re: Impact of gimple renamings on reviews (was Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places)
  2014-05-09 18:49     ` Impact of gimple renamings on reviews (was Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places) David Malcolm
@ 2014-05-09 18:57       ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 18:57 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

On 05/09/14 12:47, David Malcolm wrote:
> Jeff: thanks.  Note that I'm currently working on a grand renaming, as
> per the subthread here:
>   http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00346.html
> so that all of these will be "gphi *" rather than "gimple_phi", with
> analogous change to the other classnames in the rest of the patches.
>
> So there's both
>    (A) a shortening of:
>          gimple_phi
>        to
>          gphi
> and
>    (B) a change in "pointerness" (eliminating the typedefs), to:
>          gphi *
>
> and these obviously affect the entire patch series, so what I would
> commit is beginning to look rather different from what I've posted,
> albeit with largely mechanical changes.
>
> Are these patches going to need re-review when the renaming is done, or
> are the changes sufficiently mechanical so as to be "grandfathered in"
> from these reviews that you're doing; I'm slightly nervous about the
> pointerness change, but bootstrap&regrtesting ought to catch typo issues
> there when manually fixing up the later patches.
I think the renaming is mechanical enough that no additional reviews 
would be necessary.

The /89 patch series as a whole is pretty mechanical.  There's two or 
three types of patches I've seen as I go through them and for those 
kinds of patches, I looked at the first couple pretty closely, then less 
so for later ones.

> [In any case, this is all in a holding pattern for trunk until after
> 4.9.1]
Right.  But I've got some time now and getting the kit as a whole 
approved so that you're good to go when 4.9.1 is done is valuable.  Who 
knows what kind of crazyness will interfere with my time next month!

jeff

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

* Re: [PATCH 20/89] Introduce gimple_call
  2014-04-21 16:56 ` [PATCH 20/89] Introduce gimple_call David Malcolm
@ 2014-05-09 19:00   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 19:00 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:56, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_call): New typedef.
> 	(const_gimple_call): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_call): New.
> 	(gimple_statement_base::dyn_cast_gimple_call): New.
> 	(gimple_call_reset_alias_info): Require a gimple_call rather than
> 	a plain gimple.
> 	(gimple_call_set_internal_fn): Likewise.
> 	(gimple_call_set_chain): Likewise.
>
> 	(gimple_call_set_return_slot_opt): Likewise; remove redundant
> 	GIMPLE_CHECK.
> 	(gimple_call_set_from_thunk): Likewise.
> 	(gimple_call_from_thunk_p): Likewise.
> 	(gimple_call_set_va_arg_pack): Likewise.
> 	(gimple_call_va_arg_pack_p): Likewise.
> 	(gimple_call_set_alloca_for_var): Likewise.
> 	(gimple_call_alloca_for_var_p): Likewise.
>
> 	(gimple_build_call_vec): Return a gimple_call rather than a gimple.
> 	(gimple_build_call): Likewise.
> 	(gimple_build_call_valist): Likewise.
> 	(gimple_build_call_internal): Likewise.
> 	(gimple_build_call_internal_vec): Likewise.
> 	(gimple_build_call_from_tree): Likewise.
> 	(gimple_call_copy_skip_args): Likewise.
>
> 	(gimple_call_return_flags): Require a const_gimple_call rather than
> 	a plain const_gimple.
> 	(gimple_call_chain_ptr): Likewise.
>
> 	(gimple_expr_type): Introduce local "call_stmt", once we know we have
> 	a GIMPLE_CALL.
>
> 	* asan.c (get_mem_refs_of_builtin_call): Require a const_gimple_call
> 	rather than a plain const_gimple.
> 	(has_stmt_been_instrumented_p): Add checked cast to gimple_call in
> 	region where stmt is known to be a GIMPLE_CALL (owing to it being
> 	a builtin call).
> 	(instrument_strlen_call): Add checked cast to gimple_call.
> 	(instrument_builtin_call): Likewise.
>
> 	* builtins.c (validate_gimple_arglist): Require a const_gimple_call
> 	rather than a plain const_gimple.
> 	(gimple_fold_builtin_sprintf_chk): Require a gimple_call rather than
> 	a plain gimple.
> 	(gimple_fold_builtin_snprintf_chk): Likewise.
> 	(gimple_fold_builtin_varargs): Likewise.
> 	(fold_call_stmt): Likewise.
>
> 	* builtins.h (validate_gimple_arglist): Require a const_gimple_call
> 	rather than a plain const_gimple.
>
> 	* cfgexpand.c (expand_call_stmt): Require a gimple_call rather
> 	than a plain gimple.
> 	(expand_gimple_stmt_1): Add a checked cast to gimple_call within
> 	GIMPLE_CALL case of switch statement.
>
> 	* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Strengthen
> 	"new_stmt" from gimple to gimple_call; add checked cast.
>
> 	* cgraphunit.c (expand_thunk): Strengthen local "call" from gimple
> 	to a gimple_call.
>
> 	* gimple-fold.c (gimple_fold_builtin): Require a gimple_call rather
> 	than a plain gimple.
> 	(gimple_fold_call): Strengthen local "call" from gimple to a
> 	gimple_call.
> 	(gimple_fold_stmt_to_constant_1): Add a checked cast to gimple_call
> 	within GIMPLE_CALL case of switch statement.
>
> 	* gimple-fold.h (gimple_fold_builtin): Require a gimple_call rather
> 	than a plain gimple.
>
> 	* gimple-pretty-print.c (dump_gimple_call_args): Likewise.
> 	(dump_gimple_call): Likewise.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_call within
> 	GIMPLE_CALL case of switch statement.
>
> 	* gimple-streamer-in.c (input_gimple_stmt): Replace is_gimple_call
> 	within dyn_cast_gimple_call and a new local.  Add a checked cast to
> 	gimple_call when resetting alias information.
>
> 	* gimple-walk.c (walk_gimple_op): Add a checked cast to gimple_call
> 	within GIMPLE_CALL case of switch statement.
>
> 	* gimple.c (gimple_call_reset_alias_info): Require a gimple_call
> 	rather than a plain gimple.
> 	(gimple_build_call_1): Return a gimple_call rather than a gimple.
> 	(gimple_build_call_vec): Likewise.
> 	(gimple_build_call): Likewise.
> 	(gimple_build_call_valist): Likewise.
> 	(gimple_build_call_internal_1): Likewise.
> 	(gimple_build_call_internal): Likewise.
> 	(gimple_build_call_internal_vec): Likewise.
> 	(gimple_build_call_from_tree): Likewise.
> 	(gimple_call_copy_skip_args): Likewise.
> 	(gimple_call_return_flags): Require a const_gimple_call
> 	rather than a plain const_gimple.
>
> 	* gimplify.c (gimplify_call_expr): Convert local from gimple to
> 	gimple_call.
> 	(gimplify_modify_expr_to_memcpy): Likewise.
> 	(gimplify_modify_expr_to_memset): Likewise.
> 	(gimplify_expr): Likewise.
> 	(gimplify_function_tree): Likewise.
> 	(gimplify_modify_expr): Add checked cast to gimple_call.
>
> 	* internal-fn.def: Update comment to indicate that each
> 	expand_NAME now takes a gimple_call, rather than just a gimple.
>
> 	* internal-fn.c (expand_LOAD_LANES): Require a gimple_call
> 	rather than a plain gimple.
> 	(expand_STORE_LANES): Likewise.
> 	(expand_ANNOTATE): Likewise.
> 	(expand_GOMP_SIMD_LANE): Likewise.
> 	(expand_GOMP_SIMD_VF): Likewise.
> 	(expand_GOMP_SIMD_LAST_LANE): Likewise.
> 	(expand_UBSAN_NULL): Likewise.
> 	(ubsan_expand_si_overflow_addsub_check): Likewise.
> 	(ubsan_expand_si_overflow_neg_check): Likewise.
> 	(ubsan_expand_si_overflow_mul_check): Likewise.
> 	(expand_UBSAN_CHECK_ADD): Likewise.
> 	(expand_UBSAN_CHECK_SUB): Likewise.
> 	(expand_UBSAN_CHECK_MUL): Likewise.
> 	(expand_LOOP_VECTORIZED): Likewise.
> 	(expand_MASK_LOAD): Likewise.
> 	(expand_MASK_STORE): Likewise.
> 	(expand_ABNORMAL_DISPATCHER): Likewise.
> 	(expand_BUILTIN_EXPECT): Likewise.
> 	(internal_fn_expanders): Likewise.
> 	(expand_internal_call): Likewise.
>
> 	* internal-fn.h (expand_internal_call): Likewise.
>
> 	* ipa-prop.c (ipa_modify_call_arguments): Convert local from
> 	gimple to gimple_call.
>
> 	* ipa-pure-const.c (check_call): Require a gimple_call rather than
> 	just a gimple.
> 	(check_stmt): Add checked cast to gimple_call within GIMPLE_CALL
> 	case of switch statement.
>
> 	* ipa-split.c (split_function): Convert local from gimple to
> 	gimple_call.
>
> 	* omp-low.c (build_omp_barrier): Likewise.
> 	(lower_rec_input_clauses): Likewise.
>
> 	* trans-mem.c (build_tm_load): Return a gimple_call rather than a
> 	plain gimple.
> 	(build_tm_store): Likewise.
> 	(expand_transaction): Convert local from gimple to gimple_call.
>
> 	* tree-call-cdce.c (check_pow): Require a gimple_call rather than
> 	just a gimple.
> 	(check_builtin_call): Likewise.
> 	(is_call_dce_candidate): Likewise.
> 	(gen_conditions_for_pow): Likewise.
> 	(gen_shrink_wrap_conditions): Likewise.
> 	(shrink_wrap_one_built_in_call): Likewise.
> 	(shrink_wrap_conditional_dead_built_in_calls): Require a
> 	vec<gimple_call> rather than a vec<gimple>.
> 	(tree_call_cdce): Convert local "cond_dead_built_in_calls" from
> 	an auto_vec<gimple> to an auto_vec<gimple_call>; convert invocation
> 	of is_gimple_call to dyn_cast_gimple_call and new local.
>
> 	* tree-cfg.c (notice_special_calls): Require a gimple_call rather
> 	than just a gimple.
> 	* tree-cfg.h (notice_special_calls): Require a gimple_call rather
> 	than just a gimple.
>
> 	* tree-complex.c (expand_complex_libcall): Convert local from
> 	gimple to gimple_call.
>
> 	* tree-inline.c (remap_gimple_stmt): Add checked cast to
> 	gimple_call.
> 	(copy_bb): Likewise; convert local from gimple to gimple_call.
> 	(inline_forbidden_p_stmt): Add checked cast to gimple_call.
>
> 	* tree-nested.c (init_tmp_var_with_call): Require a gimple_call
> 	rather than a gimple.
> 	(convert_nl_goto_reference): Convert local from gimple to
> 	gimple_call.
> 	(convert_tramp_reference_op): Likewise.
> 	(convert_gimple_call): Add checked cast to gimple_call.
>
> 	* tree-nrv.c (dest_safe_for_nrv_p): Require a gimple_call
> 	rather than a gimple.
> 	(execute_return_slot_opt): Convert local from gimple to
> 	gimple_call.  Convert is_gimple_call to dyn_cast_gimple_call
> 	and new local.
>
> 	* tree-object-size.c (alloc_object_size): Require a
> 	const_gimple_call rather than a plain const_gimple.
> 	(pass_through_call): Likewise.
> 	(call_object_size): Require a gimple_call rather than a plain
> 	gimple.
> 	(collect_object_sizes_for): Add checked cast to gimple_call within
> 	GIMPLE_CALL case of switch statement.
> 	(check_for_plus_in_loops_1): Likewise.
> 	(compute_object_sizes): Add checked cast to gimple_call.
>
> 	* tree-profile.c (gimple_gen_interval_profiler): Convert local
> 	from gimple_call to gimple.
> 	(gimple_gen_pow2_profiler): Likewise.
> 	(gimple_gen_one_value_profiler): Likewise.
> 	(gimple_gen_time_profiler): Likewise.
> 	(gimple_gen_average_profiler): Likewise.
> 	(gimple_gen_ior_profiler): Likewise.
>
> 	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Require a
> 	gimple_call rather than a plain gimple.
> 	(ref_maybe_used_by_call_p): Likewise.
> 	(ref_maybe_used_by_stmt_p): Add checked cast to gimple_call.
> 	(call_may_clobber_ref_p_1): Require a gimple_call rather than a
> 	plain gimple.
> 	(call_may_clobber_ref_p): Likewise.
> 	(stmt_may_clobber_ref_p_1): Add checked cast to gimple_call.
>
> 	* tree-ssa-alias.h (call_may_clobber_ref_p): Require a gimple_call
> 	rather than a plain gimple.
>
> 	* tree-ssa-ccp.c (execute_fold_all_builtins): Add checked cast to
> 	gimple_call.
>
> 	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Likewise.
>
> 	* tree-ssa-loop-prefetch.c (emit_mfence_after_loop): Convert local
> 	from gimple to gimple_call.
>
> 	* tree-ssa-math-opts.c (build_and_insert_call): Likewise.
> 	(execute_optimize_bswap): Likewise.
>
> 	* tree-ssa-operands.c (maybe_add_call_vops): Require a gimple_call
> 	rather than a plain gimple.
> 	(parse_ssa_operands): Add checked cast to gimple_call within
> 	GIMPLE_CALL case of switch statement.
>
> 	* tree-ssa-pre.c (compute_avail): Add checked cast to gimple_call.
>
> 	* tree-ssa-sccvn.c (copy_reference_ops_from_call): Require a
> 	gimple_call rather than a plain gimple.
> 	(create_reference_ops_from_call): Likewise.
> 	(valueize_shared_reference_ops_from_call): Likewise.
> 	(visit_reference_op_call): Likewise.
> 	(visit_use): Replace is_gimple_call with dyn_cast_gimple_call and
> 	a new local.
>
> 	* tree-ssa-sccvn.h  (copy_reference_ops_from_call): Require a
> 	gimple_call rather than a plain gimple.
>
> 	* tree-ssa-structalias.c (get_call_vi): Likewise.
> 	(lookup_call_use_vi): Likewise.
> 	(lookup_call_clobber_vi): Likewise.
> 	(get_call_use_vi): Likewise.
> 	(get_call_clobber_vi): Likewise.
> 	(handle_rhs_call): Likewise.
> 	(handle_lhs_call): Likewise.
> 	(handle_const_call): Likewise.
> 	(handle_pure_call): Likewise.
> 	(get_fi_for_callee): Likewise.
> 	(find_func_aliases_for_builtin_call): Likewise.
> 	(find_func_aliases_for_call): Likewise.
> 	(find_func_aliases): Add checked cast to gimple_call.
> 	(find_func_clobbers): Replace is_gimple_call with
> 	dyn_cast_gimple_call and a new local.
> 	(compute_points_to_sets): Likewise.
> 	(ipa_pta_execute): Likewise.
>
> 	* tree-ssa-threadedge.c
> 	(record_temporary_equivalences_from_stmts_at_dest): Add checked cast
> 	to gimple_call.
>
> 	* tree-tailcall.c (find_tail_calls): Convert local from gimple to
> 	gimple_call.  Add checked cast to gimple_call.
>
> 	* tree-vect-data-refs.c (vect_setup_realignment): Split local new_stmt
> 	into two with more tight scopes, one as a gimple_assign, the other as
> 	a gimple_call.
>
> 	* tree-vect-patterns.c (vect_recog_pow_pattern): Convert local to a
> 	gimple_bind.
>
> 	* tree-vect-stmts.c (vectorizable_function): Require a gimple_call
> 	rather than a plain gimple.
> 	(vectorizable_call): Convert "stmt" to a gimple_call, by renaming
> 	parameter, and making stmt be the result of a dyn_cast.
>
> 	* tree-vectorizer.h (vectorizable_function): Require a gimple_call
> 	rather than a plain gimple.
>
> 	* tree.h (fold_call_stmt): Likewise.
> 	(gimple_fold_builtin_snprintf_chk): Likewise.
>
> 	* value-prof.c (check_ic_target): Likewise.
> 	(gimple_ic_transform): Replace check for GIMPLE_CALL with
> 	dyn_cast_gimple_call.
> 	(interesting_stringop_to_profile_p): Require a gimple_call rather
> 	than a plain gimple.
> 	(gimple_stringop_fixed_value): Likewise.
> 	(gimple_stringops_transform): Replace check for GIMPLE_CALL with
> 	dyn_cast_gimple_call.
> 	(gimple_stringops_values_to_profile): Likewise.
>
> 	* vtable-verify.c (verify_bb_vtables): Convert local from a gimple
> 	to a gimple_call.
OK once the const/renaming changes are done.

jeff

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

* Re: [PATCH 31/89] Use subclasses of gimple in various places
  2014-04-21 16:57 ` [PATCH 31/89] Use subclasses of gimple in various places David Malcolm
@ 2014-05-09 19:02   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 19:02 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* asan.c (insert_if_then_before_iter): Require a gimple cond
> 	rathern than a plain gimple.
> 	(instrument_mem_region_access): Strengthen local from gimple to
> 	gimple_cond.
>
> 	* cfgloopmanip.c (create_empty_if_region_on_edge): Likewise.
>
> 	* omp-low.c (simd_clone_adjust): Strengthen local from gimple
> 	to gimple_phi.
>
> 	* sese.c (set_ifsese_condition): Strengthen local from gimple to
> 	gimple_cond.
>
> 	* tree-call-cdce.c (gen_one_condition): Strengthen locals from
> 	gimple to gimple_assign and gimple_cond.
>
> 	* tree-ssa-phiopt.c (minmax_replacement): Likewise.
> 	(cond_store_replacement): Strengthen locals from gimple to
> 	gimple_phi and gimple_assign.
> 	(cond_if_else_store_replacement_1): Likewise.
>
> 	* tree-ssa-pre.c (do_regular_insertion): Strengthen local from
> 	gimple to gimple_assign.
>
> 	* tree-switch-conversion.c (hoist_edge_and_branch_if_true):
> 	Strengthen local from gimple to gimple_cond.
> 	(gen_def_assigns): Return a gimple_assign rather than a plain
> 	gimple.
> 	(gen_inbound_check): Strengthen locals from gimple to gimple_cond
> 	and gimple_assign.
>
> 	* tree-vect-loop-manip.c (slpeel_add_loop_guard): Strengthen local
> 	from gimple to gimple_cond.
> 	(set_prologue_iterations): Strengthen locals from gimple to
> 	gimple_phi and gimple_cond.
>
> 	* value-prof.c (gimple_ic): Strengthen local from gimple to
> 	gimple_phi.
> 	(gimple_stringop_fixed_value): Strengthen locals from gimple to
> 	gimple_assign, gimple_cond, gimple_call, and gimple_phi.
OK once any prerequisites are in and any renaming done.

jeff

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

* Re: [PATCH 32/89] Introduce gimple_try
  2014-04-21 17:13 ` [PATCH 32/89] Introduce gimple_try David Malcolm
@ 2014-05-09 19:05   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-09 19:05 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_try): New typedef.
> 	(const_gimple_try): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_try): New.
>
> 	* gimple-low.c (gimple_try_catch_may_fallthru): Require a
> 	gimple_try rather than a plain gimple.
> 	(gimple_stmt_may_fallthru): Add checked cast to gimple_try.
>
> 	* gimple-pretty-print.c (dump_gimple_try): Require a gimple_try
> 	rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_try within
> 	GIMPLE_TRY case of switch statement.
>
> 	* tree-eh.c (finally_tree_node::parent): Strengthen field from
> 	gimple to gimple_try.
> 	(record_in_finally_tree): Require a gimple_try rather than a plain
> 	gimple.
> 	(collect_finally_tree): Likewise.
> 	(collect_finally_tree_1): Likewise.
> 	(struct leh_tf_state::try_finally_expr): Strengthen field from
> 	gimple to gimple_try.
> 	(struct leh_tf_state::top_p): Likewise.
> 	(lower_eh_must_not_throw): Require a gimple_try rather than a
> 	plain gimple.
> 	(frob_into_branch_around): Likewise.
> 	(lower_try_finally_dup_block): Strengthen local from gimple to
> 	gimple_try.
> 	(honor_protect_cleanup_actions): Split out uses of "x" into new
> 	locals "eh_mnt" and "try_stmt" with stronger types.
> 	(lower_try_finally): Require a gimple_try rather than a plain
> 	gimple.
> 	(lower_catch): Likewise.
> 	(lower_eh_filter): Likewise.
> 	(lower_eh_must_not_throw): Likewise.
> 	(lower_cleanup): Likewise.
> 	(lower_eh_constructs_2): Add checked cast to gimple_try within
> 	GIMPLE_TRY case of switch statement, introducing new local
> 	"try_stmt", using it for type-safety.
OK once const and associated renaming stuff is fixed.

jeff

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

* Re: [PATCH 33/89] Use more concrete types for various gimple statements
  2014-04-21 17:14 ` [PATCH 33/89] Use more concrete types for various gimple statements David Malcolm
  2014-04-21 20:20   ` Bill Schmidt
@ 2014-05-12 17:11   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:11 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* cgraphunit.c (thunk_adjust): Strengthen local "stmt" from gimple
> 	to gimple_assign.
>
> 	* gimple-ssa-isolate-paths.c
> 	(insert_trap_and_remove_trailing_statements): Strengthen local
> 	"new_stmt" from gimple to gimple_call.
>
> 	* gimple-ssa-strength-reduction.c (replace_mult_candidate):
> 	Strengthen local "copy_stmt" from gimple to gimple_assign.
> 	(create_add_on_incoming_edge): Likewise, for "new_stmt".
> 	(insert_initializers): Likewise, for "init_stmt".
> 	(introduce_cast_before_cand): Likewise, for "cast_stmt".
> 	(replace_one_candidate): Likewise, for "copy_stmt" and
> 	"cast_stmt".
>
> 	* gimplify.c (build_stack_save_restore): Require gimple_calls
> 	rather than plain gimples.
> 	(gimplify_bind_expr): Strengthen locals "stack_save" and
> 	"stack_restore" from gimple to gimple_call.  Strengthen "gs"
> 	to gimple_try.
> 	(gimplify_switch_expr): Strengthen local "gimple_switch" from
> 	gimple to gimple_switch, and "new_default" to gimple_label.
> 	(gimplify_cond_expr): Strengthen local "gimple_cond" from gimple
> 	to gimple_cond.
> 	(gimplify_init_constructor): Strengthen local "init" from gimple
> 	to gimple_assign.
> 	(gimplify_cleanup_point_expr): Strengthen local "gtry" from gimple
> 	to gimple_try.
> 	(gimple_push_cleanup): Strengthen locals "ffalse" and "ftrue" from
> 	gimple to gimple_assign.
>
> 	* tree-eh.c (do_goto_redirection): Strengthen local to gimple_goto.
> 	(emit_post_landing_pad): Strengthen local to gimple_label.
>
> 	* tree-outof-ssa.c (insert_backedge_copies): Strengthen local
> 	"stmt" from gimple to gimple_assign.
>
> 	* tree-parloops.c (take_address_of): Likewise.
>
> 	* tree-predcom.c (replace_ref_with): Likewise, for "new_stmt".
> 	(initialize_root_vars_lm): Likewise, for "init_stmt".
> 	(reassociate_to_the_same_stmt): Likewise, for "new_stmt" and "tmp_stmt".
>
> 	* tree-profile.c (gimple_gen_edge_profiler): Likewise, for "stmt1",
> 	"stmt2", "stmt3".
> 	(gimple_gen_ic_profiler): Likewise.
> 	(gimple_gen_ic_func_profiler): Strengthen local "stmt1" from
> 	gimple to gimple_call, and "stmt2" to gimple_assign.
>
> 	* tree-scalar-evolution.c (scev_const_prop): Strengthen local
> 	"ass" from gimple to gimple_assign.
>
> 	* tree-sra.c (build_ref_for_offset): Likewise for "stmt".
> 	(generate_subtree_copies): Likewise; also strengthen "ds" to
> 	gimple_debug.
> 	(init_subtree_with_zero): Likewise.
> 	(sra_modify_expr): Likewise.
> 	(load_assign_lhs_subreplacements): Likewise.
> 	(sra_modify_assign): Strengthen "ds" to gimple_debug.
> 	(sra_ipa_reset_debug_stmts): Likewise for "def_temp".
>
> 	* tree-ssa-ccp.c (insert_clobber_before_stack_restore):
> 	Strengthen local "clobber_stmt" from gimple to gimple_assign.
>
> 	* tree-ssa-dce.c (remove_dead_stmt): Strengthen "note" to
> 	gimple_debug.
>
> 	* tree-ssa-dom.c (record_equivalences_from_stmt): Strengthen
> 	local "new_stmt" from gimple to gimple_assign.
> 	(optimize_stmt): Likewise.
>
> 	* tree-ssa-forwprop.c (simplify_bitwise_binary): Likewise for
> 	4 declarations of "newop".
> 	(simplify_rotate): Likewise for "g".
>
> 	* tree-ssa-loop-im.c (rewrite_reciprocal): Likewise for 3 locals.
> 	(rewrite_bittest): Likewise for "stmt" and "stmt2".
> 	(move_computations_dom_walker::before_dom_children): Likewise for
> 	"new_stmt".
> 	(execute_sm): Likewise for "load" and "store".
>
> 	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts):
> 	Strengthen local "stmt" from gimple to gimple_call.
> 	(unloop_loops): Likewise.
>
> 	* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Strengthen
> 	local "ass" from gimple to gimple_assign.
> 	(remove_unused_ivs): Strengthen "def_temp" to gimple_debug.
>
> 	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Strengthen local "stmt"
> 	from gimple to gimple_assign.
>
> 	* tree-ssa-loop-prefetch.c (issue_prefetch_ref): Strengthen local
> 	"prefetch" from gimple to gimple_call.
>
> 	* tree-ssa-math-opts.c (insert_reciprocals): Strengthen local
> 	"new_stmt" from gimple to gimple_assign.
> 	(powi_as_mults_1): Likewise for "mult_stmt".
> 	(powi_as_mults): Likewise for "div_stmt".
> 	(build_and_insert_binop): Likewise for "stmt".
> 	(build_and_insert_cast): Likewise.
> 	(execute_cse_sincos): Likewise for "stmt" and various decls of
> 	"new_stmt".
> 	(execute_optimize_bswap): Likewise for two decls of "convert_stmt".
> 	(convert_mult_to_fma): Likewise for "fma_stmt".
>
> 	* tree-ssa-phiopt.c (conditional_replacement): Likewise for "new_stmt".
> 	(abs_replacement): Likewise.
>
> 	* tree-ssa-phiprop.c (phiprop_insert_phi): Likewise for "tmp".
>
> 	* tree-ssa-pre.c (create_expression_by_pieces): Likewise for "newstmt".
> 	(eliminate_insert): Likewise for "tem".
>
> 	* tree-ssa-propagate.c (update_gimple_call): Strengthen locals
> 	"new_stmt" and "stmt" from gimple to gimple_call.
> 	(update_call_from_tree): Likewise for "new_stmt".
> 	(substitute_and_fold): Strengthen local "new_stmt" from gimple to
> 	gimple_assign.
>
> 	* tree-ssa-reassoc.c (build_and_add_sum): Likewise for "sum".
> 	(update_ops): Likewise for "g".
> 	(maybe_optimize_range_tests): Likewise.
> 	(rewrite_expr_tree_parallel): Require a gimple_assign rather than
> 	a plain gimple.
> 	(reassociate_bb): Add a checked cast to gimple_assign.
>
> 	* tree-ssa.c (insert_debug_temp_for_var_def): Strengthen local
> 	"def_temp" from gimple to gimple_debug.
>
> 	* tree-switch-conversion.c (emit_case_bit_tests): Strengthen local
> 	"shift_stmt" from gimple to gimple_assign.
>
> 	* tree-tailcall.c (adjust_return_value_with_ops): Likewise for
> 	"stmt".
> 	(update_accumulator_with_ops): Likewise.
>
> 	* tree-vect-data-refs.c (bump_vector_ptr): Likewise for
> 	"incr_stmt".
>
> 	* tree-vect-stmts.c (vectorizable_condition): Likewise for
> 	"new_stmt".
>
> 	* tree-vrp.c (build_assert_expr_for): Likewise for "assertion".
> 	(simplify_truth_ops_using_ranges): Likewise for "newop".
> 	(simplify_float_conversion_using_ranges): Likewise for "conv".
>
> 	* ubsan.c (instrument_member_call): Strengthen local "g" from
> 	gimple to gimple_call.
> 	(instrument_mem_ref): Likewise.
>
> 	* value-prof.c (gimple_divmod_fixed_value): Require a
> 	gimple_assign rather than a plain gimple; strengthen types of locals.
> 	(gimple_mod_pow2): Likewise.
> 	(gimple_mod_subtract): Likewise.
> 	(gimple_divmod_fixed_value_transform): Strengthen local
> 	"stmt" from gimple to gimple_assign.
> 	(gimple_mod_pow2_value_transform): Likewise.
> 	(gimple_mod_subtract_transform): Likewise.
> 	(gimple_ic): Strengthen types of locals.
OK after prerequisites have gone in.

Thanks,
Jeff

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

* Re: [PATCH 34/89] Introduce gimple_omp_atomic_load
  2014-04-21 16:56 ` [PATCH 34/89] Introduce gimple_omp_atomic_load David Malcolm
@ 2014-05-12 17:13   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:13 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_atomic_load): New typedef.
> 	(const_gimple_omp_atomic_load): New typedef.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_atomic_load): Require a
> 	gimple_omp_atomic_load rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_atomic_load
> 	within GIMPLE_OMP_ATOMIC_LOAD case of switch statement.
>
> 	* gimple-walk.c (walk_gimple_op): Likewise, introducing a new local.
>
> 	* gimple.c (gimple_build_omp_atomic_load): Return a
> 	gimple_omp_atomic_load rather than a plain gimple.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_atomic_load):
> 	New.
> 	(gimple_build_omp_atomic_load): Return a gimple_omp_atomic_load
> 	rather than a plain gimple.
> 	(gimple_omp_atomic_load_set_lhs): Require a
> 	gimple_omp_atomic_load rather than a plain gimple.
> 	(gimple_omp_atomic_load_lhs_ptr): Likewise.
> 	(gimple_omp_atomic_load_set_rhs): Likewise.
> 	(gimple_omp_atomic_load_rhs_ptr): Likewise.
> 	(gimple_omp_atomic_load_lhs): Require a
> 	const_gimple_omp_atomic_load rather than a plain const_gimple.
> 	(gimple_omp_atomic_load_rhs): Likewise.
>
> 	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
> 	to gimple_omp_atomic_load within GIMPLE_OMP_ATOMIC_LOAD case of
> 	switch statement.
>
> 	* omp-low.c (expand_omp_atomic): Strengthen type of local "load"
> 	from gimple to gimple_omp_atomic_load.
> 	(lower_omp_1): Add a checked cast to gimple_omp_atomic_load within
> 	GIMPLE_OMP_ATOMIC_LOAD case of switch statement.
OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

Jeff

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

* Re: [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call
  2014-04-21 17:15 ` [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call David Malcolm
@ 2014-05-12 17:16   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:16 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* tree-cfg.c (verify_gimple_call): Require a gimple_call rather
> 	than a plain gimple.
> 	(verify_gimple_stmt): Add checked cast to gimple_call within
> 	GIMPLE_CALL case of switch statement.
OK when prerequisites have gone in.

jeff

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

* Re: [PATCH 35/89] Introduce gimple_omp_atomic_store
  2014-04-21 17:15 ` [PATCH 35/89] Introduce gimple_omp_atomic_store David Malcolm
@ 2014-05-12 17:16   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:16 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_atomic_store): New typedef.
> 	(const_gimple_omp_atomic_store): New typedef.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_atomic_store): Require
> 	a gimple_omp_atomic_store rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_atomic_store
> 	within GIMPLE_OMP_ATOMIC_STORE case of switch statement.
> 	* gimple-walk.c (walk_gimple_op): Likewise.
>
> 	* gimple.c (gimple_build_omp_atomic_store): Return a
> 	gimple_omp_atomic_store rather than a plain gimple.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_atomic_store):
> 	New.
> 	(gimple_build_omp_atomic_store): Return a gimple_omp_atomic_store
> 	rather than a plain gimple.
> 	(gimple_omp_atomic_store_set_val): Require a gimple_omp_atomic_store
> 	rather than a plain gimple.
> 	(gimple_omp_atomic_store_val_ptr): Likewise.
> 	(gimple_omp_atomic_store_val): Require a
> 	const_gimple_omp_atomic_store rather than a plain const_gimple.
>
> 	* gimplify.c (gimplify_omp_atomic): Strengthen locals "loadstmt" and
> 	"storestmt" from gimple to gimple_omp_atomic_load loadstmt and
> 	gimple_omp_atomic_store storestmt respectively.
>
> 	* omp-low.c (expand_omp_atomic): Strengthen local "store" from
> 	gimple to gimple_omp_atomic_store.

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

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

* Re: [PATCH 41/89] Introduce gimple_omp_task
  2014-04-21 16:56 ` [PATCH 41/89] Introduce gimple_omp_task David Malcolm
@ 2014-05-12 17:18   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:18 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_task): New typedef.
> 	(const_gimple_omp_task): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_task): New.
> 	(gimple_build_omp_task): Return a gimple_omp_task
> 	rather than a plain gimple.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_task): Require a
> 	gimple_omp_task rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_task within
> 	GIMPLE_OMP_TASK case of switch statement.
>
> 	* gimple.c (gimple_build_omp_task): Return a gimple_omp_task
> 	rather than a plain gimple.
>
> 	* omp-low.c (finalize_task_copyfn): Require a gimple_omp_task
> 	rather than a plain gimple.
> 	(delete_omp_context): Add checked cast to gimple_omp_task.
> 	(scan_omp_task): Strengthen local "stmt" from gimple to
> 	gimple_omp_task.
> 	(expand_task_call): Require a gimple_omp_task rather than a plain
> 	gimple.
> 	(expand_omp_taskreg): Add checked cast to gimple_omp_task.
> 	(create_task_copyfn): Require a gimple_omp_task rather than a
> 	plain gimple.
> 	(lower_omp_taskreg): Add checked cast to gimple_omp_task.

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

Thanks,
Jeff

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

* Re: [PATCH 42/89] Introduce gimple_omp_single
  2014-04-21 17:13 ` [PATCH 42/89] Introduce gimple_omp_single David Malcolm
@ 2014-05-12 17:18   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:18 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_single): New typedef.
> 	(const_gimple_omp_single): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_single): New.
> 	(gimple_build_omp_single): Return a gimple_omp_single rather than
> 	a plain gimple.
> 	(gimple_omp_single_set_clauses): Require a gimple_omp_single
> 	rather than a plain gimple.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_single): Require a
> 	gimple_omp_single rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_single within
> 	GIMPLE_OMP_SINGLE case of switch statement.
>
> 	* gimple.c (gimple_build_omp_single): Return a gimple_omp_single
> 	rather than a plain gimple.
>
> 	* omp-low.c (scan_omp_single): Require a gimple_omp_single rather
> 	than a plain gimple.
> 	(scan_omp_1_stmt): Add checked cast to gimple_omp_single within
> 	GIMPLE_OMP_SINGLE case of switch statement.
> 	(lower_omp_single_simple): Require a gimple_omp_single rather
> 	than a plain gimple.
> 	(lower_omp_single_copy): Likewise.
> 	(lower_omp_single): Strengthen local "single_stmt" from gimple to
> 	gimple_omp_single.

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

Jeff

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

* Re: [PATCH 44/89] Introduce gimple_omp_teams
  2014-04-21 17:15 ` [PATCH 44/89] Introduce gimple_omp_teams David Malcolm
@ 2014-05-12 17:19   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:19 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_teams): New typedef.
> 	(const_gimple_omp_teams): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_teams): New.
> 	(gimple_build_omp_teams): Return a gimple_omp_teams rather than a
> 	plain gimple.
> 	(gimple_omp_teams_set_clauses): Require a gimple_omp_teams rather
> 	than a plain gimple.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_teams): Require a
> 	gimple_omp_teams rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_teams within
> 	GIMPLE_OMP_TEAMS case of switch statement.
>
> 	* gimple.c (gimple_build_omp_teams): Return a gimple_omp_teams
> 	rather than a plain gimple.
>
> 	* omp-low.c (scan_omp_teams): Likewise.
> 	(scan_omp_1_stmt): Add checked cast to gimple_omp_teams within
> 	GIMPLE_OMP_TEAMS case of switch statement.
> 	(lower_omp_teams): Strengthen local "teams_stmt" from gimple to
> 	gimple_omp_teams.
OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

Jeff

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

* Re: [PATCH 37/89] Introduce gimple_omp_critical
  2014-04-21 16:56 ` [PATCH 37/89] Introduce gimple_omp_critical David Malcolm
@ 2014-05-12 17:21   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:21 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_critical): New typedef.
> 	(const_gimple_omp_critical): New typedef.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_critical): Require a
> 	gimple_omp_critical rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_critical
> 	within GIMPLE_OMP_CRITICAL case of switch statement.
>
> 	* gimple-walk.c (walk_gimple_op): Likewise.
>
> 	* gimple.c (gimple_build_omp_critical): Return a gimple_omp_critical
> 	rather than a plain gimple.
> 	(gimple_copy): Add checked casts to gimple_omp_critical
> 	within GIMPLE_OMP_CRITICAL case of switch statement.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_critical): New.
> 	(gimple_statement_base::dyn_cast_gimple_omp_critical): New.
> 	(gimple_debug): Likewise.
> 	(gimple_build_omp_critical): Return a gimple_omp_critical rather
> 	than a plain gimple.
> 	(gimple_omp_critical_name): Require a const_gimple_omp_critical
> 	rather than a plain const_gimple.
> 	(gimple_omp_critical_name_ptr): Require a gimple_omp_critical
> 	rather than a plain gimple.
> 	(gimple_omp_critical_set_name): Likewise.
>
> 	* omp-low.c (check_omp_nesting_restrictions): Add a checked cast
> 	to gimple_omp_critical within GIMPLE_OMP_CRITICAL case of switch
> 	statement, introducing a new local "other_crit" for type-safety.
> 	(lower_omp_critical): Strengthen local "stmt" to
> 	gimple_omp_critical.
>
> 	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
> 	gimple_omp_critical within GIMPLE_OMP_CRITICAL case of switch
> 	statement.


OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.
Thanks,
Jeff

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

* Re: [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals
  2014-04-21 17:12 ` [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals David Malcolm
@ 2014-05-12 17:22   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:22 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* omp-low.c (finalize_task_copyfn): Strengthen local "bind" from
> 	plain gimple to gimple_bind.
> 	(lower_rec_input_clauses): Strengthen local "g" from
> 	plain gimple to gimple_assign.
> 	(lower_lastprivate_clauses): Likewise for "stmt" to gimple_cond
> 	and "g" to gimple_call.
> 	(expand_omp_for_init_vars): Likewise, for two decls of "stmt" to
> 	gimple_assign.
> 	(expand_omp_atomic_pipeline): Likewise for one decl of "stmt".
> 	(expand_omp_atomic_mutex): Likewise.
> 	(lower_omp_master): Likewise for "x" to gimple_call.
> 	(lower_omp_ordered): Likewise.
OK once prerequisites have gone in.

jeff

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

* Re: [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi
  2014-04-21 16:56 ` [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi David Malcolm
@ 2014-05-12 17:22   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:22 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_arg_set_location): Require a gimple_phi
> 	rather than a plain gimple.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args
  2014-04-21 17:13 ` [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args David Malcolm
@ 2014-05-12 17:23   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:23 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.c (gimple_call_copy_skip_args): Require a gimple_call.
> 	* gimple.h (gimple_call_copy_skip_args): Likewise.
OK once prerequisites have gone in.

Jeff

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

* Re: [PATCH 53/89] More gimple_phi
  2014-04-21 17:12 ` [PATCH 53/89] More gimple_phi David Malcolm
@ 2014-05-12 17:23   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:23 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_set_result): Require a gimple_phi rather
> 	than a plain gimple.
> 	(gimple_phi_set_arg): Likewise.
>
> 	* tree-outof-ssa.c (remove_gimple_phi_args): Likewise; add a checked
> 	cast to gimple_phi.
>
> 	* tree-sra.c (replace_removed_params_ssa_names): Add a checked
> 	cast to gimple_phi.
Ok once prerequisites have gone in.
jeff

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

* Re: [PATCH 58/89] Make gimple_label_set_label require a gimple_label
  2014-04-21 16:56 ` [PATCH 58/89] Make gimple_label_set_label require a gimple_label David Malcolm
@ 2014-05-12 17:24   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:24 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_label_set_label): Require a gimple_label.
OK once prerequisites have gone in.
jeff
\

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

* Re: [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto
  2014-04-21 16:57 ` [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto David Malcolm
@ 2014-05-12 17:24   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:24 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_goto_set_dest): Require a gimple_goto.
>
> 	* tree-cfg.c (factor_computed_gotos): Add checked cast to gimple_goto.
> 	(cleanup_dead_labels): Likewise.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 60/89] Concretize gimple_catch_types
  2014-04-21 16:57 ` [PATCH 60/89] Concretize gimple_catch_types David Malcolm
@ 2014-05-12 17:25   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:25 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_catch_types): Require a const_gimple_catch
> 	rather than a const_gimple.
> ---
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set
  2014-04-21 17:14 ` [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set David Malcolm
@ 2014-05-12 17:25   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:25 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_use_set): Require a gimple_call.
> 	(gimple_call_clobber_set): Likewise.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup
  2014-04-21 16:57 ` [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup David Malcolm
@ 2014-05-12 17:28   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:28 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_try_set_catch_is_cleanup): Require a gimple_try.
>
> 	* gimplify.c (gimplify_expr): Convert local "try_" from a gimple
> 	to a gimple_try.
OK after prerequisites have gone in.
jeff

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

* Re: [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places
  2014-04-21 16:57 ` [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places David Malcolm
@ 2014-05-12 17:29   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:29 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* tree-parloops.c (reduction_info::keep_res): Strengthen field
> 	from plain gimple to gimple_phi.
> 	(transform_to_exit_first_loop): Strengthen locals "phi", "nphi"
> 	to gimple_phi.  Eliminate early decl of gimple_stmt_iterator gsi
> 	in favor of more tightly scoped gimple_phi_iterators, and a final
> 	later decl as a gimple_stmt_iterator.
> ---
OK once prerequisites have gone in.

Thanks,
Jeff

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

* Re: [PATCH 45/89] Introduce gimple_omp_sections
  2014-04-21 16:57 ` [PATCH 45/89] Introduce gimple_omp_sections David Malcolm
@ 2014-05-12 17:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_sections): New typedef.
> 	(const_gimple_omp_sections): New typedef.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_sections): Require a
> 	gimple_omp_sections rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_sections within
> 	GIMPLE_OMP_SECTIONS case of switch statement.
>
> 	* gimple.c (gimple_build_omp_sections): Return a
> 	gimple_omp_sections rather than a plain gimple.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_sections): New.
> 	(gimple_build_omp_sections): Return a gimple_omp_sections rather
> 	than a plain gimple.
>
> 	* omp-low.c (scan_omp_sections): Require a gimple_omp_sections
> 	rather than a plain gimple.
> 	(scan_omp_1_stmt): Add checked cast to gimple_omp_sections within
> 	GIMPLE_OMP_SECTIONS case of switch statement.
> 	(expand_omp_sections): Strengthen local "sections_stmt" from gimple
> 	to gimple_omp_sections.
> 	(lower_omp_sections): Likewise for "stmt".

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.
Jeff

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

* Re: [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call.
  2014-04-21 17:15 ` [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call David Malcolm
@ 2014-05-12 17:35   ` Jeff Law
  2014-05-12 17:49   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:35 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_return_slot_opt_p): Require a gimple_call
> 	rather than a plain gimple.
>
> 	* gimple-walk.c (walk_stmt_load_store_addr_ops): Convert usage of
> 	is_gimple_call to dyn_cast_gimple_call, introducing a new local
> 	"call_stmt".
>
> 	* trans-mem.c (expand_call_tm): Split local "stmt", strengthening
> 	from plain gimple to a gimple_call, and introducing new local
> 	gimple_assign "assign_stmt".
>
> 	* tree-inline.c (expand_call_inline):  Convert check of code against
> 	GIMPLE_CALL to dyn_cast_gimple_call, introducing a new local
> 	"call_stmt".
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 43/89] Introduce gimple_omp_target
  2014-04-21 17:12 ` [PATCH 43/89] Introduce gimple_omp_target David Malcolm
@ 2014-05-12 17:36   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:36 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_target): New typedef.
> 	(const_gimple_omp_target): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_target): New.
> 	(gimple_build_omp_target): Return a gimple_omp_target
> 	rather than a plain gimple.
> 	(gimple_omp_target_set_clauses): Require a gimple_omp_target
> 	rather than a plain gimple.
> 	(gimple_omp_target_set_kind): Likewise.
> 	(gimple_omp_target_child_fn_ptr): Likewise.
> 	(gimple_omp_target_set_child_fn): Likewise.
> 	(gimple_omp_target_data_arg_ptr): Likewise.
> 	(gimple_omp_target_set_data_arg): Likewise.
> 	(gimple_omp_target_child_fn): Require a const_gimple_omp_target
> 	rather than a plain const_gimple.
> 	(gimple_omp_target_data_arg): Likewise.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_target): Require a
> 	gimple_omp_target rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add checked cast to gimple_omp_target within
> 	GIMPLE_OMP_TARGET case of switch statement.
>
> 	* gimple.c (gimple_build_omp_target): Return a gimple_omp_target
> 	rather than a plain gimple.
>
> 	* gimplify.c (gimplify_omp_target_update): Strengthen local "stmt"
> 	from gimple to gimple_omp_target.
>
> 	* omp-low.c (scan_omp_target): Require a gimple_omp_target rather
> 	than a plain gimple.
> 	(scan_omp_1_stmt): Add checked cast to gimple_omp_target within
> 	GIMPLE_OMP_TARGET case of switch statement.
> 	(expand_omp_target): Strengthen local "entry_stmt" from gimple to
> 	gimple_omp_target.
> 	(lower_omp_target): Likewise for "stmt".
OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.
Jeff

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

* Re: [PATCH 38/89] Introduce gimple_omp_for
  2014-04-21 17:14 ` [PATCH 38/89] Introduce gimple_omp_for David Malcolm
@ 2014-05-12 17:38   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:38 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_for): New.
> 	(const_gimple_omp_for): New.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_for): New.
> 	(gimple_statement_base::dyn_cast_gimple_omp_for): New.
> 	(gimple_build_omp_for): Return a gimple_omp_for rather than a
> 	plain gimple.
> 	(gimple_omp_for_set_kind): Require a gimple_omp_for rather than a
> 	plain gimple.
> 	(gimple_omp_for_set_combined_p): Likewise.
> 	(gimple_omp_for_set_combined_into_p): Likewise.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_for): Require a
> 	gimple_omp_for rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_for in
> 	GIMPLE_OMP_FOR case of switch statement.
>
> 	* gimple.c (gimple_build_omp_for): Return a gimple_omp_for rather
> 	than a plain gimple.
> 	(gimple_copy): Add a checked cast to gimple_omp_for and a new local.
>
> 	* gimplify.c (gimplify_omp_for): Strengthen local "gfor" from
> 	gimple to gimple_omp_for.
>
> 	* omp-low.c (omp_for_data::for_stmt): Strengthen field from gimple
> 	to gimple_omp_for.
> 	(extract_omp_for_data): Require a gimple_omp_for rather than a
> 	plain gimple.
> 	(workshare_safe_to_combine_p): Add a checked cast to
> 	gimple_omp_for.
> 	(get_ws_args_for): Convert check of code against GIMPLE_OMP_FOR
> 	with a dyn_cast_gimple_omp_for and a new local.
> 	(scan_omp_parallel): Add a checked cast to gimple_omp_for and a
> 	new local.
> 	(scan_omp_for): Require a gimple_omp_for rather than a plain
> 	gimple.
> 	(scan_omp_1_stmt): Add a checked cast to gimple_omp_for in
> 	GIMPLE_OMP_FOR case of switch statement.
> 	(expand_omp_for): Add a checked cast to gimple_omp_for.
> 	(lower_omp_for): Strengthen local "stmt" from gimple to
> 	gimple_omp_for.
>
> 	* tree-nested.c (walk_gimple_omp_for): Require a gimple_omp_for
> 	rather than a plain gimple.
> 	(convert_nonlocal_reference_stmt): Add a checked cast to
> 	gimple_omp_for in GIMPLE_OMP_FOR case of switch statement.
> 	(convert_local_reference_stmt): Likewise.
>
> 	* tree-parloops.c (create_parallel_loop): Strengthen local
> 	"for_stmt" from gimple to gimple_omp_for.
> ---

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.
Jeff

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

* Re: [PATCH 36/89] Introduce gimple_omp_continue
  2014-04-21 17:13 ` [PATCH 36/89] Introduce gimple_omp_continue David Malcolm
@ 2014-05-12 17:42   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:42 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_continue): New typedef.
> 	(const_gimple_omp_continue): New typedef.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_continue): New.
> 	(gimple_build_omp_continue): Return a gimple_omp_continue rather
> 	than a plain gimple.
> 	(gimple_omp_continue_control_def): Require a
> 	const_gimple_omp_continue rather than a plain const_gimple.
> 	(gimple_omp_continue_control_use): Likewise.
> 	(gimple_omp_continue_control_def_ptr): Require a gimple_omp_continue
> 	rather than a plain gimple.
> 	(gimple_omp_continue_set_control_def): Likewise.
> 	(gimple_omp_continue_control_use_ptr): Likewise.
> 	(gimple_omp_continue_set_control_use): Likewise.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_continue): Require a
> 	gimple_omp_continue rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_continue
> 	within GIMPLE_OMP_CONTINUE case of switch statement.
>
> 	* gimple-walk.c (walk_gimple_op): Likewise, adding a new local.
>
> 	* gimple.c (gimple_build_omp_continue): Return a
> 	gimple_omp_continue rather than a plain gimple.
>
> 	* omp-low.c (gimple_build_cond_empty): Return a gimple_cond
> 	rather than a plain gimple.
> 	(expand_omp_for_generic): Split local "stmt" into "assign_stmt",
> 	"cont_stmt", "cond_stmt", "call_stmt" of types gimple_assign,
> 	gimple_omp_continue, gimple_cond, gimple_call respectively.
> 	(expand_omp_for_static_nochunk): Likewise, splitting into two
> 	"cond_stmt" decls. "assign_stmt", "cont_stmt"
> 	(expand_omp_for_static_chunk): Likewise, splitting into
> 	"cond_stmt", "assign_stmt", "cont_stmt".
> 	(expand_omp_sections): Strengthen local "cont" from gimple to
> 	gimple_omp_continue.


OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

THanks,
Jeff


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

* Re: [PATCH 39/89] Introduce gimple_omp_parallel
  2014-04-21 16:56 ` [PATCH 39/89] Introduce gimple_omp_parallel David Malcolm
@ 2014-05-12 17:46   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:46 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* coretypes.h (gimple_omp_parallel): New typedef.
> 	(const_gimple_omp_parallel): New typedef.
>
> 	* cgraphbuild.c (build_cgraph_edges): Convert check of code
> 	against GIMPLE_OMP_PARALLEL to a dyn_cast_gimple_omp_parallel and
> 	new local.
>
> 	* gimple-pretty-print.c (dump_gimple_omp_parallel): Require a
> 	gimple_omp_parallel rather than a plain gimple.
> 	(pp_gimple_stmt_1): Add a checked cast to gimple_omp_parallel
> 	within GIMPLE_OMP_PARALLEL case of switch statement.
>
> 	* gimple-walk.c (walk_gimple_op): Likewise, introducing a local.
>
> 	* gimple.c (gimple_build_omp_parallel): Return a
> 	gimple_omp_parallel rather than a plain gimple.
> 	(gimple_copy): Add checked casts to gimple_omp_parallel within
> 	GIMPLE_OMP_PARALLEL case of switch statement, introducing locals.
>
> 	* gimple.h (gimple_statement_base::as_a_gimple_omp_parallel): New.
> 	(gimple_statement_base::dyn_cast_gimple_omp_parallel): New.
> 	(gimple_build_omp_parallel): Return a gimple_omp_parallel rather
> 	than a plain gimple.
> 	(gimple_omp_parallel_clauses_ptr): Require a gimple_omp_parallel
> 	rather than a plain gimple.
> 	(gimple_omp_parallel_set_clauses): Likewise.
> 	(gimple_omp_parallel_data_arg_ptr): Likewise.
> 	(gimple_omp_parallel_set_data_arg): Likewise.
> 	(gimple_omp_parallel_child_fn_ptr): Likewise.
> 	(gimple_omp_parallel_set_child_fn): Likewise.
> 	(gimple_omp_parallel_child_fn): Require a
> 	const_gimple_omp_parallel rather than a plain const_gimple.
> 	(gimple_omp_parallel_data_arg): Likewise.
>
> 	* omp-low.c (scan_omp_parallel): Strengthen local "stmt" from
> 	gimple to gimple_omp_parallel.
> 	(expand_parallel_call): Require a gimple_omp_parallel for
> 	"entry_stmt" rather than a plain gimple.
> 	(remove_exit_barrier):  Strengthen local "parallel_stmt" from
> 	gimple to gimple_omp_parallel.
> 	(expand_omp_taskreg): Add checked cast to gimple_omp_parallel.
>
> 	* tree-inline.c (remap_gimple_stmt): Add a checked cast to
> 	gimple_omp_parallel within GIMPLE_OMP_PARALLEL case of switch
> 	statement, introducing local.
> ---

OK with expected changes due to renaming/updates to const handling.

Please repost the final patch for archival purposes.

jeff

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

* Re: [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
  2014-04-21 17:12 ` [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location " David Malcolm
@ 2014-05-12 17:48   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:48 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_arg_def_ptr): Require a gimple_phi rather
> 	than a plain gimple.
> 	(gimple_phi_arg_has_location): Likewise.
>
> 	* gimple-streamer-in.c (input_phi): Return a gimple_phi rather
> 	than a plain gimple.
> 	* gimple-streamer-out.c (output_phi): Require a gimple_phi rather
> 	than a plain gimple.
> 	(output_bb): Convert iteration to a gimple_phi_iterator, and local
> 	"phi" to gimple_phi.
>
> 	* omp-low.c (expand_omp_for_static_chunk): Convert iterator "psi"
> 	to a gimple_phi_iterator; convert locals "phi" and "nphi" to be
> 	gimple_phi.
>
> 	* tree-cfg.c (gimple_duplicate_sese_tail): Likewise for "psi" and
> 	"phi".
> 	(move_block_to_fn): Introduce new gimple_phi_iterator "psi", using
> 	it in place of "gsi" where necessary.  Convert "phi" to be a
> 	gimple_phi.
>
> 	* tree-cfgcleanup.c (remove_forwarder_block): Likewise.
>
> 	* tree-vect-loop-manip.c (vect_loop_versioning): Convert "gsi" to
> 	a gimple_phi_iterator, and "orig_phi" and "new_phi" to be
> 	gimple_phi.
>
> 	* tree.c (find_decls_types_in_node): Introduce new
> 	gimple_phi_iterator "psi", using it in place of "si" where
> 	necessary.  Convert "phi" to be a gimple_phi.

OK once prerequisites have gone in.

Thanks,
Jeff

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

* Re: [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure
  2014-04-21 16:56 ` [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure David Malcolm
@ 2014-05-12 17:49   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:49 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_eh_filter_set_types): Require a gimple_eh_filter.
> 	(gimple_eh_filter_set_failure): Likewise.
> 	* gimple.c (gimple_copy): Add checked casts to gimple_eh_filter
> 	within GIMPLE_EH_FILTER case.
> ---
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call.
  2014-04-21 17:15 ` [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call David Malcolm
  2014-05-12 17:35   ` Jeff Law
@ 2014-05-12 17:49   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:49 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_return_slot_opt_p): Require a gimple_call
> 	rather than a plain gimple.
>
> 	* gimple-walk.c (walk_stmt_load_store_addr_ops): Convert usage of
> 	is_gimple_call to dyn_cast_gimple_call, introducing a new local
> 	"call_stmt".
>
> 	* trans-mem.c (expand_call_tm): Split local "stmt", strengthening
> 	from plain gimple to a gimple_call, and introducing new local
> 	gimple_assign "assign_stmt".
>
> 	* tree-inline.c (expand_call_inline):  Convert check of code against
> 	GIMPLE_CALL to dyn_cast_gimple_call, introducing a new local
> 	"call_stmt".
OK once prerequisites have gone in.
Jeff

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

* Re: [PATCH 65/89] Concretize three gimple_try_set_ accessors
  2014-04-21 16:56 ` [PATCH 65/89] Concretize three gimple_try_set_ accessors David Malcolm
@ 2014-05-12 17:51   ` Jeff Law
  2014-05-12 17:54   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:51 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.c (gimple_copy): Add checked casts to gimple_try.
>
> 	* gimple.h (gimple_statement_base::dyn_cast_gimple_try): New.
> 	(gimple_try_set_kind): Require a gimple_try.
> 	(gimple_try_set_eval): Likewise.
> 	(gimple_try_set_cleanup): Likewise.
>
> 	* tree-eh.c (optimize_double_finally): Require a pair of gimple_try
> 	statements.
> 	(refactor_eh_r): Convert code comparisons to dynamic casts.
> ---
OK once prerequisites have gone in.
Jeff

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

* Re: [PATCH 65/89] Concretize three gimple_try_set_ accessors
  2014-04-21 16:56 ` [PATCH 65/89] Concretize three gimple_try_set_ accessors David Malcolm
  2014-05-12 17:51   ` Jeff Law
@ 2014-05-12 17:54   ` Jeff Law
  1 sibling, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:54 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.c (gimple_copy): Add checked casts to gimple_try.
>
> 	* gimple.h (gimple_statement_base::dyn_cast_gimple_try): New.
> 	(gimple_try_set_kind): Require a gimple_try.
> 	(gimple_try_set_eval): Likewise.
> 	(gimple_try_set_cleanup): Likewise.
>
> 	* tree-eh.c (optimize_double_finally): Require a pair of gimple_try
> 	statements.
> 	(refactor_eh_r): Convert code comparisons to dynamic casts.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi
  2014-04-21 17:12 ` [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi David Malcolm
@ 2014-05-12 17:54   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:54 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_arg_location_from_edge): Require a
> 	gimple_phi.
>
> 	* tree-parloops.c (create_parallel_loop): Split up local variable
> 	"stmt", introducing other locals for the various statements created
> 	by this function.  Reuse "stmt" within the phi-handling code, and
> 	change to type gimple_phi, since this is the only remaining
> 	"non-phi" user of gimple_phi_arg_location_from_edge.
OK once prerequisites have gone in

Thanks,
jefff

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

* Re: [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond.
  2014-04-21 17:12 ` [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond David Malcolm
@ 2014-05-12 17:58   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:58 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_set_true_label): Require a gimple_cond.
> 	(gimple_cond_set_false_label): Likewise.
>
> 	* tree-cfg.c (make_cond_expr_edges): Convert "entry" from gimple to
> 	a gimple_cond.
> 	(cleanup_dead_labels): Introduce a checked cast to a gimple_cond within
> 	the GIMPLE_COND case.
OK once prerequisites have gone in.

Jeff

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

* Re: [PATCH 70/89] Concretize locals within expand_omp_for_init_counts
  2014-04-21 16:57 ` [PATCH 70/89] Concretize locals within expand_omp_for_init_counts David Malcolm
@ 2014-05-12 17:59   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:59 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* omp-low.c (expand_omp_for_init_counts): Eliminate local "stmt"
> 	in favor of new locals "cond_stmt" and "assign_stmt" with more
> 	concrete types.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 78/89] Concretize gimple_call_set_nothrow
  2014-04-21 16:57 ` [PATCH 78/89] Concretize gimple_call_set_nothrow David Malcolm
@ 2014-05-12 17:59   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 17:59 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_set_nothrow): Require a gimple_call.
>
> 	* trans-mem.c (ipa_tm_insert_gettmclone_call): Likewise.
> 	(ipa_tm_transform_calls_redirect): Add checked cast to gimple call; this
> 	is only called for gsi on a GIMPLE_CALL statement.

OK once prerequisites have gone in.
Jeff

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

* Re: [PATCH 84/89] Concretize gimple_call_arg_flags
  2014-04-21 16:57 ` [PATCH 84/89] Concretize gimple_call_arg_flags David Malcolm
@ 2014-05-12 18:02   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:02 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_arg_flags): Require a const_gimple_call
> 	rather than a const_gimple.
>
> 	* gimple.c (gimple_call_fnspec): Likewise.
> 	(gimple_call_arg_flags): Likewise.
This is fine, but will need tweaking once the const changes go in.  The 
final form is approved given its triviality, but please post for 
archival purposes.

jeff

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

* Re: [PATCH 81/89] Concretize gimple_call_set_fn
  2014-04-21 17:14 ` [PATCH 81/89] Concretize gimple_call_set_fn David Malcolm
@ 2014-05-12 18:04   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:04 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_set_fn): Require a gimple_call.
>
> 	* trans-mem.c (dump_tm_memopt_transform): Likewise.
> 	(tm_memopt_transform_blocks): Add checked casts to gimple_call in
> 	suites guarded by is_tm_simple_{load|store}, which enforce that
> 	the statement must be a GIMPLE_CALL; use this when invoking
> 	dump_tm_memopt_transform.
This is fine once prerequisites have gone in.
jeff

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

* Re: [PATCH 82/89] Concretize gimple_call_set_fntype
  2014-04-21 16:57 ` [PATCH 82/89] Concretize gimple_call_set_fntype David Malcolm
@ 2014-05-12 18:04   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:04 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_set_fntype): Require a gimple_call.
>
> 	* omp-low.c (lower_omp_1): Add a new local gimple_call "call_stmt",
> 	from a checked cast to gimple_call within the "case GIMPLE_CALL",
> 	for the regions where "stmt" is not subsequently overwritten.
This is fine once prerequisites have gone in.
jeff

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

* Re: [PATCH 80/89] Tweak to gimplify_modify_expr
  2014-04-21 16:57 ` [PATCH 80/89] Tweak to gimplify_modify_expr David Malcolm
@ 2014-05-12 18:21   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:21 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimplify.c (gimplify_modify_expr): Introduce local "call_stmt".
OK once prerequisites have gone in.

Jeff

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

* Re: [PATCH 79/89] Concretize gimple_call_nothrow_p
  2014-04-21 17:13 ` [PATCH 79/89] Concretize gimple_call_nothrow_p David Malcolm
@ 2014-05-12 18:37   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:37 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_nothrow_p): Require a gimple_call.
>
> 	* tree-eh.c (stmt_could_throw_p): Add checked cast to gimple_call.
>
> 	* tree-vect-slp.c (vect_build_slp_tree_1): Replace call to
> 	is_gimple_call with dyn_cast_gimple_call, introducing a local.
OK once prerequisites have gone in.
Jeff

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

* Re: [PATCH 73/89] Concretize gimple_cond_{true|false}_label
  2014-04-21 16:57 ` [PATCH 73/89] Concretize gimple_cond_{true|false}_label David Malcolm
@ 2014-05-12 18:37   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 18:37 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_true_label): Require a const_gimple_cond
> 	rather than just a const_gimple.
> 	(gimple_cond_false_label): Likewise.
>
> 	* omp-low.c (diagnose_sb_2): Add checked cast to gimple_cond within
> 	case GIMPLE_COND.
> 	* tree-eh.c (maybe_record_in_goto_queue): Likewise.
>
> 	* tree-cfg.c (verify_gimple_stmt): Add a checked cast to gimple_cond
> 	within "case GIMPLE_COND", splitting it out into...
> 	(verify_gimple_label): New.
OK once prerequisites have gone in.
jeff

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

* Re: [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi.
  2014-04-21 16:57 ` [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi David Malcolm
@ 2014-05-12 19:21   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:21 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_arg_location): Require a gimple_phi.
>
> 	* tree-into-ssa.c (rewrite_update_phi_arguments): Replace a check
> 	for code GIMPLE_PHI with a dyn_cast and a new local.
> 	* tree-ssa-ter.c (ter_is_replaceable_p): Likewise.
>
> 	* tree-ssa-live.c (remove_unused_locals): Replace a
> 	gimple_stmt_iterator with a gimple_phi_iterator, using it to make
> 	local "phi" be a gimple_phi.
> 	* tree-ssa-phiopt.c (tree_ssa_phiopt_worker): Likewise.
>
> 	* tree-ssa-phiopt.c (conditional_replacement): Require a gimple_phi.
> 	(single_non_singleton_phi_for_edges): Return a gimple_phi; update
> 	local to be a gimple_phi, adding checked casts since we're working
> 	on a sequence of gimple_phi.
> 	(conditional_replacement): Require a gimple_phi.
> ---
OK once prerequisites go in.

Thanks,
Jeff

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

* Re: [PATCH 74/89] Concretize gimple_cond_set_code
  2014-04-21 17:13 ` [PATCH 74/89] Concretize gimple_cond_set_code David Malcolm
@ 2014-05-12 19:22   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:22 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_set_code): Require a gimple_cond.
>
> 	* tree-complex.c (expand_complex_comparison): Add a checked cast to
> 	gimple_cond within "case GIMPLE_COND".
>
> 	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond"
> 	to a gimple_cond, adding a checked cast.  The existing code requires
> 	that the last statement before the exit edge have code GIMPLE_COND,
> 	though it's not clear to me where this is verified.
>
> 	* tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast
> 	to gimple_cond on "use->stmt".
>
> 	* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert
> 	local "exit_if" to gimple_cond, adding a checked cast.  It's not
> 	clear to me exactly where the GIMPLE_COND-ness of this is
> 	established, but the existing code requires it.
> 	(canonicalize_loop_ivs): Similarly for "stmt".
>
> 	* tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace
> 	a check against GIMPLE_COND with a dyn_cast_gimple_cond.
> ---
Fine once prerequisites go in.
Jeff

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

* Re: [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs}
  2014-04-21 17:14 ` [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs} David Malcolm
@ 2014-05-12 19:24   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:24 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_set_lhs): Require a gimple_cond.
> 	(gimple_cond_set_rhs): Likewise.
>
> 	* tree-parloops.c (transform_to_exit_first_loop): Convert locals
> 	"cond_stmt" and "cond_nit" to gimple_cond, adding checked casts,
> 	since the existing code assumes that code is GIMPLE_COND.  Convert
> 	"stmt" to a gimple_assign.
> 	(create_parallel_loop): Likewise for "cond_stmt".
>
> 	* tree-ssa-loop-im.c (rewrite_bittest): Replace check for code
> 	GIMPLE_COND with a dyn_cast, adding new local "cond_stmt".
> ---
OK once prereqs go in.

Jeff

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

* Re: [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr
  2014-04-21 16:57 ` [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr David Malcolm
@ 2014-05-12 19:26   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:26 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_lhs_ptr): Require a const_gimple_cond
> 	rather than just a const_gimple_cond.
> 	(gimple_cond_rhs_ptr): Likewise.
>
> 	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
> 	to gimple_cond within "case GIMPLE_COND".
> 	* omp-low.c (lower_omp_1): Likewise.
>
> 	* omp-low.c (expand_omp_simd): Introduce a new local cond_stmt
> 	to express that the conditional is indeed a gimple_cond.
>
> 	* tree-ssa-loop-ivopts.c (extract_cond_operands): Add a checked
> 	cast to gimple_cond within a region where the code is known to
> 	be GIMPLE_COND.
OK when prereqs go in.

Jeff

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

* Re: [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p
  2014-04-21 17:12 ` [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p David Malcolm
@ 2014-05-12 19:28   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:28 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_assign_nontemporal_move_p): Require a
> 	const_gimple_assign rather than a const_gimple.
>
> 	* cfgexpand.c (expand_gimple_stmt_1): Add local assign_stmt and
> 	checked cast within "case GIMPLE_ASSIGN".
>
> 	* gimple-streamer-out.c (output_gimple_stmt): Add checked cast to
> 	gimple_assign.
OK when prereqs have gone in.
jeff

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

* Re: [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments
  2014-04-21 16:57 ` [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments David Malcolm
@ 2014-05-12 19:30   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:30 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_copy_flags): Require gimple_calls.
>
> 	* ipa-prop.c (ipa_modify_call_arguments): Require a gimple_call.
> 	* ipa-prop.h (ipa_modify_call_arguments): Likewise.
>
> 	* tree-inline.c (copy_bb): Replace is_gimple_call with new local
> 	and call to dyn_cast_gimple_call, updating gimple_call_ uses to use
> 	the type-checked local.
>
> 	* tree-sra.c (convert_callers): Replace check for GIMPLE_CALL with
> 	a dyn_cast.
OK when prereqs go in.

jeff

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

* Re: [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c
  2014-04-21 16:57 ` [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c David Malcolm
@ 2014-05-12 19:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* tree-ssa-dom.c (struct hashable_expr): Strengthen field
> 	call.fn_from from gimple to gimple_call.
> 	(initialize_hash_element): Replace check against GIMPLE_CALL
> 	with dyn_cast_gimple_call and update gimple_call_ uses to use
> 	new gimple_call local, along with fn_from initializer.
> 	(iterative_hash_hashable_expr): Strengthen type of local "fn_from"
> 	from gimple to gimple_call.
> 	(print_expr_hash_elt): Likewise.
OK when prereqs go in.

jeff

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

* Re: [PATCH 56/89] Various gimple to gimple_call conversions in IPA
  2014-04-21 16:57 ` [PATCH 56/89] Various gimple to gimple_call conversions in IPA David Malcolm
@ 2014-05-12 19:34   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:34 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* ipa-prop.c (detect_type_change): Require a gimple_call rather
> 	than a plain gimple.
> 	(detect_type_change_ssa): Likewise.
> 	(compute_complex_assign_jump_func): Likewise.
> 	(compute_complex_ancestor_jump_func): Likewise.
> 	(compute_known_type_jump_func): Likewise.
> 	(determine_known_aggregate_parts): Likewise.
> 	(ipa_compute_jump_functions_for_edge): Strengthen local "call" to
> 	a gimple_call; add checked cast to gimple_phi.
> 	(ipa_note_param_call): Require a gimple_call rather than a plain
> 	gimple.
> 	(ipa_analyze_indirect_call_uses): Likewise.
> 	(ipa_analyze_virtual_call_uses): Likewise.
> 	(ipa_analyze_call_uses): Likewise.
> 	(ipa_analyze_stmt_uses):Add checked cast to gimple_call.
> 	(ipa_intraprocedural_devirtualization): Require a gimple_call
> 	rather than a plain gimple.
>
> 	* ipa-prop.h (ipa_intraprocedural_devirtualization): Require a
> 	gimple_call rather than a plain gimple.
>
> 	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
> 	Replace use of is_gimple_call with dyn_cast_gimple_call and a
> 	new local "call_stmt".
> ---
OK once prereqs go in.
Jeff

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

* Re: [PATCH 77/89] Concretize various expressions from gimple to gimple_cond
  2014-04-21 17:12 ` [PATCH 77/89] Concretize various expressions from gimple to gimple_cond David Malcolm
@ 2014-05-12 19:36   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:36 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* ipa-split.c (check_forbidden_calls): Replace check against
> 	GIMPLE_COND with a dyn_cast_gimple_cond, introducing a gimple_cond
> 	local.
> 	* predict.c (predict_extra_loop_exits): Likewise.
> 	* tree-vrp.c (fold_predicate_in): Likewise.
> 	(simplify_stmt_for_jump_threading): Likewise.
>
> 	* predict.c (is_comparison_with_loop_invariant_p): Require a
> 	gimple_cond.
> 	(predict_iv_comparison): Add checked cast to gimple_cond once we
> 	know the code is GIMPLE_COND.
> 	(predict_loops): Change type of "stmt" to gimple_cond,
> 	adding checked casts to its assignments (which are both guarded by
> 	checks against GIMPLE_COND).
>
> 	* tree-vrp.c (find_conditional_asserts): Require a gimple_cond.
> 	(vrp_evaluate_conditional): Likewise.
> 	(find_assert_locations_1): Add checked cast to gimple_cond.
> 	(vrp_visit_stmt): Likewise.
> ---
OK once prereqs go in.
Jeff

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

* Re: [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p
  2014-04-21 16:57 ` [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p David Malcolm
@ 2014-05-12 19:38   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:38 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_call_set_tail): Require a gimple_call.
> 	(gimple_call_tail_p): Likewise.
>
> 	* cfgexpand.c (expand_gimple_tailcall): Likewise.
> 	(expand_gimple_basic_block): Convert calls to is_gimple_call to a
> 	dyn_cast, introducing a new "call_stmt" local.
>
> 	* trans-mem.c (expand_block_edges): Likewise, for comparison against
> 	GIMPLE_CALL.
>
> 	* tree-tailcall.c (optimize_tail_call): Add checked cast to gimple_call
> 	for t->call_gsi.
> ---
OK once prereqs go in.
jeff

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

* Re: [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr
  2014-04-21 16:57 ` [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr David Malcolm
@ 2014-05-12 19:40   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:40 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_switch_index): Require a const_gimple_switch rather
> 	than a plain const_gimple.
> 	(gimple_switch_index_ptr): Likewise.
>
> 	* gimplify-me.c (gimple_regimplify_operands): Add checked cast to
> 	gimple_switch within "case GIMPLE_SWITCH".
> 	* tree-cfgcleanup.c (cleanup_control_expr_graph): Likewise.
> 	* tree-ssa-ccp.c (ccp_fold): Likewise.
> 	* tree-ssa-dom.c (optimize_stmt): Likewise.
>
> 	* tree-ssa-ccp.c (evaluate_stmt): Add checked cast to
> 	gimple_switch within region guarded by check for GIMPLE_SWITCH.
> 	* tree-ssa-dom.c (record_edge_info): Likewise.
> 	(eliminate_redundant_computations): Likewise.
> 	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Likewise.
> 	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise.
>
> 	* tree-ssa-dom.c (initialize_hash_element): Replace check for
> 	code GIMPLE_SWITCH with a dyn_cast_gimple_switch.
> 	(propagate_rhs_into_lhs): Likewise.
> 	* tree-ssa-propagate.c (may_propagate_copy_into_stmt): Likewise.
> 	(propagate_tree_value_into_stmt): Likewise.
OK once prereqs go in and will obviously need updating for const changes 
as well.

Jeff

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

* Re: [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h
  2014-04-21 16:57 ` [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h David Malcolm
@ 2014-05-12 19:42   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:42 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:58, David Malcolm wrote:
> gcc/
> 	* ssa-iterators.h (FOR_EACH_PHI_OR_STMT_USE): Add checked cast to
> 	gimple_phi.
> 	(FOR_EACH_PHI_OR_STMT_DEF): Likewise.
>
> 	* ssa-iterators.h (single_phi_def): Require a gimple_phi.
> 	(op_iter_init_phiuse): Likewise.
> 	(op_iter_init_phidef): Likewise.
> 	* tree-ssa-loop-im.c (extract_true_false_args_from_phi): Likewise.
>
> 	* tree-ssa-loop-im.c (link_use_stmts_after): Replace check against
> 	GIMPLE_PHI with add a dyn_cast to gimple_phi, using result as needed.
> 	(determine_max_movement): Likewise.
> 	* tree-ssa-reassoc.c (is_phi_for_stmt): Likewise.
> 	* tree-ssa-sccvn.c (start_over:): Likewise.
>
> 	* tree-ssa-loop-im.c
> 	(move_computations_dom_walker::before_dom_children): Split iterator
> 	into gimple_stmt_iterator and a gimple_phi_iterator so that a local
> 	can become a gimple_phi.
OK once prereq go in.
Jeff

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

* Re: [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-04-21 17:13 ` [PATCH 71/89] Concretize gimple_cond_make_{false|true} David Malcolm
  2014-04-22 15:58   ` Trevor Saunders
@ 2014-05-12 19:56   ` Jeff Law
  2014-05-12 20:16     ` David Malcolm
  1 sibling, 1 reply; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:56 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_cond_make_false): Require a gimple_cond.
> 	(gimple_cond_make_true): Likewise.
>
> 	* tree-cfg.c (fold_cond_expr_cond): Add a checked cast to
> 	gimple_cond within region guarded by check for GIMPLE_COND.
> 	* tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
>
> 	* tree-loop-distribution.c (generate_loops_for_partition): Replace
> 	a check for GIMPLE_COND with a dyn_cast_gimple_cond.
> 	* tree-ssa-ccp.c (optimize_unreachable): Likewise.
> 	* tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise.
> 	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
> 	Likewise.
>
> 	* tree-vrp.c (fold_predicate_in): Add a checked cast to
> 	gimple_cond.  We must be dealing with a GIMPLE_COND since logic
> 	at top of the function ensures we only act on GIMPLE_ASSIGN and
> 	GIMPLE_COND statements, and we're now within a "not a GIMPLE_ASSIGN"
> 	clause.
>
> 	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Add
> 	checked cast of elt->stmt to gimple_cond.  The existing code requires
> 	this to be a GIMPLE_COND, though it's not clear to me how this
> 	requirement is enforced.
> 	(remove_redundant_iv_tests): Likewise.
> 	(try_unroll_loop_completely): Likewise, for the last_stmt of the
> 	preceding bb along edge_to_cancel.
> 	* tree-ssa-reassoc.c (maybe_optimize_range_tests): Likewise, for the
> 	last_stmt of bb.
OK once prerequisites go in.
jeff

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

* Re: [PATCH 68/89] Concretize three gimple_return_ accessors
  2014-04-21 17:15 ` [PATCH 68/89] Concretize three gimple_return_ accessors David Malcolm
@ 2014-05-12 19:59   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 19:59 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_return_retval_ptr): Require a const_gimple_return
> 	rather than a const_gimple.
> 	(gimple_return_retval): Likewise.
> 	(gimple_return_set_retval): Require a gimple_return.
>
> 	* cfgexpand.c (expand_gimple_stmt_1): Add a checked cast to
> 	gimple_return.
> 	(expand_gimple_basic_block): Likewise.
> 	* tree-complex.c (expand_complex_move): Likewise.
> 	(expand_complex_comparison): Likewise.
> 	* tree-inline.c (remap_gimple_stmt): Likewise.
> 	* tree-sra.c (scan_function): Likewise.
> 	(sra_modify_function_body): Likewise.
> 	(ipa_sra_modify_function_body): Likewise.
> 	* tree-ssa-structalias.c (find_func_aliases): Likewise.
>
> 	* gimple-walk.c (walk_stmt_load_store_addr_ops): Replace a check
> 	for code GIMPLE_RETURN with a dyn_cast and a new local.
> 	* gimple.c (infer_nonnull_range): Likewise.
> 	* ipa-split.c (find_return_bb): Likewise.
> 	(find_retval): Likewise.
> 	(split_function): Likewise.
> 	* omp-low.c (ipa_simd_modify_function_body): Likewise.
> 	* tree-cfg.c (execute_warn_function_return): Likewise.
> 	* tree-nrv.c (tree_nrv): Likewise.
> 	* tree-ssa-alias.c (ref_maybe_used_by_stmt_p): Likewise.
> 	* tree-ssa-dce.c (propagate_necessity): Likewise.
> 	* tree-ssa-structalias.c (find_func_clobbers): Likewise.
> 	* tree-tailcall.c (find_tail_calls): Likewise.
>
> 	* predict.c (apply_return_prediction): Rework the search for
> 	return_stmt so that the latter can have type gimple_return.
> ---
Fine once prereqs go in.

jeff

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

* Re: [PATCH 55/89] Use gimple_call for callgraph edges
  2014-04-21 17:14 ` [PATCH 55/89] Use gimple_call for callgraph edges David Malcolm
@ 2014-05-12 20:03   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:03 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* cgraph.h (cgraph_edge::call_stmt): Strengthen field from plain
> 	gimple to a gimple_call.
> 	(cgraph_create_edge): Require a gimple_call rather than a plain
> 	gimple.
> 	(cgraph_create_indirect_edge): Likewise.
> 	(cgraph_set_call_stmt): Likewise.
> 	(cgraph_clone_edge): Likewise.
> 	(cgraph_set_call_stmt_including_clones): Likewise.
> 	(cgraph_create_edge_including_clones): Likewise.
>
> 	* cgraph.c (cgraph_set_call_stmt): Require a gimple_call rather
> 	than a plain gimple.
> 	(cgraph_create_edge_1): Likewise.
> 	(cgraph_create_edge): Likewise.
> 	(cgraph_create_indirect_edge): Likewise.
> 	(cgraph_redirect_edge_call_stmt_to_callee): Strengthen decl
> 	of "new_stmt" from gimple to gimple_call.
> 	(cgraph_update_edges_for_call_stmt_node): Add checked casts to
> 	gimple_call.
>
> 	* cgraphbuild.c (build_cgraph_edges): Replace is_gimple_call
> 	with dyn_cast_gimple_call and new local "call_stmt".
> 	(rebuild_cgraph_edges): Likewise.
>
> 	* cgraphclones.c (cgraph_clone_edge): Require a gimple_call
> 	rather than a plain gimple.
> 	(cgraph_set_call_stmt_including_clones): Likewise.
> 	(cgraph_create_edge_including_clones): Likewise.
>
> 	* lto-streamer-in.c (fixup_call_stmt_edges_1): Add checked casts
> 	to gimple_call.
>
> 	* omp-low.c (simd_clone_adjust): Strengthen local "call" from
> 	gimple to gimple_call.
>
> 	* trans-mem.c (ipa_tm_insert_irr_call): Likewise for "g".
> 	(ipa_tm_insert_gettmclone_call): Likewise; also strengthen "g2"
> 	to gimple_assign.
>
> 	* tree-emutls.c (gen_emutls_addr): Strengthen local "x" from
> 	gimple to gimple_call.
>
> 	* tree-inline.c (copy_bb): Replace is_gimple_call with
> 	dyn_cast_gimple_call and new local "call_stmt".
>
> 	* value-prof.c (gimple_ic): Require and return a gimple_call,
> 	rather than a plain gimple.
> 	* value-prof.h (gimple_ic): Likewise.
>
OK once prereqs go in.
jeff

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

* Re: [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes
  2014-04-21 17:13 ` [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes David Malcolm
@ 2014-05-12 20:06   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:06 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
> 	Strengthen local "psi" to be a gimple_phi_iterator and "phi" to
> 	a gimple_phi.
>
> 	* graphite-sese-to-poly.c (phi_arg_in_outermost_loop): Require
> 	a gimple_phi rathen than a plain gimple.
> 	(remove_simple_copy_phi): Require a gimple_phi_iterator;
> 	strengthen local "phi" to be a gimple_phi and "stmt" to be a
> 	gimple_assign.
> 	(remove_invariant_phi): Likewise.
> 	(simple_copy_phi_p): Require a gimple_phi.
> 	(reduction_phi_p): Require a gimple_phi_iterator; strengthen
> 	local "phi" to be a gimple_phi.
> 	(add_condition_to_pbb): Require a gimple_cond rather than a
> 	plain gimple.
> 	(add_conditions_to_domain): Add checked cast to gimple_cond
> 	within GIMPLE_COND case of switch statement.
> 	(single_pred_cond_non_loop_exit): Return a gimple_cond rather
> 	than a plain gimple, via a checked cast.
> 	(sese_dom_walker::before_dom_children): Strengthen local "stmt"
> 	from gimple to gimple_cond.
> 	(gsi_for_phi_node): Require a gimple_phi, and return a
> 	gimple_phi_iterator.
> 	(insert_out_of_ssa_copy): Strengthen local "stmt" from gimple to
> 	gimple_assign.
> 	(rewrite_reductions_out_of_ssa): Strengthen "psi" to be a
> 	gimple_phi_iterator, and "phi" to be a gimple_phi.
> 	(phi_contains_arg): Require a gimple_phi.
> 	(follow_ssa_with_commutative_ops): Strengthen return type from
> 	gimple to gimple_phi, by converting a check for code GIMPLE_PHI to
> 	a dyn_cast_gimple_phi, and strengthening local "res" from gimple
> 	to gimple_phi.
> 	(detect_commutative_reduction_arg): Strengthen return type from
> 	gimple to gimple_phi, and strengthen local "phi" to be a
> 	gimple_phi.
> 	(detect_commutative_reduction_assign): Strengthen return type from
> 	gimple to gimple_phi, and strengthen local "res" to be a
> 	gimple_phi.
> 	(follow_inital_value_to_phi): Strengthen return type from
> 	gimple to gimple_phi.  Replace check for code GIMPLE_PHI with
> 	a dyn_cast_gimple_phi.
> 	(detect_commutative_reduction): Strengthen return type and locals
> 	"loop_phi", "phi", "close_phi" from gimple to gimple_phi,
> 	introducing a checked cast of "stmt" in region guarded by
> 	scalar_close_phi_node_p (stmt).
> 	(translate_scalar_reduction_to_array_for_stmt): Require param
> 	"loop_phi" to be a gimple_phi.  Strengthen local "assign" from
> 	gimple to gimple_assign.
> 	(remove_phi): Require a gimple_phi.
> 	(close_phi_written_to_memory): Likewise.
> 	(translate_scalar_reduction_to_array): We expect the first element
> 	in each vector to be an arbitrary statement, but all of the
> 	subsequent elements to be phi nodes.  Hence the decls of gimple
> 	locals "loop_phi" and "close_phi" are replaced with decls of gimple
> 	"loop_stmt" and "close_stmt", with decls of the more-strongly typed
> 	gimple_phi "loop_phi" and "close_phi" occurring lower down, within
> 	the region where we're dealing with i > 0 and hence where we can
> 	safely assign them using the checked cast as_a_gimple_phi.
> 	This allows many of the strengthenings from gimple to gimple_phi
> 	above.  We eliminate the local "stmt", since we can simply use
> 	"loop_stmt".
> 	(rewrite_commutative_reductions_out_of_ssa_close_phi): Strengthen
> 	param "close_phi" from gimple to gimple_phi, and local "gsi" from
> 	gimple_stmt_iterator to gimple_phi_iterator, converting uses of
> 	gsi_stmt to gsi.phi for type-safety.
> 	(scop_ivs_can_be_represented): Strengthen local "gsi" from
> 	gimple_stmt_iterator to gimple_phi_iterator, and "phi" from gimple
> 	to gimple_phi.
> ---
OK once prereqs go in.

Jeff

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

* Re: [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-05-12 19:56   ` Jeff Law
@ 2014-05-12 20:16     ` David Malcolm
  2014-05-12 21:26       ` Jeff Law
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-12 20:16 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Mon, 2014-05-12 at 13:55 -0600, Jeff Law wrote:
> On 04/21/14 10:57, David Malcolm wrote:
> > gcc/
> > 	* gimple.h (gimple_cond_make_false): Require a gimple_cond.
> > 	(gimple_cond_make_true): Likewise.
> >
> > 	* tree-cfg.c (fold_cond_expr_cond): Add a checked cast to
> > 	gimple_cond within region guarded by check for GIMPLE_COND.
> > 	* tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
> >
> > 	* tree-loop-distribution.c (generate_loops_for_partition): Replace
> > 	a check for GIMPLE_COND with a dyn_cast_gimple_cond.
> > 	* tree-ssa-ccp.c (optimize_unreachable): Likewise.
> > 	* tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise.
> > 	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
> > 	Likewise.
> >
> > 	* tree-vrp.c (fold_predicate_in): Add a checked cast to
> > 	gimple_cond.  We must be dealing with a GIMPLE_COND since logic
> > 	at top of the function ensures we only act on GIMPLE_ASSIGN and
> > 	GIMPLE_COND statements, and we're now within a "not a GIMPLE_ASSIGN"
> > 	clause.
> >
> > 	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Add
> > 	checked cast of elt->stmt to gimple_cond.  The existing code requires
> > 	this to be a GIMPLE_COND, though it's not clear to me how this
> > 	requirement is enforced.

You asked me to speak up if my factoring turned up a case where the
existing code might be broken - and I'm slightly nervous about the last
change above.

AIUI, the invariants that hold here are that we're walking the
singly-linked list of the (struct nb_iter_bound *) of a loop, and have a
loop exit - and the existing code assumed that the nb_iter_bound's stmt
is a GIMPLE_COND.

Could that ever not be the case; could we ever be dealing with another
kind of statement?

As I understand it, the "is_exit" field is set by "record_estimate",
which is called by "estimate_numbers_of_iterations_loop" on each element
of get_loop_exit_edges (loop).

Is it possible for, say, a suitably-constructed function full of gotos
and a switch to fool the loop-handling code into considering a switch
statement as an exit from a loop? (e.g. after optimizing a goto inside a
case, maybe?).

Then again, the existing code calls gimple_cond_make_true/make_false on
the stmt, so implicitly requires it to be a GIMPLE_COND.

Sorry for my ignorance here; I'm less familiar with the loop-analysis
code.

> > 	(remove_redundant_iv_tests): Likewise.
> > 	(try_unroll_loop_completely): Likewise, for the last_stmt of the
> > 	preceding bb along edge_to_cancel.
> > 	* tree-ssa-reassoc.c (maybe_optimize_range_tests): Likewise, for the
> > 	last_stmt of bb.
> OK once prerequisites go in.

Thanks.

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

* Re: [PATCH 49/89] Make add_phi_arg require a gimple_phi
  2014-04-21 16:56 ` [PATCH 49/89] Make add_phi_arg require a gimple_phi David Malcolm
@ 2014-05-12 20:32   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:32 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* tree-phinodes.h (add_phi_arg): Require a gimple_phi rather than
> 	a plain gimple.
> 	* tree-phinodes.c (add_phi_arg): Likewise.
>
> 	* gimple-ssa-strength-reduction.c (create_phi_basis): Strengthen
> 	local "phi" from plain gimple to gimple_phi.
>
> 	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
> 	Likewise for "close_phi".
>
> 	* ipa-split.c (split_function): Convert "psi" to
> 	gimple_phi_iterator.
>
> 	* omp-low.c (expand_omp_for_static_nochunk): Introduce
> 	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
> 	gimple_phi.
> 	(expand_omp_for_static_chunk): Likewise.
>
> 	* tree-cfg.c (gimple_duplicate_bb): Make topmost "gsi" decl more
> 	tightly-scoped, and eliminate decls "phis", "phi", "stmt", "copy"
> 	in favor of more tightly-scoped gimple_phi_iterator gpi and
> 	gimple_phi decls "phi" and "copy", and gimple decls "stmt" and
> 	"copy".
>
> 	* tree-parloops.c (create_parallel_loop): Introduce
> 	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
> 	gimple_phi.
>
> 	* tree-ssa-loop-im.c (execute_sm_if_changed): Likewise.
>
> 	* tree-ssa-loop-manip.c (create_iv): Split out new gimple_phi
> 	local "phi" from "stmt", and convert the latter into being a
> 	gimple_assign.
>
> 	* tree-ssa-pre.c (insert_into_preds_of_block): Strengthen local
> 	"phi" to be a gimple_phi.
>
> 	* tree-ssa-tail-merge.c (vop_phi): Require a gimple_phi rather
> 	than a plain gimple.
> 	(replace_block_by): Strengthen local "bb2_phi" to be a gimple_phi.
>
> 	* tree-tailcall.c (add_successor_phi_arg): Use gsi.phi when
> 	invoking add_phi_arg.
> 	(eliminate_tail_call): Introduce gimple_phi_iterator gpi, using it
> 	to strengthen "phi" to be a gimple_phi.
> 	(create_tailcall_accumulator): Strengthen local "phi" to be a
> 	gimple_phi.
> 	(tree_optimize_tail_calls_1): Likewise.
>
> 	* tree-vect-data-refs.c (vect_setup_realignment): Strengthen
> 	local "phi_stmt" to be a gimple_phi.
>
> 	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
> 	Strengthen "gsi", "gsi_orig", "gsi_new" to be
> 	gimple_phi_iterators, and "phi" "orig_phi", "new_phi" to be
> 	gimple_phi instances.
> 	(slpeel_tree_peel_loop_to_edge): Strengthen local "new_phi" to be
> 	a gimple_phi.
>
> 	* tree-vect-loop.c (get_initial_def_for_induction): Likewise for
> 	"induction_phi".
> 	(vect_create_epilog_for_reduction): Add checked casts to
> 	gimple_phi; strengthen local "outer_phi" to gimple_phi and
> 	"new_vec_stmt" to gimple_assign.
> 	(vect_finalize_reduction): Strengthen local "vect_phi" to
> 	gimple_phi.
> 	(vectorizable_reduction): Likewise for "new_phi".
>
> 	* tree-vect-stmts.c (vectorizable_simd_clone_call): Likewise.
> 	(vectorizable_load): Likewise for "phi".
Fine once prereqs go in.
jeff

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

* Re: [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi
  2014-04-21 17:15 ` [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi David Malcolm
@ 2014-05-12 20:33   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:33 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_phi_arg_edge): Require a gimple_phi rather
> 	than a plain gimple.
>
> 	* graphite-sese-to-poly.c (rewrite_phi_out_of_ssa): Require a
> 	gimple_phi_iterator; strengthen local "phi" from gimple to a
> 	gimple_phi.
> 	(rewrite_cross_bb_scalar_deps): Strengthen local "psi" from
> 	a gimple_stmt_iterator to a gimple_phi_iterator.
> 	(edge_initial_value_for_loop_phi): Require a gimple phi.
> 	(initial_value_for_loop_phi): Likewise.
>
> 	* ipa-split.c (consider_split): Convert "bsi" to a
> 	gimple_phi_iterator and "stmt" to a gimple_phi.
>
> 	* predict.c (predict_extra_loop_exits): Convert "phi_stmt" to be
> 	a gimple_phi; introduce "lhs_def_stmt" as plain gimple.
> 	(apply_return_prediction): Convert "phi" to be a gimple_phi.
>
> 	* tree-cfg.c (replace_uses_by): Add checked cast to gimple_phi.
> 	(verify_gimple_in_cfg): Introduce gimple_phi_iterator "gpi" and use
> 	it to convert "phi" to a gimple_phi.
>
> 	* tree-eh.c (cleanup_empty_eh_merge_phis): Convert "ngsi", "ogsi"
> 	to be gimple_phi_iterators.  Convert "ophi", "nphi" to be
> 	gimple_phi.
>
> 	* tree-into-ssa.c (prepare_use_sites_for): Add checked cast to
> 	gimple_phi.
>
> 	* tree-ssa-coalesce.c (create_outofssa_var_map): Introduce
> 	gimple_phi_iterator "gpi" and use it to convert "phi" to a
> 	gimple_phi.
>
> 	* tree-ssa-dce.c (propagate_necessity): Introduce local "phi",
> 	from checked cast to gimple_phi.
>
> 	* tree-ssa-live.c (set_var_live_on_entry): Add checked cast to
> 	gimple_phi.
>
> 	* tree-ssa-propagate.c (replace_phi_args_in): Require a gimple_phi
> 	rather than a plain gimple.
> 	(substitute_and_fold): Introduce gimple_phi_iterator "gpi".
>
> 	* tree-ssa-sink.c (find_bb_for_arg): Require a gimple_phi rather
> 	than a plain gimple.
> 	(nearest_common_dominator_of_uses): Replace check of code against
> 	GIMPLE_PHI with a dyn_cast_gimple_phi, introducing a new local.
> 	(statement_sink_location): Add checked cast to gimple_phi.
>
> 	* tree-ssa-uninit.c (compute_uninit_opnds_pos): Require a
> 	gimple_phi rather than a plain gimple.
> 	(collect_phi_def_edges): Likewise.
> 	(find_def_preds): Likewise.
> 	(is_use_properly_guarded): Likewise.
> 	(prune_uninit_phi_opnds_in_unrealizable_paths): Likewise.  Also,
> 	convert "flag_arg_def", "phi_arg_def" to gimple_phi using
> 	dyn_cast_gimple_phi.  Similarly, introduce new local
> 	"opnd_def_phi".
> 	(use_pred_not_overlap_with_undef_path_pred): Require a
> 	gimple_phi rather than a plain gimple; add a checked cast.
> 	(find_uninit_use): Replace check of code against GIMPLE_PHI with
> 	a dyn_cast_gimple_phi, introducing a new local.
Fine once prereqs go in.

jeff

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

* Re: [PATCH 62/89] Concretize gimple_label_label
  2014-04-21 17:13 ` [PATCH 62/89] Concretize gimple_label_label David Malcolm
@ 2014-05-12 20:34   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:34 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> gcc/
> 	* gimple.h (gimple_label_label): Require a const_gimple_label
> 	rather than just a const_gimple.
>
> 	* cfgexpand.c (label_rtx_for_bb): Convert local from gimple to
> 	gimple_label, replacing a check against GIMPLE_LABEL with a
> 	dyn_cast_gimple_label.
> 	* predict.c (tree_estimate_probability_bb): Likewise.
> 	* tree-cfg.c (make_edges): Likewise.
> 	(cleanup_dead_labels): Likewise (twice).
> 	(gimple_can_merge_blocks_p): Likewise.
> 	(gimple_block_label): Likewise.
> 	* tree-eh.c (unsplit_eh): Likewise.
> 	(cleanup_empty_eh_unsplit): Likewise.
> 	* tree-inline.c (mark_local_labels_stmt): Likewise.
> 	* tree-nested.c (convert_nl_goto_receiver): Likewise.
>
> 	* cfgexpand.c (expand_gimple_stmt_1): Add a checked cast to
> 	gimple_label when invoking gimple_label_label in a region where
> 	we've checked the code is GIMPLE_LABEL.
> 	* gimple-pretty-print.c (pp_cfg_jump): Likewise.
> 	* gimple.c (gimple_set_bb): Likewise.
> 	* ipa-pure-const.c (check_stmt): Likewise.
> 	* omp-low.c (diagnose_sb_1): Likewise.
> 	* tree-cfg.c (gimple_verify_flow_info): Likewise.
> 	* tree-cfgcleanup.c (tree_forwarder_block_p): Likewise.
> 	(remove_forwarder_block): Likewise.
> 	* tree-eh.c (collect_finally_tree): Likewise.
>
> 	* ipa-split.c (verify_non_ssa_vars): Replace a check against
> 	GIMPLE_LABEL with a dyn_cast_gimple_label, introducing a
> 	gimple_label local.
> 	* tree-cfg.c (gimple_can_merge_blocks_p): Likewise.
> 	(gimple_merge_blocks): Likewise.
> 	(remove_bb): Likewise.
> 	(stmt_starts_bb_p): Likewise.
> 	(gimple_verify_flow_info): Likewise.
> 	(move_block_to_fn): Likewise.
> 	* tree-cfgcleanup.c (remove_forwarder_block): Likewise.
> 	(remove_forwarder_block_with_phi): Likewise.
> 	* tree-ssa-ccp.c (optimize_unreachable): Likewise.
OK once prereqs go in.
jeff

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

* Re: [PATCH 88/89] Use gimple_phi in many more places.
  2014-04-21 16:57 ` [PATCH 88/89] Use gimple_phi in many more places David Malcolm
@ 2014-05-12 20:38   ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 20:38 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

On 04/21/14 10:57, David Malcolm wrote:
> This patch converts almost every usage of gsi_start_phis to act on a
> gimple_phi_iterator: everywhere (I believe) where the underlying
> statements are then accessed via a gimple_phi_ accessor.
>
> There are some places where the phi nodes then just go through
> generic gimple APIs; in these cases I didn't bother converting
> the iterators.
>
> gcc/
> 	* gimple-ssa-strength-reduction.c (slsr_process_phi): Require a
> 	gimple_phi.
> 	* ipa-inline-analysis.c (predicate_for_phi_result): Likewise.
> 	* tree-emutls.c (lower_emutls_phi_arg): Likewise.
> 	* tree-if-conv.c (predicate_scalar_phi): Likewise.
> 	* tree-into-ssa.c (mark_virtual_phi_result_for_renaming): Likewise.
> 	* tree-into-ssa.h (mark_virtual_phi_result_for_renaming): Likewise.
> 	* tree-phinodes.c (degenerate_phi_result): Likewise.
> 	* tree-phinodes.h (degenerate_phi_result): Likewise.
> 	* tree-ssa.c (verify_use): Likewise.
> 	* tree-switch-conversion.c (array_value_type): Likewise.
>
> 	* graphite-scop-detection.c (same_close_phi_node): Require a pair
> 	of gimple_phi.
> 	(remove_duplicate_close_phi): Require a gimple_phi and a
> 	gimple_phi_iterator.
> 	(make_close_phi_nodes_unique): Convert a local into a
> 	gimple_phi_iterator.
>
> 	* gimple-pretty-print.c (gimple_dump_bb_for_graph): Split iterator
> 	into gimple_stmt_iterator and gimple_phi_iterator, converting local
> 	from gimple to gimple_phi.
> 	* gimple-ssa-strength-reduction.c
> 	(find_candidates_dom_walker::before_dom_children): Likewise.
> 	* ipa-inline-analysis.c (estimate_function_body_sizes): Likewise.
> 	* ipa-split.c (verify_non_ssa_vars): Likewise.
> 	(visit_bb): Likewise.
> 	(split_function): Likewise.
> 	* lto-streamer-out.c (output_function): Likewise.
> 	* sese.c (sese_build_liveouts_bb): Likewise.
> 	* tree-cfg.c (gimple_can_merge_blocks_p): Likewise.
> 	* tree-complex.c (init_dont_simulate_again): Likewise.
> 	* tree-dfa.c (collect_dfa_stats): Likewise.
> 	* tree-eh.c (sink_clobbers): Likewise.
> 	* tree-emutls.c (lower_emutls_function_body): Likewise.
> 	* tree-into-ssa.c (rewrite_dom_walker::before_dom_children):
> 	Likewise.
> 	(rewrite_update_dom_walker::before_dom_children): Likewise.
> 	(prepare_block_for_update): Likewise.
> 	* tree-loop-distribution.c (stmts_from_loop): Likewise.
> 	(generate_loops_for_partition): Likewise.
> 	(destroy_loop): Likewise.
> 	(tree_loop_distribution): Likewise.
> 	* tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise.
> 	* tree-ssa-copy.c (init_copy_prop): Likewise.
> 	* tree-ssa-copyrename.c (rename_ssa_copies): Likewise.
> 	* tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): Likewise.
> 	* tree-ssa-loop-manip.c (find_uses_to_rename_bb): Likewise.
> 	(verify_loop_closed_ssa): Likewise.
> 	* tree-ssa-math-opts.c (execute_cse_reciprocals): Likewise.
> 	* tree-ssa-pre.c (compute_avail): Likewise.
> 	(eliminate_dom_walker::before_dom_children): Likewise.
> 	* tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Likewise.
> 	* tree-ssa-structalias.c (compute_points_to_sets): Likewise.
> 	(ipa_pta_execute): Likewise.
> 	* tree-ssa-tail-merge.c (same_succ_hash): Likewise.
> 	(release_last_vdef): Likewise.
> 	* tree-ssa.c (verify_ssa): Likewise.
> 	(execute_update_addresses_taken): Likewise.
> 	* tree-stdarg.c (check_all_va_list_escapes): Likewise.
> 	(execute_optimize_stdarg): Likewise.
> 	* tree-switch-conversion.c (build_arrays): Likewise.
> 	* tree-vect-loop-manip.c (rename_variables_in_bb): Likewise.
> 	* tree-vect-loop.c (vect_determine_vectorization_factor): Likewise.
> 	(vect_analyze_loop_operations): Likewise.
> 	(vect_transform_loop): Likewise.
> 	* tree-vrp.c (find_assert_locations_1): Likewise.
> 	(vrp_initialize): Likewise.
>
> 	* graphite-sese-to-poly.c (gsi_for_phi_node): Convert psi to a
> 	gimple_phi_iterator.
> 	(rewrite_degenerate_phi): Require a gimple_phi_iterator; strengthen
> 	local "phi" from gimple to gimple-phi.
>
> 	* ipa-split.c (consider_split): Convert local psi to a
> 	gimple_phi_iterator.
> 	* tree-cfg.c (gimple_merge_blocks): Likewise.
>
> 	* tree-eh.c (unsplit_eh): Replace reuse of gsi with a new
> 	gimple_phi_iterator gpi, using it to convert statement from gimple
> 	to a gimple_phi.
> 	(cleanup_empty_eh_merge_phis): Strengthen ophi from gimple to
> 	gimple_phi.
> 	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace reuse of
> 	gsi with a new gimple_phi_iterator gpi, using it to convert
> 	expressions from gimple to gimple_phi; add a checked cast to
> 	gimple_phi.
>
> 	* tree-if-conv.c (predicate_all_scalar_phis): Convert local phi_gsi
> 	to be a gimple_phi_iterator; convert "phi" to be a gimple_phi.
> 	* tree-parloops.c (loop_has_vector_phi_nodes): Convert local to be a
> 	gimple_phi_iterator.
> 	* tree-ssa-ccp.c (ccp_initialize): Likewise.
>
> 	* tree-scalar-evolution.c (analyze_initial_condition): Add checked cast
> 	to a gimple_phi.
> 	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
> 	* tree-ssa-dom.c (get_rhs_or_phi_arg): Likewise.
Fine once prereqs go in.

This should be the last patch, if I missed anything let me know.

Given that we're waiting until after 4.9.1 before installing this set, I 
expect there will be minor tweaks just due to ongoing development. 
Similarly there may be additions.  As long as they stay in the same 
general form as this set of patches, they're pre-approved.  In all it's 
mostly mechanical/repetitive stuff.

 From a reviewer standpoint, the one thing worth mentioning is that 
there were probably more variable renames than were really necessary and 
that introduces a fair amount of clutter when reviewing the patches. 
However, I also know why you made those changes and I can't fault you 
for carrying more information in the variable name to ease long term 
maintenance at the cost of initial reviewer time.

I'm going to rest my eyes now.

Jeff

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

* Re: [PATCH 71/89] Concretize gimple_cond_make_{false|true}
  2014-05-12 20:16     ` David Malcolm
@ 2014-05-12 21:26       ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-12 21:26 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

On 05/12/14 14:14, David Malcolm wrote:
> You asked me to speak up if my factoring turned up a case where the
> existing code might be broken - and I'm slightly nervous about the last
> change above.
>
> AIUI, the invariants that hold here are that we're walking the
> singly-linked list of the (struct nb_iter_bound *) of a loop, and have a
> loop exit - and the existing code assumed that the nb_iter_bound's stmt
> is a GIMPLE_COND.
>
> Could that ever not be the case; could we ever be dealing with another
> kind of statement?
>
> As I understand it, the "is_exit" field is set by "record_estimate",
> which is called by "estimate_numbers_of_iterations_loop" on each element
> of get_loop_exit_edges (loop).
>
> Is it possible for, say, a suitably-constructed function full of gotos
> and a switch to fool the loop-handling code into considering a switch
> statement as an exit from a loop? (e.g. after optimizing a goto inside a
> case, maybe?).
>
> Then again, the existing code calls gimple_cond_make_true/make_false on
> the stmt, so implicitly requires it to be a GIMPLE_COND.
>
> Sorry for my ignorance here; I'm less familiar with the loop-analysis
> code.
Maybe.  This is code I haven't had to ever really look at -- it may well 
be broken in this regard.

jeff

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

* gphi_iterator? (was Re: [PATCH 09/89] Introduce gimple_phi_iterator)
  2014-05-09 18:51   ` Jeff Law
@ 2014-05-14 16:18     ` David Malcolm
  2014-05-14 16:27       ` Jeff Law
  0 siblings, 1 reply; 250+ messages in thread
From: David Malcolm @ 2014-05-14 16:18 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Fri, 2014-05-09 at 12:51 -0600, Jeff Law wrote:
> On 04/21/14 10:56, David Malcolm wrote:
> > gcc/
> > 	* gimple-iterator.h (struct gimple_phi_iterator): New subclass of
> > 	gimple_stmt_iterator with identical layout, but adding...
> > 	(gimple_phi_iterator::phi): ...new method, equivalent to
> > 	gsi_stmt (), but casting the underlying gimple to gimple_phi,
> > 	checking that code == GIMPLE_PHI in a checked build.
> > 	(gsi_start_phis): Return a gimple_phi_iterator, rather than just a
> > 	gimple_stmt_iterator.
> >
> > 	* tree-if-conv.c (bb_with_exit_edge_p): Require a gimple_phi rather
> > 	than just a gimple.
> > 	(if_convertible_phi_p): Likewise.
> > 	* tree-phinodes.h (add_phi_node_to_bb): Likewise.
> > 	* tree-ssa-phiprop.c (propagate_with_phi): Likewise.
> >
> > 	* tree-ssa-uninit.c (warn_uninitialized_phi): Require a gimple_phi
> > 	and a vec<gimple_phi> *, rather than just a gimple and vec<gimple> *.
> > 	(find_uninit_use): Likewise; add checked cast to gimple_phi when
> > 	adding to worklist.
> > 	(execute_late_warn_uninitialized): Strengthen types of various locals,
> > 	"worklist" from vec<gimple> to vec<gimple_phi>, "gsi" to a
> > 	gimple_phi_iterator, and "phi" and "cur_phi" to a gimple_phi.
> >
> > 	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Require a
> > 	gimple_phi_iterator * rather than a gimple_stmt_iterator *;
> > 	use it to strengthen local from a gimple to a gimple_phi.
> >
> > 	* cfgloop.c (find_subloop_latch_edge_by_ivs): Convert local from a
> > 	gimple_stmt_iterator to a gimple_phi_iterator.  Use the iterator's
> > 	"phi" method rather than gsi_stmt.  Use this checked cast to convert
> > 	the type of related local from a plain gimple to a gimple_phi.
> > 	* gimple-pretty-print.c (dump_phi_nodes): Likewise.
> > 	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behaviour):
> > 	Likewise.
> > 	* sese.c (sese_add_exit_phis_edge): Likewise.
> > 	* tree-cfg.c (reinstall_phi_args): Likewise.
> > 	(gimple_make_forwarder_block): Likewise.
> > 	(add_phi_args_after_copy_edge): Likewise.
> > 	(gimple_lv_adjust_loop_header_phi): Likewise.
> > 	* tree-cfgcleanup.c (phi_alternatives_equal): Likewise.
> > 	(remove_forwarder_block_with_phi): Likewise.
> > 	(merge_phi_nodes): Likewise.
> > 	* tree-complex.c (update_phi_components): Likewise.
> > 	* tree-if-conv.c (if_convertible_loop_p_1): Likewise.
> > 	* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
> > 	(copy_phis_for_bb): Likewise.
> > 	* tree-into-ssa.c (rewrite_add_phi_arguments): Likewise.
> > 	* tree-outof-ssa.c (eliminate_build): Likewise.
> > 	(eliminate_useless_phis): Likewise.
> > 	(rewrite_trees): Likewise.
> > 	(insert_backedge_copies): Likewise.
> > 	* tree-phinodes.c (reserve_phi_args_for_new_edge): Likewise.
> > 	(remove_phi_args): Likewise.
> > 	(remove_phi_nodes): Likewise.
> > 	* tree-predcom.c (find_looparound_phi): Likewise.
> > 	(eliminate_temp_copies): Likewise.
> > 	* tree-scalar-evolution.c (loop_closed_phi_def): Likewise.
> > 	(scev_const_prop): Likewise; also, add checked cast to phi.
> > 	* tree-ssa-coalesce.c (coalesce_partitions): Likewise.
> > 	* tree-ssa-dce.c (remove_dead_phis): Likewise.
> > 	(forward_edge_to_pdom): Likewise.
> > 	* tree-ssa-dom.c (record_equivalences_from_phis): Likewise.
> > 	(cprop_into_successor_phis): Likewise.
> > 	(propagate_rhs_into_lhs): Likewise.
> > 	(eliminate_degenerate_phis_1): Likewise.
> > 	* tree-ssa-ifcombine.c (same_phi_args_p): Likewise.
> > 	* tree-ssa-live.c (calculate_live_on_exit): Likewise.
> > 	(verify_live_on_entry): Likewise.
> > 	* tree-ssa-loop-im.c
> > 	(move_computations_dom_walker::before_dom_children): Likewise.
> > 	* tree-ssa-loop-ivopts.c (find_bivs): Likewise.
> > 	(mark_bivs): Likewise.
> > 	(find_interesting_uses_outside): Likewise.
> > 	(determine_set_costs): Likewise.
> > 	* tree-ssa-loop-manip.c (split_loop_exit_edge): Likewise.
> > 	(tree_transform_and_unroll_loop): Likewise.
> > 	(rewrite_all_phi_nodes_with_iv): Likewise.
> > 	(canonicalize_loop_ivs): Likewise.
> > 	* tree-ssa-loop-niter.c (determine_value_range): Likewise.
> > 	* tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise.
> > 	* tree-ssa-phiprop.c (tree_ssa_phiprop): Likewise.
> > 	* tree-ssa-reassoc.c (suitable_cond_bb): Likewise.
> > 	* tree-ssa-tail-merge.c (same_phi_alternatives_1): Likewise.
> > 	(vop_phi): Likewise.
> > 	* tree-ssa-threadedge.c (record_temporary_equivalences_from_phis):
> > 	Likewise.
> > 	* tree-ssa-threadupdate.c (copy_phi_arg_into_existing_phi): Likewise.
> > 	(copy_phi_args): Likewise.
> > 	(phi_args_equal_on_edges): Likewise.
> > 	* tree-ssa.c (ssa_redirect_edge): Likewise.
> > 	(flush_pending_stmts): Likewise.
> > 	* tree-switch-conversion.c (check_final_bb): Likewise.
> > 	(gather_default_values): Likewise.
> > 	(build_constructors): Likewise.
> > 	(fix_phi_nodes): Likewise.
> > 	* tree-tailcall.c (propagate_through_phis): Likewise.
> > 	(add_successor_phi_arg): Likewise.
> > 	* tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard1):
> > 	Likewise.
> > 	(slpeel_update_phi_nodes_for_guard2): Likewise.
> > 	(slpeel_tree_peel_loop_to_edge): Likewise.
> > 	(vect_can_advance_ivs_p): Likewise.
> > 	(vect_update_ivs_after_vectorizer): Likewise.
> > 	* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Likewise.
> > 	* tree-vrp.c (find_assert_locations): Likewise.
> > 	* value-prof.c (gimple_ic): Likewise.
> >
> > 	* omp-low.c (expand_parallel_call): Convert local to a gimple_phi.
> OK once prerequisites have gone in.
> 
Thanks.

I'm working my way through the patches, converting them to the latest
approach, where "gimple_phi" becomes "gphi *".

Given that renaming, it occurred to me that the new class
"gimple_phi_iterator" would be better named as
"gphi_iterator" (consistency, and less typing). 

Is this renaming OK?  (I wasn't planning to rename the pre-existing
gimple_stmt_iterator)


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

* Re: gphi_iterator? (was Re: [PATCH 09/89] Introduce gimple_phi_iterator)
  2014-05-14 16:18     ` gphi_iterator? (was Re: [PATCH 09/89] Introduce gimple_phi_iterator) David Malcolm
@ 2014-05-14 16:27       ` Jeff Law
  0 siblings, 0 replies; 250+ messages in thread
From: Jeff Law @ 2014-05-14 16:27 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

On 05/14/14 09:28, David Malcolm wrote:

> Thanks.
>
> I'm working my way through the patches, converting them to the latest
> approach, where "gimple_phi" becomes "gphi *".
>
> Given that renaming, it occurred to me that the new class
> "gimple_phi_iterator" would be better named as
> "gphi_iterator" (consistency, and less typing).
>
> Is this renaming OK?  (I wasn't planning to rename the pre-existing
> gimple_stmt_iterator)
Yea, that's fine.

jeff

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

end of thread, other threads:[~2014-05-14 16:27 UTC | newest]

Thread overview: 250+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-21 16:56 [PATCH 00/89] Compile-time gimple-checking David Malcolm
2014-04-21 16:56 ` [PATCH 04/89] Introduce gimple_cond and use it in various places David Malcolm
2014-05-09 14:13   ` Jeff Law
2014-04-21 16:56 ` [PATCH 49/89] Make add_phi_arg require a gimple_phi David Malcolm
2014-05-12 20:32   ` Jeff Law
2014-04-21 16:56 ` [PATCH 34/89] Introduce gimple_omp_atomic_load David Malcolm
2014-05-12 17:13   ` Jeff Law
2014-04-21 16:56 ` [PATCH 11/89] tree-parloops.c: use gimple_phi in various places David Malcolm
2014-05-09 18:31   ` Jeff Law
2014-04-21 16:56 ` [PATCH 41/89] Introduce gimple_omp_task David Malcolm
2014-05-12 17:18   ` Jeff Law
2014-04-21 16:56 ` [PATCH 05/89] Introduce gimple_assign and use it in various places David Malcolm
2014-05-09 14:16   ` Jeff Law
2014-04-21 16:56 ` [PATCH 65/89] Concretize three gimple_try_set_ accessors David Malcolm
2014-05-12 17:51   ` Jeff Law
2014-05-12 17:54   ` Jeff Law
2014-04-21 16:56 ` [PATCH 58/89] Make gimple_label_set_label require a gimple_label David Malcolm
2014-05-12 17:24   ` Jeff Law
2014-04-21 16:56 ` [PATCH 20/89] Introduce gimple_call David Malcolm
2014-05-09 19:00   ` Jeff Law
2014-04-21 16:56 ` [PATCH 50/89] Make gimple_phi_arg_set_location require a gimple_phi David Malcolm
2014-05-12 17:22   ` Jeff Law
2014-04-21 16:56 ` [PATCH 02/89] Introduce gimple_switch and use it in various places David Malcolm
2014-04-22  2:46   ` Trevor Saunders
2014-04-22 14:21     ` Richard Biener
2014-04-22 17:19     ` David Malcolm
2014-04-22 20:21       ` David Malcolm
2014-04-23  7:38         ` Florian Weimer
2014-04-22 22:04       ` Richard Henderson
2014-04-23 19:58         ` Jeff Law
2014-04-23 20:35           ` Richard Henderson
2014-04-23 20:38             ` Trevor Saunders
2014-04-23 20:01   ` Jeff Law
2014-04-24 13:39     ` David Malcolm
2014-04-21 16:56 ` [PATCH 63/89] Concretize gimple_eh_filter_set_types and gimple_eh_filter_set_failure David Malcolm
2014-05-12 17:49   ` Jeff Law
2014-04-21 16:56 ` [PATCH 37/89] Introduce gimple_omp_critical David Malcolm
2014-05-12 17:21   ` Jeff Law
2014-04-21 16:56 ` [PATCH 17/89] Update various expressions within tree-scalar-evolution.c to be gimple_phi David Malcolm
2014-04-21 16:56 ` [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places David Malcolm
2014-05-09 18:34   ` Jeff Law
2014-05-09 18:49     ` Impact of gimple renamings on reviews (was Re: [PATCH 16/89] tree-ssa-loop-ivopts.c: use gimple_phi in a few places) David Malcolm
2014-05-09 18:57       ` Jeff Law
2014-04-21 16:56 ` [PATCH 06/89] Introduce gimple_label and use it in a few places David Malcolm
2014-05-09 14:18   ` Jeff Law
2014-04-21 16:56 ` [PATCH 28/89] Introduce gimple_eh_else David Malcolm
2014-04-21 16:56 ` [PATCH 39/89] Introduce gimple_omp_parallel David Malcolm
2014-05-12 17:46   ` Jeff Law
2014-04-21 16:56 ` [PATCH 29/89] Introduce gimple_resx David Malcolm
2014-04-21 16:56 ` [PATCH 01/89] Const-correctness fixes for some gimple accessors David Malcolm
2014-04-21 18:46   ` Jeff Law
2014-04-21 22:45     ` David Malcolm
2014-04-27  2:35       ` Gerald Pfeifer
2014-04-21 16:57 ` [PATCH 22/89] Introduce gimple_goto David Malcolm
2014-04-22 11:49   ` Trevor Saunders
2014-04-21 16:57 ` [PATCH 45/89] Introduce gimple_omp_sections David Malcolm
2014-05-12 17:32   ` Jeff Law
2014-04-21 16:57 ` [PATCH 86/89] Concretize gimple_call_copy_flags and ipa_modify_call_arguments David Malcolm
2014-05-12 19:30   ` Jeff Law
2014-04-21 16:57 ` [PATCH 78/89] Concretize gimple_call_set_nothrow David Malcolm
2014-05-12 17:59   ` Jeff Law
2014-04-21 16:57 ` [PATCH 82/89] Concretize gimple_call_set_fntype David Malcolm
2014-05-12 18:04   ` Jeff Law
2014-04-21 16:57 ` [PATCH 14/89] tree-ssa-loop-niter.c: use gimple_phi in a few places David Malcolm
2014-05-09 18:32   ` Jeff Law
2014-04-21 16:57 ` [PATCH 88/89] Use gimple_phi in many more places David Malcolm
2014-05-12 20:38   ` Jeff Law
2014-04-21 16:57 ` [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr David Malcolm
2014-05-12 19:26   ` Jeff Law
2014-04-21 16:57 ` [PATCH 67/89] Make gimple_phi_arg_location require a gimple_phi David Malcolm
2014-05-12 19:21   ` Jeff Law
2014-04-21 16:57 ` [PATCH 21/89] Introduce gimple_return David Malcolm
2014-05-09 18:45   ` Jeff Law
2014-04-21 16:57 ` [PATCH 70/89] Concretize locals within expand_omp_for_init_counts David Malcolm
2014-05-12 17:59   ` Jeff Law
2014-04-21 16:57 ` [PATCH 73/89] Concretize gimple_cond_{true|false}_label David Malcolm
2014-05-12 18:37   ` Jeff Law
2014-04-21 16:57 ` [PATCH 25/89] Introduce gimple_catch David Malcolm
2014-04-21 16:57 ` [PATCH 89/89] Convert various gimple to gimple_phi within ssa-iterators.h David Malcolm
2014-05-12 19:42   ` Jeff Law
2014-04-21 16:57 ` [PATCH 56/89] Various gimple to gimple_call conversions in IPA David Malcolm
2014-05-12 19:34   ` Jeff Law
2014-04-21 16:57 ` [PATCH 19/89] Const-correctness of gimple_call_builtin_p David Malcolm
2014-05-07 19:39   ` Committed: " David Malcolm
2014-05-09  6:34   ` Jeff Law
2014-04-21 16:57 ` [PATCH 31/89] Use subclasses of gimple in various places David Malcolm
2014-05-09 19:02   ` Jeff Law
2014-04-21 16:57 ` [PATCH 64/89] Concretize gimple_try_set_catch_is_cleanup David Malcolm
2014-05-12 17:28   ` Jeff Law
2014-04-21 16:57 ` [PATCH 46/89] tree-parloops.c: Use gimple_phi in various places David Malcolm
2014-05-12 17:29   ` Jeff Law
2014-04-21 16:57 ` [PATCH 80/89] Tweak to gimplify_modify_expr David Malcolm
2014-05-12 18:21   ` Jeff Law
2014-04-21 16:57 ` [PATCH 07/89] Introduce gimple_debug and use it in a few places David Malcolm
2014-05-09 14:18   ` Jeff Law
2014-04-21 16:57 ` [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p David Malcolm
2014-05-12 19:38   ` Jeff Law
2014-04-21 16:57 ` [PATCH 87/89] Use gimple_call in some places within tree-ssa-dom.c David Malcolm
2014-05-12 19:32   ` Jeff Law
2014-04-21 16:57 ` [PATCH 59/89] Make gimple_goto_set_dest require a gimple_goto David Malcolm
2014-05-12 17:24   ` Jeff Law
2014-04-21 16:57 ` [PATCH 72/89] Concretize gimple_switch_index and gimple_switch_index_ptr David Malcolm
2014-05-12 19:40   ` Jeff Law
2014-04-21 16:57 ` [PATCH 60/89] Concretize gimple_catch_types David Malcolm
2014-05-12 17:25   ` Jeff Law
2014-04-21 16:57 ` [PATCH 03/89] Introduce gimple_bind and use it for accessors David Malcolm
2014-04-23 21:12   ` Jeff Law
2014-04-23 21:19     ` David Malcolm
2014-04-23 21:38       ` Jeff Law
2014-04-24  8:37         ` Richard Biener
2014-04-24 13:12           ` Andrew MacLeod
2014-04-24 15:14             ` Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.) David Malcolm
2014-04-24 16:12               ` Michael Matz
2014-04-25  8:40               ` Richard Biener
2014-04-25 17:22                 ` David Malcolm
2014-04-28  9:36                   ` Richard Biener
2014-04-21 16:57 ` [PATCH 84/89] Concretize gimple_call_arg_flags David Malcolm
2014-05-12 18:02   ` Jeff Law
2014-04-21 17:12 ` [PATCH 85/89] Concretize gimple_assign_nontemporal_move_p David Malcolm
2014-05-12 19:28   ` Jeff Law
2014-04-21 17:12 ` [PATCH 66/89] Make gimple_phi_arg_location_from_edge require a gimple_phi David Malcolm
2014-05-12 17:54   ` Jeff Law
2014-04-21 17:12 ` [PATCH 48/89] Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location " David Malcolm
2014-05-12 17:48   ` Jeff Law
2014-04-21 17:12 ` [PATCH 43/89] Introduce gimple_omp_target David Malcolm
2014-05-12 17:36   ` Jeff Law
2014-04-21 17:12 ` [PATCH 47/89] omp-low.c: Use more concrete types of gimple statement for various locals David Malcolm
2014-05-12 17:22   ` Jeff Law
2014-04-21 17:12 ` [PATCH 53/89] More gimple_phi David Malcolm
2014-05-12 17:23   ` Jeff Law
2014-04-21 17:12 ` [PATCH 77/89] Concretize various expressions from gimple to gimple_cond David Malcolm
2014-05-12 19:36   ` Jeff Law
2014-04-21 17:12 ` [PATCH 69/89] Make gimple_cond_set_{true|false}_label require gimple_cond David Malcolm
2014-05-12 17:58   ` Jeff Law
2014-04-21 17:13 ` [PATCH 57/89] Concretize parameter to gimple_call_copy_skip_args David Malcolm
2014-05-12 17:23   ` Jeff Law
2014-04-21 17:13 ` [PATCH 18/89] Concretize get_loop_exit_condition et al to working on gimple_cond David Malcolm
2014-04-21 17:13 ` [PATCH 62/89] Concretize gimple_label_label David Malcolm
2014-05-12 20:34   ` Jeff Law
2014-04-21 17:13 ` [PATCH 74/89] Concretize gimple_cond_set_code David Malcolm
2014-05-12 19:22   ` Jeff Law
2014-04-21 17:13 ` [PATCH 32/89] Introduce gimple_try David Malcolm
2014-05-09 19:05   ` Jeff Law
2014-04-21 17:13 ` [PATCH 42/89] Introduce gimple_omp_single David Malcolm
2014-05-12 17:18   ` Jeff Law
2014-04-21 17:13 ` [PATCH 51/89] Update GRAPHITE to use more concrete gimple statement classes David Malcolm
2014-05-12 20:06   ` Jeff Law
2014-04-21 17:13 ` [PATCH 24/89] Introduce gimple_transaction David Malcolm
2014-04-21 17:13 ` [PATCH 08/89] Introduce gimple_phi and use it in various places David Malcolm
2014-05-09 18:29   ` Jeff Law
2014-04-21 17:13 ` [PATCH 71/89] Concretize gimple_cond_make_{false|true} David Malcolm
2014-04-22 15:58   ` Trevor Saunders
2014-04-22 18:21     ` David Malcolm
2014-05-12 19:56   ` Jeff Law
2014-05-12 20:16     ` David Malcolm
2014-05-12 21:26       ` Jeff Law
2014-04-21 17:13 ` [PATCH 79/89] Concretize gimple_call_nothrow_p David Malcolm
2014-05-12 18:37   ` Jeff Law
2014-04-21 17:13 ` [PATCH 36/89] Introduce gimple_omp_continue David Malcolm
2014-05-12 17:42   ` Jeff Law
2014-04-21 17:14 ` [PATCH 26/89] Introduce gimple_eh_filter David Malcolm
2014-04-22 12:15   ` Trevor Saunders
2014-04-21 17:14 ` [PATCH 61/89] Concretize gimple_call_use_set and gimple_call_clobber_set David Malcolm
2014-05-12 17:25   ` Jeff Law
2014-04-21 17:14 ` [PATCH 27/89] Introduce gimple_eh_must_not_throw David Malcolm
2014-04-21 17:14 ` [PATCH 09/89] Introduce gimple_phi_iterator David Malcolm
2014-05-09 18:51   ` Jeff Law
2014-05-14 16:18     ` gphi_iterator? (was Re: [PATCH 09/89] Introduce gimple_phi_iterator) David Malcolm
2014-05-14 16:27       ` Jeff Law
2014-04-21 17:14 ` [PATCH 55/89] Use gimple_call for callgraph edges David Malcolm
2014-05-12 20:03   ` Jeff Law
2014-04-21 17:14 ` [PATCH 75/89] Concretize gimple_cond_set_{lhs|rhs} David Malcolm
2014-05-12 19:24   ` Jeff Law
2014-04-21 17:14 ` [PATCH 38/89] Introduce gimple_omp_for David Malcolm
2014-05-12 17:38   ` Jeff Law
2014-04-21 17:14 ` [PATCH 81/89] Concretize gimple_call_set_fn David Malcolm
2014-05-12 18:04   ` Jeff Law
2014-04-21 17:14 ` [PATCH 10/89] Update ssa_prop_visit_phi_fn callbacks to take a gimple_phi David Malcolm
2014-05-09 18:31   ` Jeff Law
2014-04-21 17:14 ` [PATCH 15/89] tree-ssa-loop-manip.c: use gimple_phi in three places David Malcolm
2014-05-09 18:32   ` Jeff Law
2014-04-21 17:14 ` [PATCH 33/89] Use more concrete types for various gimple statements David Malcolm
2014-04-21 20:20   ` Bill Schmidt
2014-05-12 17:11   ` Jeff Law
2014-04-21 17:15 ` [PATCH 12/89] tree-predcom.c: use gimple_phi in various places David Malcolm
2014-05-09 18:31   ` Jeff Law
2014-04-21 17:15 ` [PATCH 52/89] Make gimple_phi_arg_edge require a gimple_phi David Malcolm
2014-05-12 20:33   ` Jeff Law
2014-04-21 17:15 ` [PATCH 54/89] Make gimple_call_return_slot_opt_p require a gimple_call David Malcolm
2014-05-12 17:35   ` Jeff Law
2014-05-12 17:49   ` Jeff Law
2014-04-21 17:15 ` [PATCH 13/89] tree-ssa-phiprop.c: use gimple_phi David Malcolm
2014-05-09 18:32   ` Jeff Law
2014-04-21 17:15 ` [PATCH 44/89] Introduce gimple_omp_teams David Malcolm
2014-05-12 17:19   ` Jeff Law
2014-04-21 17:15 ` [PATCH 68/89] Concretize three gimple_return_ accessors David Malcolm
2014-05-12 19:59   ` Jeff Law
2014-04-21 17:15 ` [PATCH 40/89] tree-cfg.c: Make verify_gimple_call require a gimple_call David Malcolm
2014-05-12 17:16   ` Jeff Law
2014-04-21 17:15 ` [PATCH 23/89] Introduce gimple_asm David Malcolm
2014-04-21 17:15 ` [PATCH 35/89] Introduce gimple_omp_atomic_store David Malcolm
2014-05-12 17:16   ` Jeff Law
2014-04-21 17:29 ` [PATCH 30/89] Introduce gimple_eh_dispatch David Malcolm
2014-04-22  8:07 ` [PATCH 00/89] Compile-time gimple-checking Richard Sandiford
2014-04-22 13:20   ` Andrew MacLeod
2014-04-22 16:04     ` Trevor Saunders
2014-04-22 18:57     ` David Malcolm
2014-04-22 19:19       ` Andrew MacLeod
2014-04-22 17:13   ` David Malcolm
2014-04-22 19:11     ` Richard Sandiford
2014-04-22 19:28       ` Andrew MacLeod
2014-04-22 19:45       ` Richard Biener
2014-04-23 14:29         ` Richard Biener
2014-04-23 14:36           ` Richard Biener
2014-04-30 21:40             ` Jeff Law
2014-05-02  9:09               ` Richard Biener
2014-05-02 16:02                 ` Jeff Law
2014-05-02 16:22                   ` David Malcolm
2014-05-02 21:53                 ` [PATCH 0/3] Compile-time gimple checking, without typedefs David Malcolm
2014-05-02 21:54                   ` [PATCH 2/3] Autogenerated part of conversion of "gimple" to "gimple_stmt *" David Malcolm
2014-05-09  6:50                     ` Jeff Law
2014-05-02 21:54                   ` [PATCH 3/3] Introduce gimple_switch and use it in various places David Malcolm
2014-05-09  6:54                     ` Jeff Law
2014-05-02 21:54                   ` [PATCH 1/3] Handwritten part of conversion of "gimple" to "gimple_stmt *" David Malcolm
2014-05-09  6:49                     ` Jeff Law
2014-05-09 10:42                       ` Richard Biener
2014-05-05  8:22                   ` [PATCH 0/3] Compile-time gimple checking, without typedefs Richard Biener
2014-05-05 16:01                     ` Jeff Law
2014-05-05 17:37                       ` Richard Biener
2014-05-05 18:39                         ` David Malcolm
2014-05-05 19:36                           ` Jeff Law
2014-05-05 19:44                         ` Jeff Law
2014-05-05 19:53                           ` Jakub Jelinek
2014-05-06  9:33                             ` Martin Jambor
2014-05-06 19:00                             ` David Malcolm
2014-05-06 19:15                               ` Jeff Law
2014-05-06 19:21                                 ` Richard Biener
2014-05-05 19:56                           ` Trevor Saunders
2014-05-09  6:43                   ` Jeff Law
2014-04-23 15:38           ` [PATCH 00/89] Compile-time gimple-checking David Malcolm
2014-04-23 16:15           ` Andrew MacLeod
2014-04-23 17:32   ` Jeff Law
2014-04-24 12:23     ` Richard Sandiford
2014-04-22  8:37 ` Richard Biener
2014-04-23 17:23   ` Jeff Law
2014-04-23 14:43 ` Michael Matz
2014-04-24 13:25   ` Andrew MacLeod
2014-04-24 15:01     ` Michael Matz
2014-04-25  8:24       ` Richard Biener
2014-04-28 13:01         ` Michael Matz

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