OSDN Git Service

2007-07-06 H.J. Lu <hongjiu.lu@intel.com>
[pf3gnuchains/gcc-fork.git] / gcc / df-core.c
index 56eb039..deca875 100644 (file)
@@ -64,7 +64,7 @@ dataflow solution.  The transfer functions are only rebuilt if the
 some instruction within the block has changed.  
 
 The top layer is the dataflow solution itself.  The dataflow solution
-is computed by using an efficient iterative solver and the trasfer
+is computed by using an efficient iterative solver and the transfer
 functions.  The dataflow solution must be recomputed whenever the
 control changes or if one of the transfer function changes.
 
@@ -114,8 +114,8 @@ optimizations that reorder blocks invalidate the bitvector.
 DF_ANALYZE causes all of the defined problems to be (re)solved.  When
 DF_ANALYZE is completes, the IN and OUT sets for each basic block
 contain the computer information.  The DF_*_BB_INFO macros can be used
-to access these bitvectors.  All defered rescannings are down before
-the transfer functions are recompited.
+to access these bitvectors.  All deferred rescannings are down before
+the transfer functions are recomputed.
 
 DF_DUMP can then be called to dump the information produce to some
 file.  This calls DF_DUMP_START, to print the information that is not
@@ -126,7 +126,7 @@ can all be called separately as part of a larger dump function.
 
 DF_FINISH_PASS causes df_remove_problem to be called on all of the
 optional problems.  It also causes any insns whose scanning has been
-defered to be rescanned as well as clears all of the changeable flags.
+deferred to be rescanned as well as clears all of the changeable flags.
 Setting the pass manager TODO_df_finish flag causes this function to
 be run.  However, the pass manager will call df_finish_pass AFTER the
 pass dumping has been done, so if you want to see the results of the
@@ -177,7 +177,7 @@ There are four ways of doing the incremental scanning:
       rescanned may be impractical.  Cse and regrename fall into this
       category.
 
-2) Defered rescanning - Calls to df_insn_rescan, df_notes_rescan, and
+2) Deferred rescanning - Calls to df_insn_rescan, df_notes_rescan, and
    df_insn_delete do not immediately change the insn but instead make
    a note that the insn needs to be rescanned.  The next call to
    df_analyze, df_finish_pass, or df_process_deferred_rescans will
@@ -190,7 +190,7 @@ There are four ways of doing the incremental scanning:
 
    To enable this mode, call df_set_flags (DF_DEFER_INSN_RESCAN).
    (This mode can be cleared by calling df_clear_flags
-   (DF_DEFER_INSN_RESCAN) but this does not cause the defered insns to
+   (DF_DEFER_INSN_RESCAN) but this does not cause the deferred insns to
    be rescanned.
 
    3) Total rescanning - In this mode the rescanning is disabled.
