Commit dc936fb2 by David Malcolm Committed by David Malcolm

Eliminate n_edges macro

	* basic-block.h (n_edges_for_function): Rename macro to...
	(n_edges_for_fn): ...this.
	(n_edges): Eliminate macro as work towards making uses of
	cfun be explicit.

	* cfg.c (init_flow): Update for renaming of "n_edges_for_function"
	to "n_edges_for_fn".

	* cfg.c (unchecked_make_edge): Remove usage of n_edges macro.
	(clear_edges): Likewise.
	(free_edge): Likewise.
	* cfghooks.c (dump_flow_info): Likewise.
	* cprop.c (is_too_expensive): Likewise.
	* df-core.c (df_worklist_dataflow_doublequeue): Likewise.
	* gcse.c (is_too_expensive): Likewise.
	(prune_insertions_deletions): Likewise.
	* mcf.c (create_fixup_graph): Likewise.
	* sched-rgn.c (haifa_find_rgns): Likewise.
	* tree-cfg.c (gimple_dump_cfg): Likewise.
	* var-tracking.c (variable_tracking_main_1): Likewise.

From-SVN: r205044
parent e0f396bc
2013-11-19 David Malcolm <dmalcolm@redhat.com>
* basic-block.h (n_edges_for_function): Rename macro to...
(n_edges_for_fn): ...this.
(n_edges): Eliminate macro as work towards making uses of
cfun be explicit.
* cfg.c (init_flow): Update for renaming of "n_edges_for_function"
to "n_edges_for_fn".
* cfg.c (unchecked_make_edge): Remove usage of n_edges macro.
(clear_edges): Likewise.
(free_edge): Likewise.
* cfghooks.c (dump_flow_info): Likewise.
* cprop.c (is_too_expensive): Likewise.
* df-core.c (df_worklist_dataflow_doublequeue): Likewise.
* gcse.c (is_too_expensive): Likewise.
(prune_insertions_deletions): Likewise.
* mcf.c (create_fixup_graph): Likewise.
* sched-rgn.c (haifa_find_rgns): Likewise.
* tree-cfg.c (gimple_dump_cfg): Likewise.
* var-tracking.c (variable_tracking_main_1): Likewise.
2013-11-19 Marcus Shawcroft <marcus.shawcroft@arm.com> 2013-11-19 Marcus Shawcroft <marcus.shawcroft@arm.com>
* config/aarch64/aarch64.c (aarch64_save_or_restore_fprs): Fix over * config/aarch64/aarch64.c (aarch64_save_or_restore_fprs): Fix over
...@@ -316,7 +316,7 @@ struct GTY(()) control_flow_graph { ...@@ -316,7 +316,7 @@ struct GTY(()) control_flow_graph {
#define EXIT_BLOCK_PTR_FOR_FUNCTION(FN) ((FN)->cfg->x_exit_block_ptr) #define EXIT_BLOCK_PTR_FOR_FUNCTION(FN) ((FN)->cfg->x_exit_block_ptr)
#define basic_block_info_for_function(FN) ((FN)->cfg->x_basic_block_info) #define basic_block_info_for_function(FN) ((FN)->cfg->x_basic_block_info)
#define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks) #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
#define n_edges_for_function(FN) ((FN)->cfg->x_n_edges) #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
#define last_basic_block_for_function(FN) ((FN)->cfg->x_last_basic_block) #define last_basic_block_for_function(FN) ((FN)->cfg->x_last_basic_block)
#define label_to_block_map_for_function(FN) ((FN)->cfg->x_label_to_block_map) #define label_to_block_map_for_function(FN) ((FN)->cfg->x_label_to_block_map)
#define profile_status_for_function(FN) ((FN)->cfg->x_profile_status) #define profile_status_for_function(FN) ((FN)->cfg->x_profile_status)
...@@ -330,7 +330,6 @@ struct GTY(()) control_flow_graph { ...@@ -330,7 +330,6 @@ struct GTY(()) control_flow_graph {
#define ENTRY_BLOCK_PTR (cfun->cfg->x_entry_block_ptr) #define ENTRY_BLOCK_PTR (cfun->cfg->x_entry_block_ptr)
#define EXIT_BLOCK_PTR (cfun->cfg->x_exit_block_ptr) #define EXIT_BLOCK_PTR (cfun->cfg->x_exit_block_ptr)
#define basic_block_info (cfun->cfg->x_basic_block_info) #define basic_block_info (cfun->cfg->x_basic_block_info)
#define n_edges (cfun->cfg->x_n_edges)
#define last_basic_block (cfun->cfg->x_last_basic_block) #define last_basic_block (cfun->cfg->x_last_basic_block)
#define label_to_block_map (cfun->cfg->x_label_to_block_map) #define label_to_block_map (cfun->cfg->x_label_to_block_map)
#define profile_status (cfun->cfg->x_profile_status) #define profile_status (cfun->cfg->x_profile_status)
......
...@@ -69,7 +69,7 @@ init_flow (struct function *the_fun) ...@@ -69,7 +69,7 @@ init_flow (struct function *the_fun)
{ {
if (!the_fun->cfg) if (!the_fun->cfg)
the_fun->cfg = ggc_alloc_cleared_control_flow_graph (); the_fun->cfg = ggc_alloc_cleared_control_flow_graph ();
n_edges_for_function (the_fun) = 0; n_edges_for_fn (the_fun) = 0;
ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun) ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)
= ggc_alloc_cleared_basic_block_def (); = ggc_alloc_cleared_basic_block_def ();
ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = ENTRY_BLOCK; ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = ENTRY_BLOCK;
...@@ -88,7 +88,7 @@ init_flow (struct function *the_fun) ...@@ -88,7 +88,7 @@ init_flow (struct function *the_fun)
static void static void
free_edge (edge e) free_edge (edge e)
{ {
n_edges--; n_edges_for_fn (cfun)--;
ggc_free (e); ggc_free (e);
} }
...@@ -114,7 +114,7 @@ clear_edges (void) ...@@ -114,7 +114,7 @@ clear_edges (void)
vec_safe_truncate (EXIT_BLOCK_PTR->preds, 0); vec_safe_truncate (EXIT_BLOCK_PTR->preds, 0);
vec_safe_truncate (ENTRY_BLOCK_PTR->succs, 0); vec_safe_truncate (ENTRY_BLOCK_PTR->succs, 0);
gcc_assert (!n_edges); gcc_assert (!n_edges_for_fn (cfun));
} }
/* Allocate memory for basic_block. */ /* Allocate memory for basic_block. */
...@@ -262,7 +262,7 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags) ...@@ -262,7 +262,7 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags)
{ {
edge e; edge e;
e = ggc_alloc_cleared_edge_def (); e = ggc_alloc_cleared_edge_def ();
n_edges++; n_edges_for_fn (cfun)++;
e->src = src; e->src = src;
e->dest = dst; e->dest = dst;
......
...@@ -324,7 +324,7 @@ dump_flow_info (FILE *file, int flags) ...@@ -324,7 +324,7 @@ dump_flow_info (FILE *file, int flags)
basic_block bb; basic_block bb;
fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks_for_fn (cfun), fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks_for_fn (cfun),
n_edges); n_edges_for_fn (cfun));
FOR_ALL_BB (bb) FOR_ALL_BB (bb)
dump_bb (file, bb, 0, flags); dump_bb (file, bb, 0, flags);
......
...@@ -1729,12 +1729,12 @@ is_too_expensive (const char *pass) ...@@ -1729,12 +1729,12 @@ is_too_expensive (const char *pass)
which have a couple switch statements. Rather than simply which have a couple switch statements. Rather than simply
threshold the number of blocks, uses something with a more threshold the number of blocks, uses something with a more
graceful degradation. */ graceful degradation. */
if (n_edges > 20000 + n_basic_blocks_for_fn (cfun) * 4) if (n_edges_for_fn (cfun) > 20000 + n_basic_blocks_for_fn (cfun) * 4)
{ {
warning (OPT_Wdisabled_optimization, warning (OPT_Wdisabled_optimization,
"%s: %d basic blocks and %d edges/basic block", "%s: %d basic blocks and %d edges/basic block",
pass, n_basic_blocks_for_fn (cfun), pass, n_basic_blocks_for_fn (cfun),
n_edges / n_basic_blocks_for_fn (cfun)); n_edges_for_fn (cfun) / n_basic_blocks_for_fn (cfun));
return true; return true;
} }
......
...@@ -1097,7 +1097,7 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow, ...@@ -1097,7 +1097,7 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
fprintf (dump_file, "df_worklist_dataflow_doublequeue:" fprintf (dump_file, "df_worklist_dataflow_doublequeue:"
"n_basic_blocks %d n_edges %d" "n_basic_blocks %d n_edges %d"
" count %d (%5.2g)\n", " count %d (%5.2g)\n",
n_basic_blocks_for_fn (cfun), n_edges, n_basic_blocks_for_fn (cfun), n_edges_for_fn (cfun),
dcount, dcount / (float)n_basic_blocks_for_fn (cfun)); dcount, dcount / (float)n_basic_blocks_for_fn (cfun));
} }
......
...@@ -1964,7 +1964,7 @@ prune_insertions_deletions (int n_elems) ...@@ -1964,7 +1964,7 @@ prune_insertions_deletions (int n_elems)
/* Iterate over the edges counting the number of times each expression /* Iterate over the edges counting the number of times each expression
needs to be inserted. */ needs to be inserted. */
for (i = 0; i < (unsigned) n_edges; i++) for (i = 0; i < (unsigned) n_edges_for_fn (cfun); i++)
{ {
EXECUTE_IF_SET_IN_BITMAP (pre_insert_map[i], 0, j, sbi) EXECUTE_IF_SET_IN_BITMAP (pre_insert_map[i], 0, j, sbi)
insertions[j]++; insertions[j]++;
...@@ -1990,7 +1990,7 @@ prune_insertions_deletions (int n_elems) ...@@ -1990,7 +1990,7 @@ prune_insertions_deletions (int n_elems)
/* Now prune PRE_INSERT_MAP and PRE_DELETE_MAP based on PRUNE_EXPRS. */ /* Now prune PRE_INSERT_MAP and PRE_DELETE_MAP based on PRUNE_EXPRS. */
EXECUTE_IF_SET_IN_BITMAP (prune_exprs, 0, j, sbi) EXECUTE_IF_SET_IN_BITMAP (prune_exprs, 0, j, sbi)
{ {
for (i = 0; i < (unsigned) n_edges; i++) for (i = 0; i < (unsigned) n_edges_for_fn (cfun); i++)
bitmap_clear_bit (pre_insert_map[i], j); bitmap_clear_bit (pre_insert_map[i], j);
for (i = 0; i < (unsigned) last_basic_block; i++) for (i = 0; i < (unsigned) last_basic_block; i++)
...@@ -4069,12 +4069,12 @@ is_too_expensive (const char *pass) ...@@ -4069,12 +4069,12 @@ is_too_expensive (const char *pass)
which have a couple switch statements. Rather than simply which have a couple switch statements. Rather than simply
threshold the number of blocks, uses something with a more threshold the number of blocks, uses something with a more
graceful degradation. */ graceful degradation. */
if (n_edges > 20000 + n_basic_blocks_for_fn (cfun) * 4) if (n_edges_for_fn (cfun) > 20000 + n_basic_blocks_for_fn (cfun) * 4)
{ {
warning (OPT_Wdisabled_optimization, warning (OPT_Wdisabled_optimization,
"%s: %d basic blocks and %d edges/basic block", "%s: %d basic blocks and %d edges/basic block",
pass, n_basic_blocks_for_fn (cfun), pass, n_basic_blocks_for_fn (cfun),
n_edges / n_basic_blocks_for_fn (cfun)); n_edges_for_fn (cfun) / n_basic_blocks_for_fn (cfun));
return true; return true;
} }
......
...@@ -472,11 +472,13 @@ create_fixup_graph (fixup_graph_type *fixup_graph) ...@@ -472,11 +472,13 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
/* Each basic_block will be split into 2 during vertex transformation. */ /* Each basic_block will be split into 2 during vertex transformation. */
int fnum_vertices_after_transform = 2 * n_basic_blocks_for_fn (cfun); int fnum_vertices_after_transform = 2 * n_basic_blocks_for_fn (cfun);
int fnum_edges_after_transform = n_edges + n_basic_blocks_for_fn (cfun); int fnum_edges_after_transform =
n_edges_for_fn (cfun) + n_basic_blocks_for_fn (cfun);
/* Count the new SOURCE and EXIT vertices to be added. */ /* Count the new SOURCE and EXIT vertices to be added. */
int fmax_num_vertices = int fmax_num_vertices =
fnum_vertices_after_transform + n_edges + n_basic_blocks_for_fn (cfun) + 2; (fnum_vertices_after_transform + n_edges_for_fn (cfun)
+ n_basic_blocks_for_fn (cfun) + 2);
/* In create_fixup_graph: Each basic block and edge can be split into 3 /* In create_fixup_graph: Each basic block and edge can be split into 3
edges. Number of balance edges = n_basic_blocks. So after edges. Number of balance edges = n_basic_blocks. So after
...@@ -486,7 +488,8 @@ create_fixup_graph (fixup_graph_type *fixup_graph) ...@@ -486,7 +488,8 @@ create_fixup_graph (fixup_graph_type *fixup_graph)
max_edges = 2 * (4 * n_basic_blocks + 3 * n_edges) max_edges = 2 * (4 * n_basic_blocks + 3 * n_edges)
= 8 * n_basic_blocks + 6 * n_edges = 8 * n_basic_blocks + 6 * n_edges
< 8 * n_basic_blocks + 8 * n_edges. */ < 8 * n_basic_blocks + 8 * n_edges. */
int fmax_num_edges = 8 * (n_basic_blocks_for_fn (cfun) + n_edges); int fmax_num_edges = 8 * (n_basic_blocks_for_fn (cfun) +
n_edges_for_fn (cfun));
/* Initial num of vertices in the fixup graph. */ /* Initial num of vertices in the fixup graph. */
fixup_graph->num_vertices = n_basic_blocks_for_fn (cfun); fixup_graph->num_vertices = n_basic_blocks_for_fn (cfun);
......
...@@ -643,7 +643,7 @@ haifa_find_rgns (void) ...@@ -643,7 +643,7 @@ haifa_find_rgns (void)
/* Allocate and initialize variables for the first traversal. */ /* Allocate and initialize variables for the first traversal. */
max_hdr = XNEWVEC (int, last_basic_block); max_hdr = XNEWVEC (int, last_basic_block);
dfs_nr = XCNEWVEC (int, last_basic_block); dfs_nr = XCNEWVEC (int, last_basic_block);
stack = XNEWVEC (edge_iterator, n_edges); stack = XNEWVEC (edge_iterator, n_edges_for_fn (cfun));
inner = sbitmap_alloc (last_basic_block); inner = sbitmap_alloc (last_basic_block);
bitmap_ones (inner); bitmap_ones (inner);
......
...@@ -2106,7 +2106,8 @@ gimple_dump_cfg (FILE *file, int flags) ...@@ -2106,7 +2106,8 @@ gimple_dump_cfg (FILE *file, int flags)
{ {
dump_function_header (file, current_function_decl, flags); dump_function_header (file, current_function_decl, flags);
fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n", fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n",
n_basic_blocks_for_fn (cfun), n_edges, last_basic_block); n_basic_blocks_for_fn (cfun), n_edges_for_fn (cfun),
last_basic_block);
brief_dump_cfg (file, flags | TDF_COMMENT); brief_dump_cfg (file, flags | TDF_COMMENT);
fprintf (file, "\n"); fprintf (file, "\n");
......
...@@ -10161,7 +10161,7 @@ variable_tracking_main_1 (void) ...@@ -10161,7 +10161,7 @@ variable_tracking_main_1 (void)
} }
if (n_basic_blocks_for_fn (cfun) > 500 && if (n_basic_blocks_for_fn (cfun) > 500 &&
n_edges / n_basic_blocks_for_fn (cfun) >= 20) n_edges_for_fn (cfun) / n_basic_blocks_for_fn (cfun) >= 20)
{ {
vt_debug_insns_local (true); vt_debug_insns_local (true);
return 0; return 0;
......
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