OSDN Git Service

2010-08-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / passes.c
index 7ae4787..4823c63 100644 (file)
@@ -121,7 +121,7 @@ print_current_pass (FILE *file)
 
 
 /* Call from the debugger to get the current pass name.  */
-void
+DEBUG_FUNCTION void
 debug_pass (void)
 {
   print_current_pass (stderr);
@@ -194,8 +194,6 @@ rest_of_decl_compilation (tree decl,
            ;
          else if (TREE_CODE (decl) != FUNCTION_DECL)
            varpool_finalize_decl (decl);
-         else
-           assemble_variable (decl, top_level, at_end, 0);
        }
 
 #ifdef ASM_FINISH_DECLARE_OBJECT
@@ -795,6 +793,10 @@ init_optimization_passes (void)
           NEXT_PASS (pass_cleanup_eh);
           NEXT_PASS (pass_profile);
           NEXT_PASS (pass_local_pure_const);
+         /* Split functions creates parts that are not run through
+            early optimizations again.  It is thus good idea to do this
+            late.  */
+          NEXT_PASS (pass_split_functions);
        }
       NEXT_PASS (pass_release_ssa_names);
       NEXT_PASS (pass_rebuild_cgraph_edges);
@@ -802,15 +804,17 @@ init_optimization_passes (void)
     }
   NEXT_PASS (pass_ipa_increase_alignment);
   NEXT_PASS (pass_ipa_matrix_reorg);
+  NEXT_PASS (pass_ipa_lower_emutls);
   *p = NULL;
 
   p = &all_regular_ipa_passes;
   NEXT_PASS (pass_ipa_whole_program_visibility);
   NEXT_PASS (pass_ipa_profile);
   NEXT_PASS (pass_ipa_cp);
+  NEXT_PASS (pass_ipa_cdtor_merge);
   NEXT_PASS (pass_ipa_inline);
-  NEXT_PASS (pass_ipa_reference);
   NEXT_PASS (pass_ipa_pure_const);
+  NEXT_PASS (pass_ipa_reference);
   NEXT_PASS (pass_ipa_type_escape);
   NEXT_PASS (pass_ipa_pta);
   NEXT_PASS (pass_ipa_struct_reorg);
@@ -897,9 +901,12 @@ init_optimization_passes (void)
          NEXT_PASS (pass_check_data_deps);
          NEXT_PASS (pass_loop_distribution);
          NEXT_PASS (pass_linear_transform);
