aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog31
-rw-r--r--gcc/basic-block.h10
-rw-r--r--gcc/predict.c16
-rw-r--r--gcc/tree-cfg.c46
-rw-r--r--gcc/tree-flow-inline.h11
-rw-r--r--gcc/tree-flow.h21
-rw-r--r--gcc/tree-if-conv.c2
-rw-r--r--gcc/tree-phinodes.c6
-rw-r--r--gcc/tree-pretty-print.c3
-rw-r--r--gcc/tree-ssa-dom.c11
-rw-r--r--gcc/tree-ssa-threadupdate.c18
-rw-r--r--gcc/tree.h3
12 files changed, 74 insertions, 104 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5f06858..f9753e9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,34 @@
+2005-05-27 Kazu Hirata <kazu@cs.umass.edu>
+
+ * basic-block.h (basic_block_def): Add phi_nodes and
+ predictions. Remove tree_annotations.
+ * predict.c (tree_predicted_by_p, tree_predict_edge,
+ combine_predictions_for_bb): Adjust references to predictions.
+ * tree-cfg.c (init_empty_tree_cfg, create_bb): Don't call
+ create_block_annotation.
+ (create_block_annotation, free_blocks_annotatios,
+ clear_blocks_annotations): Remove.
+ (dump_cfg_stats): Don't print out the memory spent on
+ bb_ann_d.
+ (delete_tree_cfg_annotations): Don't call free_blocks_annotations.
+ * tree-flow-inline.h (bb_ann): Remove.
+ (phi_nodes, set_phi_nodes): Update references to phi_nodes.
+ * tree-flow.h (bb_ann_d): Remove.
+ * tree-if-conv.c (process_phi_nodes): Update a reference to
+ phi_nodes.
+ * tree-phinodes.c (reserve_phi_args_for_new_edge,
+ create_phi_node, remove_phi_node): Likewise.
+ * tree-pretty-print.c (dump_generic_bb_buff): Don't call bb_ann.
+ * tree-ssa-dom.c (threaded_blocks): New.
+ (tree_ssa_dominator_optimize): Initialize, clear, and free
+ threaded_blocks. Update a call to thread_through_all_blocks.
+ (thread_across_edge): Use threaded_blocks instead of setting
+ incoming_edge_threaded.
+ * tree-ssa-threadupdate.c (threaded_through_all_blocks): Take
+ a bitmap of blocks that are threaded through.
+ * tree.h: Move the prototype of threaded_through_blocks to
+ tree-flow.h.
+
2005-05-27 Jan Hubicka <jh@suse.cz>
* cgraph.c: Include tree-gimple.h
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 4deeb89..cedeac5 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -185,6 +185,9 @@ struct loops;
/* Declared in tree-flow.h. */
struct bb_ann_d;
+/* Declared in tree-flow.h. */
+struct edge_prediction;
+
/* A basic block is a sequence of instructions with only entry and
only one exit. If any one of the instructions are executed, they
will all be executed, and in sequence from first to last.
@@ -246,8 +249,11 @@ struct basic_block_def GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb")
/* The data used by basic block copying and reordering functions. */
struct reorder_block_def * rbi;
- /* Annotations used at the tree level. */
- struct bb_ann_d *tree_annotations;
+ /* Chain of PHI nodes for this block. */
+ tree phi_nodes;
+
+ /* A list of predictions. */
+ struct edge_prediction *predictions;
/* Expected number of executions: calculated in profile.c. */
gcov_type count;
diff --git a/gcc/predict.c b/gcc/predict.c
index 961a395..25f97f7 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -171,8 +171,8 @@ rtl_predicted_by_p (basic_block bb, enum br_predictor predictor)
bool
tree_predicted_by_p (basic_block bb, enum br_predictor predictor)
{
- struct edge_prediction *i = bb_ann (bb)->predictions;
- for (i = bb_ann (bb)->predictions; i; i = i->next)
+ struct edge_prediction *i;
+ for (i = bb->predictions; i; i = i->next)
if (i->predictor == predictor)
return true;
return false;
@@ -233,8 +233,8 @@ tree_predict_edge (edge e, enum br_predictor predictor, int probability)
{
struct edge_prediction *i = ggc_alloc (sizeof (struct edge_prediction));
- i->next = bb_ann (e->src)->predictions;
- bb_ann (e->src)->predictions = i;
+ i->next = e->src->predictions;
+ e->src->predictions = i;
i->probability = probability;
i->predictor = predictor;
i->edge = e;
@@ -488,7 +488,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
{
if (!bb->count)
set_even_probabilities (bb);
- bb_ann (bb)->predictions = NULL;
+ bb->predictions = NULL;
if (file)
fprintf (file, "%i edges in bb %i predicted to even probabilities\n",
nedges, bb->index);
@@ -500,7 +500,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
/* We implement "first match" heuristics and use probability guessed
by predictor with smallest index. */
- for (pred = bb_ann (bb)->predictions; pred; pred = pred->next)
+ for (pred = bb->predictions; pred; pred = pred->next)
{
int predictor = pred->predictor;
int probability = pred->probability;
@@ -546,7 +546,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
combined_probability = best_probability;
dump_prediction (file, PRED_COMBINED, combined_probability, bb, true);
- for (pred = bb_ann (bb)->predictions; pred; pred = pred->next)
+ for (pred = bb->predictions; pred; pred = pred->next)
{
int predictor = pred->predictor;
int probability = pred->probability;
@@ -556,7 +556,7 @@ combine_predictions_for_bb (FILE *file, basic_block bb)
dump_prediction (file, predictor, probability, bb,
!first_match || best_predictor == predictor);
}
- bb_ann (bb)->predictions = NULL;
+ bb->predictions = NULL;
if (!bb->count)
{
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a219d8b..f0428b3 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -95,9 +95,6 @@ static bool found_computed_goto;
/* Basic blocks and flowgraphs. */
static basic_block create_bb (void *, void *, basic_block);
-static void create_block_annotation (basic_block);
-static void free_blocks_annotations (void);
-static void clear_blocks_annotations (void);
static void make_blocks (tree);
static void factor_computed_gotos (void);
@@ -149,9 +146,6 @@ init_empty_tree_cfg (void)
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
-
- create_block_annotation (ENTRY_BLOCK_PTR);
- create_block_annotation (EXIT_BLOCK_PTR);
}
/*---------------------------------------------------------------------------
@@ -322,37 +316,6 @@ factor_computed_gotos (void)
}
-/* Create annotations for a single basic block. */
-
-static void
-create_block_annotation (basic_block bb)
-{
- /* Verify that the tree_annotations field is clear. */
- gcc_assert (!bb->tree_annotations);
- bb->tree_annotations = ggc_alloc_cleared (sizeof (struct bb_ann_d));
-}
-
-
-/* Free the annotations for all the basic blocks. */
-
-static void free_blocks_annotations (void)
-{
- clear_blocks_annotations ();
-}
-
-
-/* Clear the annotations for all the basic blocks. */
-
-static void
-clear_blocks_annotations (void)
-{
- basic_block bb;
-
- FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
- bb->tree_annotations = NULL;
-}
-
-
/* Build a flowgraph for the statement_list STMT_LIST. */
static void
@@ -431,8 +394,6 @@ create_bb (void *h, void *e, basic_block after)
/* Add the newly created block to the array. */
BASIC_BLOCK (last_basic_block) = bb;
- create_block_annotation (bb);
-
n_basic_blocks++;
last_basic_block++;
@@ -2561,11 +2522,6 @@ dump_cfg_stats (FILE *file)
total += size;
fprintf (file, fmt_str_1, "Edges", num_edges, SCALE (size), LABEL (size));
- size = n_basic_blocks * sizeof (struct bb_ann_d);
- total += size;
- fprintf (file, fmt_str_1, "Basic block annotations", n_basic_blocks,
- SCALE (size), LABEL (size));
-
fprintf (file, "---------------------------------------------------------\n");
fprintf (file, fmt_str_3, "Total memory used by CFG data", SCALE (total),
LABEL (total));
@@ -2876,8 +2832,6 @@ void
delete_tree_cfg_annotations (void)
{
basic_block bb;
- if (n_basic_blocks > 0)
- free_blocks_annotations ();
label_to_block_map = NULL;
FOR_EACH_BB (bb)
diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h
index 31afd9d..d7b0aa4 100644
--- a/gcc/tree-flow-inline.h
+++ b/gcc/tree-flow-inline.h
@@ -494,19 +494,12 @@ addresses_taken (tree stmt)
return ann ? ann->addresses_taken : NULL;
}
-/* Return the basic_block annotation for BB. */
-static inline bb_ann_t
-bb_ann (basic_block bb)
-{
- return (bb_ann_t)bb->tree_annotations;
-}
-
/* Return the PHI nodes for basic block BB, or NULL if there are no
PHI nodes. */
static inline tree
phi_nodes (basic_block bb)
{
- return bb_ann (bb)->phi_nodes;
+ return bb->phi_nodes;
}
/* Set list of phi nodes of a basic block BB to L. */
@@ -516,7 +509,7 @@ set_phi_nodes (basic_block bb, tree l)
{
tree phi;
- bb_ann (bb)->phi_nodes = l;
+ bb->phi_nodes = l;
for (phi = l; phi; phi = PHI_CHAIN (phi))
set_bb_for_stmt (phi, bb);
}
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 974e8b0..ceb2b33 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -377,25 +377,7 @@ struct edge_prediction GTY((chain_next ("%h.next")))
int probability;
};
-/*---------------------------------------------------------------------------
- Block annotations stored in basic_block.tree_annotations
----------------------------------------------------------------------------*/
-struct bb_ann_d GTY(())
-{
- /* Chain of PHI nodes for this block. */
- tree phi_nodes;
-
- /* Nonzero if one or more incoming edges to this block should be threaded
- to an outgoing edge of this block. */
- unsigned incoming_edge_threaded : 1;
-
- struct edge_prediction *predictions;
-};
-
-typedef struct bb_ann_d *bb_ann_t;
-
/* Accessors for basic block annotations. */
-static inline bb_ann_t bb_ann (basic_block);
static inline tree phi_nodes (basic_block);
static inline void set_phi_nodes (basic_block, tree);
@@ -782,6 +764,9 @@ extern void linear_transform_loops (struct loops *);
/* In tree-ssa-loop-ivopts.c */
extern bool expr_invariant_in_loop_p (struct loop *, tree);
+/* In tree-ssa-threadupdate.c. */
+extern bool thread_through_all_blocks (bitmap);
+
/* In gimplify.c */
tree force_gimple_operand (tree, tree *, bool, tree);
tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree);
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index decd9cd..82a710a 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -840,7 +840,7 @@ process_phi_nodes (struct loop *loop)
release_phi_node (phi);
phi = next;
}
- bb_ann (bb)->phi_nodes = NULL;
+ bb->phi_nodes = NULL;
}
return;
}
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index ca01c8c..7faedc9 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -314,7 +314,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_ann (bb)->phi_nodes);
+ for (loc = &(bb->phi_nodes);
*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_ann (bb)->phi_nodes = phi;
+ bb->phi_nodes = phi;
/* Associate BB to the PHI node. */
set_bb_for_stmt (phi, bb);
@@ -450,7 +450,7 @@ remove_phi_node (tree phi, tree prev)
}
else
{
- for (loc = &(bb_ann (bb_for_stmt (phi))->phi_nodes);
+ for (loc = &(bb_for_stmt (phi)->phi_nodes);
*loc != phi;
loc = &PHI_CHAIN (*loc))
;
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 52bf437..6ac56dd 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -2341,8 +2341,7 @@ dump_generic_bb_buff (pretty_printer *buffer, basic_block bb,
dump_bb_header (buffer, bb, indent, flags);
- if (bb_ann (bb))
- dump_phi_nodes (buffer, bb, indent, flags);
+ dump_phi_nodes (buffer, bb, indent, flags);
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
{
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index cb4abcf..910ddce 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -141,6 +141,10 @@ static VEC(tree,heap) *const_and_copies_stack;
know their exact value. */
static bitmap nonzero_vars;
+/* Bitmap of blocks that are scheduled to be threaded through. This
+ is used to communicate with thread_through_blocks. */
+static bitmap threaded_blocks;
+
/* Stack of SSA_NAMEs which need their NONZERO_VARS property cleared
when the current block is finalized.
@@ -370,6 +374,7 @@ tree_ssa_dominator_optimize (void)
vrp_variables_stack = VEC_alloc (tree, heap, 20);
stmts_to_rescan = VEC_alloc (tree, heap, 20);
nonzero_vars = BITMAP_ALLOC (NULL);
+ threaded_blocks = BITMAP_ALLOC (NULL);
need_eh_cleanup = BITMAP_ALLOC (NULL);
/* Setup callbacks for the generic dominator tree walker. */
@@ -445,7 +450,7 @@ tree_ssa_dominator_optimize (void)
free_all_edge_infos ();
/* Thread jumps, creating duplicate blocks as needed. */
- cfg_altered |= thread_through_all_blocks ();
+ cfg_altered |= thread_through_all_blocks (threaded_blocks);
/* Removal of statements may make some EH edges dead. Purge
such edges from the CFG as needed. */
@@ -480,6 +485,7 @@ tree_ssa_dominator_optimize (void)
/* Reinitialize the various tables. */
bitmap_clear (nonzero_vars);
+ bitmap_clear (threaded_blocks);
htab_empty (avail_exprs);
htab_empty (vrp_data);
@@ -523,6 +529,7 @@ tree_ssa_dominator_optimize (void)
/* Free nonzero_vars. */
BITMAP_FREE (nonzero_vars);
+ BITMAP_FREE (threaded_blocks);
BITMAP_FREE (need_eh_cleanup);
VEC_free (tree, heap, avail_exprs_stack);
@@ -830,7 +837,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
else
edge_info = allocate_edge_info (e);
edge_info->redirection_target = taken_edge;
- bb_ann (e->dest)->incoming_edge_threaded = true;
+ bitmap_set_bit (threaded_blocks, e->dest->index);
}
}
}
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index e72598d..f6bf1db 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -802,22 +802,20 @@ thread_block (basic_block bb)
Returns true if one or more edges were threaded, false otherwise. */
bool
-thread_through_all_blocks (void)
+thread_through_all_blocks (bitmap threaded_blocks)
{
- basic_block bb;
bool retval = false;
+ unsigned int i;
+ bitmap_iterator bi;
rediscover_loops_after_threading = false;
- FOR_EACH_BB (bb)
+ EXECUTE_IF_SET_IN_BITMAP (threaded_blocks, 0, i, bi)
{
- if (bb_ann (bb)->incoming_edge_threaded
- && EDGE_COUNT (bb->preds) > 0)
- {
- retval |= thread_block (bb);
- bb_ann (bb)->incoming_edge_threaded = false;
-
- }
+ basic_block bb = BASIC_BLOCK (i);
+
+ if (EDGE_COUNT (bb->preds) > 0)
+ retval |= thread_block (bb);
}
return retval;
diff --git a/gcc/tree.h b/gcc/tree.h
index b7764d8..e72a20f 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3975,9 +3975,6 @@ extern int tree_node_sizes[];
restricted to creating gimple expressions. */
extern bool in_gimple_form;
-/* In tree-ssa-threadupdate.c. */
-extern bool thread_through_all_blocks (void);
-
/* In tree-gimple.c. */
extern tree get_base_address (tree t);