OSDN Git Service

Change copyright header to refer to version 3 of the GNU General Public License and...
[pf3gnuchains/gcc-fork.git] / gcc / df-problems.c
index 67a8cb0..4dcb3b1 100644 (file)
@@ -10,7 +10,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -19,9 +19,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -46,6 +45,9 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "dce.h"
 #include "vecprim.h"
 
+/* Note that turning REG_DEAD_DEBUGGING on will cause
+   gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints
+   addresses in the dumps.  */  
 #if 0
 #define REG_DEAD_DEBUGGING
 #endif
@@ -331,6 +333,7 @@ df_ru_alloc (bitmap all_blocks)
          bb_info->out = BITMAP_ALLOC (&problem_data->ru_bitmaps);
        }
     }
+  df_ru->optional_p = true;
 }
 
 
@@ -709,9 +712,10 @@ static struct df_problem problem_RU =
   df_ru_top_dump,             /* Debugging start block.  */
   df_ru_bottom_dump,          /* Debugging end block.  */
   NULL,                       /* Incremental solution verify start.  */
-  NULL,                       /* Incremental solution verfiy end.  */
+  NULL,                       /* Incremental solution verify end.  */
   NULL,                       /* Dependent problem.  */
-  TV_DF_RU                    /* Timing variable.  */ 
+  TV_DF_RU,                   /* Timing variable.  */
+  true                        /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -841,6 +845,7 @@ df_rd_alloc (bitmap all_blocks)
          bb_info->out = BITMAP_ALLOC (&problem_data->rd_bitmaps);
        }
     }
+  df_rd->optional_p = true;
 }
 
 
@@ -1205,9 +1210,10 @@ static struct df_problem problem_RD =
   df_rd_top_dump,             /* Debugging start block.  */
   df_rd_bottom_dump,          /* Debugging end block.  */
   NULL,                       /* Incremental solution verify start.  */
-  NULL,                       /* Incremental solution verfiy end.  */
+  NULL,                       /* Incremental solution verify end.  */
   NULL,                       /* Dependent problem.  */
-  TV_DF_RD                    /* Timing variable.  */ 
+  TV_DF_RD,                   /* Timing variable.  */ 
+  true                        /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -1320,6 +1326,8 @@ df_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
           bb_info->ause = NULL;
        }
     }
+
+  df_lr->optional_p = false;
 }
 
 
@@ -1478,6 +1486,13 @@ df_lr_bb_local_compute (unsigned int bb_index)
        }
     }
 #endif
+
+  /* If the df_live problem is not defined, such as at -O0 and -O1, we
+     still need to keep the luids up to date.  This is normally done
+     in the df_live problem since this problem has a forwards
+     scan.  */
+  if (!df_live)
+    df_recompute_luids (bb);
 }
 
 
@@ -1818,7 +1833,8 @@ static struct df_problem problem_LR =
   df_lr_verify_solution_start,/* Incremental solution verify start.  */
   df_lr_verify_solution_end,  /* Incremental solution verify end.  */
   NULL,                       /* Dependent problem.  */
-  TV_DF_LR                    /* Timing variable.  */ 
+  TV_DF_LR,                   /* Timing variable.  */ 
+  false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -2016,6 +2032,7 @@ df_live_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
          bb_info->out = BITMAP_ALLOC (NULL);
        }
     }
+  df_live->optional_p = (optimize <= 1);
 }
 
 
@@ -2368,7 +2385,8 @@ static struct df_problem problem_LIVE =
   df_live_verify_solution_start,/* Incremental solution verify start.  */
   df_live_verify_solution_end,  /* Incremental solution verify end.  */
   &problem_LR,                  /* Dependent problem.  */
-  TV_DF_LIVE                    /* Timing variable.  */ 
+  TV_DF_LIVE,                   /* Timing variable.  */
+  false                         /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -2386,6 +2404,19 @@ df_live_add_problem (void)
 }
 
 
+/* Set all of the blocks as dirty.  This needs to be done if this
+   problem is added after all of the insns have been scanned.  */
+
+void
+df_live_set_all_dirty (void)
+{
+  basic_block bb;
+  FOR_ALL_BB (bb)
+    bitmap_set_bit (df_live->out_of_date_transfer_functions, 
+                   bb->index);
+}
+
+
 /* Verify that all of the lr related info is consistent and
    correct.  */
 
@@ -2555,6 +2586,7 @@ df_urec_alloc (bitmap all_blocks)
          bb_info->earlyclobber = BITMAP_ALLOC (NULL);
        }
     }
+  df_urec->optional_p = true;
 }
 
 
@@ -3039,9 +3071,10 @@ static struct df_problem problem_UREC =
   df_urec_top_dump,           /* Debugging start block.  */
   df_urec_bottom_dump,        /* Debugging end block.  */
   NULL,                       /* Incremental solution verify start.  */
-  NULL,                       /* Incremental solution verfiy end.  */
+  NULL,                       /* Incremental solution verify end.  */
   &problem_LR,                /* Dependent problem.  */
-  TV_DF_UREC                  /* Timing variable.  */ 
+  TV_DF_UREC,                 /* Timing variable.  */ 
+  false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -3213,6 +3246,7 @@ df_chain_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
   df_chain_remove_problem ();
   df_chain->block_pool = create_alloc_pool ("df_chain_block pool", 
                                         sizeof (struct df_link), 50);
+  df_chain->optional_p = true;
 }
 
 
@@ -3518,9 +3552,10 @@ static struct df_problem problem_CHAIN =
   df_chain_top_dump,          /* Debugging start block.  */
   df_chain_bottom_dump,       /* Debugging end block.  */
   NULL,                       /* Incremental solution verify start.  */
