Makefile.in (build/genmddeps.o): Depend on $(READ_MD_H).
[gcc.git] / gcc / df-core.c
index 5ec802d0f8b72ac383dd43eb4c7792e98077493d..6c9f5c927e950d44166be07dbbd08ae431d9aac9 100644 (file)
@@ -1,6 +1,6 @@
 /* Allocation for dataflow support routines.
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009 Free Software Foundation, Inc.
+   2008, 2009, 2010 Free Software Foundation, Inc.
    Originally contributed by Michael P. Hayes
              (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
    Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
@@ -504,8 +504,9 @@ df_set_blocks (bitmap blocks)
          /* 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);
+         bitmap_head diff;
+         bitmap_initialize (&diff, &df_bitmap_obstack);
+         bitmap_and_compl (&diff, df->blocks_to_analyze, blocks);
          for (p = 0; p < df->num_problems_defined; p++)
            {
              struct dataflow *dflow = df->problems_in_order[p];
@@ -516,7 +517,7 @@ df_set_blocks (bitmap blocks)
                  bitmap_iterator bi;
                  unsigned int bb_index;
 
-                 EXECUTE_IF_SET_IN_BITMAP (diff, 0, bb_index, bi)
+                 EXECUTE_IF_SET_IN_BITMAP (&diff, 0, bb_index, bi)
                    {
                      basic_block bb = BASIC_BLOCK (bb_index);
                      if (bb)
@@ -532,34 +533,34 @@ df_set_blocks (bitmap blocks)
                }
            }
 
-         BITMAP_FREE (diff);
+          bitmap_clear (&diff);
        }
       else
        {
          /* This block of code is executed to change the focus from
             the entire function to a subset.  */
