#include "hard-reg-set.h"
#include "basic-block.h"
#include "output.h"
-#include "errors.h"
#include "expr.h"
#include "function.h"
#include "diagnostic.h"
/* Basic block vectors used in this file ought to be allocated in the
heap. We use pointer vector, because ints can be easily passed by
value. */
-DEF_VEC_P(int);
-DEF_VEC_ALLOC_P(int,heap);
+DEF_VEC_I(int);
+DEF_VEC_ALLOC_I(int,heap);
/* Set of existing SSA names being replaced by update_ssa. */
static sbitmap old_ssa_names;
sbitmap_zero (interesting_blocks);
/* Initialize dominance frontier. */
- dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap *));
+ dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap));
FOR_EACH_BB (bb)
dfs[bb->index] = BITMAP_ALLOC (NULL);
{
unsigned i;
bitmap_iterator bi;
+ sbitmap_iterator sbi;
/* If a name N from NEW_SSA_NAMES is also marked to be released,
remove it from NEW_SSA_NAMES so that we don't try to visit its
/* First process names in NEW_SSA_NAMES. Otherwise, uses of old
names may be considered to be live-in on blocks that contain
definitions for their replacements. */
- EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i,
- prepare_def_site_for (ssa_name (i), blocks, insert_phi_p));
+ EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
+ prepare_def_site_for (ssa_name (i), blocks, insert_phi_p);
/* If an old name is in NAMES_TO_RELEASE, we cannot remove it from
OLD_SSA_NAMES, but we have to ignore its definition site. */
- EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i,
+ EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
{
if (names_to_release == NULL || !bitmap_bit_p (names_to_release, i))
prepare_def_site_for (ssa_name (i), blocks, insert_phi_p);
prepare_use_sites_for (ssa_name (i), blocks, insert_phi_p);
- });
+ }
}
if (new_ssa_names && sbitmap_first_set_bit (new_ssa_names) >= 0)
{
+ sbitmap_iterator sbi;
+
fprintf (file, "\nSSA replacement table\n");
fprintf (file, "N_i -> { O_1 ... O_j } means that N_i replaces "
"O_1, ..., O_j\n\n");
- EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i,
- dump_names_replaced_by (file, ssa_name (i)));
+ EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
+ dump_names_replaced_by (file, ssa_name (i));
fprintf (file, "\n");
fprintf (file, "Number of virtual NEW -> OLD mappings: %7u\n",
{
unsigned i;
bitmap ret;
+ sbitmap_iterator sbi;
ret = BITMAP_ALLOC (NULL);
- EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i,
- bitmap_set_bit (ret, i));
+ EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
+ bitmap_set_bit (ret, i);
return ret;
}
switch_virtuals_to_full_rewrite (void)
{
unsigned i;
+ sbitmap_iterator sbi;
if (dump_file)
{
/* Remove all virtual names from NEW_SSA_NAMES and OLD_SSA_NAMES.
Note that it is not really necessary to remove the mappings from
REPL_TBL, that would only waste time. */
- EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i,
+ EXECUTE_IF_SET_IN_SBITMAP (new_ssa_names, 0, i, sbi)
if (!is_gimple_reg (ssa_name (i)))
- RESET_BIT (new_ssa_names, i));
+ RESET_BIT (new_ssa_names, i);
- EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i,
+ EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
if (!is_gimple_reg (ssa_name (i)))
- RESET_BIT (old_ssa_names, i));
+ RESET_BIT (old_ssa_names, i);
bitmap_ior_into (syms_to_rename, update_ssa_stats.virtual_symbols);
}
void
update_ssa (unsigned update_flags)
{
- bitmap *dfs, blocks;
+ bitmap blocks;
basic_block bb, start_bb;
bitmap_iterator bi;
unsigned i;
sbitmap tmp;
bool insert_phi_p;
+ sbitmap_iterator sbi;
if (!need_ssa_update_p ())
return;
if (insert_phi_p)
{
- /* If the caller requested PHI nodes to be added, compute
- dominance frontiers and initialize live-in information data
- structures (DEF_BLOCKS). */
- dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap *));
- FOR_EACH_BB (bb)
- dfs[bb->index] = BITMAP_ALLOC (NULL);
- compute_dominance_frontiers (dfs);
+ /* If the caller requested PHI nodes to be added, initialize
+ live-in information data structures (DEF_BLOCKS). */
/* For each SSA name N, the DEF_BLOCKS table describes where the
name is defined, which blocks have PHI nodes for N, and which
}
else
{
- dfs = NULL;
def_blocks = NULL;
}
for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
{
tree stmt = bsi_stmt (si);
+ /* We are going to use the operand cache API, such as
+ SET_USE, SET_DEF, and FOR_EACH_IMM_USE_FAST. The operand
+ cache for each statement should be up-to-date. */
+ gcc_assert (!stmt_modified_p (stmt));
REWRITE_THIS_STMT (stmt) = 0;
REGISTER_DEFS_IN_THIS_STMT (stmt) = 0;
}
and for symbols in SYMS_TO_RENAME. */
if (insert_phi_p)
{
+ bitmap *dfs;
+
+ /* If the caller requested PHI nodes to be added, compute
+ dominance frontiers. */
+ dfs = xmalloc (last_basic_block * sizeof (bitmap));
+ FOR_EACH_BB (bb)
+ dfs[bb->index] = BITMAP_ALLOC (NULL);
+ compute_dominance_frontiers (dfs);
+
if (sbitmap_first_set_bit (old_ssa_names) >= 0)
{
+ sbitmap_iterator sbi;
+
/* insert_update_phi_nodes_for will call add_new_name_mapping
when inserting new PHI nodes, so the set OLD_SSA_NAMES
will grow while we are traversing it (but it will not
for traversal. */
sbitmap tmp = sbitmap_alloc (old_ssa_names->n_bits);
sbitmap_copy (tmp, old_ssa_names);
- EXECUTE_IF_SET_IN_SBITMAP (tmp, 0, i,
+ EXECUTE_IF_SET_IN_SBITMAP (tmp, 0, i, sbi)
insert_updated_phi_nodes_for (ssa_name (i), dfs, blocks,
- update_flags));
+ update_flags);
sbitmap_free (tmp);
}
insert_updated_phi_nodes_for (referenced_var (i), dfs, blocks,
update_flags);
+ FOR_EACH_BB (bb)
+ BITMAP_FREE (dfs[bb->index]);
+ free (dfs);
+
/* Insertion of PHI nodes may have added blocks to the region.
We need to re-compute START_BB to include the newly added
blocks. */
/* Reset the current definition for name and symbol before renaming
the sub-graph. */
- EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i,
- set_current_def (ssa_name (i), NULL_TREE));
+ EXECUTE_IF_SET_IN_SBITMAP (old_ssa_names, 0, i, sbi)
+ set_current_def (ssa_name (i), NULL_TREE);
EXECUTE_IF_SET_IN_BITMAP (syms_to_rename, 0, i, bi)
set_current_def (referenced_var (i), NULL_TREE);
/* Free allocated memory. */
done:
- if (insert_phi_p)
- {
- FOR_EACH_BB (bb)
- BITMAP_FREE (dfs[bb->index]);
- free (dfs);
- }
-
BITMAP_FREE (blocks);
delete_update_ssa ();