static void free_pre_mem PROTO ((void));
static void compute_pre_data PROTO ((void));
static int pre_expr_reaches_here_p PROTO ((int, struct expr *,
- int, int, char *));
+ int, int));
static void insert_insn_end_bb PROTO ((struct expr *, int, int));
static void pre_insert_copy_insn PROTO ((struct expr *, rtx));
static void pre_insert_copies PROTO ((void));
static int expr_killed_p PROTO ((rtx, int));
static void compute_ae_kill PROTO ((sbitmap *, sbitmap *));
static int expr_reaches_here_p PROTO ((struct occr *, struct expr *,
- int, int, char *));
+ int, int));
static rtx computing_insn PROTO ((struct expr *, rtx));
static int def_reaches_here_p PROTO ((rtx, rtx));
static int can_disregard_other_sets PROTO ((struct reg_set **, rtx, int));
the closest such expression. */
static int
-expr_reaches_here_p (occr, expr, bb, check_self_loop, visited)
+expr_reaches_here_p_work (occr, expr, bb, check_self_loop, visited)
struct occr *occr;
struct expr *expr;
int bb;
{
edge pred;
- if (visited == NULL)
- {
- visited = (char *) alloca (n_basic_blocks);
- bzero (visited, n_basic_blocks);
- }
-
for (pred = BASIC_BLOCK(bb)->pred; pred != NULL; pred = pred->pred_next)
{
int pred_bb = pred->src->index;
else
{
visited[pred_bb] = 1;
- if (expr_reaches_here_p (occr, expr, pred_bb, check_self_loop, visited))
+ if (expr_reaches_here_p_work (occr, expr, pred_bb, check_self_loop,
+ visited))
return 1;
}
}
return 0;
}
+/* This wrapper for expr_reaches_here_p_work() is to ensure that any
+ memory allocated for that function is returned. */
+
+static int
+expr_reaches_here_p (occr, expr, bb, check_self_loop)
+ struct occr *occr;
+ struct expr *expr;
+ int bb;
+ int check_self_loop;
+{
+ int rval;
+ char * visited = (char *) xcalloc (n_basic_blocks, 1);
+
+ rval = expr_reaches_here_p_work(occr, expr, bb, check_self_loop, visited);
+
+ free (visited);
+
+ return (rval);
+}
+
/* Return the instruction that computes EXPR that reaches INSN's basic block.
If there is more than one such instruction, return NULL.
We let the normal cse pass handle the other cases. */
if (INSN_CUID (insn) < INSN_CUID (occr->insn))
{
- if (expr_reaches_here_p (occr, expr, bb, 1, NULL))
+ if (expr_reaches_here_p (occr, expr, bb, 1))
{
can_reach++;
if (can_reach > 1)
}
else /* Computation of the pattern outside this block. */
{
- if (expr_reaches_here_p (occr, expr, bb, 0, NULL))
+ if (expr_reaches_here_p (occr, expr, bb, 0))
{
can_reach++;
if (can_reach > 1)
the closest such expression. */
static int
-pre_expr_reaches_here_p (occr_bb, expr, bb, check_pre_comp, visited)
+pre_expr_reaches_here_p_work (occr_bb, expr, bb, check_pre_comp, visited)
int occr_bb;
struct expr *expr;
int bb;
{
edge pred;
- if (visited == NULL)
- {
- visited = (char *) alloca (n_basic_blocks);
- bzero (visited, n_basic_blocks);
- }
-
for (pred = BASIC_BLOCK (bb)->pred; pred != NULL; pred = pred->pred_next)
{
int pred_bb = pred->src->index;
else
{
visited[pred_bb] = 1;
- if (pre_expr_reaches_here_p (occr_bb, expr, pred_bb,
- check_pre_comp, visited))
+ if (pre_expr_reaches_here_p_work (occr_bb, expr, pred_bb,
+ check_pre_comp, visited))
return 1;
}
}
/* All paths have been checked. */
return 0;
}
+
+/* The wrapper for pre_expr_reaches_here_work that ensures that any
+ memory allocated for that function is returned. */
+
+static int
+pre_expr_reaches_here_p (occr_bb, expr, bb, check_pre_comp)
+ int occr_bb;
+ struct expr *expr;
+ int bb;
+ int check_pre_comp;
+{
+ int rval;
+ char * visited = (char *) xcalloc (n_basic_blocks, 1);
+
+ rval = pre_expr_reaches_here_p_work(occr_bb, expr, bb, check_pre_comp,
+ visited);
+
+ free (visited);
+
+ return (rval);
+}
\f
/* Given an expr, generate RTL which we can insert at the end of a BB,
if (!TEST_BIT (inserted[e], j)
&& (bb == ENTRY_BLOCK
|| pre_expr_reaches_here_p (bb, expr,
- BLOCK_NUM (occr->insn), 0,
- NULL)))
+ BLOCK_NUM (occr->insn), 0)))
{
rtx insn;
edge eg = INDEX_EDGE (edge_list, e);
continue;
/* Or if the expression doesn't reach the deleted one. */
if (! pre_expr_reaches_here_p (BLOCK_NUM (avail->insn), expr,
- BLOCK_NUM (occr->insn),
- 1, NULL))
+ BLOCK_NUM (occr->insn),1))
continue;
/* Copy the result of avail to reaching_reg. */
/* Compute a mapping from expression number (`bitmap_index') to
hash table entry. */
- index_map = (struct expr **) alloca (n_exprs * sizeof (struct expr *));
- bzero ((char *) index_map, n_exprs * sizeof (struct expr *));
+ index_map = xcalloc (n_exprs, sizeof (struct expr *));
for (i = 0; i < expr_hash_table_size; i++)
{
struct expr *expr;
changed = 1;
}
+ free (index_map);
free (pre_redundant_insns);
return changed;
/* We need predecessor/successor lists as well as pred/succ counts for
each basic block. */
- s_preds = (int_list_ptr *) alloca (n_basic_blocks * sizeof (int_list_ptr));
- s_succs = (int_list_ptr *) alloca (n_basic_blocks * sizeof (int_list_ptr));
- num_preds = (int *) alloca (n_basic_blocks * sizeof (int));
- num_succs = (int *) alloca (n_basic_blocks * sizeof (int));
+ s_preds = (int_list_ptr *) gmalloc (n_basic_blocks * sizeof (int_list_ptr));
+ s_succs = (int_list_ptr *) gmalloc (n_basic_blocks * sizeof (int_list_ptr));
+ num_preds = (int *) gmalloc (n_basic_blocks * sizeof (int));
+ num_succs = (int *) gmalloc (n_basic_blocks * sizeof (int));
compute_preds_succs (s_preds, s_succs, num_preds, num_succs);
/* Allocate bitmaps to hold local and global properties. */
/* Free storage allocated by find_basic_blocks. */
free_basic_block_vars (0);
+ /* Free our local predecessor/successor lists. */
+ free (s_preds);
+ free (s_succs);
+ free (num_preds);
+ free (num_succs);
+
/* Free bitmaps. */
free (nonnull_local);
free (nonnull_killed);
char *visited;
{
edge pred;
+ int visited_allocated_locally = 0;
+
if (visited == NULL)
{
- visited = (char *) alloca (n_basic_blocks);
- bzero (visited, n_basic_blocks);
+ visited_allocated_locally = 1;
+ visited = xcalloc (n_basic_blocks, 1);
}
visited[expr_bb] = 1;
break;
}
}
-
+ if (visited_allocated_locally)
+ free (visited);
return (pred == NULL);
}
\f
/* Compute a mapping from expression number (`bitmap_index') to
hash table entry. */
- index_map = (struct expr **) alloca (n_exprs * sizeof (struct expr *));
- bzero ((char *) index_map, n_exprs * sizeof (struct expr *));
+ index_map = xcalloc (n_exprs, sizeof (struct expr *));
for (i = 0; i < expr_hash_table_size; i++)
{
struct expr *expr;
}
}
}
+ free (index_map);
}
/* Top level routine to perform one code hoisting (aka unification) pass