-  NULL,                       /* Incremental solution verfiy end.  */
+  NULL,                       /* Incremental solution verify end.  */
   &problem_RD,                /* Dependent problem.  */
-  TV_DF_CHAIN                 /* Timing variable.  */ 
+  TV_DF_CHAIN,                /* Timing variable.  */
+  false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -3543,6 +3578,12 @@ df_chain_add_problem (enum df_chain_flags chain_flags)
    This pass computes REG_DEAD and REG_UNUSED notes.
    ----------------------------------------------------------------------------*/
 
+static void 
+df_note_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
+{
+  df_note->optional_p = true;
+}
+
 #ifdef REG_DEAD_DEBUGGING
 static void 
 df_print_note (const char *prefix, rtx insn, rtx note)
@@ -3715,11 +3756,10 @@ df_set_unused_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws,
       /* Only do this if the value is totally dead.  */
     }
   else
-    for (r=mws->start_regno; r <= mws->end_regno; r++)
+    for (r = mws->start_regno; r <= mws->end_regno; r++)
       {
-       
-       if ((!bitmap_bit_p (live, r))
-           && (!bitmap_bit_p (artificial_uses, r)))
+       if (!bitmap_bit_p (live, r)
+           && !bitmap_bit_p (artificial_uses, r))
          {
            old = df_set_note (REG_UNUSED, insn, old, regno_reg_rtx[r]);
 #ifdef REG_DEAD_DEBUGGING
@@ -3781,17 +3821,15 @@ df_set_dead_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws,
   else
     {
       for (r = mws->start_regno; r <= mws->end_regno; r++)
-       {
-         if ((!bitmap_bit_p (live, r))
-             && (!bitmap_bit_p (artificial_uses, r))
-             && (!bitmap_bit_p (do_not_gen, r)))
-           {
-             old = df_set_note (REG_DEAD, insn, old, regno_reg_rtx[r]);
+       if (!bitmap_bit_p (live, r)
+           && !bitmap_bit_p (artificial_uses, r)
+           && !bitmap_bit_p (do_not_gen, r))
+         {
+           old = df_set_note (REG_DEAD, insn, old, regno_reg_rtx[r]);
 #ifdef REG_DEAD_DEBUGGING
-             df_print_note ("adding 2: ", insn, REG_NOTES (insn));
+           df_print_note ("adding 2: ", insn, REG_NOTES (insn));
 #endif
-           }
-       }
+         }
     }
   return old;
 }
@@ -3867,8 +3905,10 @@ df_note_bb_compute (unsigned int bb_index,
   for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
     {
       struct df_ref *def = *def_rec;
+#ifdef REG_DEAD_DEBUGGING
       if (dump_file)
        fprintf (dump_file, "artificial def %d\n", DF_REF_REGNO (def));
+#endif
 
       if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
        bitmap_clear_bit (live, DF_REF_REGNO (def));
@@ -3919,8 +3959,8 @@ df_note_bb_compute (unsigned int bb_index,
              df_print_regset (dump_file, live);
            }
 #endif
-         /* We only care about real sets for calls.  Clobbers only
-            may clobbers cannot be depended on.  */
+         /* We only care about real sets for calls.  Clobbers cannot
+            be depended on to really die.  */
          mws_rec = DF_INSN_UID_MWS (uid);
          while (*mws_rec)
            {
@@ -3944,6 +3984,12 @@ df_note_bb_compute (unsigned int bb_index,
                  = df_create_unused_note (insn, old_unused_notes, 
                                           def, live, do_not_gen, 
                                           artificial_uses);
+
+             /* However a may or must clobber still needs to kill the
+                reg so that REG_DEAD notes are later placed
+                appropriately.  */ 
+             else 
+               bitmap_clear_bit (live, DF_REF_REGNO (def));
            }
        }
       else
@@ -4075,7 +4121,7 @@ static struct df_problem problem_NOTE =
 {
   DF_NOTE,                    /* Problem id.  */
   DF_NONE,                    /* Direction.  */
-  NULL,                       /* Allocate the problem specific data.  */
+  df_note_alloc,              /* Allocate the problem specific data.  */
   NULL,                       /* Reset global information.  */
   NULL,                       /* Free basic block info.  */
   df_note_compute,            /* Local compute function.  */
@@ -4091,13 +4137,14 @@ static struct df_problem problem_NOTE =
   NULL,                       /* Debugging start block.  */
   NULL,                       /* Debugging end block.  */
   NULL,                       /* Incremental solution verify start.  */
-  NULL,                       /* Incremental solution verfiy end.  */
+  NULL,                       /* Incremental solution verify end.  */
 
   /* Technically this is only dependent on the live registers problem
      but it will produce information if built one of uninitialized
      register problems (UR, UREC) is also run.  */
   &problem_LR,                /* Dependent problem.  */
-  TV_DF_NOTE                  /* Timing variable.  */ 
+  TV_DF_NOTE,                 /* Timing variable.  */
+  false                       /* Reset blocks on dropping out of blocks_to_analyze.  */
 };
 
 
@@ -4264,7 +4311,7 @@ df_simulate_fixup_sets (basic_block bb, bitmap live)
 }
 
 
-/* Apply the artifical uses and defs at the top of BB in a forwards
+/* Apply the artificial uses and defs at the top of BB in a forwards
    direction.  */
 
 void 
@@ -4304,7 +4351,7 @@ df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
 }
 
 
-/* Apply the artifical uses and defs at the end of BB in a backwards
+/* Apply the artificial uses and defs at the end of BB in a backwards
    direction.  */
 
 void