remove_phi_nodes_and_edges_for_unreachable_block (bb);
}
-
-/* Examine BB to determine if it is a forwarding block (a block which only
- transfers control to a new destination). If BB is a forwarding block,
- then return the edge leading to the ultimate destination. */
-
-edge
-tree_block_forwards_to (basic_block bb)
-{
- block_stmt_iterator bsi;
- bb_ann_t ann = bb_ann (bb);
- tree stmt;
-
- /* If this block is not forwardable, then avoid useless work. */
- if (! ann->forwardable)
- return NULL;
-
- /* Set this block to not be forwardable. This prevents infinite loops since
- any block currently under examination is considered non-forwardable. */
- ann->forwardable = 0;
-
- /* No forwarding is possible if this block is a special block (ENTRY/EXIT),
- this block has more than one successor, this block's single successor is
- reached via an abnormal edge, this block has phi nodes, or this block's
- single successor has phi nodes. */
- if (bb == EXIT_BLOCK_PTR
- || bb == ENTRY_BLOCK_PTR
- || EDGE_COUNT (bb->succs) != 1
- || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
- || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) != 0
- || phi_nodes (bb)
- || phi_nodes (EDGE_SUCC (bb, 0)->dest))
- return NULL;
-
- /* Walk past any labels at the start of this block. */
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
- {
- stmt = bsi_stmt (bsi);
- if (TREE_CODE (stmt) != LABEL_EXPR)
- break;
- }
-
- /* If we reached the end of this block we may be able to optimize this
- case. */
- if (bsi_end_p (bsi))
- {
- edge dest;
-
- /* Recursive call to pick up chains of forwarding blocks. */
- dest = tree_block_forwards_to (EDGE_SUCC (bb, 0)->dest);
-
- /* If none found, we forward to bb->succs[0] at minimum. */
- if (!dest)
- dest = EDGE_SUCC (bb, 0);
-
- ann->forwardable = 1;
- return dest;
- }
-
- /* No forwarding possible. */
- return NULL;
-}
-
-
/* Try to remove superfluous control structures. */
static bool
extern edge thread_edge (edge, basic_block);
extern basic_block label_to_block (tree);
extern void tree_optimize_tail_calls (bool, enum tree_dump_index);
-extern edge tree_block_forwards_to (basic_block bb);
extern void bsi_insert_on_edge (edge, tree);
extern basic_block bsi_insert_on_edge_immediate (edge, tree);
extern void bsi_commit_edge_inserts (int *);