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] Add TDF_NOUID


This adds TDF_NOUID (and corresponding -nouid flag for tree and rtl
dumps).  It avoids dumping DECL_UID and replaces it with xxxx.
This can be useful if you want to compare dumps of slightly differing
sources, compile options or compiler revisions.  It is also necessary
to keep -fcompare-debug working (with an additional patch required)
if you randomize UIDs in some way.

Bootstrapped and tested on x86_64-unknown-linux-gnu, I will commit
this together with 
http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01606.html.

Richard.

2009-11-29  Richard Guenther  <rguenther@suse.de>

	* tree-dump.c (dump_option_value_in): Add TDF_NOUID.
	* tree-pass.h (TDF_NOUID): Likewise.
	* print-rtl.c: Include tree-pass.h.
	(print_mem_expr): Pass dump_flags.
	(print_rtx): Likewise.
	* print-tree.c: Include tree-pass.h.
	(print_node_brief): Handle TDF_NOUID.
	(print_node): Likewise.
	* tree-pretty-print.c (dump_decl_name): Likewise.
	(dump_generic_node): Likewise.
	* Makefile.in (print-rtl.o, print-tree.o): Add $(TREE_PASS_H)
	dependency.

Index: gcc/print-rtl.c
===================================================================
*** gcc/print-rtl.c.orig	2009-11-29 16:20:17.000000000 +0100
--- gcc/print-rtl.c	2009-11-29 16:20:23.000000000 +0100
*************** along with GCC; see the file COPYING3.  
*** 42,47 ****
--- 42,48 ----
  #include "basic-block.h"
  #include "diagnostic.h"
  #include "cselib.h"
+ #include "tree-pass.h"
  #endif
  
  static FILE *outfile;
*************** void
*** 78,84 ****
  print_mem_expr (FILE *outfile, const_tree expr)
  {
    fputc (' ', outfile);
!   print_generic_expr (outfile, CONST_CAST_TREE (expr), 0);
  }
  #endif
  
--- 79,85 ----
  print_mem_expr (FILE *outfile, const_tree expr)
  {
    fputc (' ', outfile);
!   print_generic_expr (outfile, CONST_CAST_TREE (expr), dump_flags);
  }
  #endif
  
*************** print_rtx (const_rtx in_rtx)
*** 241,247 ****
  	  {
  	    tree decl = SYMBOL_REF_DECL (in_rtx);
  	    if (decl)
! 	      print_node_brief (outfile, "", decl, 0);
  	  }
  #endif
  	else if (i == 4 && NOTE_P (in_rtx))
--- 242,248 ----
  	  {
  	    tree decl = SYMBOL_REF_DECL (in_rtx);
  	    if (decl)
! 	      print_node_brief (outfile, "", decl, dump_flags);
  	  }
  #endif
  	else if (i == 4 && NOTE_P (in_rtx))
Index: gcc/print-tree.c
===================================================================
*** gcc/print-tree.c.orig	2009-11-29 16:20:17.000000000 +0100
--- gcc/print-tree.c	2009-11-29 16:32:09.000000000 +0100
*************** along with GCC; see the file COPYING3.  
*** 32,37 ****
--- 32,38 ----
  #include "tree-iterator.h"
  #include "diagnostic.h"
  #include "tree-flow.h"
+ #include "tree-pass.h"
  
  /* Define the hash table of nodes already seen.
     Such nodes are not repeated; brief cross-references are used.  */
*************** print_node_brief (FILE *file, const char
*** 95,104 ****
  	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (TREE_CODE (node) == LABEL_DECL
  	       && LABEL_DECL_UID (node) != -1)
! 	fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
        else
! 	fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
! 		 DECL_UID (node));
      }
    else if (tclass == tcc_type)
      {
--- 96,117 ----
  	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (TREE_CODE (node) == LABEL_DECL
  	       && LABEL_DECL_UID (node) != -1)
! 	{
! 	  if (dump_flags & TDF_NOUID)
! 	    fprintf (file, " L.xxxx");
! 	  else
! 	    fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
! 	}
        else
! 	{
! 	  if (dump_flags & TDF_NOUID)
! 	    fprintf (file, " %c.xxxx",
! 		     TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
! 	  else
! 	    fprintf (file, " %c.%u",
! 		     TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
! 		     DECL_UID (node));
! 	}
      }
    else if (tclass == tcc_type)
      {
*************** print_node (FILE *file, const char *pref
*** 260,269 ****
  	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (code == LABEL_DECL
  	       && LABEL_DECL_UID (node) != -1)
! 	fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
        else
! 	fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
! 		 DECL_UID (node));
      }
    else if (tclass == tcc_type)
      {
--- 273,292 ----
  	fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (code == LABEL_DECL
  	       && LABEL_DECL_UID (node) != -1)
! 	{
! 	  if (dump_flags & TDF_NOUID)
! 	    fprintf (file, " L.xxxx");
! 	  else
! 	    fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
! 	}
        else
! 	{
! 	  if (dump_flags & TDF_NOUID)
! 	    fprintf (file, " %c.xxxx", code == CONST_DECL ? 'C' : 'D');
! 	  else
! 	    fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
! 		     DECL_UID (node));
! 	}
      }
    else if (tclass == tcc_type)
      {
Index: gcc/tree-dump.c
===================================================================
*** gcc/tree-dump.c.orig	2009-11-29 16:20:17.000000000 +0100
--- gcc/tree-dump.c	2009-11-29 16:20:23.000000000 +0100
*************** static const struct dump_option_value_in
*** 821,826 ****
--- 821,827 ----
    {"memsyms", TDF_MEMSYMS},
    {"verbose", TDF_VERBOSE},
    {"eh", TDF_EH},
+   {"nouid", TDF_NOUID},
    {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
  	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
  	    | TDF_RHS_ONLY)},