@@ -506,15 +506,17 @@ df_set_blocks (bitmap blocks)
        bitmap_print (dump_file, blocks, "setting blocks to analyze ", "\n");
       if (df->blocks_to_analyze)
        {
+         /* This block is called to change the focus from one subset
+            to another.  */
          int p;
          bitmap diff = BITMAP_ALLOC (&df_bitmap_obstack);
          bitmap_and_compl (diff, df->blocks_to_analyze, blocks);
-         for (p = df->num_problems_defined - 1; p >= DF_FIRST_OPTIONAL_PROBLEM ;p--)
+         for (p = 0; p < df->num_problems_defined; p++)
            {
              struct dataflow *dflow = df->problems_in_order[p];
-             if (dflow->problem->reset_fun)
+             if (dflow->optional_p && dflow->problem->reset_fun)
                dflow->problem->reset_fun (df->blocks_to_analyze);
-             else if (dflow->problem->free_bb_fun)
+             else if (dflow->problem->free_blocks_on_set_blocks)
                {
                  bitmap_iterator bi;
                  unsigned int bb_index;
@@ -539,33 +541,31 @@ df_set_blocks (bitmap blocks)
        }
       else
        {
-         /* If we have not actually run scanning before, do not try
-            to clear anything.  */
-         if (df_scan->problem_data)
+         /* This block of code is executed to change the focus from
+            the entire function to a subset.  */
+         bitmap blocks_to_reset = NULL;
+         int p;
+         for (p = 0; p < df->num_problems_defined; p++)
            {
-             bitmap blocks_to_reset = NULL;
-             int p;
-             for (p = df->num_problems_defined - 1; p >= DF_FIRST_OPTIONAL_PROBLEM ;p--)
+             struct dataflow *dflow = df->problems_in_order[p];
+             if (dflow->optional_p && dflow->problem->reset_fun)
                {
-                 struct dataflow *dflow = df->problems_in_order[p];
-                 if (dflow->problem->reset_fun)
+                 if (!blocks_to_reset)
                    {
-                     if (!blocks_to_reset)
+                     basic_block bb;
+                     blocks_to_reset =
+                       BITMAP_ALLOC (&df_bitmap_obstack);
+                     FOR_ALL_BB(bb)
                        {
-                         basic_block bb;
-                         blocks_to_reset =
-                           BITMAP_ALLOC (&df_bitmap_obstack);
-                         FOR_ALL_BB(bb)
-                           {
-                             bitmap_set_bit (blocks_to_reset, bb->index); 
-                           }
+                         bitmap_set_bit (blocks_to_reset, bb->index); 
                        }
-                     dflow->problem->reset_fun (blocks_to_reset);
                    }
+                 dflow->problem->reset_fun (blocks_to_reset);
                }
-             if (blocks_to_reset)
-               BITMAP_FREE (blocks_to_reset);
            }
+         if (blocks_to_reset)
+           BITMAP_FREE (blocks_to_reset);
+
          df->blocks_to_analyze = BITMAP_ALLOC (&df_bitmap_obstack);
        }
       bitmap_copy (df->blocks_to_analyze, blocks);
@@ -573,8 +573,10 @@ df_set_blocks (bitmap blocks)
     }
   else
     {
+      /* This block is executed to reset the focus to the entire
+        function.  */
       if (dump_file)
-       fprintf (dump_file, "clearing blocks to analyze\n");
+       fprintf (dump_file, "clearing blocks_to_analyze\n");
       if (df->blocks_to_analyze)
        {
          BITMAP_FREE (df->blocks_to_analyze);
@@ -599,7 +601,6 @@ df_remove_problem (struct dataflow *dflow)
 {
   struct df_problem *problem;
   int i;
-  int start = 0;
 
   if (!dflow)
     return;
@@ -607,18 +608,13 @@ df_remove_problem (struct dataflow *dflow)
   problem = dflow->problem;
   gcc_assert (problem->remove_problem_fun);
 
-  /* Normally only optional problems are removed, but during global,
-     we remove ur and live and replace it with urec.  */
-  if (problem->id >= DF_FIRST_OPTIONAL_PROBLEM)
-    start = DF_FIRST_OPTIONAL_PROBLEM;
-
   /* Delete any problems that depended on this problem first.  */
-  for (i = start; i < df->num_problems_defined; i++)
+  for (i = 0; i < df->num_problems_defined; i++)
     if (df->problems_in_order[i]->problem->dependent_problem == problem)
       df_remove_problem (df->problems_in_order[i]);
 
   /* Now remove this problem.  */
-  for (i = start; i < df->num_problems_defined; i++)
+  for (i = 0; i < df->num_problems_defined; i++)
     if (df->problems_in_order[i] == dflow)
       {
        int j;
@@ -635,7 +631,7 @@ df_remove_problem (struct dataflow *dflow)
 
 
 /* Remove all of the problems that are not permanent.  Scanning, lr,
-   ur and live are permanent, the rest are removeable.  Also clear all
+   ur and live are permanent, the rest are removable.  Also clear all
    of the changeable_flags.  */
 
 void
@@ -644,7 +640,7 @@ df_finish_pass (void)
   int i;
   int removed = 0;
 
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
   enum df_changeable_flags saved_flags;
 #endif
 
@@ -654,20 +650,23 @@ df_finish_pass (void)
   df_maybe_reorganize_def_refs (DF_REF_ORDER_NO_TABLE);
   df_maybe_reorganize_use_refs (DF_REF_ORDER_NO_TABLE);
 
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
   saved_flags = df->changeable_flags;
 #endif
 
-  for (i = DF_FIRST_OPTIONAL_PROBLEM; i < df->num_problems_defined; i++)
+  for (i = 0; i < df->num_problems_defined; i++)
     {
       struct dataflow *dflow = df->problems_in_order[i];
       struct df_problem *problem = dflow->problem;
 
-      gcc_assert (problem->remove_problem_fun);
-      (problem->remove_problem_fun) ();
-      df->problems_in_order[i] = NULL;
-      df->problems_by_index[problem->id] = NULL;
-      removed++;
+      if (dflow->optional_p)
+       {
+         gcc_assert (problem->remove_problem_fun);
+         (problem->remove_problem_fun) ();
+         df->problems_in_order[i] = NULL;
+         df->problems_by_index[problem->id] = NULL;
+         removed++;
+       }
     }
   df->num_problems_defined -= removed;
 
@@ -684,7 +683,7 @@ df_finish_pass (void)
       df->analyze_subset = false;
     }
 
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
   /* Verification will fail in DF_NO_INSN_RESCAN.  */
   if (!(saved_flags & DF_NO_INSN_RESCAN))
     {
@@ -720,7 +719,7 @@ rest_of_handle_df_initialize (void)
 
   /* These three problems are permanent.  */
   df_lr_add_problem ();
-  if (optimize)
+  if (optimize > 1)
     df_live_add_problem ();
 
   df->postorder = XNEWVEC (int, last_basic_block);
@@ -1040,7 +1039,7 @@ df_analyze_problem (struct dataflow *dflow,
 {
   timevar_push (dflow->problem->tv_id);
 
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
   if (dflow->problem->verify_start_fun)
     dflow->problem->verify_start_fun ();
 #endif
@@ -1062,7 +1061,7 @@ df_analyze_problem (struct dataflow *dflow,
   if (dflow->problem->finalize_fun)
     dflow->problem->finalize_fun (blocks_to_consider);
 
-#ifdef ENABLE_CHECKING
+#ifdef ENABLE_DF_CHECKING
   if (dflow->problem->verify_end_fun)
     dflow->problem->verify_end_fun ();
 #endif
@@ -1100,9 +1099,10 @@ df_analyze (void)
   df_compute_regs_ever_live (false);
   df_process_deferred_rescans ();
 
-#ifdef ENABLE_CHECKING
   if (dump_file)
     fprintf (dump_file, "df_analyze called\n");
+
+#ifdef ENABLE_DF_CHECKING
   df_verify ();
 #endif 
 
@@ -1505,7 +1505,7 @@ df_bb_delete (int bb_index)
    dataflow infomation is not being updated properly.  You can just
    sprinkle calls in until you find the place that is changing an
    underlying structure without calling the proper updating
-   rountine.  */
+   routine.  */
 
 void
 df_verify (void)
@@ -1599,40 +1599,6 @@ df_set_clean_cfg (void)
 ----------------------------------------------------------------------------*/
 
 
-/* Return last use of REGNO within BB.  */
-
-struct df_ref *
-df_bb_regno_last_use_find (basic_block bb, unsigned int regno)
-{
-  rtx insn;
-  struct df_ref **use_rec;
-  unsigned int uid;
-
-  FOR_BB_INSNS_REVERSE (bb, insn)
-    {
-      if (!INSN_P (insn))
-       continue;
-
-      uid = INSN_UID (insn);
-      for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
-       {
-         struct df_ref *use = *use_rec;
-         if (DF_REF_REGNO (use) == regno)
-           return use;
-       }
-
-      if (df->changeable_flags & DF_EQ_NOTES)
-       for (use_rec = DF_INSN_UID_EQ_USES (uid); *use_rec; use_rec++)
-         {
-           struct df_ref *use = *use_rec;
-           if (DF_REF_REGNO (use) == regno)
-             return use;
-         }
-    }
-  return NULL;
-}
-
-
 /* Return first def of REGNO within BB.  */
 
 struct df_ref *
@@ -1685,26 +1651,6 @@ df_bb_regno_last_def_find (basic_block bb, unsigned int regno)
   return NULL;
 }
 
-/* Return true if INSN defines REGNO.  */
-
-bool
-df_insn_regno_def_p (rtx insn, unsigned int regno)
-{
-  unsigned int uid;
-  struct df_ref **def_rec;
-
-  uid = INSN_UID (insn);
-  for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
-    {
-      struct df_ref *def = *def_rec;
-      if (DF_REF_REGNO (def) == regno)
-       return true;
-    }
-  
-  return false;
-}
-
-
 /* Finds the reference corresponding to the definition of REG in INSN.
    DF is the dataflow object.  */