/* Control flow graph analysis code for GNU compiler.
- Copyright (C) 1987-2015 Free Software Foundation, Inc.
+ Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GCC.
#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_ds {
(from successors to predecessors).
This ordering can be used for forward dataflow problems among others.
+ Optionally if START_POINTS is specified, start from exit block and all
+ basic blocks in START_POINTS. This is used by CD-DCE.
+
This function assumes that all blocks in the CFG are reachable
from the ENTRY (but not necessarily from EXIT).
and do another inverted traversal from that block. */
int
-inverted_post_order_compute (int *post_order)
+inverted_post_order_compute (int *post_order,
+ sbitmap *start_points)
{
basic_block bb;
edge_iterator *stack;
int post_order_num = 0;
sbitmap visited;
-#if ENABLE_CHECKING
- verify_no_unreachable_blocks ();
-#endif
+ if (flag_checking)
+ verify_no_unreachable_blocks ();
/* Allocate stack for back-tracking up CFG. */
stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
/* None of the nodes in the CFG have been visited yet. */
bitmap_clear (visited);
+ if (start_points)
+ {
+ FOR_ALL_BB_FN (bb, cfun)
+ if (bitmap_bit_p (*start_points, bb->index)
+ && EDGE_COUNT (bb->preds) > 0)
+ {
+ stack[sp++] = ei_start (bb->preds);
+ bitmap_set_bit (visited, bb->index);
+ }
+ if (EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds))
+ {
+ stack[sp++] = ei_start (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds);
+ bitmap_set_bit (visited, EXIT_BLOCK_PTR_FOR_FN (cfun)->index);
+ }
+ }
+ else
/* Put all blocks that have no successor into the initial work list. */
FOR_ALL_BB_FN (bb, cfun)
if (EDGE_COUNT (bb->succs) == 0)