Commit d9d4706f by Kazu Hirata Committed by Kazu Hirata

cfg.c (unchecked_make_edge): Call execute_on_growing_pred after making an edge.

	* cfg.c (unchecked_make_edge): Call execute_on_growing_pred
	after making an edge.
	(remove_edge): Call execute_on_shrinking_pred before removing
	an edge.
	(redirect_edge_succ): Call execute_on_growing_pred and
	execute_on_shrinking_pred.
	* cfghooks.c (execute_on_growing_pred): New.
	(execute_on_shrinking_pred): Likewise.
	* cfghooks.h (cfg_hooks): Add execute_on_growing_pred and
	execute_on_shrinking_pred.
	Add prototypes for execute_on_growing_pred and
	execute_on_shrinking_pred.
	* cfgrtl.c (rtl_cfg_hooks): Add NULL hooks to
	execute_on_growing_pred and execute_on_shrinking_pred.
	(cfg_layout_rtl_cfg_hook): Likewise.
	* tree-cfg.c (tree_cfg_hooks): Likewise.

From-SVN: r91035
parent b31997c0
...@@ -7,6 +7,23 @@ ...@@ -7,6 +7,23 @@
* tree-ssa.c (ssa_remove_edge): Call remove_phi_args instead * tree-ssa.c (ssa_remove_edge): Call remove_phi_args instead
of remove_phi_arg. of remove_phi_arg.
* cfg.c (unchecked_make_edge): Call execute_on_growing_pred
after making an edge.
(remove_edge): Call execute_on_shrinking_pred before removing
an edge.
(redirect_edge_succ): Call execute_on_growing_pred and
execute_on_shrinking_pred.
* cfghooks.c (execute_on_growing_pred): New.
(execute_on_shrinking_pred): Likewise.
* cfghooks.h (cfg_hooks): Add execute_on_growing_pred and
execute_on_shrinking_pred.
Add prototypes for execute_on_growing_pred and
execute_on_shrinking_pred.
* cfgrtl.c (rtl_cfg_hooks): Add NULL hooks to
execute_on_growing_pred and execute_on_shrinking_pred.
(cfg_layout_rtl_cfg_hook): Likewise.
* tree-cfg.c (tree_cfg_hooks): Likewise.
2004-11-23 Ben Elliston <bje@au.ibm.com> 2004-11-23 Ben Elliston <bje@au.ibm.com>
* doc/cfg.texi (Maintaining the CFG): Use @ftable instead of * doc/cfg.texi (Maintaining the CFG): Use @ftable instead of
......
...@@ -277,6 +277,8 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags) ...@@ -277,6 +277,8 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags)
e->flags = flags; e->flags = flags;
e->dest_idx = EDGE_COUNT (dst->preds) - 1; e->dest_idx = EDGE_COUNT (dst->preds) - 1;
execute_on_growing_pred (e);
return e; return e;
} }
...@@ -358,6 +360,8 @@ remove_edge (edge e) ...@@ -358,6 +360,8 @@ remove_edge (edge e)
bool found = false; bool found = false;
edge_iterator ei; edge_iterator ei;
execute_on_shrinking_pred (e);
src = e->src; src = e->src;
dest = e->dest; dest = e->dest;
dest_idx = e->dest_idx; dest_idx = e->dest_idx;
...@@ -394,6 +398,8 @@ redirect_edge_succ (edge e, basic_block new_succ) ...@@ -394,6 +398,8 @@ redirect_edge_succ (edge e, basic_block new_succ)
basic_block dest = e->dest; basic_block dest = e->dest;
unsigned int dest_idx = e->dest_idx; unsigned int dest_idx = e->dest_idx;
execute_on_shrinking_pred (e);
VEC_unordered_remove (edge, dest->preds, dest_idx); VEC_unordered_remove (edge, dest->preds, dest_idx);
/* If we removed an edge in the middle of the edge vector, we need /* If we removed an edge in the middle of the edge vector, we need
...@@ -405,6 +411,7 @@ redirect_edge_succ (edge e, basic_block new_succ) ...@@ -405,6 +411,7 @@ redirect_edge_succ (edge e, basic_block new_succ)
VEC_safe_push (edge, new_succ->preds, e); VEC_safe_push (edge, new_succ->preds, e);
e->dest = new_succ; e->dest = new_succ;
e->dest_idx = EDGE_COUNT (new_succ->preds) - 1; e->dest_idx = EDGE_COUNT (new_succ->preds) - 1;
execute_on_growing_pred (e);
} }
/* Like previous but avoid possible duplicate edge. */ /* Like previous but avoid possible duplicate edge. */
......
...@@ -804,3 +804,23 @@ flow_call_edges_add (sbitmap blocks) ...@@ -804,3 +804,23 @@ flow_call_edges_add (sbitmap blocks)
return (cfg_hooks->flow_call_edges_add) (blocks); return (cfg_hooks->flow_call_edges_add) (blocks);
} }
/* This function is called immediately after edge E is added to the
edge vector E->dest->preds. */
void
execute_on_growing_pred (edge e)
{
if (cfg_hooks->execute_on_growing_pred)
cfg_hooks->execute_on_growing_pred (e);
}
/* This function is called immediately before edge E is removed from
the edge vector E->dest->preds. */
void
execute_on_shrinking_pred (edge e)
{
if (cfg_hooks->execute_on_shrinking_pred)
cfg_hooks->execute_on_shrinking_pred (e);
}
...@@ -100,6 +100,14 @@ struct cfg_hooks ...@@ -100,6 +100,14 @@ struct cfg_hooks
The goal is to expose cases in which entering a basic block does not imply The goal is to expose cases in which entering a basic block does not imply
that all subsequent instructions must be executed. */ that all subsequent instructions must be executed. */
int (*flow_call_edges_add) (sbitmap); int (*flow_call_edges_add) (sbitmap);
/* This function is called immediately after edge E is added to the
edge vector E->dest->preds. */
void (*execute_on_growing_pred) (edge);
/* This function is called immediately before edge E is removed from
the edge vector E->dest->preds. */
void (*execute_on_shrinking_pred) (edge);
}; };
extern void verify_flow_info (void); extern void verify_flow_info (void);
...@@ -126,6 +134,8 @@ extern basic_block duplicate_block (basic_block, edge); ...@@ -126,6 +134,8 @@ extern basic_block duplicate_block (basic_block, edge);
extern bool block_ends_with_call_p (basic_block bb); extern bool block_ends_with_call_p (basic_block bb);
extern bool block_ends_with_condjump_p (basic_block bb); extern bool block_ends_with_condjump_p (basic_block bb);
extern int flow_call_edges_add (sbitmap); extern int flow_call_edges_add (sbitmap);
extern void execute_on_growing_pred (edge);
extern void execute_on_shrinking_pred (edge);
/* Hooks containers. */ /* Hooks containers. */
extern struct cfg_hooks tree_cfg_hooks; extern struct cfg_hooks tree_cfg_hooks;
......
...@@ -3071,7 +3071,9 @@ struct cfg_hooks rtl_cfg_hooks = { ...@@ -3071,7 +3071,9 @@ struct cfg_hooks rtl_cfg_hooks = {
rtl_tidy_fallthru_edge, rtl_tidy_fallthru_edge,
rtl_block_ends_with_call_p, rtl_block_ends_with_call_p,
rtl_block_ends_with_condjump_p, rtl_block_ends_with_condjump_p,
rtl_flow_call_edges_add rtl_flow_call_edges_add,
NULL, /* execute_on_growing_pred */
NULL /* execute_on_shrinking_pred */
}; };
/* Implementation of CFG manipulation for cfg layout RTL, where /* Implementation of CFG manipulation for cfg layout RTL, where
...@@ -3107,6 +3109,8 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = { ...@@ -3107,6 +3109,8 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = {
NULL, NULL,
rtl_block_ends_with_call_p, rtl_block_ends_with_call_p,
rtl_block_ends_with_condjump_p, rtl_block_ends_with_condjump_p,
rtl_flow_call_edges_add rtl_flow_call_edges_add,
NULL, /* execute_on_growing_pred */
NULL /* execute_on_shrinking_pred */
}; };
...@@ -5360,7 +5360,9 @@ struct cfg_hooks tree_cfg_hooks = { ...@@ -5360,7 +5360,9 @@ struct cfg_hooks tree_cfg_hooks = {
NULL, /* tidy_fallthru_edge */ NULL, /* tidy_fallthru_edge */
tree_block_ends_with_call_p, /* block_ends_with_call_p */ tree_block_ends_with_call_p, /* block_ends_with_call_p */
tree_block_ends_with_condjump_p, /* block_ends_with_condjump_p */ tree_block_ends_with_condjump_p, /* block_ends_with_condjump_p */
tree_flow_call_edges_add /* flow_call_edges_add */ tree_flow_call_edges_add, /* flow_call_edges_add */
NULL, /* execute_on_growing_pred */
NULL, /* execute_on_shrinking_pred */
}; };
......
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