#include "coretypes.h"
#include "backend.h"
#include "cfghooks.h"
-#include "hard-reg-set.h"
-#include "cfganal.h"
#include "timevar.h"
+#include "cfganal.h"
/* Store the data structures necessary for depth-first search. */
-struct depth_first_search_dsS {
+struct depth_first_search_ds {
/* stack for backtracking during the algorithm */
basic_block *stack;
/* record of basic blocks already seen by depth-first search */
sbitmap visited_blocks;
};
-typedef struct depth_first_search_dsS *depth_first_search_ds;
-static void flow_dfs_compute_reverse_init (depth_first_search_ds);
-static void flow_dfs_compute_reverse_add_bb (depth_first_search_ds,
+static void flow_dfs_compute_reverse_init (depth_first_search_ds *);
+static void flow_dfs_compute_reverse_add_bb (depth_first_search_ds *,
basic_block);
-static basic_block flow_dfs_compute_reverse_execute (depth_first_search_ds,
+static basic_block flow_dfs_compute_reverse_execute (depth_first_search_ds *,
basic_block);
-static void flow_dfs_compute_reverse_finish (depth_first_search_ds);
+static void flow_dfs_compute_reverse_finish (depth_first_search_ds *);
\f
/* Mark the back edges in DFS traversal.
Return nonzero if a loop (natural or otherwise) is present.
free (worklist);
}
+
+/* Verify that there are no unreachable blocks in the current function. */
+
+void
+verify_no_unreachable_blocks (void)
+{
+ find_unreachable_blocks ();
+
+ basic_block bb;
+ FOR_EACH_BB_FN (bb, cfun)
+ gcc_assert ((bb->flags & BB_REACHABLE) != 0);
+}
+
\f
/* Functions to access an edge list with a vector representation.
Enough data is kept such that given an index number, the
{
basic_block unvisited_block = EXIT_BLOCK_PTR_FOR_FN (cfun);
basic_block deadend_block;
- struct depth_first_search_dsS dfs_ds;
+ depth_first_search_ds dfs_ds;
/* Perform depth-first search in the reverse graph to find nodes
reachable from the exit block. */
int post_order_num = 0;
sbitmap visited;
+#if ENABLE_CHECKING
+ verify_no_unreachable_blocks ();
+#endif
+
/* Allocate stack for back-tracking up CFG. */
stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
sp = 0;
pre_order[pre_order_num] = ENTRY_BLOCK;
pre_order_num++;
if (rev_post_order)
- rev_post_order[rev_post_order_num--] = ENTRY_BLOCK;
+ rev_post_order[rev_post_order_num--] = EXIT_BLOCK;
}
else
rev_post_order_num -= NUM_FIXED_BLOCKS;
pre_order[pre_order_num] = EXIT_BLOCK;
pre_order_num++;
if (rev_post_order)
- rev_post_order[rev_post_order_num--] = EXIT_BLOCK;
+ rev_post_order[rev_post_order_num--] = ENTRY_BLOCK;
}
return pre_order_num;
element on the stack. */
static void
-flow_dfs_compute_reverse_init (depth_first_search_ds data)
+flow_dfs_compute_reverse_init (depth_first_search_ds *data)
{
/* Allocate stack for back-tracking up CFG. */
data->stack = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun));
block. */
static void
-flow_dfs_compute_reverse_add_bb (depth_first_search_ds data, basic_block bb)
+flow_dfs_compute_reverse_add_bb (depth_first_search_ds *data, basic_block bb)
{
data->stack[data->sp++] = bb;
bitmap_set_bit (data->visited_blocks, bb->index);
available. */
static basic_block
-flow_dfs_compute_reverse_execute (depth_first_search_ds data,
+flow_dfs_compute_reverse_execute (depth_first_search_ds *data,
basic_block last_unvisited)
{
basic_block bb;
reverse graph. */
static void
-flow_dfs_compute_reverse_finish (depth_first_search_ds data)
+flow_dfs_compute_reverse_finish (depth_first_search_ds *data)
{
free (data->stack);
sbitmap_free (data->visited_blocks);