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 "predict.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "emit-rtl.h"
#include "cfgrtl.h"
#include "cfgbuild.h"
#include "cfgcleanup.h"
#include "dce.h"
#include "valtrack.h"
#include "tree-pass.h"
#include "dbgcnt.h"
#include "rtl-iter.h"
Data Structures | |
struct | check_argument_load_data |
Variables | |
static bool | df_in_progress = false |
static bool | can_alter_cfg = false |
static vec< rtx_insn * > | worklist |
static sbitmap | marked |
static bitmap_obstack | dce_blocks_bitmap_obstack |
static bitmap_obstack | dce_tmp_bitmap_obstack |
Don't delete calls that may throw if we cannot do so.
References BB_END, BLOCK_FOR_INSN(), CALL_P, can_alter_cfg, cfun, FOR_EACH_EDGE, gcc_assert, and insn_nothrow_p().
Referenced by deletable_insn_p(), and mark_insn().
|
static |
Helper function for find_call_stack_args. Check if there are any loads from the argument slots in between the const/pure call and store to the argument slot, set LOAD_FOUND if any is found.
References bitmap_bit_p, check_argument_load_data::call_insn, check_argument_load_data::fast, FOR_EACH_SUBRTX, INTTYPE_MINIMUM, check_argument_load_data::load_found, MAX, check_argument_load_data::max_sp_off, MEM_P, MEM_SIZE, MEM_SIZE_KNOWN_P, MIN, check_argument_load_data::min_sp_off, sp_based_mem_offset(), and check_argument_load_data::sp_bytes.
Referenced by find_call_stack_args().
|
static |
Return true if a store to SIZE bytes, starting OFF bytes from stack pointer, is a call argument store, and clear corresponding bits from SP_BYTES bitmap if it is.
References bitmap_clear_bit().
Referenced by find_call_stack_args().
|
static |
Process basic block BB. Return true if the live_in set has changed. REDO_OUT is true if the info at the bottom of the block needs to be recalculated before starting. AU is the proper set of artificial uses. Track global substitution of uses of dead pseudos in debug insns using GLOBAL_DEBUG.
References BITMAP_ALLOC, bitmap_bit_p, bitmap_clear(), bitmap_copy(), bitmap_empty_p(), bitmap_equal_p(), BITMAP_FREE, control_flow_insn_p(), dce_tmp_bitmap_obstack, dead_debug_add(), dead_debug_insert_temp(), dead_debug_local_finish(), dead_debug_local_init(), debug, DEBUG_INSN_P, DEBUG_TEMP_AFTER_WITH_REG_FORCE, DEBUG_TEMP_BEFORE_WITH_VALUE, df_lr, DF_LR_IN, DF_LR_OUT, df_print_regset(), DF_REF_REGNO, df_simulate_defs(), df_simulate_finalize_backwards(), df_simulate_initialize_backwards(), df_simulate_uses(), dump_file, FOR_BB_INSNS_REVERSE, FOR_EACH_EDGE, FOR_EACH_INSN_DEF, FOR_EACH_INSN_USE, basic_block_def::index, INSN_P, mark_insn(), marked_insn_p(), NULL, and basic_block_def::succs.
Referenced by fast_dce().
Return true if INSN is a normal instruction that can be deleted by the DCE pass.
References as_a(), CALL_P, can_alter_cfg, can_delete_call(), cfun, crtl, deletable_insn_p_1(), df_in_progress, DF_REF_REG, DF_REF_REGNO, find_call_stack_args(), find_reg_note(), FOR_EACH_INSN_DEF, GET_CODE, global_regs, HARD_REGISTER_NUM_P, HARD_REGISTER_P, i, insn_nothrow_p(), NONJUMP_INSN_P, NULL, PATTERN(), pic_offset_table_rtx, REG_P, REGNO, reload_completed, RTL_CONST_OR_PURE_CALL_P, RTL_LOOPING_CONST_OR_PURE_CALL_P, RTX_FRAME_RELATED_P, SIBLING_CALL_P, XEXP, XVECEXP, and XVECLEN.
Referenced by find_call_stack_args(), and prescan_insns_for_dce().
A subroutine for which BODY is part of the instruction being tested; either the top-level pattern, or an element of a PARALLEL. The instruction is known not to be a bare USE or CLOBBER.
References GET_CODE, and volatile_refs_p().
Referenced by deletable_insn_p().
|
static |
Delete every instruction that hasn't been marked.
References can_alter_cfg, CDI_DOMINATORS, cfun, dbg_cnt(), delete_insn_and_edges(), delete_unreachable_blocks(), df_insn_rescan(), dump_file, find_reg_note(), FOR_BB_INSNS_REVERSE_SAFE, FOR_EACH_BB_REVERSE_FN, free_dominance_info(), gcc_assert, GET_MODE, INSN_CODE, insn_nothrow_p(), INSN_UID(), marked_insn_p(), df_link::next, NONDEBUG_INSN_P, noop_move_p(), NULL, NULL_RTX, PATTERN(), REG_P, remove_reg_equal_equiv_notes_for_defs(), RTX_FRAME_RELATED_P, and XEXP.
Referenced by fast_dce(), and rest_of_handle_ud_dce().
|
static |
Perform fast DCE once initialization is done. If WORD_LEVEL is true, use the word level dce, otherwise do it at the pseudo level.
References all_blocks, BASIC_BLOCK_FOR_FN, bb_has_eh_pred(), BITMAP_ALLOC, bitmap_bit_p, bitmap_clear(), BITMAP_FREE, bitmap_set_bit, cfun, dce_blocks_bitmap_obstack, dce_process_block(), dead_debug_global_finish(), dead_debug_global_init(), delete_unmarked_insns(), df, df_analyze_problem(), DF_BACKWARD, df_clear_flags(), df_get_n_blocks(), df_get_postorder(), df_lr, df_lr_dce, DF_LR_RUN_DCE, df_set_flags(), df_word_lr, df_d::eh_block_artificial_uses, FOR_EACH_EDGE, i, marked, NULL, NUM_FIXED_BLOCKS, basic_block_def::preds, prescan_insns_for_dce(), processed, df_d::regular_block_artificial_uses, and word_dce_process_block().
Referenced by rest_of_handle_fast_dce(), and run_word_dce().
|
static |
Try to find all stack stores of CALL_INSN arguments if ACCUMULATE_OUTGOING_ARGS. If all stack stores have been found and it is therefore safe to eliminate the call, return true, otherwise return false. This function should be first called with DO_MARK false, and only when the CALL_INSN is actually going to be marked called again with DO_MARK true.
References ACCUMULATE_OUTGOING_ARGS, BB_HEAD, BITMAP_ALLOC, bitmap_clear(), bitmap_empty_p(), BITMAP_FREE, bitmap_set_bit, BLOCK_FOR_INSN(), check_argument_load_data::call_insn, CALL_INSN_FUNCTION_USAGE, CALL_P, check_argument_load(), check_argument_store(), deletable_insn_p(), check_argument_load_data::fast, gcc_assert, gcc_checking_assert, gcc_unreachable, GET_CODE, INSN_UID(), INTTYPE_MAXIMUM, INTTYPE_MINIMUM, mark_insn(), MAX, check_argument_load_data::max_sp_off, MEM_P, MEM_SIZE, MEM_SIZE_KNOWN_P, MIN, check_argument_load_data::min_sp_off, NONDEBUG_INSN_P, note_uses(), NULL, PATTERN(), PREV_INSN(), SET_DEST, single_set(), sp_based_mem_offset(), check_argument_load_data::sp_bytes, stack_pointer_rtx, and XEXP.
Referenced by deletable_insn_p(), and mark_insn().
|
static |
Free the data allocated by init_dce.
References bitmap_obstack_release(), dce_blocks_bitmap_obstack, dce_tmp_bitmap_obstack, marked, and sbitmap_free().
Referenced by rest_of_handle_fast_dce(), rest_of_handle_ud_dce(), and run_word_dce().
|
static |
Initialize global variables for a new DCE pass.
References bitmap_clear(), bitmap_obstack_initialize(), can_alter_cfg, dce_blocks_bitmap_obstack, dce_tmp_bitmap_obstack, df_analyze(), df_chain_add_problem(), df_dump(), df_in_progress, DF_RD_PRUNE_DEAD_DEFS, df_set_flags(), DF_UD_CHAIN, dump_file, get_max_uid(), marked, and sbitmap_alloc().
Referenced by rest_of_handle_fast_dce(), rest_of_handle_ud_dce(), and run_word_dce().
rtl_opt_pass * make_pass_fast_rtl_dce | ( | gcc::context * | ctxt | ) |
rtl_opt_pass * make_pass_ud_rtl_dce | ( | gcc::context * | ctxt | ) |
|
static |
UD-based DSE routines.
Mark instructions that define artificially-used registers, such as the frame pointer and the stack pointer.
References cfun, defs, DF_REF_CHAIN, DF_REF_INSN, DF_REF_IS_ARTIFICIAL, FOR_ALL_BB_FN, FOR_EACH_ARTIFICIAL_USE, basic_block_def::index, mark_insn(), and insn_def::next.
Referenced by rest_of_handle_ud_dce().
If INSN has not yet been marked as needed, mark it now, and add it to the worklist.
References as_a(), bitmap_set_bit, CALL_P, can_delete_call(), df_in_progress, dump_file, find_call_stack_args(), INSN_UID(), marked, marked_insn_p(), NULL, RTL_CONST_OR_PURE_CALL_P, RTL_LOOPING_CONST_OR_PURE_CALL_P, SIBLING_CALL_P, and worklist.
Referenced by dce_process_block(), find_call_stack_args(), mark_artificial_uses(), mark_nonreg_stores_1(), mark_nonreg_stores_2(), mark_reg_dependencies(), prescan_insns_for_dce(), and word_dce_process_block().
Mark INSN if it stores to a non-register destination.
References mark_nonreg_stores_1(), mark_nonreg_stores_2(), and note_stores().
Referenced by prescan_insns_for_dce().
A note_stores callback used by mark_nonreg_stores. DATA is the instruction containing DEST.
References GET_CODE, mark_insn(), and REG_P.
Referenced by mark_nonreg_stores().
A note_stores callback used by mark_nonreg_stores. DATA is the instruction containing DEST.
References GET_CODE, mark_insn(), and REG_P.
Referenced by mark_nonreg_stores().
|
static |
Mark every instruction that defines a register value that INSN uses.
References DEBUG_INSN_P, defs, DF_REF_CHAIN, DF_REF_INSN, DF_REF_IS_ARTIFICIAL, DF_REF_REG, dump_file, FOR_EACH_INSN_USE, INSN_UID(), mark_insn(), insn_def::next, and print_simple_rtl().
Referenced by rest_of_handle_ud_dce().
|
inlinestatic |
Return true if INSN has been marked as needed.
References bitmap_bit_p, gcc_assert, INSN_UID(), and marked.
Referenced by dce_process_block(), delete_unmarked_insns(), mark_insn(), reset_unmarked_insns_debug_uses(), and word_dce_process_block().
|
static |
Go through the instructions and mark those whose necessity is not dependent on inter-instruction information. Make sure all other instructions are not marked.
References ACCUMULATE_OUTGOING_ARGS, BITMAP_ALLOC, bitmap_bit_p, bitmap_clear(), BITMAP_FREE, cfun, deletable_insn_p(), df_in_progress, dump_file, FOR_BB_INSNS_REVERSE_SAFE, FOR_EACH_BB_FN, INSN_UID(), mark_insn(), mark_nonreg_stores(), NONDEBUG_INSN_P, and NULL.
Referenced by fast_dce(), and rest_of_handle_ud_dce().
|
static |
Remove all REG_EQUAL and REG_EQUIV notes referring to the registers INSN writes to.
References DF_REF_REGNO, FOR_EACH_INSN_DEF, and remove_reg_equal_equiv_notes_for_regno().
Referenced by delete_unmarked_insns().
|
static |
Scan all BBs for debug insns and reset those that reference values defined in unmarked insns.
References cfun, DEBUG_INSN_P, defs, df_insn_rescan_debug_internal(), DF_REF_CHAIN, DF_REF_INSN, DF_REF_IS_ARTIFICIAL, FOR_BB_INSNS_REVERSE_SAFE, FOR_EACH_BB_REVERSE_FN, FOR_EACH_INSN_USE, gen_rtx_UNKNOWN_VAR_LOC, INSN_VAR_LOCATION_LOC, marked_insn_p(), and insn_def::next.
Referenced by rest_of_handle_ud_dce().
|
static |
Fast register level DCE.
References fast_dce(), fini_dce(), and init_dce().
Referenced by run_fast_dce(), and run_fast_df_dce().
|
static |
UD-chain based DCE.
References delete_unmarked_insns(), df_chain, df_remove_problem(), fini_dce(), init_dce(), mark_artificial_uses(), mark_reg_dependencies(), MAY_HAVE_DEBUG_BIND_INSNS, prescan_insns_for_dce(), reset_unmarked_insns_debug_uses(), and worklist.
void run_fast_dce | ( | void | ) |
Run a fast DCE pass.
References rest_of_handle_fast_dce().
Referenced by cleanup_cfg(), and do_reload().
void run_fast_df_dce | ( | void | ) |
This is an internal call that is used by the df live register problem to run fast dce as a side effect of creating the live information. The stack is organized so that the lr problem is run, this pass is run, which updates the live info and the df scanning info, and then returns to allow the rest of the problems to be run. This can be called by elsewhere but it will not update the bit vectors for any other problems than LR.
References df_clear_flags(), DF_DEFER_INSN_RESCAN, df_in_progress, DF_NO_INSN_RESCAN, df_set_flags(), and rest_of_handle_fast_dce().
Referenced by df_lr_dce_finalize().
void run_word_dce | ( | void | ) |
Fast byte level DCE.
References df_clear_flags(), DF_DEFER_INSN_RESCAN, DF_NO_INSN_RESCAN, df_set_flags(), df_word_lr_add_problem(), fast_dce(), fini_dce(), init_dce(), timevar_pop(), and timevar_push().
Referenced by decompose_multiword_subregs().
|
static |
If MEM has sp address, return 0, if it has sp + const address, return that const, if it has reg address where reg is set to sp + const and FAST is false, return const, otherwise return INTTYPE_MINUMUM (HOST_WIDE_INT).
References CONST_INT_P, defs, DF_REF_CHAIN, DF_REF_INSN, DF_REF_IS_ARTIFICIAL, DF_REF_REG, FOR_EACH_INSN_USE, GET_CODE, INTTYPE_MINIMUM, INTVAL, insn_def::next, NULL, REG_P, rtx_equal_p(), SET_SRC, single_set(), stack_pointer_rtx, and XEXP.
Referenced by check_argument_load(), and find_call_stack_args().
|
static |
------------------------------------------------------------------------- Fast DCE functions -------------------------------------------------------------------------
Process basic block BB. Return true if the live_in set has changed. REDO_OUT is true if the info at the bottom of the block needs to be recalculated before starting. AU is the proper set of artificial uses. Track global substitution of uses of dead pseudos in debug insns using GLOBAL_DEBUG.
References BITMAP_ALLOC, bitmap_bit_p, bitmap_clear(), bitmap_copy(), bitmap_empty_p(), bitmap_equal_p(), BITMAP_FREE, control_flow_insn_p(), dce_tmp_bitmap_obstack, dead_debug_add(), dead_debug_insert_temp(), dead_debug_local_finish(), dead_debug_local_init(), debug, DEBUG_INSN_P, DEBUG_TEMP_AFTER_WITH_REG_FORCE, DEBUG_TEMP_BEFORE_WITH_VALUE, df_print_word_regset(), DF_REF_REAL_REG, DF_REF_REGNO, df_word_lr, DF_WORD_LR_IN, DF_WORD_LR_OUT, df_word_lr_simulate_defs(), df_word_lr_simulate_uses(), dump_file, FOR_BB_INSNS_REVERSE, FOR_EACH_EDGE, FOR_EACH_INSN_DEF, FOR_EACH_INSN_USE, GET_MODE, GET_MODE_SIZE(), basic_block_def::index, INSN_P, INSN_UID(), known_eq, mark_insn(), marked_insn_p(), NULL, and basic_block_def::succs.
Referenced by fast_dce().
True if we are allowed to alter the CFG in this pass.
Referenced by can_delete_call(), deletable_insn_p(), delete_unmarked_insns(), and init_dce().
|
static |
Bitmap obstacks used for block processing by the fast algorithm.
Referenced by fast_dce(), fini_dce(), and init_dce().
|
static |
Referenced by dce_process_block(), fini_dce(), init_dce(), and word_dce_process_block().
RTL dead code elimination. Copyright (C) 2005-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/>.
------------------------------------------------------------------------- Core mark/delete routines -------------------------------------------------------------------------
True if we are invoked while the df engine is running; in this case, we don't want to reenter it.
Referenced by deletable_insn_p(), init_dce(), mark_insn(), prescan_insns_for_dce(), and run_fast_df_dce().
|
static |
Bitmap of instructions marked as needed indexed by INSN_UID.
Referenced by check_regexp_units_distribution(), const_ok_for_output_1(), fast_dce(), fini_dce(), init_dce(), mark_insn(), and marked_insn_p().
Instructions that have been marked but whose dependencies have not yet been processed.
Referenced by build_bitint_stmt_ssa_conflicts(), compute_added_num_insns(), compute_antic(), compute_antic_aux(), compute_antinout_edge(), compute_avail(), compute_available(), path_range_query::compute_exit_dependencies(), compute_laterin(), compute_live_loop_exits(), compute_nearerout(), compute_partial_antic_aux(), determine_unlikely_bbs(), df_worklist_dataflow_doublequeue(), df_worklist_propagate_backward(), df_worklist_propagate_forward(), do_reassoc(), do_rpo_vn_1(), dse_classify_store(), evaluate_bbs(), fill_always_executed_in_1(), find_always_executed_bbs(), find_bbs_reachable_by_hot_paths(), find_deps_in_bb_for_stmt(), find_necessary_statements(), back_threader::find_paths_to_names(), ana::exploded_graph::find_previous_entry_to(), find_unreachable_blocks(), find_vdef_in_loop(), fwprop(), handle_missing_profiles(), has_nonexceptional_receiver(), has_nonexceptional_receiver(), ifcvt_local_dce(), lower_for(), mark_insn(), mark_operand_necessary(), mark_stmt_necessary(), match_pattern_2(), maybe_push_to_hybrid_worklist(), omp_discover_implicit_declare_target(), omp_sese_split_blocks(), optimize_mask_stores(), optimize_vector_load(), prepare_block_for_update(), process_use(), scc_copy_prop::propagate(), propagate_unlikely_bbs_forward(), prune_unused_phi_nodes(), purge_all_uses(), ana::reachability< GraphTraits >::reachability(), rest_of_handle_ud_dce(), rewrite_blocks(), scale_dominated_blocks_in_loop(), scale_strictly_dominated_blocks(), tm_memopt_compute_antic(), tm_memopt_compute_available(), pcom_worker::try_combine_chains(), vect_analyze_scalar_cycles_1(), vect_bb_slp_mark_live_stmts(), vect_bb_slp_scalar_cost(), vect_build_slp_tree_2(), vect_detect_hybrid_slp(), vect_mark_relevant(), vect_mark_stmts_to_be_vectorized(), vect_slp_check_for_roots(), vect_slp_linearize_chain(), verify_non_ssa_vars(), vt_find_locations(), and dom_walker::walk().