-         NEXT_PASS (pass_graphite_transforms);
+         NEXT_PASS (pass_copy_prop);
+         NEXT_PASS (pass_graphite);
            {
-             struct opt_pass **p = &pass_graphite_transforms.pass.sub;
+             struct opt_pass **p = &pass_graphite.pass.sub;
+             NEXT_PASS (pass_copy_prop);
+             NEXT_PASS (pass_graphite_transforms);
              NEXT_PASS (pass_copy_prop);
              NEXT_PASS (pass_dce_loop);
              NEXT_PASS (pass_lim);
@@ -1120,7 +1127,7 @@ do_per_function (void (*callback) (void *data), void *data)
    keep the array visible to garbage collector to avoid reading collected
    out nodes.  */
 static int nnodes;
-static GTY ((length ("nnodes"))) struct cgraph_node **order;
+static GTY ((length ("nnodes"))) cgraph_node_ptr *order;
 
 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
    function CALLBACK for every function in the call graph.  Otherwise,
@@ -1136,7 +1143,7 @@ do_per_function_toporder (void (*callback) (void *data), void *data)
   else
     {
       gcc_assert (!order);
-      order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes);
+      order = ggc_alloc_vec_cgraph_node_ptr (cgraph_n_nodes);
       nnodes = cgraph_postorder (order);
       for (i = nnodes - 1; i >= 0; i--)
         order[i]->process = 1;
@@ -1171,14 +1178,10 @@ static void
 execute_function_todo (void *data)
 {
   unsigned int flags = (size_t)data;
-  if (cfun->curr_properties & PROP_ssa)
-    flags |= TODO_verify_ssa;
   flags &= ~cfun->last_verified;
   if (!flags)
     return;
 
-  statistics_fini_pass ();
-
   /* Always cleanup the CFG before trying to update SSA.  */
   if (flags & TODO_cleanup_cfg)
     {
@@ -1243,22 +1246,7 @@ execute_function_todo (void *data)
     }
 
   if (flags & TODO_rebuild_frequencies)
-    {
-      if (profile_status == PROFILE_GUESSED)
-       {
-         loop_optimizer_init (0);
-         add_noreturn_fake_exit_edges ();
-         mark_irreducible_loops ();
-         connect_infinite_loops_to_exit ();
-         estimate_bb_frequencies ();
-         remove_fake_exit_edges ();
-         loop_optimizer_finalize ();
-       }
-      else if (profile_status == PROFILE_READ)
-       counts_to_freqs ();
-      else
-       gcc_unreachable ();
-    }
+    rebuild_frequencies ();
 
 #if defined ENABLE_CHECKING
   if (flags & TODO_verify_ssa
@@ -1290,6 +1278,8 @@ execute_todo (unsigned int flags)
   /* Inform the pass whether it is the first time it is run.  */
   first_pass_instance = (flags & TODO_mark_first_instance) != 0;
 
+  statistics_fini_pass ();
+
   do_per_function (execute_function_todo, (void *)(size_t) flags);
 
   /* Always remove functions just as before inlining: IPA passes might be
@@ -1495,20 +1485,11 @@ execute_one_ipa_transform_pass (struct cgraph_node *node,
 void
 execute_all_ipa_transforms (void)
 {
-  enum cgraph_state old_state = cgraph_state;
   struct cgraph_node *node;
   if (!cfun)
     return;
   node = cgraph_node (current_function_decl);
 
-  /* Statement verification skip verification of nothorw when
-     state is IPA_SSA because we do not modify function bodies
-     after setting the flag on function.  Instead we leave it
-     to fixup_cfg to do such a transformation.  We need to temporarily
-     change the cgraph state so statement verifier before
-     transform do not fire.  */
-  cgraph_state = CGRAPH_STATE_IPA_SSA;
-
   if (node->ipa_transforms_to_apply)
     {
       unsigned int i;
@@ -1522,7 +1503,6 @@ execute_all_ipa_transforms (void)
       VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply);
       node->ipa_transforms_to_apply = NULL;
     }
-  cgraph_state = old_state;
 }
 
 /* Execute PASS. */
@@ -1670,8 +1650,12 @@ ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
          if (pass->tv_id)
            timevar_push (pass->tv_id);
 
+          pass_init_dump_file (pass);
+
          ipa_pass->write_summary (set,vset);
 
+          pass_fini_dump_file (pass);
+
          /* If a timevar is present, start it.  */
          if (pass->tv_id)
            timevar_pop (pass->tv_id);
@@ -1784,8 +1768,12 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set,
          if (pass->tv_id)
            timevar_push (pass->tv_id);
 
+          pass_init_dump_file (pass);
+
          ipa_pass->write_optimization_summary (set, vset);
 
+          pass_fini_dump_file (pass);
+
          /* If a timevar is present, start it.  */
          if (pass->tv_id)
            timevar_pop (pass->tv_id);
@@ -1805,9 +1793,26 @@ void
 ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset)
 {
   struct lto_out_decl_state *state = lto_new_out_decl_state ();
+  cgraph_node_set_iterator csi;
   compute_ltrans_boundary (state, set, vset);
 
   lto_push_out_decl_state (state);
+  for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
+    {
+      struct cgraph_node *node = csi_node (csi);
+      /* When streaming out references to statements as part of some IPA
+        pass summary, the statements need to have uids assigned.
+
+        For functions newly born at WPA stage we need to initialize
+        the uids here.  */
+      if (node->analyzed
+         && gimple_has_body_p (node->decl))
+       {
+         push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+         renumber_gimple_stmt_uids ();
+         pop_cfun ();
+       }
+    }
 
   gcc_assert (flag_wpa);
   ipa_write_optimization_summaries_1 (all_regular_ipa_passes, set, vset, state);
@@ -1840,8 +1845,12 @@ ipa_read_summaries_1 (struct opt_pass *pass)
              if (pass->tv_id)
                timevar_push (pass->tv_id);
 
+             pass_init_dump_file (pass);
+
              ipa_pass->read_summary ();
 
+             pass_fini_dump_file (pass);
+
              /* Stop timevar.  */
              if (pass->tv_id)
                timevar_pop (pass->tv_id);
@@ -1886,8 +1895,12 @@ ipa_read_optimization_summaries_1 (struct opt_pass *pass)
              if (pass->tv_id)
                timevar_push (pass->tv_id);
 
+             pass_init_dump_file (pass);
+
              ipa_pass->read_optimization_summary ();
 
+             pass_fini_dump_file (pass);
+
              /* Stop timevar.  */
              if (pass->tv_id)
                timevar_pop (pass->tv_id);
@@ -1988,7 +2001,7 @@ execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple *stmts)
 extern void debug_properties (unsigned int);
 extern void dump_properties (FILE *, unsigned int);
 
-void
+DEBUG_FUNCTION void
 dump_properties (FILE *dump, unsigned int props)
 {
   fprintf (dump, "Properties:\n");
@@ -2012,9 +2025,11 @@ dump_properties (FILE *dump, unsigned int props)
     fprintf (dump, "PROP_gimple_lomp\n");
   if (props & PROP_gimple_lcx)
     fprintf (dump, "PROP_gimple_lcx\n");
+  if (props & PROP_cfglayout)
+    fprintf (dump, "PROP_cfglayout\n");
 }
 
-void
+DEBUG_FUNCTION void
 debug_properties (unsigned int props)
 {
   dump_properties (stderr, props);