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]: Fix PR 18519


This was a latent problem exposed (in one place) and caused (in another)
by my must-def patch.

For things renaming vars or fixing def def chains, we can't call
cleanup_tree_cfg until after that happens, because the phi nodes may be
out of whack, and cleanup_tree_cfg calls thread_jumps and friends (which
depend on correct phi nodes).

Rather than simply remove the call to cleanup_tree_cfg, i made it into a
todo flag, and made the todo execute after the SSA fixups.

I didn't change the few remaining places which either iterate
cleanup_tree_cfg or were calling it before the end of the pass.

Bootstrappde and regtested on i686-pc-linux-gnu.

Okay for mainline?


2004-11-16  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/18519
	
	* tree-optimize (execute_todo): Add case for TODO_cleanup_cfg.
	* tree-pass.h: Add TODO_cleanup_cfg.
	* tree-ssa-ccp.c (pass_ccp): Use TODO_cleanup_cfg.
	(ccp_finalize): Remove call to cleanup_cfg.
	* tree-ssa-dce.c (pass_dce): Use TODO_cleanup_cfg.
	(pass_cd_dce): Ditto.
	(perform_tree_ssa_dce): Remove call to cleanup_cfg.
	* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
	(pass_ch): Add TODO_cleanup_cfg.
	* tree-ssa-loop.c (tree_ssa_loop_done): Remove call to
	cleanup_cfg.
	(pass_loop_done): Add TODO_cleanup_cfg.
	* tree-ssa-phiopt.c (pass_phiopt): Ditto.
	(tree_ssa_phiopt): Remove call to cleanup_cfg.	
	

Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.61
diff -u -p -r2.61 tree-optimize.c
--- tree-optimize.c	2 Nov 2004 00:23:04 -0000	2.61
+++ tree-optimize.c	16 Nov 2004 20:04:00 -0000
@@ -426,6 +426,9 @@ execute_todo (int properties, unsigned i
       bitmap_clear (vars_to_rename);
     }
 
+  if (flags & TODO_cleanup_cfg)
+    cleanup_tree_cfg ();
+
   if ((flags & TODO_dump_func) && dump_file)
     {
       if (properties & PROP_trees)
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pass.h,v
retrieving revision 2.20
diff -u -p -r2.20 tree-pass.h
--- tree-pass.h	27 Oct 2004 17:45:20 -0000	2.20
+++ tree-pass.h	16 Nov 2004 20:04:00 -0000
@@ -107,6 +107,7 @@ struct dump_file_info
 #define TODO_verify_flow	(1 << 4)
 #define TODO_verify_stmts	(1 << 5)
 #define TODO_fix_def_def_chains (1 << 6)        /* rewrite def-def chains  */
+#define TODO_cleanup_cfg        (1 << 7)        /* cleanup the cfg.  */
 
 #define TODO_verify_all \
   (TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts)
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-ccp.c,v
retrieving revision 2.49
diff -u -p -r2.49 tree-ssa-ccp.c
--- tree-ssa-ccp.c	4 Nov 2004 22:07:39 -0000	2.49
+++ tree-ssa-ccp.c	16 Nov 2004 20:04:00 -0000
@@ -629,9 +629,6 @@ ccp_finalize (void)
   /* Perform substitutions based on the known constant values.  */
   substitute_and_fold ();
 
-  /* Now cleanup any unreachable code.  */
-  cleanup_tree_cfg ();
-
   free (value_vector);
 }
 
@@ -1229,7 +1226,7 @@ struct tree_opt_pass pass_ccp = 
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  TODO_dump_func | TODO_rename_vars
+  TODO_cleanup_cfg | TODO_dump_func | TODO_rename_vars
     | TODO_ggc_collect | TODO_verify_ssa
     | TODO_verify_stmts,		/* todo_flags_finish */
   0					/* letter */
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dce.c,v
retrieving revision 2.26
diff -u -p -r2.26 tree-ssa-dce.c
--- tree-ssa-dce.c	4 Nov 2004 08:41:15 -0000	2.26
+++ tree-ssa-dce.c	16 Nov 2004 20:04:00 -0000
@@ -951,8 +951,6 @@ perform_tree_ssa_dce (bool aggressive)
   if (aggressive)
     free_dominance_info (CDI_POST_DOMINATORS);
 
