This corresponds to:
  [PATCH 30/89] Introduce gimple_eh_dispatch
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01236.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> 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.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00628.html

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_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/ChangeLog.gimple-classes | 53 ++++++++++++++++++++++++++++++++++++++++++++
 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                 |  6 ++---
 gcc/gimple.h                 | 15 +++++--------
 gcc/tree-cfg.c               | 12 +++++-----
 gcc/tree-eh.c                | 17 ++++++++------
 gcc/tree-eh.h                |  6 ++---
 gcc/tree-inline.c            |  7 +++---
 11 files changed, 98 insertions(+), 34 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 6e2d2f5..a7461cd 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,58 @@
 2014-10-24  David Malcolm  <dmalc...@redhat.com>
 
+       Introduce gimple_eh_dispatch
+
+       * 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_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.
+
+2014-10-24  David Malcolm  <dmalc...@redhat.com>
+
        Introduce gimple_resx
 
        * coretypes.h (gimple_resx): New typedef.
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index fc2dbf3..6914027 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -154,6 +154,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 81f1a35..00ff34c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1069,7 +1069,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,
@@ -2218,7 +2218,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, as_a <gimple_eh_dispatch> (gs), spc,
+                              flags);
       break;
 
     case GIMPLE_DEBUG:
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index 55f939c..202ecac 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 (as_a <gimple_eh_dispatch> (stmt),
+                                    streamer_read_hwi (ib));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index b23dfb7..2bc605f 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 (
+                           as_a <gimple_eh_dispatch> (stmt)));
       break;
 
     case GIMPLE_ASM:
diff --git a/gcc/gimple.c b/gcc/gimple.c
index c94611a..2b00869 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -760,11 +760,11 @@ 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_eh_dispatch p =
+    as_a <gimple_eh_dispatch> (
       gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
   p->region = region;
   return p;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index f15693b..f1af63a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1335,7 +1335,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)
@@ -4035,23 +4035,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 3ac05cb..feeefea 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -812,7 +812,8 @@ make_edges (void)
              fallthru = false;
              break;
            case GIMPLE_EH_DISPATCH:
-             fallthru = make_eh_dispatch_edges (last);
+             fallthru =
+               make_eh_dispatch_edges (as_a <gimple_eh_dispatch> (last));
              break;
 
            case GIMPLE_CALL:
@@ -5324,7 +5325,7 @@ gimple_verify_flow_info (void)
          break;
 
        case GIMPLE_EH_DISPATCH:
-         err |= verify_eh_dispatch_edge (stmt);
+         err |= verify_eh_dispatch_edge (as_a <gimple_eh_dispatch> (stmt));
          break;
 
        default:
@@ -5578,7 +5579,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 (as_a <gimple_eh_dispatch> (stmt), e, dest);
       break;
 
     case GIMPLE_TRANSACTION:
@@ -6533,9 +6534,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 = as_a <gimple_eh_dispatch> (stmt);
+       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 f58e518..5a83f3f 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -816,7 +816,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);
 }
 
@@ -2197,7 +2197,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;
@@ -2355,7 +2355,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;
@@ -3544,7 +3544,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;
@@ -3732,7 +3732,8 @@ pass_lower_eh_dispatch::execute (function *fun)
        continue;
       if (gimple_code (last) == GIMPLE_EH_DISPATCH)
        {
-         redirected |= lower_eh_dispatch (bb, last);
+         redirected |= lower_eh_dispatch (bb,
+                                          as_a <gimple_eh_dispatch> (last));
          flags |= TODO_update_ssa_only_virtuals;
        }
       else if (gimple_code (last) == GIMPLE_RESX)
@@ -3824,7 +3825,9 @@ mark_reachable_handlers (sbitmap *r_reachablep, sbitmap 
*lp_reachablep)
                              gimple_resx_region (as_a <gimple_resx> (stmt)));
              break;
            case GIMPLE_EH_DISPATCH:
-             bitmap_set_bit (r_reachable, gimple_eh_dispatch_region (stmt));
+             bitmap_set_bit (r_reachable,
+                             gimple_eh_dispatch_region (
+                                as_a <gimple_eh_dispatch> (stmt)));
              break;
            default:
              break;
@@ -4666,7 +4669,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 51c2adc..78198d1 100644
--- a/gcc/tree-eh.h
+++ b/gcc/tree-eh.h
@@ -30,10 +30,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);
@@ -51,6 +51,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 60f501d..beb06a3 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1593,9 +1593,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 = as_a <gimple_eh_dispatch> (copy);
+             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;
 
@@ -2105,7 +2106,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 (as_a <gimple_eh_dispatch> (copy_stmt));
       else if (can_throw)
        make_eh_edges (copy_stmt);
 
-- 
1.8.5.3

Reply via email to