GCC Middle and Back End API Reference
cfgrtl.h File Reference

Go to the source code of this file.

Functions

void delete_insn (rtx_insn *)
 
bool delete_insn_and_edges (rtx_insn *)
 
void delete_insn_chain (rtx, rtx_insn *, bool)
 
basic_block create_basic_block_structure (rtx_insn *, rtx_insn *, rtx_note *, basic_block)
 
void compute_bb_for_insn (void)
 
void free_bb_for_insn (void)
 
rtx_insnentry_of_function (void)
 
void update_bb_for_insn (basic_block)
 
bool contains_no_active_insn_p (const_basic_block)
 
bool forwarder_block_p (const_basic_block)
 
bool can_fallthru (basic_block, basic_block)
 
rtx_notebb_note (basic_block)
 
rtx_code_labelblock_label (basic_block)
 
edge try_redirect_by_replacing_jump (edge, basic_block, bool)
 
void emit_barrier_after_bb (basic_block bb)
 
basic_block force_nonfallthru_and_redirect (edge, basic_block, rtx)
 
void insert_insn_on_edge (rtx, edge)
 
void prepend_insn_to_edge (rtx, edge)
 
void commit_one_edge_insertion (edge e)
 
void commit_edge_insertions (void)
 
void print_rtl_with_bb (FILE *, const rtx_insn *, dump_flags_t)
 
void update_br_prob_note (basic_block)
 
rtx_insnget_last_bb_insn (basic_block)
 
void fixup_partitions (void)
 
bool purge_dead_edges (basic_block)
 
bool purge_all_dead_edges (void)
 
bool fixup_abnormal_edges (void)
 
void update_cfg_for_uncondjump (rtx_insn *)
 
rtx_insnunlink_insn_chain (rtx_insn *, rtx_insn *)
 
void relink_block_chain (bool)
 
rtx_insnduplicate_insn_chain (rtx_insn *, rtx_insn *, class loop *, class copy_bb_data *)
 
void cfg_layout_initialize (int)
 
void cfg_layout_finalize (void)
 
void break_superblocks (void)
 
void init_rtl_bb_info (basic_block)
 
void find_bbs_reachable_by_hot_paths (hash_set< basic_block > *)
 

Function Documentation

◆ bb_note()

◆ block_label()

◆ break_superblocks()

◆ can_fallthru()

bool can_fallthru ( basic_block src,
basic_block target )
extern
Return nonzero if we can reach target from src by falling through.   
FIXME: Make this a cfg hook, the result is only valid in cfgrtl mode.   

References active_insn_p(), BB_END, BB_HEAD, cfun, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, next_active_insn(), basic_block_def::next_bb, NULL, basic_block_def::succs, and tablejump_p().

Referenced by expand_gimple_basic_block(), expand_gimple_tailcall(), fixup_reorder_chain(), try_redirect_by_replacing_jump(), and try_simplify_condjump().

◆ cfg_layout_finalize()

void cfg_layout_finalize ( void )
extern

◆ cfg_layout_initialize()

void cfg_layout_initialize ( int flags)
extern
Main entry point to this module - initialize the datastructures for
CFG layout changes.  It keeps LOOPS up-to-date if not null.

FLAGS is a set of additional flags to pass to cleanup_cfg().   

References BLOCK_FOR_INSN(), cfg_layout_rtl_register_cfg_hooks(), cleanup_cfg(), CLEANUP_CFGLAYOUT, crtl, basic_block_def::flags, gcc_assert, initialize_original_copy_tables(), rtx_insn_list::insn(), rtx_insn_list::next(), nonlocal_goto_handler_labels, and record_effective_endpoints().

Referenced by reorder_loops(), and thread_prologue_and_epilogue_insns().

◆ commit_edge_insertions()

◆ commit_one_edge_insertion()

◆ compute_bb_for_insn()

void compute_bb_for_insn ( void )
extern
Records the basic block struct in BLOCK_FOR_INSN for every insn.   

References BB_END, BB_HEAD, BLOCK_FOR_INSN(), cfun, end(), FOR_EACH_BB_FN, and NEXT_INSN().

◆ contains_no_active_insn_p()

bool contains_no_active_insn_p ( const_basic_block bb)
extern
Return true if the block has no effect and only forwards control flow to
its single destination.   

References BB_END, BB_HEAD, cfun, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, flow_active_insn_p(), INSN_P, JUMP_P, NEXT_INSN(), simplejump_p(), single_succ_edge(), and single_succ_p().

