tree-phinodes.c (reserve_phi_args_for_new_edge, [...]): Use phi_nodes_ptr.

* tree-phinodes.c (reserve_phi_args_for_new_edge, remove_phi_node):
	Use phi_nodes_ptr.
	(create_phi_node): Use set_phi_nodes.
	* omp-low.c (expand_omp_parallel): Use bb_stmt_list.
	* tree-if-conv.c (process_phi_nodes): Use set_phi_nodes.
	(combine_blocks):  Use bb_stmt_list and set_bb_stmt_list.
	* tree-flow-inline.h (phi_nodes, set_phi_nodes,
	(bsi_start, bsi_last): Use bb_stmt_list.
	(phi_nodes_ptr, bb_stmt_list, set_bb_stmt_list): New functions.
	* cfgexpand.c (expand_gimple_basic_block): Use bb_stmt_list.
	Traverse the statements using tsi iterator.
	* basic-block.h (struct basic_block_def): Fields stmt_list
	and phi_nodes moved to ...
	(struct tree_bb_info): ... new structure.
	* tree-cfg.c (create_bb): Allocate il.tree.  Use set_bb_stmt_list.
	(tree_merge_blocks): Use bb_stmt_list and set_bb_stmt_list.
	(remove_bb): Handle blocks with NULL stmt list.  Clear il.tree field.
	(tree_verify_flow_info): Verify that il.tree is not set for
	entry and exit block.
	(tree_split_block): Use set_bb_stmt_list.

From-SVN: r124086
This commit is contained in:
Zdenek Dvorak 2007-04-24 01:15:54 +02:00 committed by Zdenek Dvorak
parent 933e4fe7ae
commit 7506e1cbdc
8 changed files with 150 additions and 84 deletions

View File

@ -1,3 +1,26 @@
2007-04-23 Zdenek Dvorak <dvorakz@suse.cz>
* tree-phinodes.c (reserve_phi_args_for_new_edge, remove_phi_node):
Use phi_nodes_ptr.
(create_phi_node): Use set_phi_nodes.
* omp-low.c (expand_omp_parallel): Use bb_stmt_list.
* tree-if-conv.c (process_phi_nodes): Use set_phi_nodes.
(combine_blocks): Use bb_stmt_list and set_bb_stmt_list.
* tree-flow-inline.h (phi_nodes, set_phi_nodes,
(bsi_start, bsi_last): Use bb_stmt_list.
(phi_nodes_ptr, bb_stmt_list, set_bb_stmt_list): New functions.
* cfgexpand.c (expand_gimple_basic_block): Use bb_stmt_list.
Traverse the statements using tsi iterator.
* basic-block.h (struct basic_block_def): Fields stmt_list
and phi_nodes moved to ...
(struct tree_bb_info): ... new structure.
* tree-cfg.c (create_bb): Allocate il.tree. Use set_bb_stmt_list.
(tree_merge_blocks): Use bb_stmt_list and set_bb_stmt_list.
(remove_bb): Handle blocks with NULL stmt list. Clear il.tree field.
(tree_verify_flow_info): Verify that il.tree is not set for
entry and exit block.
(tree_split_block): Use set_bb_stmt_list.
2007-04-23 Mike Stump <mrs@apple.com>
* config/i386/i386.c (ix86_tune_features

View File

@ -213,9 +213,6 @@ struct rtl_bb_info;
/* Basic block information indexed by block number. */
struct basic_block_def GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb")))
{
/* Pointers to the first and last trees of the block. */
tree stmt_list;
/* The edges into and out of the block. */
VEC(edge,gc) *preds;
VEC(edge,gc) *succs;
@ -234,12 +231,10 @@ struct basic_block_def GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb")
struct basic_block_def *next_bb;
union basic_block_il_dependent {
struct tree_bb_info * GTY ((tag ("0"))) tree;
struct rtl_bb_info * GTY ((tag ("1"))) rtl;
} GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il;
/* Chain of PHI nodes for this block. */
tree phi_nodes;
/* Expected number of executions: calculated in profile.c. */
gcov_type count;
@ -277,6 +272,15 @@ struct rtl_bb_info GTY(())
int visited;
};
struct tree_bb_info GTY(())
{
/* Pointers to the first and last trees of the block. */
tree stmt_list;
/* Chain of PHI nodes for this block. */
tree phi_nodes;
};
typedef struct basic_block_def *basic_block;
DEF_VEC_P(basic_block);

View File

@ -1439,7 +1439,8 @@ expand_gimple_tailcall (basic_block bb, tree stmt, bool *can_fallthru)
static basic_block
expand_gimple_basic_block (basic_block bb)
{
block_stmt_iterator bsi = bsi_start (bb);
tree_stmt_iterator tsi;
tree stmts = bb_stmt_list (bb);
tree stmt = NULL;
rtx note, last;
edge e;
@ -1452,11 +1453,13 @@ expand_gimple_basic_block (basic_block bb)
bb->index);
}
bb->il.tree = NULL;
init_rtl_bb_info (bb);
bb->flags |= BB_RTL;
if (!bsi_end_p (bsi))
stmt = bsi_stmt (bsi);
tsi = tsi_start (stmts);
if (!tsi_end_p (tsi))
stmt = tsi_stmt (tsi);
if (stmt && TREE_CODE (stmt) == LABEL_EXPR)
{
@ -1469,7 +1472,7 @@ expand_gimple_basic_block (basic_block bb)
BB_HEAD (bb) = NEXT_INSN (last);
if (NOTE_P (BB_HEAD (bb)))
BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
bsi_next (&bsi);
tsi_next (&tsi);
note = emit_note_after (NOTE_INSN_BASIC_BLOCK, BB_HEAD (bb));
maybe_dump_rtl_for_tree_stmt (stmt, last);
@ -1493,9 +1496,9 @@ expand_gimple_basic_block (basic_block bb)
ei_next (&ei);
}
for (; !bsi_end_p (bsi); bsi_next (&bsi))
for (; !tsi_end_p (tsi); tsi_next (&tsi))
{
tree stmt = bsi_stmt (bsi);
tree stmt = tsi_stmt (tsi);
basic_block new_bb;
if (!stmt)

View File

@ -2495,7 +2495,7 @@ expand_omp_parallel (struct omp_region *region)
/* Declare local variables needed in CHILD_CFUN. */
block = DECL_INITIAL (child_fn);
BLOCK_VARS (block) = list2chain (child_cfun->unexpanded_var_list);
DECL_SAVED_TREE (child_fn) = single_succ (entry_bb)->stmt_list;
DECL_SAVED_TREE (child_fn) = bb_stmt_list (single_succ (entry_bb));
/* Reset DECL_CONTEXT on locals and function arguments. */
for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))

View File

@ -368,7 +368,8 @@ create_bb (void *h, void *e, basic_block after)
bb->index = last_basic_block;
bb->flags = BB_NEW;
bb->stmt_list = h ? (tree) h : alloc_stmt_list ();
bb->il.tree = GGC_CNEW (struct tree_bb_info);
set_bb_stmt_list (bb, h ? (tree) h : alloc_stmt_list ());
/* Add the new block to the linked list of blocks. */
link_block (bb, after);
@ -1306,9 +1307,9 @@ tree_merge_blocks (basic_block a, basic_block b)
}
/* Merge the chains. */
last = tsi_last (a->stmt_list);
tsi_link_after (&last, b->stmt_list, TSI_NEW_STMT);
b->stmt_list = NULL;
last = tsi_last (bb_stmt_list (a));
tsi_link_after (&last, bb_stmt_list (b), TSI_NEW_STMT);
set_bb_stmt_list (b, NULL_TREE);
}
@ -1944,57 +1945,60 @@ remove_bb (basic_block bb)
}
/* Remove all the instructions in the block. */
for (i = bsi_start (bb); !bsi_end_p (i);)
if (bb_stmt_list (bb) != NULL_TREE)
{
tree stmt = bsi_stmt (i);
if (TREE_CODE (stmt) == LABEL_EXPR
&& (FORCED_LABEL (LABEL_EXPR_LABEL (stmt))
|| DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt))))
for (i = bsi_start (bb); !bsi_end_p (i);)
{
basic_block new_bb;
block_stmt_iterator new_bsi;
/* A non-reachable non-local label may still be referenced.
But it no longer needs to carry the extra semantics of
non-locality. */
if (DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)))
tree stmt = bsi_stmt (i);
if (TREE_CODE (stmt) == LABEL_EXPR
&& (FORCED_LABEL (LABEL_EXPR_LABEL (stmt))
|| DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt))))
{
DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)) = 0;
FORCED_LABEL (LABEL_EXPR_LABEL (stmt)) = 1;
basic_block new_bb;
block_stmt_iterator new_bsi;
/* A non-reachable non-local label may still be referenced.
But it no longer needs to carry the extra semantics of
non-locality. */
if (DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)))
{
DECL_NONLOCAL (LABEL_EXPR_LABEL (stmt)) = 0;
FORCED_LABEL (LABEL_EXPR_LABEL (stmt)) = 1;
}
new_bb = bb->prev_bb;
new_bsi = bsi_start (new_bb);
bsi_remove (&i, false);
bsi_insert_before (&new_bsi, stmt, BSI_NEW_STMT);
}
else
{
/* Release SSA definitions if we are in SSA. Note that we
may be called when not in SSA. For example,
final_cleanup calls this function via
cleanup_tree_cfg. */
if (gimple_in_ssa_p (cfun))
release_defs (stmt);
bsi_remove (&i, true);
}
new_bb = bb->prev_bb;
new_bsi = bsi_start (new_bb);
bsi_remove (&i, false);
bsi_insert_before (&new_bsi, stmt, BSI_NEW_STMT);
}
else
{
/* Release SSA definitions if we are in SSA. Note that we
may be called when not in SSA. For example,
final_cleanup calls this function via
cleanup_tree_cfg. */
if (gimple_in_ssa_p (cfun))
release_defs (stmt);
bsi_remove (&i, true);
}
/* Don't warn for removed gotos. Gotos are often removed due to
jump threading, thus resulting in bogus warnings. Not great,
since this way we lose warnings for gotos in the original
program that are indeed unreachable. */
if (TREE_CODE (stmt) != GOTO_EXPR && EXPR_HAS_LOCATION (stmt) && !loc)
{
/* Don't warn for removed gotos. Gotos are often removed due to
jump threading, thus resulting in bogus warnings. Not great,
since this way we lose warnings for gotos in the original
program that are indeed unreachable. */
if (TREE_CODE (stmt) != GOTO_EXPR && EXPR_HAS_LOCATION (stmt) && !loc)
{
#ifdef USE_MAPPED_LOCATION
if (EXPR_HAS_LOCATION (stmt))
loc = EXPR_LOCATION (stmt);
if (EXPR_HAS_LOCATION (stmt))
loc = EXPR_LOCATION (stmt);
#else
source_locus t;
t = EXPR_LOCUS (stmt);
if (t && LOCATION_LINE (*t) > 0)
loc = t;
source_locus t;
t = EXPR_LOCUS (stmt);
if (t && LOCATION_LINE (*t) > 0)
loc = t;
#endif
}
}
}
@ -2011,6 +2015,7 @@ remove_bb (basic_block bb)
#endif
remove_phi_nodes_and_edges_for_unreachable_block (bb);
bb->il.tree = NULL;
}
@ -3651,15 +3656,15 @@ tree_verify_flow_info (void)
edge e;
edge_iterator ei;
if (ENTRY_BLOCK_PTR->stmt_list)
if (ENTRY_BLOCK_PTR->il.tree)
{
error ("ENTRY_BLOCK has a statement list associated with it");
error ("ENTRY_BLOCK has IL associated with it");
err = 1;
}
if (EXIT_BLOCK_PTR->stmt_list)
if (EXIT_BLOCK_PTR->il.tree)
{
error ("EXIT_BLOCK has a statement list associated with it");
error ("EXIT_BLOCK has IL associated with it");
err = 1;
}
@ -4200,7 +4205,7 @@ tree_split_block (basic_block bb, void *stmt)
{
block_stmt_iterator bsi;
tree_stmt_iterator tsi_tgt;
tree act;
tree act, list;
basic_block new_bb;
edge e;
edge_iterator ei;
@ -4240,8 +4245,9 @@ tree_split_block (basic_block bb, void *stmt)
brings ugly quadratic memory consumption in the inliner.
(We are still quadratic since we need to update stmt BB pointers,
sadly.) */
new_bb->stmt_list = tsi_split_statement_list_before (&bsi.tsi);
for (tsi_tgt = tsi_start (new_bb->stmt_list);
list = tsi_split_statement_list_before (&bsi.tsi);
set_bb_stmt_list (new_bb, list);
for (tsi_tgt = tsi_start (list);
!tsi_end_p (tsi_tgt); tsi_next (&tsi_tgt))
change_bb_for_stmt (tsi_stmt (tsi_tgt), new_bb);

View File

@ -637,7 +637,19 @@ addresses_taken (tree stmt)
static inline tree
phi_nodes (basic_block bb)
{
return bb->phi_nodes;
gcc_assert (!(bb->flags & BB_RTL));
if (!bb->il.tree)
return NULL;
return bb->il.tree->phi_nodes;
}
/* Return pointer to the list of PHI nodes for basic block BB. */
static inline tree *
phi_nodes_ptr (basic_block bb)
{
gcc_assert (!(bb->flags & BB_RTL));
return &bb->il.tree->phi_nodes;
}
/* Set list of phi nodes of a basic block BB to L. */
@ -647,7 +659,8 @@ set_phi_nodes (basic_block bb, tree l)
{
tree phi;
bb->phi_nodes = l;
gcc_assert (!(bb->flags & BB_RTL));
bb->il.tree->phi_nodes = l;
for (phi = l; phi; phi = PHI_CHAIN (phi))
set_bb_for_stmt (phi, bb);
}
@ -746,20 +759,37 @@ phi_ssa_name_p (tree t)
/* ----------------------------------------------------------------------- */
/* Returns the list of statements in BB. */
static inline tree
bb_stmt_list (basic_block bb)
{
gcc_assert (!(bb->flags & BB_RTL));
return bb->il.tree->stmt_list;
}
/* Sets the list of statements in BB to LIST. */
static inline void
set_bb_stmt_list (basic_block bb, tree list)
{
gcc_assert (!(bb->flags & BB_RTL));
bb->il.tree->stmt_list = list;
}
/* Return a block_stmt_iterator that points to beginning of basic
block BB. */
static inline block_stmt_iterator
bsi_start (basic_block bb)
{
block_stmt_iterator bsi;
if (bb->stmt_list)
bsi.tsi = tsi_start (bb->stmt_list);
else
if (bb->index < NUM_FIXED_BLOCKS)
{
gcc_assert (bb->index < NUM_FIXED_BLOCKS);
bsi.tsi.ptr = NULL;
bsi.tsi.container = NULL;
}
else
bsi.tsi = tsi_start (bb_stmt_list (bb));
bsi.bb = bb;
return bsi;
}
@ -784,14 +814,14 @@ static inline block_stmt_iterator
bsi_last (basic_block bb)
{
block_stmt_iterator bsi;
if (bb->stmt_list)
bsi.tsi = tsi_last (bb->stmt_list);
else
if (bb->index < NUM_FIXED_BLOCKS)
{
gcc_assert (bb->index < NUM_FIXED_BLOCKS);
bsi.tsi.ptr = NULL;
bsi.tsi.container = NULL;
}
else
bsi.tsi = tsi_last (bb_stmt_list (bb));
bsi.bb = bb;
return bsi;
}

View File

@ -865,7 +865,7 @@ process_phi_nodes (struct loop *loop)
release_phi_node (phi);
phi = next;
}
bb->phi_nodes = NULL;
set_phi_nodes (bb, NULL_TREE);
}
return;
}
@ -960,9 +960,9 @@ combine_blocks (struct loop *loop)
}
/* Update stmt list. */
last = tsi_last (merge_target_bb->stmt_list);
tsi_link_after (&last, bb->stmt_list, TSI_NEW_STMT);
bb->stmt_list = alloc_stmt_list ();
last = tsi_last (bb_stmt_list (merge_target_bb));
tsi_link_after (&last, bb_stmt_list (bb), TSI_NEW_STMT);
set_bb_stmt_list (bb, NULL);
delete_basic_block (bb);
}

View File

@ -313,7 +313,7 @@ reserve_phi_args_for_new_edge (basic_block bb)
int len = EDGE_COUNT (bb->preds);
int cap = ideal_phi_node_len (len + 4);
for (loc = &(bb->phi_nodes);
for (loc = phi_nodes_ptr (bb);
*loc;
loc = &PHI_CHAIN (*loc))
{
@ -354,7 +354,7 @@ create_phi_node (tree var, basic_block bb)
/* Add the new PHI node to the list of PHI nodes for block BB. */
PHI_CHAIN (phi) = phi_nodes (bb);
bb->phi_nodes = phi;
set_phi_nodes (bb, phi);
/* Associate BB to the PHI node. */
set_bb_for_stmt (phi, bb);
@ -458,7 +458,7 @@ remove_phi_node (tree phi, tree prev, bool release_lhs_p)
}
else
{
for (loc = &(bb_for_stmt (phi)->phi_nodes);
for (loc = phi_nodes_ptr (bb_for_stmt (phi));
*loc != phi;
loc = &PHI_CHAIN (*loc))
;