From 8838e2081789dd01485b19b6f96cf509e292e2bf Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 10 Dec 2013 13:19:47 -0500 Subject: [PATCH] Introduce gimple_debug and use it in a few places This corresponds to: [PATCH 07/89] Introduce gimple_debug and use it in a few places https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01192.html from the original 89-patch kit That earlier patch was approved by Jeff: > Same as prior patches. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00598.html 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. (is_a_helper ::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 to a vec. * 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/ChangeLog.gimple-classes | 37 +++++++++++++++++++++++++++++++++++++ gcc/coretypes.h | 4 ++++ gcc/gdbhooks.py | 2 ++ gcc/gimple-pretty-print.c | 4 ++-- gcc/gimple.c | 20 +++++++++++--------- gcc/gimple.h | 26 ++++++++++++++++++++++++-- gcc/tree-inline.c | 16 +++++++++------- gcc/tree-inline.h | 2 +- 8 files changed, 90 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 68eb66985a6..ec16551a968 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,42 @@ 2014-10-24 David Malcolm + Introduce gimple_debug and use it in a few places + + * 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. + (is_a_helper ::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 to a vec. + + * 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. + +2014-10-24 David Malcolm + Introduce gimple_label and use it in a few places * coretypes.h (gimple_label): New typedef. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 24c6352c8e0..a338599fda8 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -94,6 +94,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 7514e45a01e..455fa5cd5c7 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -460,6 +460,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 9766d57f315..4ab867376ab 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -1082,7 +1082,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) { @@ -2217,7 +2217,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, as_a (gs), spc, flags); break; case GIMPLE_PREDICT: diff --git a/gcc/gimple.c b/gcc/gimple.c index 7eff0b64799..b99e0d4158c 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -765,13 +765,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 = + as_a (gimple_build_with_ops_stat (GIMPLE_DEBUG, + (unsigned)GIMPLE_DEBUG_BIND, 2 + PASS_MEM_STAT)); gimple_debug_bind_set_var (p, var); gimple_debug_bind_set_value (p, value); if (stmt) @@ -785,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 = + as_a ( + gimple_build_with_ops_stat (GIMPLE_DEBUG, + (unsigned)GIMPLE_DEBUG_SOURCE_BIND, 2 + PASS_MEM_STAT)); 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 0e34c678228..8e5b42a8f94 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -780,6 +780,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. @@ -864,6 +878,14 @@ is_a_helper ::test (gimple gs) template <> template <> inline bool +is_a_helper ::test (gimple gs) +{ + return gs->code == GIMPLE_DEBUG; +} + +template <> +template <> +inline bool is_a_helper ::test (gimple gs) { return gs->code == GIMPLE_LABEL; @@ -1278,10 +1300,10 @@ gimple gimple_build_resx (int); gimple_switch gimple_build_switch_nlabels (unsigned, tree, tree); gimple_switch gimple_build_switch (tree, tree, vec ); 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 5b7cdea3ac5..96bd561c033 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1509,15 +1509,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); @@ -2317,7 +2318,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; @@ -2645,7 +2647,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; @@ -2737,7 +2739,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 53059da57b3..87351b17a90 100644 --- a/gcc/tree-inline.h +++ b/gcc/tree-inline.h @@ -127,7 +127,7 @@ struct copy_body_data bitmap blocks_to_copy; /* Debug statements that need processing. */ - vec debug_stmts; + vec debug_stmts; /* A map from local declarations in the inlined function to equivalents in the function into which it is being inlined, where -- 2.11.4.GIT