-         bitmap blocks_to_reset = NULL;
+         bitmap_head blocks_to_reset;
+         bool initialized = false;
          int p;
          for (p = 0; p < df->num_problems_defined; p++)
            {
              struct dataflow *dflow = df->problems_in_order[p];
              if (dflow->optional_p && dflow->problem->reset_fun)
                {
-                 if (!blocks_to_reset)
+                 if (!initialized)
                    {
                      basic_block bb;
-                     blocks_to_reset =
-                       BITMAP_ALLOC (&df_bitmap_obstack);
+                     bitmap_initialize (&blocks_to_reset, &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 (initialized)
+           bitmap_clear (&blocks_to_reset);
 
          df->blocks_to_analyze = BITMAP_ALLOC (&df_bitmap_obstack);
        }
@@ -636,7 +637,7 @@ df_finish_pass (bool verify ATTRIBUTE_UNUSED)
   int removed = 0;
 
 #ifdef ENABLE_DF_CHECKING
-  enum df_changeable_flags saved_flags;
+  int saved_flags;
 #endif
 
   if (!df)
@@ -1083,15 +1084,15 @@ df_analyze_problem (struct dataflow *dflow,
 {
   timevar_push (dflow->problem->tv_id);
 
+  /* (Re)Allocate the datastructures necessary to solve the problem.  */
+  if (dflow->problem->alloc_fun)
+    dflow->problem->alloc_fun (blocks_to_consider);
+
 #ifdef ENABLE_DF_CHECKING
   if (dflow->problem->verify_start_fun)
     dflow->problem->verify_start_fun ();
 #endif
 
-  /* (Re)Allocate the datastructures necessary to solve the problem.  */
-  if (dflow->problem->alloc_fun)
-    dflow->problem->alloc_fun (blocks_to_consider);
-
   /* Set up the problem and compute the local information.  */
   if (dflow->problem->local_compute_fun)
     dflow->problem->local_compute_fun (blocks_to_consider);
@@ -1354,6 +1355,30 @@ df_set_bb_dirty (basic_block bb)
 }
 
 
+/* Mark BB as needing it's transfer functions as being out of
+   date, except for LR problem.  Used when analyzing DEBUG_INSNs,
+   as LR problem can trigger DCE, and DEBUG_INSNs shouldn't ever
+   shorten or enlarge lifetime of regs.  */
+
+void
+df_set_bb_dirty_nonlr (basic_block bb)
+{
+  if (df)
+    {
+      int p;
+      for (p = 1; p < df->num_problems_defined; p++)
+       {
+         struct dataflow *dflow = df->problems_in_order[p];
+         if (dflow == df_lr)
+           continue;
+         if (dflow->out_of_date_transfer_functions)
+           bitmap_set_bit (dflow->out_of_date_transfer_functions, bb->index);
+         dflow->solutions_dirty = true;
+       }
+    }
+}
+
+
 /* Clear the dirty bits.  This is called from places that delete
    blocks.  */
 static void
@@ -1377,9 +1402,10 @@ df_compact_blocks (void)
   basic_block bb;
   void **problem_temps;
   int size = last_basic_block * sizeof (void *);
-  bitmap tmp = BITMAP_ALLOC (&df_bitmap_obstack);
+  bitmap_head tmp;
   problem_temps = XNEWVAR (void *, size);
 
+  bitmap_initialize (&tmp, &df_bitmap_obstack);
   for (p = 0; p < df->num_problems_defined; p++)
     {
       struct dataflow *dflow = df->problems_in_order[p];
@@ -1388,17 +1414,17 @@ df_compact_blocks (void)
         dflow problem.  */
       if (dflow->out_of_date_transfer_functions)
        {
-         bitmap_copy (tmp, dflow->out_of_date_transfer_functions);
+         bitmap_copy (&tmp, dflow->out_of_date_transfer_functions);
          bitmap_clear (dflow->out_of_date_transfer_functions);
-         if (bitmap_bit_p (tmp, ENTRY_BLOCK))
+         if (bitmap_bit_p (&tmp, ENTRY_BLOCK))
            bitmap_set_bit (dflow->out_of_date_transfer_functions, ENTRY_BLOCK);
-         if (bitmap_bit_p (tmp, EXIT_BLOCK))
+         if (bitmap_bit_p (&tmp, EXIT_BLOCK))
            bitmap_set_bit (dflow->out_of_date_transfer_functions, EXIT_BLOCK);
 
          i = NUM_FIXED_BLOCKS;
          FOR_EACH_BB (bb)
            {
-             if (bitmap_bit_p (tmp, bb->index))
+             if (bitmap_bit_p (&tmp, bb->index))
                bitmap_set_bit (dflow->out_of_date_transfer_functions, i);
              i++;
            }
@@ -1439,22 +1465,22 @@ df_compact_blocks (void)
 
   if (df->blocks_to_analyze)
     {
-      if (bitmap_bit_p (tmp, ENTRY_BLOCK))
+      if (bitmap_bit_p (&tmp, ENTRY_BLOCK))
        bitmap_set_bit (df->blocks_to_analyze, ENTRY_BLOCK);
-      if (bitmap_bit_p (tmp, EXIT_BLOCK))
+      if (bitmap_bit_p (&tmp, EXIT_BLOCK))
        bitmap_set_bit (df->blocks_to_analyze, EXIT_BLOCK);
-      bitmap_copy (tmp, df->blocks_to_analyze);
+      bitmap_copy (&tmp, df->blocks_to_analyze);
       bitmap_clear (df->blocks_to_analyze);
       i = NUM_FIXED_BLOCKS;
       FOR_EACH_BB (bb)
        {
-         if (bitmap_bit_p (tmp, bb->index))
+         if (bitmap_bit_p (&tmp, bb->index))
            bitmap_set_bit (df->blocks_to_analyze, i);
          i++;
        }
     }
 
-  BITMAP_FREE (tmp);
+  bitmap_clear (&tmp);
 
   free (problem_temps);
 
@@ -2070,13 +2096,13 @@ df_insn_uid_debug (unsigned int uid,
 }
 
 
-void
+DEBUG_FUNCTION void
 df_insn_debug (rtx insn, bool follow_chain, FILE *file)
 {
   df_insn_uid_debug (INSN_UID (insn), follow_chain, file);
 }
 
-void
+DEBUG_FUNCTION void
 df_insn_debug_regno (rtx insn, FILE *file)
 {
   struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
@@ -2094,7 +2120,7 @@ df_insn_debug_regno (rtx insn, FILE *file)
   fprintf (file, "\n");
 }
 
-void
+DEBUG_FUNCTION void
 df_regno_debug (unsigned int regno, FILE *file)
 {
   fprintf (file, "reg %d defs ", regno);
@@ -2107,13 +2133,13 @@ df_regno_debug (unsigned int regno, FILE *file)
 }
 
 
-void
+DEBUG_FUNCTION void
 df_ref_debug (df_ref ref, FILE *file)
 {
   fprintf (file, "%c%d ",
           DF_REF_REG_DEF_P (ref) ? 'd' : 'u',
           DF_REF_ID (ref));
-  fprintf (file, "reg %d bb %d insn %d flag 0x%x type 0x%x ",
+  fprintf (file, "reg %d bb %d insn %d flag %#x type %#x ",
           DF_REF_REGNO (ref),
           DF_REF_BBNO (ref),
           DF_REF_IS_ARTIFICIAL (ref) ? -1 : DF_REF_INSN_UID (ref),
@@ -2135,7 +2161,7 @@ df_ref_debug (df_ref ref, FILE *file)
 \f
 /* Functions for debugging from GDB.  */
 
-void
+DEBUG_FUNCTION void
 debug_df_insn (rtx insn)
 {
   df_insn_debug (insn, true, stderr);
@@ -2143,42 +2169,42 @@ debug_df_insn (rtx insn)
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_reg (rtx reg)
 {
   df_regno_debug (REGNO (reg), stderr);
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_regno (unsigned int regno)
 {
   df_regno_debug (regno, stderr);
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_ref (df_ref ref)
 {
   df_ref_debug (ref, stderr);
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_defno (unsigned int defno)
 {
   df_ref_debug (DF_DEFS_GET (defno), stderr);
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_useno (unsigned int defno)
 {
   df_ref_debug (DF_USES_GET (defno), stderr);
 }
 
 
-void
+DEBUG_FUNCTION void
 debug_df_chain (struct df_link *link)
 {
   df_chain_dump (link, stderr);