OSDN Git Service

2006-01-16 Gabor Loki <loki@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / passes.c
index 86d38cf..b79a038 100644 (file)
@@ -420,7 +420,25 @@ next_pass_1 (struct tree_opt_pass **list, struct tree_opt_pass *pass)
           
 }
 
-/* Construct the pass tree.  */
+/* Construct the pass tree.  The sequencing of passes is driven by
+   the cgraph routines:
+
+   cgraph_finalize_compilation_unit ()
+       for each node N in the cgraph
+          cgraph_analyze_function (N)
+              cgraph_lower_function (N) -> all_lowering_passes
+
+   If we are optimizing, cgraph_optimize is then invoked:
+
+   cgraph_optimize ()
+       ipa_passes ()                   -> all_ipa_passes
+       cgraph_expand_all_functions ()
+           for each node N in the cgraph
+              cgraph_expand_function (N)
+                  cgraph_lower_function (N)    -> Now a NOP.
+                  lang_hooks.callgraph.expand_function (DECL (N))
+                       tree_rest_of_compilation (DECL (N))  -> all_passes
+*/
 
 void
 init_optimization_passes (void)
@@ -439,9 +457,8 @@ init_optimization_passes (void)
   NEXT_PASS (pass_ipa_type_escape);
   *p = NULL;
 
-  /* All passes needed to lower the function into shape optimizers can operate
-     on.  These passes are performed before interprocedural passes, unlike rest
-     of local passes (all_passes).  */
+  /* All passes needed to lower the function into shape optimizers can
+     operate on.  */
   p = &all_lowering_passes;
   NEXT_PASS (pass_remove_useless_stmts);
   NEXT_PASS (pass_mudflap_1);
@@ -481,7 +498,6 @@ init_optimization_passes (void)
   NEXT_PASS (pass_return_slot);
   NEXT_PASS (pass_rename_ssa_copies);
   NEXT_PASS (pass_early_warn_uninitialized);
-  NEXT_PASS (pass_eliminate_useless_stores);
 
   /* Initial scalar cleanups.  */
   NEXT_PASS (pass_ccp);
@@ -494,6 +510,12 @@ init_optimization_passes (void)
   NEXT_PASS (pass_merge_phi);
   NEXT_PASS (pass_dominator);
 
+  /* The only copy propagation opportunities left after DOM
+     should be due to degenerate PHI nodes.  So rather than
+     run the full copy propagator, just discover and copy
+     propagate away the degenerate PHI nodes.  */
+  NEXT_PASS (pass_phi_only_copy_prop);
+
   NEXT_PASS (pass_phiopt);
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_tail_recursion);
@@ -508,7 +530,14 @@ init_optimization_passes (void)
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_rename_ssa_copies);
   NEXT_PASS (pass_dominator);
-  NEXT_PASS (pass_copy_prop);
+
+  /* The only copy propagation opportunities left after DOM
+     should be due to degenerate PHI nodes.  So rather than
+     run the full copy propagator, just discover and copy
+     propagate away the degenerate PHI nodes.  */
+  NEXT_PASS (pass_phi_only_copy_prop);
+
+  NEXT_PASS (pass_reassoc);
   NEXT_PASS (pass_dce);
   NEXT_PASS (pass_dse);
   NEXT_PASS (pass_may_alias);
@@ -522,14 +551,21 @@ init_optimization_passes (void)
      we add may_alias right after fold builtins
      which can create arbitrary GIMPLE.  */
   NEXT_PASS (pass_may_alias);
-  NEXT_PASS (pass_cse_reciprocals);
   NEXT_PASS (pass_split_crit_edges);
-  NEXT_PASS (pass_reassoc);
   NEXT_PASS (pass_pre);
+  NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_sink_code);
   NEXT_PASS (pass_tree_loop);
+  NEXT_PASS (pass_cse_reciprocals);
+  NEXT_PASS (pass_reassoc);
   NEXT_PASS (pass_dominator);
-  NEXT_PASS (pass_copy_prop);
+
+  /* The only copy propagation opportunities left after DOM
+     should be due to degenerate PHI nodes.  So rather than
+     run the full copy propagator, just discover and copy
+     propagate away the degenerate PHI nodes.  */
+  NEXT_PASS (pass_phi_only_copy_prop);
+
   NEXT_PASS (pass_cd_dce);
 
   /* FIXME: If DCE is not run before checking for uninitialized uses,
@@ -550,7 +586,6 @@ init_optimization_passes (void)
   NEXT_PASS (pass_uncprop);
   NEXT_PASS (pass_del_ssa);
   NEXT_PASS (pass_nrv);
-  NEXT_PASS (pass_remove_useless_vars);
   NEXT_PASS (pass_mark_used_blocks);
   NEXT_PASS (pass_cleanup_cfg_post_optimizing);
   *p = NULL;
@@ -570,12 +605,16 @@ init_optimization_passes (void)
   /* NEXT_PASS (pass_may_alias) cannot be done again because the
      vectorizer creates alias relations that are not supported by
      pass_may_alias.  */
-  NEXT_PASS (pass_lower_vector_ssa);
   NEXT_PASS (pass_complete_unroll);
   NEXT_PASS (pass_iv_optimize);
   NEXT_PASS (pass_tree_loop_done);
   *p = NULL;
 
+  p = &pass_vectorize.sub;
+  NEXT_PASS (pass_lower_vector_ssa);
+  NEXT_PASS (pass_dce_loop);
+  *p = NULL;
+
   p = &pass_loop2.sub;
   NEXT_PASS (pass_rtl_loop_init);
   NEXT_PASS (pass_rtl_move_loop_invariants);
@@ -628,6 +667,7 @@ init_optimization_passes (void)
   NEXT_PASS (pass_postreload_cse);
   NEXT_PASS (pass_gcse2);
   NEXT_PASS (pass_flow2);
+  NEXT_PASS (pass_rtl_seqabstr);
   NEXT_PASS (pass_stack_adjustments);
   NEXT_PASS (pass_peephole2);
   NEXT_PASS (pass_if_after_reload);
@@ -656,15 +696,12 @@ init_optimization_passes (void)
 #undef NEXT_PASS
 
   /* Register the passes with the tree dump code.  */
+  register_dump_files (all_ipa_passes, true, PROP_gimple_leh | PROP_cfg);
   register_dump_files (all_lowering_passes, false, PROP_gimple_any);
-  register_dump_files (all_passes, false, PROP_gimple_leh
-                                         | PROP_cfg);
-  register_dump_files (all_ipa_passes, true, PROP_gimple_leh
-                                            | PROP_cfg);
+  register_dump_files (all_passes, false, PROP_gimple_leh | PROP_cfg);
 }
 
 static unsigned int last_verified;
-
 static void
 execute_todo (struct tree_opt_pass *pass, unsigned int flags, bool use_required)
 {
@@ -700,6 +737,9 @@ execute_todo (struct tree_opt_pass *pass, unsigned int flags, bool use_required)
       update_ssa (update_flags);
     }
 
+  if (flags & TODO_remove_unused_locals)
+    remove_unused_locals ();
+
   if ((flags & TODO_dump_func)
       && dump_file && current_function_decl)
     {