This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Unify tree/RTL dump file handling (2/5)


This part changes graph.* so that it receives the full base name
of the dump (without the `.vcg' suffix), and adapts passes.c to the
new interface.

Paolo

2004-08-13  Paolo Bonzini  <bonzini@gnu.org>

	* graph.c (print_rtl_graph_with_bb, clean_graph_dump_file,
	finish_graph_dump_file): Remove SUFFIX parameter.
	* graph.h (print_rtl_graph_with_bb, clean_graph_dump_file,
	finish_graph_dump_file): Likewise.
	* passes.c (open_dump_file, close_dump_file): Adjust.
	(finish_optimization_passes): Update finish_graph_dump_file loop.

diff -rpu gcc-backup/gcc/graph.c gcc-pass/gcc/graph.c
*** gcc-backup/gcc/graph.c	2004-08-08 10:20:19.000000000 +0200
--- gcc-pass/gcc/graph.c	2004-08-08 10:35:32.000000000 +0200
***************
*** 220,240 ****
  /* Like print_rtl, but also print out live information for the start of each
     basic block.  */
  void
! print_rtl_graph_with_bb (const char *base, const char *suffix, rtx rtx_first)
  {
    rtx tmp_rtx;
    size_t namelen = strlen (base);
-   size_t suffixlen = strlen (suffix);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + suffixlen + extlen);
    FILE *fp;
  
    if (basic_block_info == NULL)
      return;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, suffix, suffixlen);
!   memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "a");
    if (fp == NULL)
--- 220,238 ----
  /* Like print_rtl, but also print out live information for the start of each
     basic block.  */
  void
! print_rtl_graph_with_bb (const char *base, rtx rtx_first)
  {
    rtx tmp_rtx;
    size_t namelen = strlen (base);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + extlen);
    FILE *fp;
  
    if (basic_block_info == NULL)
      return;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "a");
    if (fp == NULL)
***************
*** 385,401 ****
  /* Similar as clean_dump_file, but this time for graph output files.  */
  
  void
! clean_graph_dump_file (const char *base, const char *suffix)
  {
    size_t namelen = strlen (base);
-   size_t suffixlen = strlen (suffix);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + extlen + suffixlen);
    FILE *fp;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, suffix, suffixlen);
!   memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "w");
  
--- 383,397 ----
  /* Similar as clean_dump_file, but this time for graph output files.  */
  
  void
! clean_graph_dump_file (const char *base)
  {
    size_t namelen = strlen (base);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + extlen);
    FILE *fp;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "w");
  
***************
*** 417,433 ****
  
  /* Do final work on the graph output file.  */
  void
! finish_graph_dump_file (const char *base, const char *suffix)
  {
    size_t namelen = strlen (base);
-   size_t suffixlen = strlen (suffix);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + suffixlen + extlen);
    FILE *fp;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, suffix, suffixlen);
!   memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "a");
    if (fp != NULL)
--- 413,427 ----
  
  /* Do final work on the graph output file.  */
  void
! finish_graph_dump_file (const char *base)
  {
    size_t namelen = strlen (base);
    size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
!   char *buf = alloca (namelen + extlen);
    FILE *fp;
  
    memcpy (buf, base, namelen);
!   memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
  
    fp = fopen (buf, "a");
    if (fp != NULL)
diff -rpu gcc-backup/gcc/graph.h gcc-pass/gcc/graph.h
*** gcc-backup/gcc/graph.h	2004-08-08 10:20:19.000000000 +0200
--- gcc-pass/gcc/graph.h	2004-08-08 10:35:32.000000000 +0200
***************
*** 21,28 ****
  #ifndef GCC_GRAPH_H
  #define GCC_GRAPH_H
  
! extern void print_rtl_graph_with_bb (const char *, const char *, rtx);
! extern void clean_graph_dump_file (const char *, const char *);
! extern void finish_graph_dump_file (const char *, const char *);
  
  #endif /* ! GCC_GRAPH_H */
--- 21,28 ----
  #ifndef GCC_GRAPH_H
  #define GCC_GRAPH_H
  
! extern void print_rtl_graph_with_bb (const char *, rtx);
! extern void clean_graph_dump_file (const char *);
! extern void finish_graph_dump_file (const char *);
  
  #endif /* ! GCC_GRAPH_H */
diff -rpu gcc-backup/gcc/passes.c gcc-pass/gcc/passes.c
*** gcc-backup/gcc/passes.c	2004-08-08 10:20:19.000000000 +0200
--- gcc-pass/gcc/passes.c	2004-08-13 16:07:40.000000000 +0200
***************
*** 226,237 ****
    { "dbr",	'd', 0, 0, 0 },
  };
  
  /* Routine to open a dump file.  Return true if the dump file is enabled.  */
  
  static int
  open_dump_file (enum dump_file_index index, tree decl)
  {
-   char *dump_name;
    const char *open_arg;
    char seq[16];
  
--- 226,238 ----
    { "dbr",	'd', 0, 0, 0 },
  };
  
+ static char *dump_name;
+ 
  /* Routine to open a dump file.  Return true if the dump file is enabled.  */
  
  static int
  open_dump_file (enum dump_file_index index, tree decl)
  {
    const char *open_arg;
    char seq[16];
  
***************
*** 244,274 ****
  
    sprintf (seq, DUMPFILE_FORMAT, index);
  
    if (! dump_file_tbl[index].initialized)
      {
        /* If we've not initialized the files, do so now.  */
        if (graph_dump_format != no_graph
  	  && dump_file_tbl[index].graph_dump_p)
! 	{
! 	  dump_name = concat (seq, dump_file_tbl[index].extension, NULL);
! 	  clean_graph_dump_file (dump_base_name, dump_name);
! 	  free (dump_name);
! 	}
        dump_file_tbl[index].initialized = 1;
        open_arg = "w";
      }
    else
      open_arg = "a";
  
-   dump_name = concat (dump_base_name, seq,
- 		      dump_file_tbl[index].extension, NULL);
- 
    dump_file = fopen (dump_name, open_arg);
    if (dump_file == NULL)
      fatal_error ("can't open %s: %m", dump_name);
  
-   free (dump_name);
- 
    if (decl)
      fprintf (dump_file, "\n;; Function %s%s\n\n",
  	     lang_hooks.decl_printable_name (decl, 2),
--- 245,270 ----
  
    sprintf (seq, DUMPFILE_FORMAT, index);
  
+   dump_name = concat (dump_base_name, seq,
+ 		      dump_file_tbl[index].extension, NULL);
+ 
    if (! dump_file_tbl[index].initialized)
      {
        /* If we've not initialized the files, do so now.  */
        if (graph_dump_format != no_graph
  	  && dump_file_tbl[index].graph_dump_p)
! 	clean_graph_dump_file (dump_name);
! 
        dump_file_tbl[index].initialized = 1;
        open_arg = "w";
      }
    else
      open_arg = "a";
  
    dump_file = fopen (dump_name, open_arg);
    if (dump_file == NULL)
      fatal_error ("can't open %s: %m", dump_name);
  
    if (decl)
      fprintf (dump_file, "\n;; Function %s%s\n\n",
  	     lang_hooks.decl_printable_name (decl, 2),
***************
*** 296,316 ****
    if (insns
        && graph_dump_format != no_graph
        && dump_file_tbl[index].graph_dump_p)
!     {
!       char seq[16];
!       char *suffix;
! 
!       sprintf (seq, DUMPFILE_FORMAT, index);
!       suffix = concat (seq, dump_file_tbl[index].extension, NULL);
!       print_rtl_graph_with_bb (dump_base_name, suffix, insns);
!       free (suffix);
!     }
  
    if (func && insns)
      func (dump_file, insns);
  
    fflush (dump_file);
    fclose (dump_file);
  
    dump_file = NULL;
    timevar_pop (TV_DUMP);
--- 292,305 ----
    if (insns
        && graph_dump_format != no_graph
        && dump_file_tbl[index].graph_dump_p)
!     print_rtl_graph_with_bb (dump_name, insns);
  
    if (func && insns)
      func (dump_file, insns);
  
    fflush (dump_file);
    fclose (dump_file);
+   free (dump_name);
  
    dump_file = NULL;
    timevar_pop (TV_DUMP);
***************
*** 2007,2018 ****
  	if (dump_file_tbl[i].initialized && dump_file_tbl[i].graph_dump_p)
  	  {
  	    char seq[16];
! 	    char *suffix;
  
  	    sprintf (seq, DUMPFILE_FORMAT, i);
! 	    suffix = concat (seq, dump_file_tbl[i].extension, NULL);
! 	    finish_graph_dump_file (dump_base_name, suffix);
! 	    free (suffix);
  	  }
      }
  
--- 1846,1857 ----
  	if (dump_file_tbl[i].initialized && dump_file_tbl[i].graph_dump_p)
  	  {
  	    char seq[16];
! 	    char *graph_dump_name;
  
  	    sprintf (seq, DUMPFILE_FORMAT, i);
! 	    graph_dump_name = concat (dump_base_name, seq, dump_file_tbl[i].extension, NULL);
! 	    finish_graph_dump_file (graph_dump_name);
! 	    free (graph_dump_name);
  	  }
      }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]