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"
Variables | |
bitmap | cfgcleanup_altered_bbs |
|
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 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 cleanup_control_flow_pre().
|
static |
Cleanup the GF_CALL_CTRL_ALTERING flag according to to updated gimple_call_flags.
References 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_control_flow_bb().
|
static |
Disconnect an unreachable block in the control expression starting at block BB.
References as_a(), bitmap_set_bit, cfgcleanup_altered_bbs, gimple_match_op::code, convert_single_case_switch(), ei_next(), ei_safe_edge(), ei_start, find_taken_edge(), fold_defer_overflow_warnings(), fold_undefer_and_ignore_overflow_warnings(), fold_undefer_overflow_warnings(), 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(), basic_block_def::succs, and WARN_STRICT_OVERFLOW_CONDITIONAL.
Referenced by 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(), 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_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(), 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(), vec_safe_truncate(), and visited.
Referenced by cleanup_tree_cfg_noloop().
bool cleanup_tree_cfg | ( | unsigned | ssa_update_flags | ) |
Cleanup cfg and repair loop structures.
References changed, cleanup_tree_cfg_noloop(), current_loops, LOOPS_NEED_FIXUP, loops_state_satisfies_p(), NULL, and repair_loop_structures().
Referenced by autofdo::auto_profile(), 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(), 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, merge_blocks(), remove_forwarder_block(), single_pred(), single_pred_p(), single_succ(), single_succ_p(), tree_forwarder_block_p(), and want_merge_blocks_p().
Referenced by 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, changed, checking_verify_dominators(), checking_verify_flow_info(), cleanup_control_flow_bb(), cleanup_control_flow_pre(), cleanup_tree_cfg_bb(), 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().
|
static |
Convert a SWTCH with single non-default case to gcond and replace it at GSI.
References CASE_HIGH, CASE_LABEL, CASE_LOW, cfun, 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().
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, cgraph_edge::callee, cfun, changed, cgraph_node::clone_of, cgraph_node::clones, delete_basic_block(), 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(), cgraph_edge::inline_failed, basic_block_def::next_bb, cgraph_node::next_sibling_clone, NULL, cgraph_edge::remove(), symtab_node::remove_stmt_references(), and cgraph_node::remove_symbol_and_inline_clones().
Referenced by 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 cleanup_dead_labels(), cleanup_tree_cfg(), dump_enumerated_decls(), dump_flags, error(), execute_fixup_cfg(), fopen, group_case_labels(), maybe_remove_unreachable_handlers(), NULL, TDF_NOUID, TDF_SLIM, todo, TODO_cleanup_cfg, and TODO_update_ssa.
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, changed, create_tmp_reg(), 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 eliminate_dom_walker::eliminate_cleanup(), execute_fixup_cfg(), and substitute_and_fold_engine::substitute_and_fold().
gimple_opt_pass * make_pass_cleanup_cfg_post_optimizing | ( | gcc::context * | ctxt | ) |
gimple_opt_pass * make_pass_merge_phi | ( | gcc::context * | ctxt | ) |
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(), NULL_TREE, TREE_CODE, and TREE_OPERAND.
Referenced by cleanup_control_flow_pre().
References CDI_DOMINATORS, dom_info_available_p(), and dominated_by_p().
Referenced by cleanup_tree_cfg_noloop().
|
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, stmt_ends_bb_p(), and update_stmt().
Referenced by remove_forwarder_block(), and remove_forwarder_block_with_phi().
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(), and gphi_iterator::phi().
Referenced by tree_switch_conversion::switch_conversion::collect(), remove_forwarder_block(), and remove_forwarder_block_with_phi().
Remove any fallthru edge from EV. Return true if an edge was removed.
References EDGE_COMPLEX, FOR_EACH_EDGE, and remove_edge_and_dominated_blocks().
Referenced by cleanup_control_flow_bb().
|
static |
Removes forwarder block BB. Returns false if this failed.
References as_a(), bb_has_abnormal_pred(), bitmap_set_bit, CDI_DOMINATORS, cfgcleanup_altered_bbs, copy_phi_arg_into_existing_phi(), current_loops, DECL_ARTIFICIAL, DECL_NONLOCAL, delete_basic_block(), dom_info_available_p(), dyn_cast(), EH_LANDING_PAD_NR, ei_safe_edge(), ei_start, find_edge(), first_stmt(), FOR_EACH_EDGE, FORCED_LABEL, get_immediate_dominator(), gimple_label_label(), gimple_seq_empty_p(), gsi_end_p(), gsi_move_before(), gsi_next(), gsi_start_bb(), gsi_stmt(), basic_block_def::index, is_gimple_debug(), loop::latch, basic_block_def::loop_father, move_debug_stmts_from_forwarder(), nearest_common_dominator(), NULL, phi_alternatives_equal(), phi_nodes(), basic_block_def::preds, redirect_edge_and_branch(), redirect_edge_succ_nodup(), set_immediate_dominator(), single_pred(), single_pred_p(), single_succ_edge(), and single_succ_p().
Referenced by cleanup_tree_cfg_bb().
|
static |
Tries to merge the PHI nodes at BB into those at BB's sole successor. Returns true if successful.
References add_phi_arg(), loop::any_likely_upper_bound, loop::any_upper_bound, bb_loop_header_p(), CDI_DOMINATORS, current_loops, DECL_NONLOCAL, delete_basic_block(), dominated_by_p(), dyn_cast(), EDGE_COUNT, EDGE_PRED, find_edge(), first_stmt(), free_numbers_of_iterations_estimates(), gcc_assert, get_immediate_dominator(), gimple_label_label(), gimple_phi_arg_def(), gimple_phi_arg_location_from_edge(), gsi_end_p(), gsi_next(), gsi_start_phis(), loop::header, i, loop::latch, basic_block_def::loop_father, move_debug_stmts_from_forwarder(), nearest_common_dominator(), NULL, gphi_iterator::phi(), phi_alternatives_equal(), basic_block_def::preds, redirect_edge_and_branch(), redirect_edge_var_map_clear(), redirect_edge_var_map_def(), redirect_edge_var_map_location(), redirect_edge_var_map_result(), redirect_edge_var_map_vector(), set_immediate_dominator(), single_pred(), single_pred_p(), single_succ_edge(), single_succ_p(), split_edge(), and TREE_CODE.
|
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, rewrite_into_loop_closed_ssa(), scev_reset(), timevar_pop(), timevar_push(), and TODO_update_ssa.
Referenced by cleanup_tree_cfg().
|
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. As a precondition, we require that BB be not equal to the entry block.
References as_a(), bb_loop_header_p(), cfun, current_loops, DECL_NONLOCAL, EDGE_SUCC, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, gcc_checking_assert, gimple_has_location(), gimple_label_label(), gimple_location(), gimple_seq_empty_p(), gsi_end_p(), gsi_last_bb(), gsi_prev(), gsi_stmt(), loop::header, LOCATION_LOCUS, basic_block_def::loop_father, loop_outer(), LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_SIMPLE_LATCHES, LOOPS_MAY_HAVE_MULTIPLE_LATCHES, loops_state_satisfies_p(), phi_nodes(), basic_block_def::preds, single_pred_p(), single_succ(), single_succ_edge(), single_succ_p(), and UNKNOWN_LOCATION.
Referenced by cleanup_tree_cfg_bb().
|
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(), and stmt_can_terminate_bb_p().
Referenced by cleanup_tree_cfg_bb().
bitmap cfgcleanup_altered_bbs |
CFG cleanup for trees. Copyright (C) 2001-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/>.
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.
Referenced by cleanup_control_expr_graph(), cleanup_control_flow_bb(), cleanup_tree_cfg_bb(), cleanup_tree_cfg_noloop(), gimple_merge_blocks(), remove_edge_and_dominated_blocks(), remove_forwarder_block(), and replace_uses_by().