-  cleanup_tree_cfg ();
-
   /* Debugging dumps.  */
   if (dump_file)
     {
@@ -997,7 +995,7 @@ struct tree_opt_pass pass_dce =
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  TODO_fix_def_def_chains |TODO_ggc_collect | TODO_verify_ssa,	/* todo_flags_finish */
+  TODO_fix_def_def_chains | TODO_cleanup_cfg | TODO_ggc_collect | TODO_verify_ssa,	/* todo_flags_finish */
   0					/* letter */
 };
 
@@ -1014,7 +1012,7 @@ struct tree_opt_pass pass_cd_dce =
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  TODO_fix_def_def_chains | TODO_ggc_collect | TODO_verify_ssa | TODO_verify_flow,
+  TODO_fix_def_def_chains | TODO_cleanup_cfg | TODO_ggc_collect | TODO_verify_ssa | TODO_verify_flow,
 					/* todo_flags_finish */
   0					/* letter */
 };
Index: tree-ssa-loop-ch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ch.c,v
retrieving revision 2.8
diff -u -p -r2.8 tree-ssa-loop-ch.c
--- tree-ssa-loop-ch.c	28 Sep 2004 07:59:52 -0000	2.8
+++ tree-ssa-loop-ch.c	16 Nov 2004 20:04:00 -0000
@@ -214,11 +214,6 @@ copy_loop_headers (void)
 #endif
 
   loop_optimizer_finalize (loops, NULL);
-
-  /* Run cleanup_tree_cfg here regardless of whether we have done anything, so
-     that we cleanup the blocks created in order to get the loops into a
-     canonical shape.  */
-  cleanup_tree_cfg ();
 }
 
 static bool
@@ -240,7 +235,7 @@ struct tree_opt_pass pass_ch = 
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  (TODO_dump_func
-   | TODO_verify_ssa),			/* todo_flags_finish */
+  TODO_cleanup_cfg | TODO_dump_func 
+  | TODO_verify_ssa,			/* todo_flags_finish */
   0					/* letter */
 };
Index: tree-ssa-loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop.c,v
retrieving revision 2.21
diff -u -p -r2.21 tree-ssa-loop.c
--- tree-ssa-loop.c	1 Nov 2004 03:24:44 -0000	2.21
+++ tree-ssa-loop.c	16 Nov 2004 20:04:00 -0000
@@ -411,7 +411,6 @@ tree_ssa_loop_done (void)
   loop_optimizer_finalize (current_loops,
 			   (dump_flags & TDF_DETAILS ? dump_file : NULL));
   current_loops = NULL;
-  cleanup_tree_cfg ();
 }
   
 struct tree_opt_pass pass_loop_done = 
@@ -427,7 +426,7 @@ struct tree_opt_pass pass_loop_done = 
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  TODO_dump_func,			/* todo_flags_finish */
+  TODO_cleanup_cfg | TODO_dump_func,	/* todo_flags_finish */
   0					/* letter */
 };
 
Index: tree-ssa-phiopt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-phiopt.c,v
retrieving revision 2.18
diff -u -p -r2.18 tree-ssa-phiopt.c
--- tree-ssa-phiopt.c	22 Oct 2004 17:05:08 -0000	2.18
+++ tree-ssa-phiopt.c	16 Nov 2004 20:04:00 -0000
@@ -137,11 +137,6 @@ tree_ssa_phiopt (void)
 	      }
 	}
     }
-
-  /* If we removed any PHIs, then we have unreachable blocks and blocks
-     which need to be merged in the CFG.  */
-  if (removed_phis)
-    cleanup_tree_cfg ();
 }
 
 /* Return TRUE if block BB has no executable statements, otherwise return
@@ -668,7 +663,7 @@ struct tree_opt_pass pass_phiopt =
   0,					/* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  TODO_dump_func | TODO_ggc_collect	/* todo_flags_finish */
+  TODO_cleanup_cfg | TODO_dump_func | TODO_ggc_collect	/* todo_flags_finish */
     | TODO_verify_ssa | TODO_rename_vars
     | TODO_verify_flow,
   0					/* letter */

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