diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2017-11-20 08:32:57 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2017-11-20 08:32:57 +0000 |
commit | 19a30b7123aa90caf7de3e9ec588266e218f8028 (patch) | |
tree | 32e5e7fae29ce15cabb6a27c2982ccabef10c491 /gcc | |
parent | 7cfaa4c643eabd8d5aaa74a8406f0bf4880b8fe6 (diff) | |
download | gcc-19a30b7123aa90caf7de3e9ec588266e218f8028.zip gcc-19a30b7123aa90caf7de3e9ec588266e218f8028.tar.gz gcc-19a30b7123aa90caf7de3e9ec588266e218f8028.tar.bz2 |
vec.h (debug_helper): New function.
* vec.h (debug_helper): New function.
(DEFINE_DEBUG_VEC): New macro.
* hash-set.h (debug_helper): New function.
(DEFINE_DEBUG_HASH_SET): New macro.
* cfg.c (debug_slim (edge)): New function.
Call DEFINE_DEBUG_VEC for edges.
Call DEFINE_DEBUG_HASH_SET for edges.
* cfghooks.c (debug_slim (basic_block)): New function.
Call DEFINE_DEBUG_VEC for basic blocks.
Call DEFINE_DEBUG_HASH_SET for basic blocks.
* print-tree.c (debug_slim): New function to handle trees.
Call DEFINE_DEBUG_VEC for trees.
Call DEFINE_DEBUG_HASH_SET for trees.
(debug (vec<tree, va_gc>) &): Remove.
(debug (<vec<tree, va_gc>) *): Remove.
* print-rtl.c (debug_slim): New function to handle const_rtx.
Call DEFINE_DEBUG_VEC for rtx_def.
Call DEFINE_DEBUG_VEC for rtx_insn.
Call DEFINE_DEBUG_HASH_SET for rtx_def.
Call DEFINE_DEBUG_HASH_SET for rtx_insn.
* sel-sched-dump.c (debug (vec<rtx_insn *> &): Remove.
(debug (vec<rtx_insn *> *ptr): Remove.
(debug_insn_vector): Remove.
* stor-layout.c (debug_rli): Call debug() instead of debug_vec_tree.
From-SVN: r254945
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/cfg.c | 10 | ||||
-rw-r--r-- | gcc/cfghooks.c | 8 | ||||
-rw-r--r-- | gcc/hash-set.h | 38 | ||||
-rw-r--r-- | gcc/print-rtl.c | 17 | ||||
-rw-r--r-- | gcc/print-tree.c | 35 | ||||
-rw-r--r-- | gcc/sel-sched-dump.c | 29 | ||||
-rw-r--r-- | gcc/stor-layout.c | 2 | ||||
-rw-r--r-- | gcc/vec.h | 77 |
9 files changed, 184 insertions, 59 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 827ee60..c0bec3a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2017-11-20 Aldy Hernandez <aldyh@redhat.com> + + * vec.h (debug_helper): New function. + (DEFINE_DEBUG_VEC): New macro. + * hash-set.h (debug_helper): New function. + (DEFINE_DEBUG_HASH_SET): New macro. + * cfg.c (debug_slim (edge)): New function. + Call DEFINE_DEBUG_VEC for edges. + Call DEFINE_DEBUG_HASH_SET for edges. + * cfghooks.c (debug_slim (basic_block)): New function. + Call DEFINE_DEBUG_VEC for basic blocks. + Call DEFINE_DEBUG_HASH_SET for basic blocks. + * print-tree.c (debug_slim): New function to handle trees. + Call DEFINE_DEBUG_VEC for trees. + Call DEFINE_DEBUG_HASH_SET for trees. + (debug (vec<tree, va_gc>) &): Remove. + (debug (<vec<tree, va_gc>) *): Remove. + * print-rtl.c (debug_slim): New function to handle const_rtx. + Call DEFINE_DEBUG_VEC for rtx_def. + Call DEFINE_DEBUG_VEC for rtx_insn. + Call DEFINE_DEBUG_HASH_SET for rtx_def. + Call DEFINE_DEBUG_HASH_SET for rtx_insn. + * sel-sched-dump.c (debug (vec<rtx_insn *> &): Remove. + (debug (vec<rtx_insn *> *ptr): Remove. + (debug_insn_vector): Remove. + * stor-layout.c (debug_rli): Call debug() instead of debug_vec_tree. + 2017-11-20 Tom de Vries <tom@codesourcery.com> PR rtl-optimization/82020 @@ -553,6 +553,16 @@ debug (edge_def *ptr) else fprintf (stderr, "<nil>\n"); } + +static void +debug_slim (edge e) +{ + fprintf (stderr, "<edge 0x%p (%d -> %d)>", (void *) e, + e->src->index, e->dest->index); +} + +DEFINE_DEBUG_VEC (edge) +DEFINE_DEBUG_HASH_SET (edge) /* Simple routines to easily allocate AUX fields of basic blocks. */ diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c index 4a22424..2bee65a 100644 --- a/gcc/cfghooks.c +++ b/gcc/cfghooks.c @@ -300,6 +300,14 @@ debug (basic_block_def *ptr) fprintf (stderr, "<nil>\n"); } +static void +debug_slim (basic_block ptr) +{ + fprintf (stderr, "<basic_block %p (%d)>", (void *) ptr, ptr->index); +} + +DEFINE_DEBUG_VEC (basic_block_def *) +DEFINE_DEBUG_HASH_SET (basic_block_def *) /* Dumps basic block BB to pretty-printer PP, for use as a label of a DOT graph record-node. The implementation of this hook is diff --git a/gcc/hash-set.h b/gcc/hash-set.h index 8ce796d..75ca147 100644 --- a/gcc/hash-set.h +++ b/gcc/hash-set.h @@ -127,6 +127,44 @@ private: hash_table<Traits> m_table; }; +/* Generic hash_set<TYPE> debug helper. + + This needs to be instantiated for each hash_set<TYPE> used throughout + the compiler like this: + + DEFINE_DEBUG_HASH_SET (TYPE) + + The reason we have a debug_helper() is because GDB can't + disambiguate a plain call to debug(some_hash), and it must be called + like debug<TYPE>(some_hash). */ +template<typename T> +void +debug_helper (hash_set<T> &ref) +{ + for (typename hash_set<T>::iterator it = ref.begin (); + it != ref.end (); ++it) + { + debug_slim (*it); + fputc ('\n', stderr); + } +} + +#define DEFINE_DEBUG_HASH_SET(T) \ + template static void debug_helper (hash_set<T> &); \ + DEBUG_FUNCTION void \ + debug (hash_set<T> &ref) \ + { \ + debug_helper <T> (ref); \ + } \ + DEBUG_FUNCTION void \ + debug (hash_set<T> *ptr) \ + { \ + if (ptr) \ + debug (*ptr); \ + else \ + fprintf (stderr, "<nil>\n"); \ + } + /* ggc marking routines. */ template<typename K, typename H> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 28d9986..5fe2380 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -967,6 +967,23 @@ debug (const rtx_def *ptr) fprintf (stderr, "<nil>\n"); } +/* Like debug_rtx but with no newline, as debug_helper will add one. + + Note: No debug_slim(rtx_insn *) variant implemented, as this + function can serve for both rtx and rtx_insn. */ + +static void +debug_slim (const_rtx x) +{ + rtx_writer w (stderr, 0, false, false, NULL); + w.print_rtx (x); +} + +DEFINE_DEBUG_VEC (rtx_def *) +DEFINE_DEBUG_VEC (rtx_insn *) +DEFINE_DEBUG_HASH_SET (rtx_def *) +DEFINE_DEBUG_HASH_SET (rtx_insn *) + /* Count of rtx's to print with debug_rtx_list. This global exists because gdb user defined commands have no arguments. */ diff --git a/gcc/print-tree.c b/gcc/print-tree.c index d534c76..3a0f85d 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -1095,32 +1095,6 @@ debug_raw (vec<tree, va_gc> &ref) } DEBUG_FUNCTION void -debug (vec<tree, va_gc> &ref) -{ - tree elt; - unsigned ix; - - /* Print the slot this node is in, and its code, and address. */ - fprintf (stderr, "<VEC"); - dump_addr (stderr, " ", ref.address ()); - - FOR_EACH_VEC_ELT (ref, ix, elt) - { - fprintf (stderr, "elt:%d ", ix); - debug (elt); - } -} - -DEBUG_FUNCTION void -debug (vec<tree, va_gc> *ptr) -{ - if (ptr) - debug (*ptr); - else - fprintf (stderr, "<nil>\n"); -} - -DEBUG_FUNCTION void debug_raw (vec<tree, va_gc> *ptr) { if (ptr) @@ -1129,8 +1103,11 @@ debug_raw (vec<tree, va_gc> *ptr) fprintf (stderr, "<nil>\n"); } -DEBUG_FUNCTION void -debug_vec_tree (vec<tree, va_gc> *vec) +static void +debug_slim (tree t) { - debug_raw (vec); + print_node_brief (stderr, "", t, 0); } + +DEFINE_DEBUG_VEC (tree) +DEFINE_DEBUG_HASH_SET (tree) diff --git a/gcc/sel-sched-dump.c b/gcc/sel-sched-dump.c index 388a8af..027b6b1 100644 --- a/gcc/sel-sched-dump.c +++ b/gcc/sel-sched-dump.c @@ -989,35 +989,6 @@ debug_blist (blist_t bnds) restore_dump (); } -/* Dump a rtx vector REF. */ -DEBUG_FUNCTION void -debug (vec<rtx_insn *> &ref) -{ - switch_dump (stderr); - dump_insn_vector (ref); - sel_print ("\n"); - restore_dump (); -} - -DEBUG_FUNCTION void -debug (vec<rtx_insn *> *ptr) -{ - if (ptr) - debug (*ptr); - else - fprintf (stderr, "<nil>\n"); -} - -/* Dump an insn vector SUCCS. */ -DEBUG_FUNCTION void -debug_insn_vector (rtx_vec_t succs) -{ - switch_dump (stderr); - dump_insn_vector (succs); - sel_print ("\n"); - restore_dump (); -} - /* Dump a hard reg set SET to stderr. */ DEBUG_FUNCTION void debug_hard_reg_set (HARD_REG_SET set) diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 7730ac3..0ce97a5 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -942,7 +942,7 @@ debug_rli (record_layout_info rli) if (!vec_safe_is_empty (rli->pending_statics)) { fprintf (stderr, "pending statics:\n"); - debug_vec_tree (rli->pending_statics); + debug (rli->pending_statics); } } @@ -407,6 +407,83 @@ struct GTY((user)) vec { }; +/* Generic vec<> debug helpers. + + These need to be instantiated for each vec<TYPE> used throughout + the compiler like this: + + DEFINE_DEBUG_VEC (TYPE) + + The reason we have a debug_helper() is because GDB can't + disambiguate a plain call to debug(some_vec), and it must be called + like debug<TYPE>(some_vec). */ + +template<typename T> +void +debug_helper (vec<T> &ref) +{ + unsigned i; + for (i = 0; i < ref.length (); ++i) + { + fprintf (stderr, "[%d] = ", i); + debug_slim (ref[i]); + fputc ('\n', stderr); + } +} + +/* We need a separate va_gc variant here because default template + argument for functions cannot be used in c++-98. Once this + restriction is removed, those variant should be folded with the + above debug_helper. */ + +template<typename T> +void +debug_helper (vec<T, va_gc> &ref) +{ + unsigned i; + for (i = 0; i < ref.length (); ++i) + { + fprintf (stderr, "[%d] = ", i); + debug_slim (ref[i]); + fputc ('\n', stderr); + } +} + +/* Macro to define debug(vec<T>) and debug(vec<T, va_gc>) helper + functions for a type T. */ + +#define DEFINE_DEBUG_VEC(T) \ + template static void debug_helper (vec<T> &); \ + template static void debug_helper (vec<T, va_gc> &); \ + /* Define the vec<T> debug functions. */ \ + DEBUG_FUNCTION void \ + debug (vec<T> &ref) \ + { \ + debug_helper <T> (ref); \ + } \ + DEBUG_FUNCTION void \ + debug (vec<T> *ptr) \ + { \ + if (ptr) \ + debug (*ptr); \ + else \ + fprintf (stderr, "<nil>\n"); \ + } \ + /* Define the vec<T, va_gc> debug functions. */ \ + DEBUG_FUNCTION void \ + debug (vec<T, va_gc> &ref) \ + { \ + debug_helper <T> (ref); \ + } \ + DEBUG_FUNCTION void \ + debug (vec<T, va_gc> *ptr) \ + { \ + if (ptr) \ + debug (*ptr); \ + else \ + fprintf (stderr, "<nil>\n"); \ + } + /* Default-construct N elements in DST. */ template <typename T> |