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]

[tree-ssa] Add -fdump-tree-dom [patch]


Adds -fdump-tree-dom and a separate dump file for dominator
optimizations.

It also restores the counting check to make sure we don't run the SSA
rename pass more than twice.

Tested on x86 by rebuilding stage3 and testing -fdump-tree-dom.


Diego.


	* Makefile.in (tree-ssa-dom.o): Add dependency on $(TREE_DUMP_H).
	* fold-const.c (fold): Remove unusued local variable 'invert'.
	* tree-dump.c (dump_files): Add entry for -fdump-tree-dom.
	* tree-flow.h (tree_ssa_dominator_optimize): Change declaration to
	accept a function decl.
	* tree-ssa-dom.c: Include timevar.h and tree-dump.h.
	(tree_ssa_dominator_optimize): Change to receive the function decl
	for the function to optimize.  Update callers.
	Use own dump file instead of dumping on the .ssa dump file.
	Dump function at the end.
	Push and pop TV_TREE_SSA_DOMINATOR_OPTS.
	* tree-ssa.c (rewrite_into_ssa): Restore check for number of times
	that the rename loop has been executed.  Abort if the loop executes
	more than twice.
	* tree.h (enum tree_dump_index): Add TDI_dom.
	* doc/invoke.texi: Document -fdump-tree-dom.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.100
diff -d -u -p -r1.903.2.100 Makefile.in
--- Makefile.in	21 Jul 2003 13:50:23 -0000	1.903.2.100
+++ Makefile.in	21 Jul 2003 17:13:19 -0000
@@ -1529,7 +1529,7 @@ tree-ssa.o : tree-ssa.c $(TREE_FLOW_H) $
    cfgloop.h
 tree-ssa-dom.o : tree-ssa-dom.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
-   errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h 
+   errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H)
 tree-ssa-live.o : tree-ssa-live.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
    ssa.h errors.h toplev.h function.h $(TIMEVAR_H) tree-alias-common.h \
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.37
diff -d -u -p -r1.213.2.37 fold-const.c
--- fold-const.c	21 Jul 2003 13:50:46 -0000	1.213.2.37
+++ fold-const.c	21 Jul 2003 17:13:21 -0000
@@ -4912,7 +4912,7 @@ fold (tree expr)
   tree arg0 = NULL_TREE, arg1 = NULL_TREE;
   enum tree_code code = TREE_CODE (t);
   int kind = TREE_CODE_CLASS (code);
