GCC Middle and Back End API Reference
cfghooks.c File Reference


void rtl_register_cfg_hooks ()
void cfg_layout_rtl_register_cfg_hooks ()
void gimple_register_cfg_hooks ()
struct cfg_hooks get_cfg_hooks ()
void set_cfg_hooks ()
enum ir_type current_ir_type ()
DEBUG_FUNCTION void verify_flow_info ()
void dump_bb ()
DEBUG_FUNCTION void debug ()
void dump_bb_for_graph ()
void dump_flow_info ()
void debug_flow_info (void)
edge redirect_edge_and_branch ()
bool can_remove_branch_p ()
void remove_branch ()
void remove_edge ()
edge redirect_edge_succ_nodup ()
basic_block redirect_edge_and_branch_force ()
edge split_block ()
edge split_block_after_labels ()
bool move_block_after ()
void delete_basic_block ()
basic_block split_edge ()
basic_block create_basic_block ()
basic_block create_empty_bb ()
bool can_merge_blocks_p ()
void predict_edge ()
bool predicted_by_p ()
void merge_blocks ()
edge make_forwarder_block (basic_block bb, bool(*redirect_edge_p)(edge), void(*new_bb_cbk)(basic_block))
void tidy_fallthru_edge ()
void tidy_fallthru_edges ()
basic_block force_nonfallthru ()
bool can_duplicate_block_p ()
basic_block duplicate_block ()
bool block_ends_with_call_p ()
bool block_ends_with_condjump_p ()
int flow_call_edges_add ()
void execute_on_growing_pred ()
void execute_on_shrinking_pred ()
void lv_flush_pending_stmts ()
bool cfg_hook_duplicate_loop_to_header_edge (struct loop *loop, edge e, unsigned int ndupl, sbitmap wont_exit, edge orig, vec< edge > *to_remove, int flags)
void extract_cond_bb_edges ()
void lv_adjust_loop_header_phi (basic_block first, basic_block second, basic_block new_block, edge e)
void lv_add_condition_to_bb (basic_block first, basic_block second, basic_block new_block, void *cond)
bool can_copy_bbs_p ()
void copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs, edge *edges, unsigned num_edges, edge *new_edges, struct loop *base, basic_block after, bool update_dominance)
bool empty_block_p ()
basic_block split_block_before_cond_jump ()
void account_profile_record ()


static struct cfg_hookscfg_hooks

Function Documentation

void account_profile_record ( )
   Work-horse for passes.c:check_profile_consistency.
   Do book-keeping of the CFG for the profile consistency checker.
   If AFTER_PASS is 0, do pre-pass accounting, or if AFTER_PASS is 1
   then do post-pass accounting.  Store the counting in RECORD.  
bool block_ends_with_call_p ( )
   Return 1 if BB ends with a call, possibly followed by some
   instructions that must stay with the call, 0 otherwise.  

References cfg_hooks::flush_pending_stmts.

Referenced by find_traces_1_round().

bool block_ends_with_condjump_p ( )
   Return 1 if BB ends with a conditional branch, 0 otherwise.  

References cfg_hooks::cfg_hook_duplicate_loop_to_header_edge.

bool can_copy_bbs_p ( )
   Checks whether all N blocks in BBS array can be copied.  
         In case we should redirect abnormal edge during duplication, fail.  

References loop::header, loop::latch, and basic_block_def::loop_father.

Referenced by copy_loop_info().

bool can_duplicate_block_p ( )
bool can_merge_blocks_p ( )
   Checks whether we may merge blocks BB1 and BB2.  

Referenced by cond_exec_find_if_block().

bool can_remove_branch_p ( )
   Returns true if it is possible to remove the edge E by redirecting it
   to the destination of the other edge going from its source.  

References edge_def::dest, edge_def::flags, redirect_edge_and_branch(), edge_def::src, and basic_block_def::succs.

