+
+/* Returns true if we can duplicate basic block BB. */
+
+bool
+can_duplicate_block_p (basic_block bb)
+{
+ edge e;
+
+ if (!cfg_hooks->can_duplicate_block_p)
+ internal_error ("%s does not support can_duplicate_block_p.",
+ cfg_hooks->name);
+
+ if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR)
+ return false;
+
+ /* Duplicating fallthru block to exit would require adding a jump
+ and splitting the real last BB. */
+ e = find_edge (bb, EXIT_BLOCK_PTR);
+ if (e && (e->flags & EDGE_FALLTHRU))
+ return false;
+
+ return cfg_hooks->can_duplicate_block_p (bb);
+}
+
+/* Duplicates basic block BB and redirects edge E to it. Returns the
+ new basic block. */
+
+basic_block
+duplicate_block (basic_block bb, edge e)
+{
+ edge s, n;
+ basic_block new_bb;
+ gcov_type new_count = e ? e->count : 0;
+ edge_iterator ei;
+
+ if (!cfg_hooks->duplicate_block)
+ internal_error ("%s does not support duplicate_block.",
+ cfg_hooks->name);
+
+ if (bb->count < new_count)
+ new_count = bb->count;
+
+#ifdef ENABLE_CHECKING
+ gcc_assert (can_duplicate_block_p (bb));
+#endif
+
+ new_bb = cfg_hooks->duplicate_block (bb);
+
+ new_bb->loop_depth = bb->loop_depth;
+ new_bb->flags = bb->flags;
+ FOR_EACH_EDGE (s, ei, bb->succs)
+ {
+ /* Since we are creating edges from a new block to successors
+ of another block (which therefore are known to be disjoint), there
+ is no need to actually check for duplicated edges. */
+ n = unchecked_make_edge (new_bb, s->dest, s->flags);
+ n->probability = s->probability;
+ if (e && bb->count)
+ {
+ /* Take care for overflows! */
+ n->count = s->count * (new_count * 10000 / bb->count) / 10000;
+ s->count -= n->count;
+ }
+ else
+ n->count = s->count;
+ n->aux = s->aux;
+ }
+
+ if (e)
+ {
+ new_bb->count = new_count;
+ bb->count -= new_count;
+
+ new_bb->frequency = EDGE_FREQUENCY (e);
+ bb->frequency -= EDGE_FREQUENCY (e);
+
+ redirect_edge_and_branch_force (e, new_bb);
+
+ if (bb->count < 0)
+ bb->count = 0;
+ if (bb->frequency < 0)
+ bb->frequency = 0;
+ }
+ else
+ {
+ new_bb->count = bb->count;
+ new_bb->frequency = bb->frequency;
+ }
+
+ new_bb->rbi->original = bb;
+ bb->rbi->copy = new_bb;
+
+ return new_bb;
+}
+
+/* Return 1 if BB ends with a call, possibly followed by some
+ instructions that must stay with the call, 0 otherwise. */
+
+bool
+block_ends_with_call_p (basic_block bb)
+{
+ if (!cfg_hooks->block_ends_with_call_p)
+ internal_error ("%s does not support block_ends_with_call_p", cfg_hooks->name);
+
+ return (cfg_hooks->block_ends_with_call_p) (bb);
+}
+
+/* Return 1 if BB ends with a conditional branch, 0 otherwise. */
+
+bool
+block_ends_with_condjump_p (basic_block bb)
+{
+ if (!cfg_hooks->block_ends_with_condjump_p)
+ internal_error ("%s does not support block_ends_with_condjump_p",
+ cfg_hooks->name);
+
+ return (cfg_hooks->block_ends_with_condjump_p) (bb);
+}
+
+/* Add fake edges to the function exit for any non constant and non noreturn
+ calls, volatile inline assembly in the bitmap of blocks specified by
+ BLOCKS or to the whole CFG if BLOCKS is zero. Return the number of blocks
+ that were split.
+
+ The goal is to expose cases in which entering a basic block does not imply
+ that all subsequent instructions must be executed. */
+
+int
+flow_call_edges_add (sbitmap blocks)
+{
+ if (!cfg_hooks->flow_call_edges_add)
+ internal_error ("%s does not support flow_call_edges_add",
+ cfg_hooks->name);
+
+ return (cfg_hooks->flow_call_edges_add) (blocks);
+}
+
+/* This function is called immediately after edge E is added to the
+ edge vector E->dest->preds. */
+
+void
+execute_on_growing_pred (edge e)
+{
+ if (cfg_hooks->execute_on_growing_pred)
+ cfg_hooks->execute_on_growing_pred (e);
+}
+
+/* This function is called immediately before edge E is removed from
+ the edge vector E->dest->preds. */
+
+void
+execute_on_shrinking_pred (edge e)
+{
+ if (cfg_hooks->execute_on_shrinking_pred)
+ cfg_hooks->execute_on_shrinking_pred (e);
+}