|
GCC Middle and Back End API Reference
|
#include "config.h"#include "system.h"#include "coretypes.h"#include "backend.h"#include "rtl.h"#include "tree.h"#include "gimple.h"#include "cfghooks.h"#include "tree-pass.h"#include "ssa.h"#include "diagnostic-core.h"#include "fold-const.h"#include "cfganal.h"#include "cfgcleanup.h"#include "tree-eh.h"#include "gimplify.h"#include "gimple-iterator.h"#include "tree-cfg.h"#include "tree-ssa-loop-manip.h"#include "tree-dfa.h"#include "tree-ssa.h"#include "cfgloop.h"#include "tree-scalar-evolution.h"#include "gimple-match.h"#include "gimple-fold.h"#include "tree-ssa-loop-niter.h"#include "cgraph.h"#include "tree-into-ssa.h"#include "tree-cfgcleanup.h"#include "gimple-pretty-print.h"#include "target.h"
Variables | |
| bitmap | cfgcleanup_altered_bbs |
|
static |
Returns true if a phi of the basic block BB has an use of a ssa name that is used in an abnormal edge.
References as_a(), bb_phis_references_abnormal_uses(), gimple_phi_arg_def(), gimple_phi_num_args(), gsi_end_p(), gsi_next(), gsi_start(), i, phi_nodes(), SSA_NAME_OCCURS_IN_ABNORMAL_PHI, and TREE_CODE.
Referenced by bb_phis_references_abnormal_uses(), and maybe_remove_forwarder_block().
|
static |
If BB is a basic block ending with __builtin_setjmp_setup, return edge from .ABNORMAL_DISPATCHER basic block to corresponding __builtin_setjmp_receiver basic block, otherwise return NULL.
References builtin_setjmp_setup_bb(), cfun, EDGE_COUNT, EDGE_PRED, EDGE_SUCC, gimple_call_arg(), gimple_call_builtin_p(), gsi_end_p(), gsi_last_nondebug_bb(), gsi_stmt(), label_to_block(), NULL, basic_block_def::preds, basic_block_def::succs, TREE_CODE, and TREE_OPERAND.
Referenced by builtin_setjmp_setup_bb(), and cleanup_control_flow_pre().
| bool canonicalize_bool_cond | ( | gcond * | stmt, |
| basic_block | bb ) |
Canonicalize _Bool == 0 and _Bool != 1 to _Bool != 0 of STMT in BB by swapping edges of the BB.
References build_zero_cst(), canonicalize_bool_cond(), dump_file, EDGE_SUCC, gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_cond_set_code(), gimple_cond_set_rhs(), integer_onep(), integer_zerop(), INTEGRAL_TYPE_P, print_gimple_expr(), TREE_CODE, TREE_TYPE, and TYPE_PRECISION.
Referenced by canonicalize_bool_cond(), cleanup_control_expr_graph(), and forward_propagate_into_gimple_cond().
|
static |
Cleanup the GF_CALL_CTRL_ALTERING flag according to to updated gimple_call_flags.
References cleanup_call_ctrl_altering_flag(), ECF_CONST, ECF_LEAF, ECF_LOOPING_CONST_OR_PURE, ECF_NORETURN, ECF_PURE, FOR_EACH_EDGE, gimple_call_ctrl_altering_p(), gimple_call_flags(), gimple_call_internal_p(), gimple_call_internal_unique_p(), gimple_call_set_ctrl_altering(), is_gimple_call(), and basic_block_def::succs.
Referenced by cleanup_call_ctrl_altering_flag(), and cleanup_control_flow_bb().
|
static |
Disconnect an unreachable block in the control expression starting at block BB.
References as_a(), bitmap_set_bit, canonicalize_bool_cond(), cfgcleanup_altered_bbs, cleanup_control_expr_graph(), gimple_match_op::code, convert_single_case_switch(), ei_next(), ei_safe_edge(), ei_start, find_taken_edge(), gimple_simplify(), gimple_switch_index(), gsi_remove(), gsi_stmt(), basic_block_def::index, no_follow_ssa_edges(), NULL, NULL_TREE, gimple_match_op::ops, remove_edge_and_dominated_blocks(), single_succ_edge(), single_succ_p(), and basic_block_def::succs.
Referenced by cleanup_control_expr_graph(), and cleanup_control_flow_bb().
|
static |
Try to remove superfluous control structures in basic block BB. Returns true if anything changes.
References bitmap_set_bit, cfgcleanup_altered_bbs, cfun, cleanup_call_ctrl_altering_flag(), cleanup_control_expr_graph(), cleanup_control_flow_bb(), DECL_CONTEXT, ei_next(), ei_safe_edge(), ei_start, gcc_checking_assert, gimple_call_lhs(), gimple_call_noreturn_p(), gimple_call_set_ctrl_altering(), gimple_goto_dest(), gimple_purge_dead_eh_edges(), gsi_end_p(), gsi_last_bb(), gsi_last_nondebug_bb(), gsi_next(), gsi_remove(), gsi_stmt(), basic_block_def::index, is_gimple_call(), label_to_block(), remove_edge_and_dominated_blocks(), remove_fallthru_edge(), should_remove_lhs_p(), basic_block_def::succs, TREE_CODE, and TREE_OPERAND.
Referenced by cleanup_control_flow_bb(), cleanup_control_flow_pre(), and cleanup_tree_cfg_noloop().
|
static |
Do cleanup_control_flow_bb in PRE order.
References BASIC_BLOCK_FOR_FN, bitmap_bit_p, bitmap_clear(), bitmap_clear_bit(), bitmap_set_bit, builtin_setjmp_setup_bb(), CDI_DOMINATORS, cfun, cleanup_control_flow_bb(), cleanup_control_flow_pre(), delete_basic_block(), dom_info_state(), DOM_NONE, EDGE_COUNT, ei_container(), ei_edge(), ei_next(), ei_one_before_end_p(), ei_start, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, free_dominance_info(), g, gimple_call_internal_p(), gsi_start_nondebug_after_labels_bb(), gsi_stmt(), i, basic_block_def::index, last_basic_block_for_fn, maybe_dead_abnormal_edge_p(), n_basic_blocks_for_fn, NULL, NUM_FIXED_BLOCKS, set_dom_info_availability(), basic_block_def::succs, vec_free(), vec_safe_length(), vec_safe_push(), and vec_safe_truncate().
Referenced by cleanup_control_flow_pre(), and cleanup_tree_cfg_noloop().
| bool cleanup_tree_cfg | ( | unsigned | ssa_update_flags | ) |
Cleanup cfg and repair loop structures.
References cleanup_tree_cfg(), cleanup_tree_cfg_noloop(), current_loops, LOOPS_NEED_FIXUP, loops_state_satisfies_p(), NULL, and repair_loop_structures().
Referenced by autofdo::auto_profile(), cleanup_tree_cfg(), execute_build_cfg(), execute_cleanup_cfg_post_optimizing(), execute_function_todo(), expand_omp_target(), expand_omp_taskreg(), gimple_lower_bitint(), tree_loop_unroll_and_jam(), tree_profiling(), tree_ssa_unswitch_loops(), and tree_unroll_loops_completely().
|
static |
Tries to cleanup cfg in basic block BB by merging blocks. Returns true if anything changes.
References bitmap_set_bit, cfgcleanup_altered_bbs, cleanup_tree_cfg_bb(), maybe_remove_forwarder_block(), merge_blocks(), single_pred(), single_pred_p(), single_succ(), single_succ_p(), and want_merge_blocks_p().
Referenced by cleanup_tree_cfg_bb(), and cleanup_tree_cfg_noloop().
|
static |
Remove unreachable blocks and other miscellaneous clean up work. Return true if the flowgraph was modified, false otherwise.
References add_bb_to_loop(), BASIC_BLOCK_FOR_FN, BITMAP_ALLOC, bitmap_clear_first_set_bit(), bitmap_empty_p(), BITMAP_FREE, calculate_dominance_info(), CDI_DOMINATORS, cfgcleanup_altered_bbs, cfun, checking_verify_dominators(), checking_verify_flow_info(), cleanup_control_flow_bb(), cleanup_control_flow_pre(), cleanup_tree_cfg_bb(), cleanup_tree_cfg_noloop(), compact_blocks(), current_loops, dom_info_available_p(), dominated_by_p(), end_recording_case_labels(), find_common_loop(), FOR_EACH_EDGE, free_numbers_of_iterations_estimates(), gcc_assert, get_loops(), loop::header, i, last_basic_block_for_fn, LOOPS_NEED_FIXUP, loops_state_satisfies_p(), loops_state_set(), make_forwarder_block(), mark_dfs_back_edges(), mfb_keep_latches(), NULL, NUM_FIXED_BLOCKS, basic_block_def::preds, remove_bb_from_loops(), scev_initialized_p(), start_recording_case_labels(), timevar_pop(), timevar_push(), and update_ssa().
Referenced by cleanup_tree_cfg(), and cleanup_tree_cfg_noloop().
|
static |
Convert a SWTCH with single non-default case to gcond and replace it at GSI.
References CASE_HIGH, CASE_LABEL, CASE_LOW, cfun, convert_single_case_switch(), find_edge(), fold_convert, generate_range_test(), gimple_bb(), gimple_build_cond(), gimple_switch_default_bb(), gimple_switch_index(), gimple_switch_label(), gimple_switch_num_labels(), gsi_replace(), label_to_block(), NULL_TREE, range_check_type(), and TREE_TYPE.
Referenced by cleanup_control_expr_graph(), and convert_single_case_switch().
| bool delete_unreachable_blocks_update_callgraph | ( | cgraph_node * | dst_node, |
| bool | update_clones ) |
Delete all unreachable basic blocks and update callgraph. Doing so is somewhat nontrivial because we need to update all clones and remove inline function that become unreachable.
References b, cfun, cgraph_node::clones, delete_basic_block(), delete_unreachable_blocks_update_callgraph(), ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, find_unreachable_blocks(), cgraph_node::get_edge(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), NULL, cgraph_edge::remove(), and symtab_node::remove_stmt_references().
Referenced by delete_unreachable_blocks_update_callgraph(), ipcp_transform_function(), optimize_inline_calls(), and tree_function_versioning().
|
static |
Pass: cleanup the CFG just before expanding trees to RTL. This is just a round of label cleanups and case node grouping because after the tree optimizers have run such cleanups may be necessary.
References builtin_decl_implicit(), cfun, cleanup_dead_labels(), cleanup_tree_cfg(), dump_enumerated_decls(), dump_flags, ENTRY_BLOCK_PTR_FOR_FN, error(), execute_cleanup_cfg_post_optimizing(), execute_fixup_cfg(), fix_loop_structure(), fopen, gimple_call_builtin_p(), gimple_call_set_fndecl(), group_case_labels(), gsi_end_p(), gsi_remove(), gsi_start_nondebug_after_labels_bb(), gsi_stmt(), make_forwarders_with_degenerate_phis(), make_single_succ_edge(), maybe_remove_unreachable_handlers(), NULL, single_succ(), targetm, TDF_NOUID, TDF_SLIM, TODO_cleanup_cfg, TODO_update_ssa, and update_stmt().
Referenced by execute_cleanup_cfg_post_optimizing().
STMT is a call that has been discovered noreturn. Split the block to prepare fixing up the CFG and remove LHS. Return true if cleanup-cfg needs to run.
References cfun, create_tmp_reg(), fixup_noreturn_call(), gimple_bb(), gimple_build_nop(), gimple_call_builtin_p(), gimple_call_ctrl_altering_p(), gimple_call_fntype(), gimple_call_lhs(), gimple_call_set_ctrl_altering(), gimple_call_set_lhs(), gsi_end_p(), gsi_for_stmt(), gsi_last_bb(), gsi_last_nondebug_bb(), gsi_next(), gsi_remove(), gsi_stmt(), NULL_TREE, set_ssa_default_def(), SET_SSA_NAME_VAR_OR_IDENTIFIER, should_remove_lhs_p(), split_block(), SSA_NAME_DEF_STMT, TREE_CODE, TREE_TYPE, update_stmt(), and VOID_TYPE_P.
Referenced by copy_edges_for_bb(), eliminate_dom_walker::eliminate_cleanup(), execute_fixup_cfg(), fixup_noreturn_call(), and substitute_and_fold_engine::substitute_and_fold().
| gimple_opt_pass * make_pass_cleanup_cfg_post_optimizing | ( | gcc::context * | ctxt | ) |
References make_pass_cleanup_cfg_post_optimizing().
Referenced by make_pass_cleanup_cfg_post_optimizing(), and make_pass_dispatcher_calls().
| gimple_opt_pass * make_pass_merge_phi | ( | gcc::context * | ctxt | ) |
References make_pass_merge_phi().
Referenced by make_pass_empty_loop(), and make_pass_merge_phi().
Return true if E is an EDGE_ABNORMAL edge for returns_twice calls, i.e. one going from .ABNORMAL_DISPATCHER to basic block which doesn't start with a forced or nonlocal label. Calls which return twice can return the second time only if they are called normally the first time, so basic blocks which can be only entered through these abnormal edges but not normally are effectively unreachable as well. Additionally ignore __builtin_setjmp_receiver starting blocks, which have one FORCED_LABEL and which are always only reachable through EDGE_ABNORMAL edge. They are handled in cleanup_control_flow_pre.
References DECL_NONLOCAL, dyn_cast(), FORCED_LABEL, g, gimple_call_arg(), gimple_call_builtin_p(), gimple_call_internal_p(), gimple_label_label(), gsi_end_p(), gsi_next(), gsi_next_nondebug(), gsi_start_bb(), gsi_start_nondebug_after_labels_bb(), gsi_stmt(), is_gimple_debug(), maybe_dead_abnormal_edge_p(), NULL_TREE, TREE_CODE, and TREE_OPERAND.
Referenced by cleanup_control_flow_pre(), and maybe_dead_abnormal_edge_p().
|
static |
Return true if basic block BB does nothing except pass control flow to another block and that we can safely insert a label at the start of the successor block and was removed. As a precondition, we require that BB be not equal to the entry block. If CAN_SPLIT is true, we can split the edge to have another bb with with the phi.
References loop::any_likely_upper_bound, loop::any_upper_bound, as_a(), bb_has_abnormal_pred(), bb_loop_header_p(), bb_phis_references_abnormal_uses(), bitmap_set_bit, CDI_DOMINATORS, cfgcleanup_altered_bbs, cfun, copy_phi_arg_into_existing_phi(), current_loops, DECL_ARTIFICIAL, DECL_NONLOCAL, delete_basic_block(), dominated_by_p(), EH_LANDING_PAD_NR, ei_safe_edge(), ei_start, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, find_edge(), first_stmt(), FOR_EACH_EDGE, FORCED_LABEL, free_numbers_of_iterations_estimates(), gcc_checking_assert, get_immediate_dominator(), gimple_bb(), gimple_has_location(), gimple_label_label(), gimple_location(), gimple_phi_arg_def(), gimple_phi_result(), gimple_seq_empty_p(), gsi_end_p(), gsi_last_bb(), gsi_move_before(), gsi_next(), gsi_prev(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), has_zero_uses(), loop::header, basic_block_def::index, is_gimple_debug(), loop::latch, LOCATION_LOCUS, basic_block_def::loop_father, loop_outer(), LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_SIMPLE_LATCHES, loops_state_satisfies_p(), maybe_remove_forwarder_block(), move_debug_stmts_from_forwarder(), nearest_common_dominator(), NULL, gphi_iterator::phi(), phi_alternatives_equal(), phi_nodes(), basic_block_def::preds, redirect_edge_and_branch(), redirect_edge_succ_nodup(), redirect_edge_var_map_clear(), safe_dyn_cast(), set_immediate_dominator(), single_imm_use(), single_pred(), single_pred_edge(), single_pred_p(), single_succ(), single_succ_edge(), single_succ_p(), split_edge(), and UNKNOWN_LOCATION.
Referenced by cleanup_tree_cfg_bb(), and maybe_remove_forwarder_block().
Callback function for make_forwarder_block which returns true when E is not a latch.
References CDI_DOMINATORS, dom_info_available_p(), dominated_by_p(), and mfb_keep_latches().
Referenced by cleanup_tree_cfg_noloop(), and mfb_keep_latches().
|
static |
Move debug stmts from the forwarder block SRC to DEST or PRED.
References debug, gcc_assert, gimple_debug_bind_p(), gimple_debug_bind_reset_value(), gsi_after_labels(), gsi_end_p(), gsi_last_bb(), gsi_move_after(), gsi_move_before(), gsi_next(), gsi_stmt(), is_gimple_debug(), MAY_HAVE_DEBUG_STMTS, move_debug_stmts_from_forwarder(), stmt_ends_bb_p(), and update_stmt().
Referenced by maybe_remove_forwarder_block(), and move_debug_stmts_from_forwarder().
| bool phi_alternatives_equal | ( | basic_block | dest, |
| edge | e1, | ||
| edge | e2 ) |
If all the PHI nodes in DEST have alternatives for E1 and E2 and those alternatives are equal in each of the PHI nodes, then return true, else return false.
References gcc_assert, gimple_phi_arg_def(), gsi_end_p(), gsi_next(), gsi_start_phis(), NULL_TREE, operand_equal_for_phi_arg_p(), gphi_iterator::phi(), and phi_alternatives_equal().
Referenced by tree_switch_conversion::switch_conversion::collect(), maybe_remove_forwarder_block(), and phi_alternatives_equal().
Remove any fallthru edge from EV. Return true if an edge was removed.
References EDGE_COMPLEX, FOR_EACH_EDGE, remove_edge_and_dominated_blocks(), and remove_fallthru_edge().
Referenced by cleanup_control_flow_bb(), and remove_fallthru_edge().
|
static |
Repairs loop structures.
References BITMAP_ALLOC, bitmap_empty_p(), BITMAP_FREE, calculate_dominance_info(), CDI_DOMINATORS, checking_verify_loop_structure(), fix_loop_structure(), LOOP_CLOSED_SSA, loops_state_satisfies_p(), NULL, repair_loop_structures(), rewrite_into_loop_closed_ssa(), scev_reset(), timevar_pop(), timevar_push(), and TODO_update_ssa.
Referenced by cleanup_tree_cfg(), and repair_loop_structures().
|
static |
Return true if we want to merge BB1 and BB2 into a single block.
References can_merge_blocks_p(), basic_block_def::count, gsi_end_p(), gsi_last_nondebug_bb(), gsi_stmt(), profile_count::ok_for_merging(), stmt_can_terminate_bb_p(), and want_merge_blocks_p().
Referenced by cleanup_tree_cfg_bb(), and want_merge_blocks_p().
| bitmap cfgcleanup_altered_bbs |
CFG cleanup for trees. Copyright (C) 2001-2026 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/>.
The set of blocks in that at least one of the following changes happened:
-- the statement at the end of the block was changed
-- the block was newly created
-- the set of the predecessors of the block changed
-- the set of the successors of the block changed
??? Maybe we could track these changes separately, since they determine
what cleanups it makes sense to try on the block. Header file for CFG cleanup for trees. Copyright (C) 2013-2026 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/>.
In tree-cfgcleanup.cc
Referenced by cleanup_control_expr_graph(), cleanup_control_flow_bb(), cleanup_tree_cfg_bb(), cleanup_tree_cfg_noloop(), gimple_merge_blocks(), maybe_remove_forwarder_block(), remove_edge_and_dominated_blocks(), and replace_uses_by().