-  int invert;
+
   /* WINS will be nonzero when the switch is done
      if all operands are constant.  */
   int wins = 1;
Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.6.2.30
diff -d -u -p -r1.6.2.30 tree-dump.c
--- tree-dump.c	21 Jul 2003 13:51:05 -0000	1.6.2.30
+++ tree-dump.c	21 Jul 2003 17:13:21 -0000
@@ -653,6 +653,7 @@ static struct dump_file_info dump_files[
   {".dot", "tree-dot", 0, 0},
   {".pta", "tree-pta", 0, 0},
   {".ssa", "tree-ssa", 0, 0},
+  {".dom", "tree-dom", 0, 0},
   {".mustalias", "tree-mustalias", 0, 0},
   {".predot", "tree-predot", 0, 0},
   {".pre", "tree-pre", 0, 0},
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.94
diff -d -u -p -r1.1.4.94 tree-flow.h
--- tree-flow.h	21 Jul 2003 13:51:05 -0000	1.1.4.94
+++ tree-flow.h	21 Jul 2003 17:13:21 -0000
@@ -472,7 +472,7 @@ void tree_ssa_ccp (tree);
 void fold_stmt (tree);
 
 /* In tree-ssa-dom.c  */
-extern bool tree_ssa_dominator_optimize (FILE *, int);
+extern bool tree_ssa_dominator_optimize (tree);
 extern void dump_dominator_optimization_stats (FILE *);
 extern void debug_dominator_optimization_stats (void);
 
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.5
diff -d -u -p -r1.1.2.5 tree-ssa-dom.c
--- tree-ssa-dom.c	17 Jul 2003 19:56:20 -0000	1.1.2.5
+++ tree-ssa-dom.c	21 Jul 2003 17:13:21 -0000
@@ -34,6 +34,8 @@ Boston, MA 02111-1307, USA.  */
 #include "expr.h"
 #include "function.h"
 #include "diagnostic.h"
+#include "timevar.h"
+#include "tree-dump.h"
 #include "tree-flow.h"
 
 /* This file implements optimizations on the dominator tree.  */
@@ -93,7 +95,7 @@ static hashval_t avail_expr_hash (const 
 static int avail_expr_eq (const void *, const void *);
 static void htab_statistics (FILE *, htab_t);
 
-/* Optimize the current function based on the dominator tree.  This does
+/* Optimize function FNDECL based on the dominator tree.  This does
    simple const/copy propagation and redundant expression elimination using
    value numbering.
 
@@ -103,11 +105,12 @@ static void htab_statistics (FILE *, hta
    ADDR_EXPRs to their pointer use sites.  */
 
 bool
-tree_ssa_dominator_optimize (FILE *file, int flags)
+tree_ssa_dominator_optimize (tree fndecl)
 {
+  timevar_push (TV_TREE_SSA_DOMINATOR_OPTS);
+
   /* Set up debugging dump files.  */
-  dump_file = file;
-  dump_flags = flags;
+  dump_file = dump_begin (TDI_dom, &dump_flags);
 
   /* Create our hash tables.  */
   const_and_copies = htab_create (1024, var_value_hash, var_value_eq, free);
@@ -129,7 +132,11 @@ tree_ssa_dominator_optimize (FILE *file,
     {
       if (dump_flags & TDF_STATS)
 	dump_dominator_optimization_stats (dump_file);
+      dump_end (TDI_dom, dump_file);
     }
+
+  dump_function (TDI_dom, fndecl);
+  timevar_pop (TV_TREE_SSA_DOMINATOR_OPTS);
 
   return addr_expr_propagated_p;
 }
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.105
diff -d -u -p -r1.1.4.105 tree-ssa.c
--- tree-ssa.c	17 Jul 2003 22:50:08 -0000	1.1.4.105
+++ tree-ssa.c	21 Jul 2003 17:13:22 -0000
@@ -352,14 +352,9 @@ rewrite_into_ssa (tree fndecl, sbitmap v
       rewrite_block (ENTRY_BLOCK_PTR);
       timevar_pop (TV_TREE_SSA_REWRITE_BLOCKS);
 
+      /* Now optimize all the basic blocks in the program.  */
       if (flag_tree_dom)
-	{
-	  /* Now optimize all the basic blocks in the program.  */
-	  timevar_push (TV_TREE_SSA_DOMINATOR_OPTS);
-	  addr_expr_propagated_p = tree_ssa_dominator_optimize (dump_file,
-								dump_flags);
-	  timevar_pop (TV_TREE_SSA_DOMINATOR_OPTS);
-	}
+	addr_expr_propagated_p = tree_ssa_dominator_optimize (fndecl);
 
       /* If the dominator optimizations propagated ADDR_EXPRs, we may need
 	 to repeat the SSA renaming process for the new symbols that may
@@ -380,6 +375,10 @@ rewrite_into_ssa (tree fndecl, sbitmap v
 	      sbitmap_zero (globals);
 	    }
 	}
+
+      /* Sanity check.  We should not iterate more than twice.  */
+      if (rename_count++ >= 2)
+	abort ();
     }
   while (sbitmap_first_set_bit (vars_to_rename) >= 0);
 
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.77
diff -d -u -p -r1.342.2.77 tree.h
--- tree.h	21 Jul 2003 13:51:06 -0000	1.342.2.77
+++ tree.h	21 Jul 2003 17:13:23 -0000
@@ -3402,6 +3402,8 @@ enum tree_dump_index
   TDI_pta,                      /* dump points-to information for each
 				   function.  */
   TDI_ssa,                      /* dump SSA information for each function.  */
+  TDI_dom,			/* dump dominator optimization information
+				   for each function.  */
   TDI_mustalias,		/* dump must-alias information for each
 				   function.  */
   TDI_predot,
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.152.2.47
diff -d -u -p -r1.152.2.47 invoke.texi
--- doc/invoke.texi	21 Jul 2003 13:52:04 -0000	1.152.2.47
+++ doc/invoke.texi	21 Jul 2003 17:13:27 -0000
@@ -248,7 +248,7 @@ in the following sections.
 -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
 -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
 -fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol
--fdump-tree-must-alias@r{[}-@var{n}@r{]} @gol
+-fdump-tree-must-alias@r{[}-@var{n}@r{]} -fdump-tree-dom@r{[}-@var{n}@r{]}@gol
 -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
 -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs @gol
 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
@@ -3397,6 +3397,11 @@ made by appending @file{.mudflap} to the
 Dump each function after computing must-alias information and promoting
 virtual operands to real operands.  The file name is made by appending
 @file{.must-alias} to the source file name.
+
+@item dom
+@opindex fdump-tree-dom
+Dump each function after applying dominator tree optimizations.  The file
+name is made by appending @file{.dom} to the source file name.
 
 @item all
 @opindex fdump-tree-all



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