This corresponds to: [PATCH 29/89] Introduce gimple_resx https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01161.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_resx): New typedef. (const_gimple_resx): New typedef. * gimple.h (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_resx): Convert local "x" from gimple to gimple_resx. (lower_resx): Require a gimple_resx rather than a plain gimple. (pass_lower_resx::execute): 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/ChangeLog.gimple-classes | 39 +++++++++++++++++++++++++++++++++++++++ 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 | 13 +++++-------- gcc/tree-cfg.c | 5 +++-- gcc/tree-eh.c | 11 +++++++---- gcc/tree-inline.c | 5 +++-- 10 files changed, 69 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index fe3008a..6e2d2f5 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,44 @@ 2014-10-24 David Malcolm <dmalc...@redhat.com> + Introduce gimple_resx + + * coretypes.h (gimple_resx): New typedef. + (const_gimple_resx): New typedef. + + * gimple.h (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_resx): Convert local "x" from gimple to + gimple_resx. + (lower_resx): Require a gimple_resx rather than a plain gimple. + (pass_lower_resx::execute): 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. + +2014-10-24 David Malcolm <dmalc...@redhat.com> + Introduce gimple_eh_else * coretypes.h (gimple_eh_else): New typedef. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index ba076ec..fc2dbf3 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -150,6 +150,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 a82049f..81f1a35 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1057,7 +1057,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, @@ -2214,7 +2214,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, as_a <gimple_resx> (gs), spc, flags); break; case GIMPLE_EH_DISPATCH: diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 1d1ad27..55f939c 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 (as_a <gimple_resx> (stmt), + 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 41a4dc4..b23dfb7 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 (as_a <gimple_resx> (stmt))); break; case GIMPLE_EH_MUST_NOT_THROW: diff --git a/gcc/gimple.c b/gcc/gimple.c index b3c663c..c94611a 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -710,12 +710,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 = + as_a <gimple_resx> (gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0)); p->region = region; return p; } diff --git a/gcc/gimple.h b/gcc/gimple.h index 9b73e00..f15693b 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1332,7 +1332,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); @@ -4019,22 +4019,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 10422c6..3ac05cb 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6524,9 +6524,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 = as_a <gimple_resx> (stmt); + 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 fbb40e5..f58e518 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -805,7 +805,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); @@ -3145,7 +3145,8 @@ 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, hash_map<eh_region, tree> *mnt_map) +lower_resx (basic_block bb, gimple_resx stmt, + hash_map<eh_region, tree> *mnt_map) { int lp_nr; eh_region src_r, dst_r; @@ -3333,7 +3334,8 @@ pass_lower_resx::execute (function *fun) gimple last = last_stmt (bb); if (last && is_gimple_resx (last)) { - dominance_invalidated |= lower_resx (bb, last, &mnt_map); + dominance_invalidated |= + lower_resx (bb, as_a <gimple_resx> (last), &mnt_map); any_rewritten = true; } } @@ -3818,7 +3820,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 (as_a <gimple_resx> (stmt))); 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 b6f2a5c..60f501d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1584,9 +1584,10 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) case GIMPLE_RESX: { - int r = gimple_resx_region (copy); + gimple_resx resx_stmt = as_a <gimple_resx> (copy); + 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