Commit 006844a3 by Diego Novillo Committed by Diego Novillo

basic-block.h (basic_block): Add new field 'flags'.


	* 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.

From-SVN: r45068
parent 0760faf9
2001-08-20 Diego Novillo <dnovillo@redhat.com> 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. * doc/invoke.texi: Replace references to -fdump-tree with -fdump-ast.
2001-08-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2001-08-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
......
...@@ -218,10 +218,16 @@ typedef struct basic_block_def { ...@@ -218,10 +218,16 @@ typedef struct basic_block_def {
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */ /* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
int frequency; int frequency;
/* Various flags. See BB_* below. */
int flags;
} *basic_block; } *basic_block;
#define BB_FREQ_MAX 10000 #define BB_FREQ_MAX 10000
/* Masks for basic_block.flags. */
#define BB_REACHABLE 1
/* Number of basic blocks in the current function. */ /* Number of basic blocks in the current function. */
extern int n_basic_blocks; extern int n_basic_blocks;
...@@ -609,6 +615,7 @@ extern void debug_regset PARAMS ((regset)); ...@@ -609,6 +615,7 @@ extern void debug_regset PARAMS ((regset));
extern void allocate_reg_life_data PARAMS ((void)); extern void allocate_reg_life_data PARAMS ((void));
extern void allocate_bb_life_data PARAMS ((void)); extern void allocate_bb_life_data PARAMS ((void));
extern void find_unreachable_blocks PARAMS ((void)); extern void find_unreachable_blocks PARAMS ((void));
extern void expunge_block PARAMS ((basic_block));
extern void delete_noop_moves PARAMS ((rtx)); extern void delete_noop_moves PARAMS ((rtx));
extern rtx last_loop_beg_note PARAMS ((rtx)); extern rtx last_loop_beg_note PARAMS ((rtx));
extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block)); extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block));
......
...@@ -208,7 +208,8 @@ struct basic_block_def entry_exit_blocks[2] ...@@ -208,7 +208,8 @@ struct basic_block_def entry_exit_blocks[2]
ENTRY_BLOCK, /* index */ ENTRY_BLOCK, /* index */
0, /* loop_depth */ 0, /* loop_depth */
0, /* count */ 0, /* count */
0 /* frequency */ 0, /* frequency */
0 /* flags */
}, },
{ {
NULL, /* head */ NULL, /* head */
...@@ -225,7 +226,8 @@ struct basic_block_def entry_exit_blocks[2] ...@@ -225,7 +226,8 @@ struct basic_block_def entry_exit_blocks[2]
EXIT_BLOCK, /* index */ EXIT_BLOCK, /* index */
0, /* loop_depth */ 0, /* loop_depth */
0, /* count */ 0, /* count */
0 /* frequency */ 0, /* frequency */
0 /* flags */
} }
}; };
...@@ -383,7 +385,6 @@ static void commit_one_edge_insertion PARAMS ((edge)); ...@@ -383,7 +385,6 @@ static void commit_one_edge_insertion PARAMS ((edge));
static void delete_unreachable_blocks PARAMS ((void)); static void delete_unreachable_blocks PARAMS ((void));
static int can_delete_note_p PARAMS ((rtx)); 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 can_delete_label_p PARAMS ((rtx));
static int tail_recursion_label_p PARAMS ((rtx)); static int tail_recursion_label_p PARAMS ((rtx));
static int merge_blocks_move_predecessor_nojumps PARAMS ((basic_block, static int merge_blocks_move_predecessor_nojumps PARAMS ((basic_block,
...@@ -1030,6 +1031,8 @@ void ...@@ -1030,6 +1031,8 @@ void
cleanup_cfg (mode) cleanup_cfg (mode)
int mode; int mode;
{ {
int i;
timevar_push (TV_CLEANUP_CFG); timevar_push (TV_CLEANUP_CFG);
delete_unreachable_blocks (); delete_unreachable_blocks ();
if (try_optimize_cfg (mode)) if (try_optimize_cfg (mode))
...@@ -1040,6 +1043,10 @@ cleanup_cfg (mode) ...@@ -1040,6 +1043,10 @@ cleanup_cfg (mode)
free_EXPR_LIST_list (&label_value_list); free_EXPR_LIST_list (&label_value_list);
free_EXPR_LIST_list (&tail_recursion_label_list); free_EXPR_LIST_list (&tail_recursion_label_list);
timevar_pop (TV_CLEANUP_CFG); 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 /* Create a new basic block consisting of the instructions between
...@@ -2643,8 +2650,9 @@ flow_call_edges_add (blocks) ...@@ -2643,8 +2650,9 @@ flow_call_edges_add (blocks)
return blocks_split; return blocks_split;
} }
/* Find unreachable blocks. An unreachable block will have NULL in /* Find unreachable blocks. An unreachable block will have 0 in
block->aux, a non-NULL value indicates the block is reachable. */ the reachable bit in block->flags. A non-zero value indicates the
block is reachable. */
void void
find_unreachable_blocks () find_unreachable_blocks ()
...@@ -2656,10 +2664,10 @@ find_unreachable_blocks () ...@@ -2656,10 +2664,10 @@ find_unreachable_blocks ()
n = n_basic_blocks; n = n_basic_blocks;
tos = worklist = (basic_block *) xmalloc (sizeof (basic_block) * n); 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) 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 /* Add our starting points to the worklist. Almost always there will
be only one. It isn't inconcievable that we might one day directly be only one. It isn't inconcievable that we might one day directly
...@@ -2669,8 +2677,8 @@ find_unreachable_blocks () ...@@ -2669,8 +2677,8 @@ find_unreachable_blocks ()
{ {
*tos++ = e->dest; *tos++ = e->dest;
/* Mark the block with a handy non-null value. */ /* Mark the block reachable. */
e->dest->aux = e; e->dest->flags |= BB_REACHABLE;
} }
/* Iterate: find everything reachable from what we've already seen. */ /* Iterate: find everything reachable from what we've already seen. */
...@@ -2680,10 +2688,10 @@ find_unreachable_blocks () ...@@ -2680,10 +2688,10 @@ find_unreachable_blocks ()
basic_block b = *--tos; basic_block b = *--tos;
for (e = b->succ; e; e = e->succ_next) for (e = b->succ; e; e = e->succ_next)
if (!e->dest->aux) if (!(e->dest->flags & BB_REACHABLE))
{ {
*tos++ = e->dest; *tos++ = e->dest;
e->dest->aux = e; e->dest->flags |= BB_REACHABLE;
} }
} }
...@@ -2706,10 +2714,7 @@ delete_unreachable_blocks () ...@@ -2706,10 +2714,7 @@ delete_unreachable_blocks ()
{ {
basic_block b = BASIC_BLOCK (i); basic_block b = BASIC_BLOCK (i);
if (b->aux != NULL) if (!(b->flags & BB_REACHABLE))
/* This block was found. Tidy up the mark. */
b->aux = NULL;
else
flow_delete_block (b); flow_delete_block (b);
} }
...@@ -2845,7 +2850,7 @@ flow_delete_block (b) ...@@ -2845,7 +2850,7 @@ flow_delete_block (b)
/* Remove block B from the basic block array and compact behind it. */ /* Remove block B from the basic block array and compact behind it. */
static void void
expunge_block (b) expunge_block (b)
basic_block b; basic_block b;
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment