This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
sched-vis: prevent visual_tbl overflow
- To: gcc-patches at gcc dot gnu dot org
- Subject: sched-vis: prevent visual_tbl overflow
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 05 Dec 2000 19:49:20 -0200
- Organization: GCC Team, Red Hat
While playing with scheduling, I introduced an insn with a huge
ready-delay, and this exercised a latent bug in sched-vis.c. Tested
on i686-pc-linux-gnu with -dap. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* sched-vis.c (visual_tbl_line_length): New variable.
(get_visual_tbl_length): Set it.
(visualize_stall_cycles): Don't let stalls overrun
visual_tbl_line_length.
Index: gcc/sched-vis.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-vis.c,v
retrieving revision 1.2
diff -u -p -r1.2 sched-vis.c
--- gcc/sched-vis.c 2000/12/05 16:51:13 1.2
+++ gcc/sched-vis.c 2000/12/05 21:41:18
@@ -82,6 +82,7 @@ insn_print_units (insn)
#define MAX_VISUAL_LINES 100
#define INSN_LEN 30
int n_visual_lines;
+static int visual_tbl_line_length;
char *visual_tbl;
int n_vis_no_unit;
rtx vis_no_unit[10];
@@ -133,6 +134,8 @@ get_visual_tbl_length ()
n += n1;
n += strlen ("\n") + 2;
+ visual_tbl_line_length = n;
+
/* Compute length of visualization string. */
return (MAX_VISUAL_LINES * n);
}
@@ -897,6 +900,8 @@ visualize_stall_cycles (stalls)
int stalls;
{
int i;
+ const char *prefix = ";; ";
+ const char *suffix = "\n";
/* If no more room, split table into two. */
if (n_visual_lines >= MAX_VISUAL_LINES)
@@ -906,11 +911,19 @@ visualize_stall_cycles (stalls)
}
n_visual_lines++;
+
+ sprintf (visual_tbl + strlen (visual_tbl), "%s", prefix);
- sprintf (visual_tbl + strlen (visual_tbl), ";; ");
+ if (stalls > visual_tbl_line_length - strlen (prefix) - strlen (suffix))
+ {
+ suffix = "[...]\n";
+ stalls = visual_tbl_line_length - strlen (prefix) - strlen (suffix);
+ }
+
for (i = 0; i < stalls; i++)
sprintf (visual_tbl + strlen (visual_tbl), ".");
- sprintf (visual_tbl + strlen (visual_tbl), "\n");
+
+ sprintf (visual_tbl + strlen (visual_tbl), "%s", suffix);
}
/* Allocate data used for visualization during scheduling. */
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me