Referenced by doloop_optimize(), and forwarder_block_p().

◆ create_basic_block_structure()

basic_block create_basic_block_structure ( rtx_insn * head,
rtx_insn * end,
rtx_note * bb_note,
basic_block after )
extern
Create a new basic block consisting of the instructions between HEAD and END
inclusive.  This function is designed to allow fast BB construction - reuses
the note and basic block struct in BB_NOTE, if any and do not grow
BASIC_BLOCK chain and should be used directly only by CFG construction code.
END can be NULL in to create new empty basic block before HEAD.  Both END
and HEAD can be NULL to create basic block at the end of INSN chain.
AFTER is the basic block we should be put after.   

References alloc_block(), basic_block_def::aux, BB_END, BB_HEAD, bb_note(), BB_SET_PARTITION, BB_UNPARTITIONED, cfun, df_bb_refs_record(), emit_note_after(), emit_note_before(), end(), basic_block_def::flags, get_last_insn(), basic_block_def::index, init_rtl_bb_info(), LABEL_P, last_basic_block_for_fn, link_block(), NEXT_INSN(), NOTE_BASIC_BLOCK, NULL, PREV_INSN(), reorder_insns_nobb(), SET_BASIC_BLOCK_FOR_FN, and update_bb_for_insn().

Referenced by rtl_create_basic_block().

◆ delete_insn()

void delete_insn ( rtx_insn * insn)
extern
Define control flow data structures for the CFG.
   Copyright (C) 2014-2024 Free Software Foundation, Inc.

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/>.   
Delete INSN by patching it out.   

References as_a(), BB_END, BB_HEAD, bb_note(), BLOCK_FOR_INSN(), can_delete_label_p(), rtx_insn::deleted(), df_insn_delete(), dyn_cast(), find_reg_note(), gcc_assert, GET_NUM_ELEM, i, INSN_P, JUMP_LABEL, JUMP_P, LABEL_NAME, LABEL_NUSES, LABEL_P, NEXT_INSN(), nonlocal_goto_handler_labels, NOTE_DELETED_LABEL_NAME, NOTE_INSN_BASIC_BLOCK_P, NOTE_KIND, NOTE_P, NULL, NULL_RTX, PUT_CODE, remove_insn(), remove_node_from_insn_list(), remove_note(), reorder_insns_nobb(), RTVEC_ELT, rtx_insn::set_deleted(), table, and XEXP.

Referenced by add_test(), attempt_change(), find_comparison_dom_walker::before_dom_children(), calculate_needs_all_insns(), cfg_layout_merge_blocks(), cfg_layout_redirect_edge_and_branch(), cleanup_barriers(), combine_and_move_insns(), combine_stack_adjustments_for_block(), commit_one_edge_insertion(), copyprop_hardreg_forward_1(), cprop_jump(), cse_cc_succs(), dead_or_predicable(), delete_address_reloads_1(), delete_caller_save_insns(), delete_dead_jumptables(), delete_dead_store_insn(), delete_insn_and_edges(), delete_insn_chain(), delete_output_reload(), delete_redundant_insns_1(), delete_related_insns(), delete_vta_debug_insn(), doloop_modify(), dse_step5(), duplicate_insn_chain(), eliminate_partially_redundant_load(), expand_gimple_tailcall(), final_1(), final_scan_insn_1(), find_and_remove_re(), find_bb_boundaries(), find_cond_trap(), fix_crossing_unconditional_branches(), fixup_abnormal_edges(), fixup_reorder_chain(), hoist_code(), instantiate_virtual_regs_in_insn(), lra_final_code_change(), maybe_cleanup_end_of_block(), merge_blocks_move_predecessor_nojumps(), merge_blocks_move_successor_nojumps(), merge_if_block(), move_insn_for_shrink_wrap(), move_invariant_reg(), move_unallocated_pseudos(), pre_delete(), reemit_insn_block_notes(), reemit_marker_as_note(), reload(), reload_as_needed(), reload_combine_recognize_const_pattern(), reload_combine_recognize_pattern(), reload_cse_move2add(), replace_store_insn(), resolve_shift_zext(), resolve_simple_move(), resolve_use(), rtl_tidy_fallthru_edge(), split_iv(), try_eliminate_compare(), try_merge_compare(), try_optimize_cfg(), try_split(), and update_cfg_for_uncondjump().

◆ delete_insn_and_edges()

bool delete_insn_and_edges ( rtx_insn * insn)
extern

◆ delete_insn_chain()

void delete_insn_chain ( rtx start,
rtx_insn * finish,
bool clear_bb )
extern
Unlink a chain of insns between START and FINISH, leaving notes
that must be paired.  If CLEAR_BB is true, we set bb field for
insns that cannot be removed to NULL.   

References as_a(), can_delete_note_p(), delete_insn(), rtx_insn::deleted(), NOTE_P, NULL, PREV_INSN(), and set_block_for_insn().

Referenced by cond_exec_process_if_block(), peep2_attempt(), rtl_delete_block(), rtl_merge_blocks(), rtl_tidy_fallthru_edge(), try_head_merge_bb(), and try_redirect_by_replacing_jump().

◆ duplicate_insn_chain()

◆ emit_barrier_after_bb()

◆ entry_of_function()

rtx_insn * entry_of_function ( void )
extern
Return RTX to emit after when we want to emit code on the entry of function.   

References BB_HEAD, cfun, ENTRY_BLOCK_PTR_FOR_FN, get_insns(), n_basic_blocks_for_fn, and NUM_FIXED_BLOCKS.

Referenced by expand_builtin_apply_args(), expand_builtin_saveregs(), and get_arg_pointer_save_area().

◆ find_bbs_reachable_by_hot_paths()

void find_bbs_reachable_by_hot_paths ( hash_set< basic_block > * set)
extern
Add all BBs reachable from entry via hot paths into the SET.   

References BB_PARTITION, cfun, ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, basic_block_def::succs, and worklist.

Referenced by find_partition_fixes(), and find_rarely_executed_basic_blocks_and_crossing_edges().

◆ fixup_abnormal_edges()

bool fixup_abnormal_edges ( void )
extern
This is used by a few passes that emit some instructions after abnormal
calls, moving the basic block's end, while they in fact do want to emit
them on the fallthru edge.  Look for abnormal call edges, find backward
the call in the block and insert the instructions on the edge instead.

Similarly, handle instructions throwing exceptions internally.

Return true when instructions have been found and inserted on edges.   

References BARRIER_P, BB_END, BB_HEAD, CALL_P, can_throw_internal(), cfun, delete_insn(), find_fallthru_edge(), FOR_EACH_BB_FN, FOR_EACH_EDGE, insert_insn_on_edge(), INSN_P, NEXT_INSN(), NONJUMP_INSN_P, NOTE_P, NULL, NULL_RTX, PREV_INSN(), purge_dead_edges(), set_block_for_insn(), SET_NEXT_INSN(), SET_PREV_INSN(), rtx_insn::set_undeleted(), and basic_block_def::succs.

Referenced by lra(), and reload().

◆ fixup_partitions()

◆ force_nonfallthru_and_redirect()

◆ forwarder_block_p()

bool forwarder_block_p ( const_basic_block bb)
extern
Likewise, but protect loop latches, headers and preheaders.   
FIXME: Make this a cfg hook.   

References contains_no_active_insn_p(), current_loops, EDGE_SUCC, loop::header, and basic_block_def::loop_father.

Referenced by add_forwarder_blocks(), find_if_case_1(), notice_new_block(), relink_block_chain(), and update_forwarder_flag().

◆ free_bb_for_insn()

void free_bb_for_insn ( void )
extern
Release the basic_block_for_insn array.   

References BARRIER_P, BLOCK_FOR_INSN(), get_insns(), NEXT_INSN(), and NULL.

Referenced by rest_of_clean_state().

◆ get_last_bb_insn()

rtx_insn * get_last_bb_insn ( basic_block bb)
extern
Get the last insn associated with block BB (that includes barriers and
tablejumps after BB).   

References BARRIER_P, BB_END, end(), next_nonnote_nondebug_insn_bb(), NULL, table, and tablejump_p().

Referenced by cond_exec_process_if_block(), rtl_delete_block(), rtl_split_edge(), and try_optimize_cfg().

◆ init_rtl_bb_info()

◆ insert_insn_on_edge()

void insert_insn_on_edge ( rtx pattern,
edge e )
extern
Queue instructions for insertion on an edge between two basic blocks.
The new instructions and basic blocks (if any) will not appear in the
CFG until commit_edge_insertions is called.  If there are already
queued instructions on the edge, PATTERN is appended to them.   

