2001-08-20 Diego Novillo <dnovillo@redhat.com>
+ * basic-block.h (basic_block): Add new field 'flags'.
+ (BB_REACHABLE): Define.
+ (expunge_block): Declare.
+ * flow.c (ENTRY_BLOCK_PTR): Initialize field 'flags'.
+ (EXIT_BLOCK_PTR): Ditto.
+ (expunge_block): Remove static declaration.
+ (cleanup_cfg): Clear bb->aux on every basic block.
+ (find_unreachable_blocks): Set BB_REACHABLE bit in bb->flags when
+ computing reachability.
+ (delete_unreachable_blocks): Delete block b if b->flags has
+ BB_REACHABLE unset.
+
+2001-08-20 Diego Novillo <dnovillo@redhat.com>
+
* doc/invoke.texi: Replace references to -fdump-tree with -fdump-ast.
2001-08-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
int frequency;
+
+ /* Various flags. See BB_* below. */
+ int flags;
} *basic_block;
#define BB_FREQ_MAX 10000
+/* Masks for basic_block.flags. */
+#define BB_REACHABLE 1
+
/* Number of basic blocks in the current function. */
extern int n_basic_blocks;
extern void allocate_reg_life_data PARAMS ((void));
extern void allocate_bb_life_data PARAMS ((void));
extern void find_unreachable_blocks PARAMS ((void));
+extern void expunge_block PARAMS ((basic_block));
extern void delete_noop_moves PARAMS ((rtx));
extern rtx last_loop_beg_note PARAMS ((rtx));
extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block));
ENTRY_BLOCK, /* index */
0, /* loop_depth */
0, /* count */
- 0 /* frequency */
+ 0, /* frequency */
+ 0 /* flags */
},
{
NULL, /* head */
EXIT_BLOCK, /* index */
0, /* loop_depth */
0, /* count */
- 0 /* frequency */
+ 0, /* frequency */
+ 0 /* flags */
}
};
static void delete_unreachable_blocks PARAMS ((void));
static int can_delete_note_p PARAMS ((rtx));
-static void expunge_block PARAMS ((basic_block));
static int can_delete_label_p PARAMS ((rtx));
static int tail_recursion_label_p PARAMS ((rtx));
static int merge_blocks_move_predecessor_nojumps PARAMS ((basic_block,
cleanup_cfg (mode)
int mode;
{
+ int i;
+
timevar_push (TV_CLEANUP_CFG);
delete_unreachable_blocks ();
if (try_optimize_cfg (mode))
free_EXPR_LIST_list (&label_value_list);
free_EXPR_LIST_list (&tail_recursion_label_list);
timevar_pop (TV_CLEANUP_CFG);
+
+ /* Clear bb->aux on all basic blocks. */
+ for (i = 0; i < n_basic_blocks; ++i)
+ BASIC_BLOCK (i)->aux = NULL;
}
/* Create a new basic block consisting of the instructions between
return blocks_split;
}
\f
-/* Find unreachable blocks. An unreachable block will have NULL in
- block->aux, a non-NULL value indicates the block is reachable. */
+/* Find unreachable blocks. An unreachable block will have 0 in
+ the reachable bit in block->flags. A non-zero value indicates the
+ block is reachable. */
void
find_unreachable_blocks ()
n = n_basic_blocks;
tos = worklist = (basic_block *) xmalloc (sizeof (basic_block) * n);
- /* Use basic_block->aux as a marker. Clear them all. */
+ /* Clear all the reachability flags. */
for (i = 0; i < n; ++i)
- BASIC_BLOCK (i)->aux = NULL;
+ BASIC_BLOCK (i)->flags &= ~BB_REACHABLE;
/* Add our starting points to the worklist. Almost always there will
be only one. It isn't inconcievable that we might one day directly
{
*tos++ = e->dest;
- /* Mark the block with a handy non-null value. */
- e->dest->aux = e;
+ /* Mark the block reachable. */
+ e->dest->flags |= BB_REACHABLE;
}
/* Iterate: find everything reachable from what we've already seen. */
basic_block b = *--tos;
for (e = b->succ; e; e = e->succ_next)
- if (!e->dest->aux)
+ if (!(e->dest->flags & BB_REACHABLE))
{
*tos++ = e->dest;
- e->dest->aux = e;
+ e->dest->flags |= BB_REACHABLE;
}
}
{
basic_block b = BASIC_BLOCK (i);
- if (b->aux != NULL)
- /* This block was found. Tidy up the mark. */
- b->aux = NULL;
- else
+ if (!(b->flags & BB_REACHABLE))
flow_delete_block (b);
}
/* Remove block B from the basic block array and compact behind it. */
-static void
+void
expunge_block (b)
basic_block b;
{