Commit 47044ef2 by Martin Liska Committed by Martin Liska

Fix print_node for CONSTRUCTORs

	* print-tree.c (struct bucket): Remove.
	(print_node): Add new argument which drives whether a tree node
	is printed briefly or not.
	(debug_tree): Replace a custom hash table with hash_set<T>.
	* print-tree.h (print_node): Add the argument.

From-SVN: r242820
parent 665ad37b
2016-11-24 Martin Liska <mliska@suse.cz>
* print-tree.c (struct bucket): Remove.
(print_node): Add new argument which drives whether a tree node
is printed briefly or not.
(debug_tree): Replace a custom hash table with hash_set<T>.
* print-tree.h (print_node): Add the argument.
2016-11-24 Chung-Lin Tang <cltang@codesourcery.com> 2016-11-24 Chung-Lin Tang <cltang@codesourcery.com>
* config/nios2/nios2.c (nios2_init_libfuncs): Add ATTRIBUTE_UNUSED. * config/nios2/nios2.c (nios2_init_libfuncs): Add ATTRIBUTE_UNUSED.
...@@ -33,19 +33,14 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,19 +33,14 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-pretty-print.h" /* FIXME */ #include "gimple-pretty-print.h" /* FIXME */
#include "tree-cfg.h" #include "tree-cfg.h"
#include "tree-dump.h" #include "tree-dump.h"
#include "print-tree.h"
/* Define the hash table of nodes already seen. /* Define the hash table of nodes already seen.
Such nodes are not repeated; brief cross-references are used. */ Such nodes are not repeated; brief cross-references are used. */
#define HASH_SIZE 37 #define HASH_SIZE 37
struct bucket static hash_set<tree> *table = NULL;
{
tree node;
struct bucket *next;
};
static struct bucket **table;
/* Print PREFIX and ADDR to FILE. */ /* Print PREFIX and ADDR to FILE. */
void void
...@@ -176,10 +171,9 @@ indent_to (FILE *file, int column) ...@@ -176,10 +171,9 @@ indent_to (FILE *file, int column)
starting in column INDENT. */ starting in column INDENT. */
void void
print_node (FILE *file, const char *prefix, tree node, int indent) print_node (FILE *file, const char *prefix, tree node, int indent,
bool brief_for_visited)
{ {
int hash;
struct bucket *b;
machine_mode mode; machine_mode mode;
enum tree_code_class tclass; enum tree_code_class tclass;
int len; int len;
...@@ -219,21 +213,14 @@ print_node (FILE *file, const char *prefix, tree node, int indent) ...@@ -219,21 +213,14 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
/* Allow this function to be called if the table is not there. */ /* Allow this function to be called if the table is not there. */
if (table) if (table)
{ {
hash = ((uintptr_t) node) % HASH_SIZE;
/* If node is in the table, just mention its address. */ /* If node is in the table, just mention its address. */
for (b = table[hash]; b; b = b->next) if (table->contains (node) && brief_for_visited)
if (b->node == node) {
{ print_node_brief (file, prefix, node, indent);
print_node_brief (file, prefix, node, indent); return;
return; }
}
/* Add this node to the table. */ table->add (node);
b = XNEW (struct bucket);
b->node = node;
b->next = table[hash];
table[hash] = b;
} }
/* Indent to the specified column, since this is the long form. */ /* Indent to the specified column, since this is the long form. */
...@@ -846,8 +833,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent) ...@@ -846,8 +833,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
cnt, index, value) cnt, index, value)
{ {
print_node (file, "idx", index, indent + 4); print_node (file, "idx", index, indent + 4, false);
print_node (file, "val", value, indent + 4); print_node (file, "val", value, indent + 4, false);
} }
} }
break; break;
...@@ -997,10 +984,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent) ...@@ -997,10 +984,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
DEBUG_FUNCTION void DEBUG_FUNCTION void
debug_tree (tree node) debug_tree (tree node)
{ {
table = XCNEWVEC (struct bucket *, HASH_SIZE); table = new hash_set<tree> (HASH_SIZE);
print_node (stderr, "", node, 0); print_node (stderr, "", node, 0);
free (table); delete table;
table = 0; table = NULL;
putc ('\n', stderr); putc ('\n', stderr);
} }
......
...@@ -38,7 +38,8 @@ extern void debug_raw (vec<tree, va_gc> &ref); ...@@ -38,7 +38,8 @@ extern void debug_raw (vec<tree, va_gc> &ref);
extern void debug_raw (vec<tree, va_gc> *ptr); extern void debug_raw (vec<tree, va_gc> *ptr);
#ifdef BUFSIZ #ifdef BUFSIZ
extern void dump_addr (FILE*, const char *, const void *); extern void dump_addr (FILE*, const char *, const void *);
extern void print_node (FILE *, const char *, tree, int); extern void print_node (FILE *, const char *, tree, int,
bool brief_for_visited = true);
extern void print_node_brief (FILE *, const char *, const_tree, int); extern void print_node_brief (FILE *, const char *, const_tree, int);
extern void indent_to (FILE *, int); extern void indent_to (FILE *, int);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment