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

Functions

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 ()

Variables

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.   

References cfg_hooks::account_profile_record, cfun, edge_def::count, basic_block_def::count, basic_block_def::frequency, profile_record::num_mismatched_count_in, profile_record::num_mismatched_count_out, profile_record::num_mismatched_freq_in, profile_record::num_mismatched_freq_out, basic_block_def::preds, edge_def::probability, PROFILE_ABSENT, and basic_block_def::succs.

Referenced by check_profile_consistency().

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::block_ends_with_call_p, internal_error(), and cfg_hooks::name.

Referenced by compute_branch_probabilities(), find_traces_1_round(), fix_up_fall_thru_edges(), is_edge_inconsistent(), and is_inconsistent().

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

References cfg_hooks::block_ends_with_condjump_p, internal_error(), and cfg_hooks::name.

Referenced by compute_branch_probabilities().

bool can_duplicate_block_p ( )
bool can_merge_blocks_p ( )
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 cfg_hooks::can_remove_branch_p, internal_error(), cfg_hooks::name, edge_def::src, and basic_block_def::succs.

Referenced by remove_path().

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.   

References cfg_hooks::cfg_hook_duplicate_loop_to_header_edge.

Referenced by loop_version().

void cfg_layout_rtl_register_cfg_hooks ( void  )
Initialization of functions specific to the rtl IR.   

References cfg_layout_rtl_cfg_hooks.

Referenced by cfg_layout_initialize().

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.   

References CDI_DOMINATORS, edge_def::dest, duplicate_block(), basic_block_def::flags, get_bb_copy(), get_immediate_dominator(), loop::header, loop::latch, basic_block_def::loop_father, redirect_edge_and_branch_force(), set_immediate_dominator(), and basic_block_def::succs.

Referenced by duplicate_loop_to_header_edge(), gimple_duplicate_sese_region(), gimple_duplicate_sese_tail(), ipa_uninstrument_transaction(), and slpeel_tree_duplicate_loop_to_edge_cfg().

DEBUG_FUNCTION void debug ( )

References dump_bb().

DEBUG_FUNCTION void debug_flow_info ( void  )
Like above, but dump to stderr.  To be called from debuggers.   

References dump_flow_info().

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.   

References cfg_hooks::dump_bb, and dump_bb_info().

Referenced by debug(), debug_bb(), debug_bb_slim(), debug_region(), df_dump_region(), dump_basic_block(), dump_flow_info(), dump_function_to_file(), gimple_debug_bb(), is_edge_inconsistent(), is_inconsistent(), print_loops_bb(), print_pbb_body(), and remove_bb().

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 basic_block_def::count, cfg_hooks::dump_bb_for_graph, dump_flags, basic_block_def::frequency, HOST_WIDEST_INT_PRINT_DEC, internal_error(), cfg_hooks::name, pp_printf(), and pp_write_text_to_stream().

Referenced by draw_cfg_node().

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

References dump_bb().

void execute_on_growing_pred ( )
This function is called immediately after edge E is added to the
   edge vector E->dest->preds.   

References cfg_hooks::execute_on_growing_pred.

Referenced by redirect_edge_succ(), and unchecked_make_edge().

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

References cfg_hooks::execute_on_shrinking_pred.

Referenced by redirect_edge_succ(), and remove_edge_raw().

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.   

References cfg_hooks::extract_cond_bb_edges.

Referenced by loop_version().

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::flow_call_edges_add, internal_error(), and cfg_hooks::name.

Referenced by branch_prob().

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.   

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

Referenced by emit_to_new_bb_before(), fix_up_fall_thru_edges(), fixup_reorder_chain(), merge_blocks_move(), and rtl_split_edge().

struct cfg_hooks get_cfg_hooks ( void  )
read

References cfg_hooks.

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 cfg_hooks::lv_add_condition_to_bb.

Referenced by lv_adjust_loop_entry_edge().

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.   

References cfg_hooks::lv_adjust_loop_header_phi.

Referenced by lv_adjust_loop_entry_edge().

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 cfg_hooks::flush_pending_stmts.

Referenced by loop_version().

edge make_forwarder_block ( basic_block  bb,
bool(*)(edge redirect_edge_p,
void(*)(basic_block new_bb_cbk 
)
bool move_block_after ( )
Moves block BB immediately after block AFTER.  Returns false if the
   movement was impossible.   

References internal_error(), cfg_hooks::move_block_after, and cfg_hooks::name.

Referenced by create_preheader(), duplicate_block(), gimple_merge_blocks(), loop_version(), and move_block_to_fn().

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.   

References internal_error(), cfg_hooks::name, cfg_hooks::redirect_edge_and_branch, and rescan_loop_exit().

Referenced by combine_blocks(), create_parallel_loop(), eliminate_tail_call(), expand_omp_for_static_chunk(), fixup_reorder_chain(), forward_edge_to_pdom(), gimple_duplicate_sese_region(), gimple_duplicate_sese_tail(), gimple_split_edge(), remove_branch(), remove_forwarder_block(), remove_forwarder_block_with_phi(), replace_block_by(), rtl_redirect_edge_and_branch_force(), rtl_split_edge(), split_function(), ssa_fix_duplicate_block_edges(), ssa_redirect_edges(), thread_single_edge(), and try_forward_edges().

edge redirect_edge_succ_nodup ( )
Like redirect_edge_succ but avoid possible duplicate edge.   

References edge_def::count, find_edge(), edge_def::flags, edge_def::probability, redirect_edge_succ(), redirect_edge_var_map_dup(), remove_edge(), 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 edge_def::dest, edge_def::flags, redirect_edge_and_branch(), edge_def::src, and basic_block_def::succs.

Referenced by remove_path().

void rtl_register_cfg_hooks ( void  )
Initialization of functions specific to the rtl IR.   

References rtl_cfg_hooks.

Referenced by cfg_layout_finalize(), and gimple_expand_cfg().

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.   

References add_bb_to_loop(), CDI_DOMINATORS, basic_block_def::count, basic_block_def::discriminator, dom_info_available_p(), edge_def::flags, basic_block_def::flags, basic_block_def::frequency, internal_error(), loop::latch, basic_block_def::loop_father, make_single_succ_edge(), cfg_hooks::name, redirect_immediate_dominators(), set_immediate_dominator(), and cfg_hooks::split_block.

Referenced by copy_edges_for_bb(), create_call_for_reduction_1(), create_cond_insert_point(), create_pre_exit(), decompose_multiword_subregs(), expand_call_inline(), expand_complex_div_wide(), expand_omp_for_generic(), expand_omp_for_init_counts(), expand_omp_for_static_chunk(), expand_omp_for_static_nochunk(), expand_omp_simd(), expand_omp_taskreg(), expand_parallel_call(), find_bb_boundaries(), fixup_fallthru_exit_predecessor(), fixup_noreturn_call(), gen_inbound_check(), gimple_divmod_fixed_value(), gimple_flow_call_edges_add(), gimple_ic(), gimple_mod_pow2(), gimple_mod_subtract(), gimple_split_block_before_cond_jump(), gimple_stringop_fixed_value(), hoist_edge_and_branch_if_true(), mf_build_check_statement_for(), peep2_attempt(), rtl_flow_call_edges_add(), rtl_split_block_before_cond_jump(), sched_split_block_1(), shrink_wrap_one_built_in_call(), split_bb_make_tm_edge(), split_block_after_labels(), split_function(), split_pbb(), split_region_for_bb(), thread_prologue_and_epilogue_insns(), and try_crossjump_to_edge().

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.   

References cfg_hooks::split_block_before_cond_jump.

basic_block split_edge ( )
Splits edge E and returns the newly created basic block.   

References add_bb_to_loop(), CDI_DOMINATORS, count, edge_def::count, basic_block_def::count, edge_def::dest, dom_info_available_p(), dom_info_state(), DOM_NO_FAST_QUERY, dominated_by_p(), find_common_loop(), edge_def::flags, basic_block_def::flags, basic_block_def::frequency, get_immediate_dominator(), loop::header, internal_error(), loop::latch, basic_block_def::loop_father, cfg_hooks::name, edge_def::probability, rescan_loop_exit(), set_immediate_dominator(), single_pred(), single_pred_edge(), single_succ(), single_succ_edge(), cfg_hooks::split_edge, and edge_def::src.

Referenced by analyze_insns_in_loop(), begin_move_insn(), branch_prob(), canon_loop(), canonicalize_loop_closed_ssa(), commit_one_edge_insertion(), copy_bb_and_scalar_dependences(), copy_loop_headers(), create_add_on_incoming_edge(), create_bb_after_loop(), create_empty_if_region_on_edge(), create_empty_loop_on_edge(), create_parallel_loop(), create_pre_exit(), disambiguate_multiple_latches(), doloop_modify(), emit_case_bit_tests(), emit_return_for_exit(), execute_sm_if_changed(), expand_omp_for_generic(), expand_omp_for_static_chunk(), expand_omp_for_static_nochunk(), expand_omp_simd(), expand_phi_nodes(), find_implicit_sets(), fixup_reorder_chain(), force_one_exit_fallthru(), force_single_succ_latches(), gimple_duplicate_sese_tail(), gimple_find_edge_insert_loc(), gimple_gen_ic_func_profiler(), gimple_ic(), loop_version(), lv_adjust_loop_entry_edge(), move_sese_in_condition(), optimize_mode_switching(), remove_forwarder_block_with_phi(), remove_path(), rewrite_cross_bb_scalar_deps_out_of_ssa(), separate_decls_in_region(), set_prologue_iterations(), slpeel_tree_duplicate_loop_to_edge_cfg(), slpeel_tree_peel_loop_to_edge(), slpeel_update_phi_nodes_for_guard1(), slpeel_update_phi_nodes_for_guard2(), split_critical_edges(), split_edge_and_insert(), split_loop_exit_edge(), thread_through_loop_header(), translate_clast_assignment(), translate_clast_for_loop(), tree_function_versioning(), tree_optimize_tail_calls_1(), tree_transform_and_unroll_loop(), unroll_loop_runtime_iterations(), unswitch_loop(), vect_loop_versioning(), and vect_transform_loop().

void tidy_fallthru_edge ( )
Try to make the edge fallthru.   

References cfg_hooks::tidy_fallthru_edge.

Referenced by merge_if_block(), tidy_fallthru_edges(), and try_simplify_condjump().

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.   

References edge_def::dest, find_reg_note(), edge_def::flags, basic_block_def::next_bb, basic_block_def::prev_bb, single_succ_edge(), single_succ_p(), cfg_hooks::tidy_fallthru_edge, and tidy_fallthru_edge().

Referenced by delete_unreachable_blocks(), and post_order_compute().


Variable Documentation

struct cfg_hooks* cfg_hooks
static
@verbatim 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 get_cfg_hooks().