bool cfg_hook_duplicate_loop_to_header_edge ( struct loop loop,
edge  e,
unsigned int  ndupl,
sbitmap  wont_exit,
edge  orig,
vec< edge > *  to_remove,
int  flags 
   Loop versioning uses the duplicate_loop_to_header_edge to create
   a new version of the loop basic-blocks, the parameters here are
   exactly the same as in duplicate_loop_to_header_edge or
   tree_duplicate_loop_to_header_edge; while in tree-ssa there is
   additional work to maintain ssa information that's why there is
   a need to call the tree_duplicate_loop_to_header_edge rather
   than duplicate_loop_to_header_edge when we are in tree mode.  
void cfg_layout_rtl_register_cfg_hooks ( void  )
   Initialization of functions specific to the rtl IR.  

References gimple_cfg_hooks.

void copy_bbs ( basic_block bbs,
unsigned  n,
basic_block new_bbs,
edge edges,
unsigned  num_edges,
edge new_edges,
struct loop base,
basic_block  after,
bool  update_dominance 
   Duplicates N basic blocks stored in array BBS.  Newly created basic blocks
   are placed into array NEW_BBS in the same order.  Edges from basic blocks
   in BBS are also duplicated and copies of those that lead into BBS are
   redirected to appropriate newly created block.  The function assigns bbs
   into loops (copy of basic block bb is assigned to bb->loop_father->copy
   loop, so this must be set up correctly in advance)

   If UPDATE_DOMINANCE is true then this function updates dominators locally
   (LOOPS structure that contains the information about dominators is passed
   to enable this), otherwise it does not update the dominator information
   and it assumed that the caller will do this, perhaps by destroying and
   recreating it instead of trying to do an incremental update like this
   function does when update_dominance is true.

   BASE is the superloop to that basic block belongs; if its header or latch
   is copied, we do not set the new blocks as header or latch.

   Created copies of N_EDGES edges in array EDGES are stored in array NEW_EDGES,
   also in the same order.

   Newly created basic blocks are put after the basic block AFTER in the
   instruction stream, and the order of the blocks in BBS array is preserved.  
     Duplicate bbs, update dominators, assign bbs to loops.  
             Possibly set loop header.  
             Or latch.  
     Set dominators.  
     Redirect edges.  
     Clear information about duplicates.  

Referenced by tm_memopt_clear_visited().

basic_block create_basic_block ( )
   Creates a new basic block just after the basic block AFTER.
   HEAD and END are the first and the last statement belonging
   to the block.  If both are NULL, an empty block is created.  

Referenced by rtl_force_nonfallthru(), rtl_redirect_edge_and_branch_force(), and split_function().

basic_block create_empty_bb ( )
   Creates an empty basic block just after basic block AFTER.  

Referenced by expand_transaction(), factor_computed_gotos(), gimple_make_forwarder_block(), gimple_redirect_edge_and_branch(), and stmt_starts_bb_p().

enum ir_type current_ir_type ( void  )
   Returns current ir type.  

Referenced by cond_exec_find_if_block(), gimplify_build3(), and remove_branch().

DEBUG_FUNCTION void debug ( )
DEBUG_FUNCTION void debug_flow_info ( void  )
   Like above, but dump to stderr.  To be called from debuggers.  
void delete_basic_block ( )
   Deletes the basic block BB.  
         If we remove the header or the latch of a loop, mark the loop for
         removal by setting its header and latch to NULL.  
     Remove the edges into and out of this block.  Note that there may
     indeed be edges in, if we are removing an unreachable loop.  
     Remove the basic block from the array.  

Referenced by build_arrays(), and cond_exec_find_if_block().

void dump_bb ( )
   Print out one basic block BB to file OUTF.  INDENT is printed at the
   start of each new line.  FLAGS are the TDF_* flags in dumpfile.h.

   This function takes care of the purely graph related information.
   The cfg hook for the active representation should dump
   representation-specific information.  

Referenced by debug_regions(), and dump_bb_for_graph().

void dump_bb_for_graph ( )
   Dumps basic block BB to pretty-printer PP, for use as a label of
   a DOT graph record-node.  The implementation of this hook is
   expected to write the label to the stream that is attached to PP.
   Field separators between instructions are pipe characters printed
   verbatim.  Instructions should be written with some characters
   escaped, using pp_write_text_as_dot_label_to_stream().  

References dump_bb().

void dump_flow_info ( )
   Dump the complete CFG to FILE.  FLAGS are the TDF_* flags in dumpfile.h.  

References dump_flow_info().

basic_block duplicate_block ( )
   Duplicates basic block BB and redirects edge E to it.  Returns the
   new basic block.  The new basic block is placed after the basic block
         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.  
             Take care for overflows!  
     Add the new block to the copy of the loop of BB, or directly to the loop
     of BB if the loop is not being copied.  
         If we copied the loop header block but not the loop
         we have created a loop with multiple entries.  Ditch the loop,
         add the new block to the outer loop and arrange for a fixup.  
             If we copied the loop latch block but not the loop, adjust
             loop state.  

Referenced by lv_add_condition_to_bb().

bool empty_block_p ( )
   Return true if BB contains only labels or non-executable
void execute_on_growing_pred ( )
   This function is called immediately after edge E is added to the
   edge vector E->dest->preds.  

Referenced by disconnect_dest().

void execute_on_shrinking_pred ( )
   This function is called immediately before edge E is removed from
   the edge vector E->dest->preds.  

Referenced by make_single_succ_edge().

void extract_cond_bb_edges ( )
   Conditional jumps are represented differently in trees and RTL,
   this hook takes a basic block that is known to have a cond jump
   at its end and extracts the taken and not taken edges out of it
   and store it in E1 and E2 respectively.  
int flow_call_edges_add ( )
   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.  

References cfg_hooks::extract_cond_bb_edges.

Referenced by output_location().

basic_block force_nonfallthru ( )
   Edge E is assumed to be fallthru edge.  Emit needed jump instruction
   (and possibly create new basic block) to make edge non-fallthru.
   Return newly created BB or NULL if none.  
struct cfg_hooks get_cfg_hooks ( void  )
void gimple_register_cfg_hooks ( void  )
   Initialization of functions specific to the tree IR.  

References cfg_hooks.

Referenced by cgraph_process_new_functions().

void lv_add_condition_to_bb ( basic_block  first,
basic_block  second,
basic_block  new_block,
void *  cond 
   Conditions in trees and RTL are different so we need
   a different handling when we add the condition to the
   versioning code.  

References duplicate_block().

void lv_adjust_loop_header_phi ( basic_block  first,
basic_block  second,
basic_block  new_block,
edge  e 
   Responsible for updating the ssa info (PHI nodes) on the
   new condition basic block that guards the versioned loop.  
void lv_flush_pending_stmts ( )
   This is used inside loop versioning when we want to insert
   stmts/insns on the edges, which have a different behavior
   in tree's and in RTL, so we made a CFG hook.  

References can_duplicate_block_p(), edge_def::dest, edge_def::flags, and basic_block_def::flags.

edge make_forwarder_block ( basic_block  bb,
bool(*)(edge redirect_edge_p,
void(*)(basic_block new_bb_cbk 
   Split BB into entry part and the rest (the rest is the newly created block).
   Redirect those edges for that REDIRECT_EDGE_P returns true to the entry
   part.  Returns the edge connecting the entry part to the rest.  
     Redirect back edges we want to keep.  
             If we redirected the loop latch edge, the JUMP block now acts like
             the new latch of the loop.  
         If we do not split a loop header, then both blocks belong to the
         same loop.  In case we split loop header and do not redirect the
         latch edge to DUMMY, then DUMMY belongs to the outer loop, and
         BB becomes the new header.  If latch is not recorded for the loop,
         we leave this updating on the caller (this may only happen during
         loop analysis).  
         In case we split loop latch, update it.  
void merge_blocks ( )
   Merges basic block B into basic block A.  
         If the block we merge into is a loop header do nothing unless ... 
             ... we merge two loop headers, in which case we kill
             the inner loop.  
         If we merge a loop header into its predecessor, update the loop
     Normally there should only be one successor of A and that is B, but
     partway though the merge of blocks for conditional_execution we'll
     be merging a TEST block with THEN and ELSE successors.  Free the
     whole lot of them and hope the caller knows what they're doing.  
     Adjust the edges out of B for the new owner.  
             If b was a latch, a now is.  
     B hasn't quite yet ceased to exist.  Attempt to prevent mishap.  

Referenced by cond_exec_find_if_block(), merge_blocks_move_predecessor_nojumps(), merge_blocks_move_successor_nojumps(), noce_find_if_block(), split_bbs_on_noreturn_calls(), and trivially_empty_bb_p().

bool move_block_after ( )
   Moves block BB immediately after block AFTER.  Returns false if the
   movement was impossible.  

References loop::header, loop::latch, LOOPS_NEED_FIXUP, and loops_state_set().

edge redirect_edge_and_branch ( )
   Redirect edge E to the given basic block DEST and update underlying program
   representation.  Returns edge representing redirected branch (that may not
   be equivalent to E in the case of duplicate edges being removed) or NULL
   if edge is not easily redirectable for whatever reason.  
     If RET != E, then either the redirection failed, or the edge E
     was removed since RET already lead to the same destination.  

Referenced by can_remove_branch_p(), find_clusters_1(), remove_conditions_and_labels(), split_function(), and stmt_starts_bb_p().

basic_block redirect_edge_and_branch_force ( )
   Redirect the edge E to basic block DEST even if it requires creating
   of a new basic block; then it returns the newly created basic block.
   Aborts when redirection is impossible.  

Referenced by can_duplicate_block_p().

edge redirect_edge_succ_nodup ( )
   Like redirect_edge_succ but avoid possible duplicate edge.  
         FIXME: This should be called via a hook and only for IR_GIMPLE.  

References add_bb_to_loop(), CDI_DOMINATORS, dom_info_available_p(), find_common_loop(), internal_error(), cfg_hooks::name, cfg_hooks::redirect_edge_and_branch_force, rescan_loop_exit(), set_immediate_dominator(), single_pred(), single_succ(), and edge_def::src.

void remove_branch ( )
   Removes E, by redirecting it to the destination of the other edge going
   from its source.  Can_remove_branch_p must be true for E, hence this
   operation cannot fail.  

References current_ir_type(), IR_GIMPLE, redirect_edge_var_map_clear(), remove_edge_raw(), and rescan_loop_exit().

void remove_edge ( )
   Removes edge E from cfg.  Unlike remove_branch, it does not update IL.  
     This is probably not needed, but it doesn't hurt.  
     FIXME: This should be called via a remove_edge hook.  

Referenced by build_arrays(), cond_exec_find_if_block(), find_edge(), gimple_expand_cfg(), move_stmt_r(), print_succ_bbs(), and remove_ctrl_stmt_and_useless_edges().

void rtl_register_cfg_hooks ( void  )
   Initialization of functions specific to the rtl IR.  
void set_cfg_hooks ( )
edge split_block ( )
   Splits basic block BB after the specified instruction I (but at least after
   the labels).  If I is NULL, splits just after labels.  The newly created edge
   is returned.  The new basic block is created just after the old one.  

Referenced by create_phi_for_local_result(), create_pre_exit(), and try_crossjump_to_edge().

edge split_block_after_labels ( )
   Splits block BB just after labels.  The newly created edge is returned.  

Referenced by create_loop_fn(), create_single_entry_edge(), ipa_tm_diagnose_tm_safe(), and same_close_phi_node().

basic_block split_block_before_cond_jump ( )
   Split a basic block if it ends with a conditional branch and if
   the other part of the block is not empty.  
basic_block split_edge ( )
   Splits edge E and returns the newly created basic block.  
         There are two cases:

         If the immediate dominator of e->dest is not e->src, it
         remains unchanged.

         If immediate dominator of e->dest is e->src, it may become
         ret, provided that all other predecessors of e->dest are
         dominated by e->dest.  
         If we split the latch edge of loop adjust the latch block.  

References CDI_DOMINATORS, dominated_by_p(), get_immediate_dominator(), set_immediate_dominator(), single_pred(), single_succ(), single_succ_edge(), and edge_def::src.

Referenced by create_empty_if_region_on_edge(), create_if_region_on_edge(), create_loads_and_stores_for_name(), create_pre_exit(), create_preheader(), graphite_create_new_loop_guard(), rewrite_trees(), translate_clast_for_loop(), update_dominators_in_loop(), vect_create_cond_for_alias_checks(), and verify_loop_closed_ssa().

void tidy_fallthru_edge ( )
   Try to make the edge fallthru.  

References cfg_hooks::force_nonfallthru, internal_error(), cfg_hooks::name, and edge_def::src.

void tidy_fallthru_edges ( void  )
   Fix up edges that now fall through, or rather should now fall through
   but previously required a jump around now deleted blocks.  Simplify
   the search by only examining blocks numerically adjacent, since this
   is how they were created.

   ??? This routine is currently RTL specific.  
         We care about simple conditional or unconditional jumps with
         a single successor.

         If we had a conditional branch to the next instruction when
         CFG was built, then there will only be one out edge for the
         block which ended with the conditional branch (since we do
         not create duplicate edges).

         Furthermore, the edge will be marked as a fallthru because we
         merge the flags for the duplicate edges.  So we do not want to
         check that the edge is not a FALLTHRU edge.  

References add_bb_to_loop(), CDI_DOMINATORS, dom_info_available_p(), find_common_loop(), rescan_loop_exit(), set_immediate_dominator(), single_pred(), and single_succ().

DEBUG_FUNCTION void verify_flow_info ( void  )
   Verify the CFG consistency.

   Currently it does following: checks edge and basic block list correctness
   and calls into IL dependent checking then.  
     Check bb chain & numbers.  
     Now check the basic blocks (boundaries etc.) 
     Complete edge checksumming for ENTRY and EXIT.  
     Clean up.  

Referenced by cleanup_tree_cfg_1().

Variable Documentation

struct cfg_hooks* cfg_hooks

Hooks for cfg representation specific functions. Copyright (C) 2003-2013 Free Software Foundation, Inc. Contributed by Sebastian Pop s.pop.nosp@m.@lap.nosp@m.oste..nosp@m.net

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

   A pointer to one of the hooks containers.  

Referenced by gimple_register_cfg_hooks().