References EDGE_CRITICAL_P, emit_insn(), end_sequence(), gcc_assert, get_insns(), NULL_RTX, push_to_sequence(), and start_sequence().

Referenced by bypass_block(), eliminate_partially_redundant_load(), emit_insn_at_entry(), emit_moves(), fixup_abnormal_edges(), insert_part_to_rtx_on_edge(), insert_partition_copy_on_edge(), insert_prologue_epilogue_for_components(), insert_rtx_to_part_on_edge(), insert_store(), insert_value_copy_on_edge(), ira(), pre_edge_insert(), rtl_flow_call_edges_add(), sjlj_emit_function_enter(), and thread_prologue_and_epilogue_insns().

◆ prepend_insn_to_edge()

void prepend_insn_to_edge ( rtx pattern,
edge e )
extern
Like insert_insn_on_edge, but if there are already queued instructions
on the edge, PATTERN is prepended to them.   

References EDGE_CRITICAL_P, emit_insn(), end_sequence(), gcc_assert, get_insns(), and start_sequence().

Referenced by expand_asm_stmt().

◆ print_rtl_with_bb()

void print_rtl_with_bb ( FILE * outf,
const rtx_insn * rtx_first,
dump_flags_t flags )
extern

◆ purge_all_dead_edges()

bool purge_all_dead_edges ( void )
extern
Search all basic blocks for potentially dead edges and purge them.  Return
true if some edge has been eliminated.   

References cfun, FOR_EACH_BB_FN, and purge_dead_edges().

Referenced by combine_instructions(), indirect_jump_optimize(), rest_of_handle_cse_after_global_opts(), rest_of_handle_dse(), and rest_of_handle_thread_prologue_and_epilogue().

◆ purge_dead_edges()

◆ relink_block_chain()

void relink_block_chain ( bool stay_in_cfglayout_mode)
extern
Link the basic blocks in the correct order, compacting the basic
block queue while at it.  If STAY_IN_CFGLAYOUT_MODE is false, this
function also clears the basic block header and footer fields.

This function is usually called after a pass (e.g. tracer) finishes
some transformations while in cfglayout mode.  The required sequence
of the basic blocks is in a linked list along the bb->aux field.
This functions re-links the basic block prev_bb and next_bb pointers
accordingly, and it compacts and renumbers the blocks.

FIXME: This currently works only for RTL, but the only RTL-specific
bits are the STAY_IN_CFGLAYOUT_MODE bits.  The tracer pass was moved
to GIMPLE a long time ago, but it doesn't relink the basic block
chain.  It could do that (to give better initial RTL) if this function
is made IR-agnostic (and moved to cfganal.cc or cfg.cc while at it).   

References basic_block_def::aux, BB_FOOTER, BB_HEAD, BB_HEADER, cfun, compact_blocks(), dump_file, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_ALL_BB_FN, forwarder_block_p(), free_original_copy_tables(), get_bb_original(), basic_block_def::index, initialize_original_copy_tables(), LABEL_P, basic_block_def::next_bb, NULL, NUM_FIXED_BLOCKS, original_copy_tables_initialized_p(), and basic_block_def::prev_bb.

Referenced by fixup_reorder_chain(), and reorder_basic_blocks().

◆ try_redirect_by_replacing_jump()

◆ unlink_insn_chain()

◆ update_bb_for_insn()

void update_bb_for_insn ( basic_block bb)
extern

◆ update_br_prob_note()

◆ update_cfg_for_uncondjump()

void update_cfg_for_uncondjump ( rtx_insn * insn)
extern
Delete the unconditional jump INSN and adjust the CFG correspondingly.
Note that the INSN should be deleted *after* removing dead edges, so
that the kept edge is the fallthrough edge for a (set (pc) (pc))
but not for a (set (pc) (label_ref FOO)).   

References BARRIER_P, BB_END, BB_FOOTER, BLOCK_FOR_INSN(), current_ir_type(), delete_insn(), EDGE_COUNT, emit_barrier_after(), find_fallthru_edge(), gcc_assert, IR_RTL_CFGLAYOUT, LABEL_P, NEXT_INSN(), next_nonnote_nondebug_insn(), PREV_INSN(), purge_dead_edges(), SET_NEXT_INSN(), SET_PREV_INSN(), single_succ_edge(), and basic_block_def::succs.

Referenced by try_combine().