This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 07/16] Introduce gimple_debug and use it in a few places
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Fri, 13 Dec 2013 10:58:17 -0500
- Subject: [PATCH 07/16] Introduce gimple_debug and use it in a few places
- Authentication-results: sourceware.org; auth=none
- References: <1386950306-11944-1-git-send-email-dmalcolm at redhat dot com>
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 5d69c5d..57db319 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -74,6 +74,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 2b29585..9f28c4e 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 515e0b9..aa7c148 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)
{
@@ -2222,7 +2222,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 cf7613c..a07e582 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 e0d2226..f5dcf0c 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -217,6 +217,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 ()
{
@@ -255,6 +261,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 ()
{
@@ -855,6 +867,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.
@@ -939,6 +965,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;
@@ -1353,10 +1387,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 9879d11..d3c769c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1465,15 +1465,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);
@@ -2254,7 +2255,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;
@@ -2573,7 +2575,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;
@@ -2665,7 +2667,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 d871fc4..fc4d07b 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -124,7 +124,7 @@ typedef 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.7.11.7