This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Avoid recursion in dump_generic_node
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dberlin at dberlin dot org
- Date: Tue, 12 Aug 2003 20:42:06 +0200
- Subject: [tree-ssa] Avoid recursion in dump_generic_node
Hello,
when dumping long compound_expr chains, dump_generic_node may run
out of stack. This patch fixes it.
Zdenek
* Makefile.in (tree-pretty-print.o): Add tree-iterator.h dependency.
* tree-pretty-print.c: Include tree-iterator.h.
(dump_generic_node): Avoid recursing into COMPOUND_EXPRs.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.108
diff -c -3 -p -r1.903.2.108 Makefile.in
*** Makefile.in 8 Aug 2003 00:27:09 -0000 1.903.2.108
--- Makefile.in 12 Aug 2003 18:35:55 -0000
*************** tree-nomudflap.o : $(CONFIG_H) errors.h
*** 1583,1589 ****
output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H) $(TREE_FLOW_H) \
! $(TM_H) coretypes.h
fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
flags.h real.h toplev.h $(HASHTAB_H) $(EXPR_H) $(RTL_H) $(GGC_H) $(TM_P_H) langhooks.h
diagnostic.o : diagnostic.c diagnostic.h real.h diagnostic.def \
--- 1587,1593 ----
output.h varray.h langhooks.h tree-mudflap.h $(TM_H) coretypes.h
tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H) $(TREE_FLOW_H) \
! $(TM_H) coretypes.h tree-iterator.h
fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
flags.h real.h toplev.h $(HASHTAB_H) $(EXPR_H) $(RTL_H) $(GGC_H) $(TM_P_H) langhooks.h
diagnostic.o : diagnostic.c diagnostic.h real.h diagnostic.def \
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.34
diff -c -3 -p -r1.1.2.34 tree-pretty-print.c
*** tree-pretty-print.c 23 Jul 2003 16:59:59 -0000 1.1.2.34
--- tree-pretty-print.c 12 Aug 2003 18:35:56 -0000
*************** Software Foundation, 59 Temple Place - S
*** 30,35 ****
--- 30,36 ----
#include "hashtab.h"
#include "tree-flow.h"
#include "langhooks.h"
+ #include "tree-iterator.h"
/* Local functions, macros and variables. */
static int op_prio (tree);
*************** dump_generic_node (output_buffer *buffer
*** 135,140 ****
--- 136,142 ----
tree type;
tree op0, op1;
const char* str;
+ tree_stmt_iterator si;
if (node == NULL_TREE)
return spc;
*************** dump_generic_node (output_buffer *buffer
*** 643,661 ****
if (dumping_stmts)
{
dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
! if (!(flags & TDF_SLIM))
{
- output_add_character (buffer, ';');
newline_and_indent (buffer, spc);
! dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
}
}
else
{
dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
! output_add_character (buffer, ',');
! output_add_space (buffer);
! dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
}
break;
--- 645,675 ----
if (dumping_stmts)
{
dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
! if (flags & TDF_SLIM)
! break;
! output_add_character (buffer, ';');
!
! for (si = tsi_start (&TREE_OPERAND (node, 1));
! !tsi_end_p (si);
! tsi_next (&si))
{
newline_and_indent (buffer, spc);
! dump_generic_node (buffer, tsi_stmt (si), spc, flags);
! output_add_character (buffer, ';');
}
}
else
{
dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
!
! for (si = tsi_start (&TREE_OPERAND (node, 1));
! !tsi_end_p (si);
! tsi_next (&si))
! {
! output_add_character (buffer, ',');
! output_add_space (buffer);
! dump_generic_node (buffer, tsi_stmt (si), spc, flags);
! }
}
break;