Index: gcc/tree-pass.h
===================================================================
*** gcc/tree-pass.h.orig	2009-11-29 16:20:17.000000000 +0100
--- gcc/tree-pass.h	2009-11-29 16:20:23.000000000 +0100
*************** enum tree_dump_index
*** 79,84 ****
--- 79,85 ----
  #define TDF_EH		(1 << 19)	/* display EH region number
  					   holding this gimple statement.  */
  
+ #define TDF_NOUID	(1 << 20)	/* omit UIDs from dumps.  */
  
  /* In tree-dump.c */
  
Index: gcc/tree-pretty-print.c
===================================================================
*** gcc/tree-pretty-print.c.orig	2009-11-29 16:20:17.000000000 +0100
--- gcc/tree-pretty-print.c	2009-11-29 16:20:23.000000000 +0100
*************** dump_decl_name (pretty_printer *buffer, 
*** 182,194 ****
    if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
      {
        if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
!         pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
        else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
! 	pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
        else
  	{
  	  char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
! 	  pp_printf (buffer, "%c.%u", c, DECL_UID (node));
  	}
      }
  }
--- 182,202 ----
    if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
      {
        if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
! 	pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
        else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
! 	{
! 	  if (flags & TDF_NOUID)
! 	    pp_string (buffer, "D#xxxx");
! 	  else
! 	    pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
! 	}
        else
  	{
  	  char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
! 	  if (flags & TDF_NOUID)
! 	    pp_printf (buffer, "%c.xxxx", c);
! 	  else
! 	    pp_printf (buffer, "%c.%u", c, DECL_UID (node));
  	}
      }
  }
*************** dump_generic_node (pretty_printer *buffe
*** 1030,1038 ****
        if (DECL_NAME (node))
  	dump_decl_name (buffer, node, flags);
        else if (LABEL_DECL_UID (node) != -1)
!         pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
        else
!         pp_printf (buffer, "<D.%u>", DECL_UID (node));
        break;
  
      case TYPE_DECL:
--- 1038,1051 ----
        if (DECL_NAME (node))
  	dump_decl_name (buffer, node, flags);
        else if (LABEL_DECL_UID (node) != -1)
! 	pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
        else
! 	{
! 	  if (flags & TDF_NOUID)
! 	    pp_string (buffer, "<D.xxxx>");
! 	  else
! 	    pp_printf (buffer, "<D.%u>", DECL_UID (node));
! 	}
        break;
  
      case TYPE_DECL:
Index: gcc/Makefile.in
===================================================================
*** gcc/Makefile.in.orig	2009-11-29 16:19:45.000000000 +0100
--- gcc/Makefile.in	2009-11-29 16:20:23.000000000 +0100
*************** tree-inline.o : tree-inline.c $(CONFIG_H
*** 2264,2270 ****
     $(IPA_PROP_H) value-prof.h $(TREE_PASS_H) $(TARGET_H) $(INTEGRATE_H)
  print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(GGC_H) langhooks.h $(REAL_H) tree-iterator.h fixed-value.h \
!    $(DIAGNOSTIC_H) $(TREE_FLOW_H)
  stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) $(PARAMS_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) output.h $(RTL_H) \
     $(GGC_H) $(TM_P_H) $(TARGET_H) langhooks.h $(REGS_H) gt-stor-layout.h \
--- 2264,2270 ----
     $(IPA_PROP_H) value-prof.h $(TREE_PASS_H) $(TARGET_H) $(INTEGRATE_H)
  print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(GGC_H) langhooks.h $(REAL_H) tree-iterator.h fixed-value.h \
!    $(DIAGNOSTIC_H) $(TREE_FLOW_H) $(TREE_PASS_H)
  stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(TREE_H) $(PARAMS_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) output.h $(RTL_H) \
     $(GGC_H) $(TM_P_H) $(TARGET_H) langhooks.h $(REGS_H) gt-stor-layout.h \
*************** rtl.o : rtl.c $(CONFIG_H) $(SYSTEM_H) co
*** 2744,2750 ****
  
  print-rtl.o : print-rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
      $(RTL_H) $(TREE_H) hard-reg-set.h $(BASIC_BLOCK_H) $(FLAGS_H) \
!     $(BCONFIG_H) $(REAL_H) $(DIAGNOSTIC_H) cselib.h
  rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H) \
     $(RTL_H) hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H) $(REAL_H) \
     $(FLAGS_H) $(REGS_H) output.h $(TARGET_H) $(FUNCTION_H) $(TREE_H) \
--- 2744,2750 ----
  
  print-rtl.o : print-rtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
      $(RTL_H) $(TREE_H) hard-reg-set.h $(BASIC_BLOCK_H) $(FLAGS_H) \
!     $(BCONFIG_H) $(REAL_H) $(DIAGNOSTIC_H) cselib.h $(TREE_PASS_H)
  rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H) \
     $(RTL_H) hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H) $(REAL_H) \
     $(FLAGS_H) $(REGS_H) output.h $(TARGET_H) $(FUNCTION_H) $(TREE_H) \


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