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
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/>. */
/*
OVERVIEW:
Here is an example of using the dataflow routines.
- df_[ru,rd,urec,ri,chain]_add_problem (flags);
+ df_[chain,live,note,rd]_add_problem (flags);
df_set_blocks (blocks);
df_dump (stderr);
- df_finish_pass ();
+ df_finish_pass (false);
-DF_[ru,rd,urec,ri,chain]_ADD_PROBLEM adds a problem, defined by an
+DF_[chain,live,note,rd]_ADD_PROBLEM adds a problem, defined by an
instance to struct df_problem, to the set of problems solved in this
instance of df. All calls to add a problem for a given instance of df
must occur before the first call to DF_ANALYZE.
For most modern rtl passes, this is certainly the easiest way to
manage rescanning the insns. This technique also has the advantage
that the scanning information is always correct and can be relied
- apon even after changes have been made to the instructions. This
+ upon even after changes have been made to the instructions. This
technique is contra indicated in several cases:
a) If def-use chains OR use-def chains (but not both) are built,
insns when only a small number of them have really changed.
4) Do it yourself - In this mechanism, the pass updates the insns
- itself using the low level df primatives. Currently no pass does
+ itself using the low level df primitives. Currently no pass does
this, but it has the advantage that it is quite efficient given
that the pass generally has exact knowledge of what it is changing.
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;
}
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);
}
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);
{
struct df_problem *problem;
int i;
- int start = 0;
if (!dflow)
return;
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;
}
-/* Remove all of the problems that are not permanent. Scanning, lr,
- ur and live are permanent, the rest are removable. Also clear all
- of the changeable_flags. */
+/* Remove all of the problems that are not permanent. Scanning, LR
+ and (at -O2 or higher) LIVE are permanent, the rest are removable.
+ Also clear all of the changeable_flags. */
void
-df_finish_pass (void)
+df_finish_pass (bool verify ATTRIBUTE_UNUSED)
{
int i;
int removed = 0;
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;
df_set_clean_cfg ();
#endif
#endif
+
+#ifdef ENABLE_CHECKING
+ if (verify)
+ df->changeable_flags |= DF_VERIFY_SCHEDULED;
+#endif
}
/* 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);
if (dump_file)
fprintf (dump_file, "df_analyze called\n");
-#ifdef ENABLE_DF_CHECKING
- df_verify ();
-#endif
+#ifndef ENABLE_DF_CHECKING
+ if (df->changeable_flags & DF_VERIFY_SCHEDULED)
+#endif
+ df_verify ();
for (i = 0; i < df->n_blocks; i++)
bitmap_set_bit (current_all_blocks, df->postorder[i]);
/* Verify that there is a place for everything and everything is in
its place. This is too expensive to run after every pass in the
mainline. However this is an excellent debugging tool if the
- dataflow infomation is not being updated properly. You can just
+ dataflow information 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
routine. */
df_verify (void)
{
df_scan_verify ();
+#ifdef ENABLE_DF_CHECKING
df_lr_verify_transfer_functions ();
if (df_live)
df_live_verify_transfer_functions ();
+#endif
}
#ifdef DF_DEBUG_CFG
----------------------------------------------------------------------------*/
-/* 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 *
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. */
/* Dump dataflow info. */
+
void
df_dump (FILE *file)
{
}
+/* Dump dataflow info for df->blocks_to_analyze. */
+
+void
+df_dump_region (FILE *file)
+{
+ if (df->blocks_to_analyze)
+ {
+ bitmap_iterator bi;
+ unsigned int bb_index;
+
+ fprintf (file, "\n\nstarting region dump\n");
+ df_dump_start (file);
+
+ EXECUTE_IF_SET_IN_BITMAP (df->blocks_to_analyze, 0, bb_index, bi)
+ {
+ basic_block bb = BASIC_BLOCK (bb_index);
+
+ df_print_bb_index (bb, file);
+ df_dump_top (bb, file);
+ df_dump_bottom (bb, file);
+ }
+ fprintf (file, "\n");
+ }
+ else
+ df_dump (file);
+}
+
+
/* Dump the introductory information for each problem defined. */
void