[PATCH 07/89] Introduce gimple_debug and use it in a few places
David Malcolm
dmalcolm@redhat.com
Mon Apr 21 16:57:00 GMT 2014
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
More information about the Gcc-patches
mailing list