@@ -58,7 +58,7 @@ private:
and heavily borrowed from pre_and_rev_post_order_compute. */
bool
-mark_dfs_back_edges (void)
+mark_dfs_back_edges (struct function *fun)
{
int *pre;
int *post;
@@ -67,20 +67,20 @@ mark_dfs_back_edges (void)
bool found = false;
/* Allocate the preorder and postorder number arrays. */
- pre = XCNEWVEC (int, last_basic_block_for_fn (cfun));
- post = XCNEWVEC (int, last_basic_block_for_fn (cfun));
+ pre = XCNEWVEC (int, last_basic_block_for_fn (fun));
+ post = XCNEWVEC (int, last_basic_block_for_fn (fun));
/* Allocate stack for back-tracking up CFG. */
- auto_vec<edge_iterator, 20> stack (n_basic_blocks_for_fn (cfun) + 1);
+ auto_vec<edge_iterator, 20> stack (n_basic_blocks_for_fn (fun) + 1);
/* Allocate bitmap to track nodes that have been visited. */
- auto_sbitmap visited (last_basic_block_for_fn (cfun));
+ auto_sbitmap visited (last_basic_block_for_fn (fun));
/* None of the nodes in the CFG have been visited yet. */
bitmap_clear (visited);
/* Push the first edge on to the stack. */
- stack.quick_push (ei_start (ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs));
+ stack.quick_push (ei_start (ENTRY_BLOCK_PTR_FOR_FN (fun)->succs));
while (!stack.is_empty ())
{
@@ -94,8 +94,8 @@ mark_dfs_back_edges (void)
ei_edge (ei)->flags &= ~EDGE_DFS_BACK;
/* Check if the edge destination has been visited yet. */
- if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && ! bitmap_bit_p (visited,
- dest->index))
+ if (dest != EXIT_BLOCK_PTR_FOR_FN (fun) && ! bitmap_bit_p (visited,
+ dest->index))
{
/* Mark that we have visited the destination. */
bitmap_set_bit (visited, dest->index);
@@ -112,14 +112,14 @@ mark_dfs_back_edges (void)
}
else
{
- if (dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
- && src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
+ if (dest != EXIT_BLOCK_PTR_FOR_FN (fun)
+ && src != ENTRY_BLOCK_PTR_FOR_FN (fun)
&& pre[src->index] >= pre[dest->index]
&& post[dest->index] == 0)
ei_edge (ei)->flags |= EDGE_DFS_BACK, found = true;
if (ei_one_before_end_p (ei)
- && src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
+ && src != ENTRY_BLOCK_PTR_FOR_FN (fun))
post[src->index] = postnum++;
if (!ei_one_before_end_p (ei))
@@ -135,6 +135,12 @@ mark_dfs_back_edges (void)
return found;
}
+bool
+mark_dfs_back_edges (void)
+{
+ return mark_dfs_back_edges (cfun);
+}
+
/* Find unreachable blocks. An unreachable block will have 0 in
the reachable bit in block->flags. A nonzero value indicates the
block is reachable. */
@@ -49,6 +49,7 @@ private:
bitmap_obstack m_bitmaps;
};
+extern bool mark_dfs_back_edges (struct function *);
extern bool mark_dfs_back_edges (void);
extern void find_unreachable_blocks (void);
extern void verify_no_unreachable_blocks (void);
@@ -169,14 +169,14 @@ draw_cfg_nodes_no_loops (pretty_printer *pp, struct function *fun)
int *rpo = XNEWVEC (int, n_basic_blocks_for_fn (fun));
int i, n;
- auto_sbitmap visited (last_basic_block_for_fn (cfun));
+ auto_sbitmap visited (last_basic_block_for_fn (fun));
bitmap_clear (visited);
n = pre_and_rev_post_order_compute_fn (fun, NULL, rpo, true);
for (i = n_basic_blocks_for_fn (fun) - n;
i < n_basic_blocks_for_fn (fun); i++)
{
- basic_block bb = BASIC_BLOCK_FOR_FN (cfun, rpo[i]);
+ basic_block bb = BASIC_BLOCK_FOR_FN (fun, rpo[i]);
draw_cfg_node (pp, fun->funcdef_no, bb);
bitmap_set_bit (visited, bb->index);
}
@@ -248,7 +248,8 @@ draw_cfg_nodes_for_loop (pretty_printer *pp, int funcdef_no,
static void
draw_cfg_nodes (pretty_printer *pp, struct function *fun)
{
- if (loops_for_fn (fun))
+ /* ??? The loop and dominance APIs are dependent on fun == cfun. */
+ if (fun == cfun && loops_for_fn (fun))
draw_cfg_nodes_for_loop (pp, fun->funcdef_no, get_loop (fun, 0));
else
draw_cfg_nodes_no_loops (pp, fun);
@@ -267,7 +268,7 @@ draw_cfg_edges (pretty_printer *pp, struct function *fun)
edge e;
edge_iterator ei;
unsigned int idx = 0;
- FOR_EACH_BB_FN (bb, cfun)
+ FOR_EACH_BB_FN (bb, fun)
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->flags & EDGE_DFS_BACK)
@@ -275,13 +276,13 @@ draw_cfg_edges (pretty_printer *pp, struct function *fun)
idx++;
}
- mark_dfs_back_edges ();
- FOR_ALL_BB_FN (bb, cfun)
+ mark_dfs_back_edges (fun);
+ FOR_ALL_BB_FN (bb, fun)
draw_cfg_node_succ_edges (pp, fun->funcdef_no, bb);
/* Restore EDGE_DFS_BACK flag from dfs_back. */
idx = 0;
- FOR_EACH_BB_FN (bb, cfun)
+ FOR_EACH_BB_FN (bb, fun)
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (bitmap_bit_p (dfs_back, idx))