From f9d52516c192ce8530432a3c46af00f3c3c5e0e9 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 16 Dec 2013 12:37:56 -0500 Subject: [PATCH] Introduce gimple_eh_must_not_throw This corresponds to: [PATCH 27/89] Introduce gimple_eh_must_not_throw https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01218.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_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_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/ChangeLog.gimple-classes | 27 +++++++++++++++++++++++++++ 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 | 9 ++++----- gcc/tree-eh.c | 3 ++- 8 files changed, 53 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index e91317caf8d..dd39ce6e7dc 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,32 @@ 2014-10-24 David Malcolm + Introduce gimple_eh_must_not_throw + + * 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_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. + +2014-10-24 David Malcolm + Introduce gimple_eh_filter * coretypes.h (gimple_eh_filter): New typedef. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index d2d19ecd2e6..51b73f680b2 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -142,6 +142,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 5876a0cfed4..42f94a361c4 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1021,8 +1021,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, @@ -2203,7 +2203,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, + as_a (gs), + spc, flags); break; case GIMPLE_EH_ELSE: diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index a4130a5be05..1d1ad27ccb5 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 ( + as_a (stmt), + 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 cc87e8891aa..41a4dc485bb 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 ( + as_a (stmt)), + true); break; case GIMPLE_EH_DISPATCH: diff --git a/gcc/gimple.c b/gcc/gimple.c index 3b1ff987f2f..a52d989a459 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -644,10 +644,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 = + as_a ( + gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0)); 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 0d95035b326..445a1c00840 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1327,7 +1327,7 @@ gimple_asm gimple_build_asm_vec (const char *, vec *, vec *); 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); @@ -3652,18 +3652,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 (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 (gs); eh_mnt_stmt->fndecl = decl; } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 15dcf518c4f..d22eb45b8af 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -1861,7 +1861,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 ( + as_a (inner)); this_region->u.must_not_throw.failure_loc = LOCATION_LOCUS (gimple_location (tp)); -- 2.11.4.GIT