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 "timevar.h"
#include "ssa.h"
#include "cgraph.h"
#include "gimple-pretty-print.h"
#include "diagnostic-core.h"
#include "gimple-iterator.h"
#include "tree-dfa.h"
#include "dumpfile.h"
#include "tree-ssa-live.h"
#include "debug.h"
#include "tree-ssa.h"
#include "ipa-utils.h"
#include "cfgloop.h"
#include "stringpool.h"
#include "attribs.h"
#include "optinfo.h"
#include "gimple-walk.h"
#include "cfganal.h"
#include "tree-cfg.h"
Data Structures | |
struct | compute_live_vars_data |
Macros | |
#define | INCLUDE_MEMORY |
Variables | |
static bitmap | usedvars |
#define INCLUDE_MEMORY |
Liveness for SSA trees. Copyright (C) 2003-2024 Free Software Foundation, Inc. Contributed by Andrew MacLeod <amacleod@redhat.com> 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/>.
|
static |
Calculate the live on exit vectors based on the entry info in LIVEINFO.
References bitmap_clear(), bitmap_ior_into(), bitmap_set_bit, cfun, FOR_EACH_BB_FN, FOR_EACH_EDGE, gimple_phi_arg_edge(), gimple_phi_num_args(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), i, basic_block_def::index, live_on_entry(), tree_live_info_d::liveout, tree_live_info_d::map, NO_PARTITION, gphi_iterator::phi(), PHI_ARG_DEF, region_contains_p(), basic_block_def::succs, TREE_CODE, var_to_partition(), _var_map::vec_bbs, and virtual_operand_p().
Referenced by calculate_live_ranges().
tree_live_info_p calculate_live_ranges | ( | var_map | map, |
bool | want_livein ) |
Given partition map MAP, calculate all the live on entry bitmaps for each partition. Return a new live info object.
References bitmap_obstack_release(), calculate_live_on_exit(), free(), i, live_worklist(), tree_live_info_d::livein, tree_live_info_d::livein_obstack, map, new_tree_live_info(), NULL, NULL_TREE, num_var_partitions(), partition_to_var(), set_var_live_on_entry(), and verify_live_on_entry().
Referenced by coalesce_ssa_name().
|
static |
Set all block pointer in debug or clobber stmt to NULL if the block is unused, so that they will not be streamed out.
References b, BLOCK_ABSTRACT_ORIGIN, BLOCK_SUPERCONTEXT, cfun, clear_unused_block_pointer_1(), clear_unused_block_pointer_in_block(), current_function_decl, DECL_INITIAL, FOR_EACH_BB_FN, gimple_block(), gimple_clobber_p(), gimple_debug_nonbind_marker_p(), gimple_num_ops(), gimple_op_ptr(), gimple_set_block(), gsi_end_p(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_stmt(), i, inlined_function_outer_scope_p(), is_gimple_debug(), NULL, TREE_CODE, TREE_USED, and walk_tree.
Referenced by remove_unused_locals().
Helper function for clear_unused_block_pointer, called via walk_tree.
References EXPR_P, NULL, NULL_TREE, TREE_BLOCK, TREE_SET_BLOCK, and TREE_USED.
Referenced by clear_unused_block_pointer(), and clear_unused_block_pointer_in_block().
|
static |
Clear references to unused BLOCKs from DECL_VALUE_EXPRs of variables in BLOCK.
References BLOCK_CHAIN, BLOCK_SUBBLOCKS, BLOCK_VARS, clear_unused_block_pointer_1(), clear_unused_block_pointer_in_block(), DECL_CHAIN, DECL_HAS_VALUE_EXPR_P, DECL_VALUE_EXPR, NULL, VAR_P, and walk_tree.
Referenced by clear_unused_block_pointer(), and clear_unused_block_pointer_in_block().
vec< bitmap_head > compute_live_vars | ( | struct function * | fn, |
live_vars_map * | vars ) |
For function FN and live_vars_map (hash map from DECL_UIDs to a dense set of indexes of automatic variables VARS, compute which of those variables are (might be) live at the end of each basic block.
References BASIC_BLOCK_FOR_FN, BITMAP_ALLOC, bitmap_default_obstack, BITMAP_FREE, bitmap_initialize(), bitmap_ior_into(), changed, compute_live_vars_1(), free(), i, basic_block_def::index, last_basic_block_for_fn, NULL, and pre_and_rev_post_order_compute_fn().
Referenced by add_clobbers_to_eh_landing_pad(), and find_tail_calls().
|
static |
Helper routine for compute_live_vars, calculating the sets of live variables at the end of BB, leaving the result in DATA->work. If STOP_AFTER is non-NULL, stop processing after that stmt.
References bitmap_clear(), bitmap_clear_bit(), bitmap_ior_into(), compute_live_vars_visit(), DECL_UID, FOR_EACH_EDGE, gimple_assign_lhs(), gimple_clobber_p(), gsi_after_labels(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), is_gimple_debug(), NULL, basic_block_def::preds, VAR_P, visit, and walk_stmt_load_store_addr_ops().
Referenced by compute_live_vars(), and live_vars_at_stmt().
Callback for walk_stmt_load_store_addr_ops. If OP is a VAR_DECL with uid set in DATA->vars, enter its corresponding index into bitmap DATA->work.
References bitmap_set_bit, DECL_UID, get_base_address(), and VAR_P.
Referenced by compute_live_vars_1().
DEBUG_FUNCTION void debug | ( | _var_map & | ref | ) |
Generic dump for the above.
References dump_var_map().
DEBUG_FUNCTION void debug | ( | _var_map * | ptr | ) |
References debug.
DEBUG_FUNCTION void debug | ( | tree_live_info_d & | ref | ) |
Generic dump for the above.
References dump_live_info().
DEBUG_FUNCTION void debug | ( | tree_live_info_d * | ptr | ) |
References debug.
DEBUG_FUNCTION void debug_scope_block | ( | tree | scope, |
dump_flags_t | flags ) |
Dump the tree of lexical scopes starting at SCOPE to stderr. FLAGS is as in print_generic_expr.
References dump_scope_block().
DEBUG_FUNCTION void debug_scope_blocks | ( | dump_flags_t | flags | ) |
Dump the tree of lexical scopes of current_function_decl to stderr. FLAGS is as in print_generic_expr.
References dump_scope_blocks().
void delete_tree_live_info | ( | tree_live_info_p | live | ) |
Free storage for live range info object LIVE.
References bitmap_obstack_release(), free(), tree_live_info_d::livein, tree_live_info_d::livein_obstack, tree_live_info_d::liveout, tree_live_info_d::liveout_obstack, and tree_live_info_d::work_stack.
Referenced by coalesce_ssa_name().
void delete_var_map | ( | var_map | map | ) |
Free memory associated with MAP.
References BITMAP_FREE, free(), map, and var_map_base_fini().
Referenced by finish_out_of_ssa().
void destroy_live_vars | ( | vec< bitmap_head > & | active | ) |
Destroy what compute_live_vars has returned when it is no longer needed.
References bitmap_clear(), and i.
Referenced by add_clobbers_to_eh_landing_pad(), and tree_optimize_tail_calls_1().
void dump_live_info | ( | FILE * | f, |
tree_live_info_p | live, | ||
int | flag ) |
Output live range info LIVE to file F, controlled by FLAG.
References cfun, EXECUTE_IF_SET_IN_BITMAP, FOR_EACH_BB_FN, i, basic_block_def::index, LIVEDUMP_ENTRY, LIVEDUMP_EXIT, tree_live_info_d::livein, tree_live_info_d::liveout, map, tree_live_info_d::map, partition_to_var(), print_generic_expr(), and TDF_SLIM.
Referenced by coalesce_ssa_name(), and debug().
|
static |
Dump scope blocks starting at SCOPE to FILE. INDENT is the indentation level and FLAGS is as in print_generic_expr.
References BLOCK_ABSTRACT_ORIGIN, BLOCK_CHAIN, BLOCK_FRAGMENT_CHAIN, BLOCK_FRAGMENT_ORIGIN, BLOCK_NONLOCALIZED_VAR, BLOCK_NUM_NONLOCALIZED_VARS, BLOCK_NUMBER, BLOCK_SOURCE_LOCATION, BLOCK_SUBBLOCKS, block_ultimate_origin(), BLOCK_VARS, DECL_CHAIN, DECL_P, dump_scope_block(), expand_location(), i, LOCATION_LOCUS, print_generic_decl(), TREE_USED, and UNKNOWN_LOCATION.
Referenced by debug_scope_block(), dump_scope_block(), and dump_scope_blocks().
void dump_scope_blocks | ( | FILE * | file, |
dump_flags_t | flags ) |
Dump the tree of lexical scopes of current_function_decl to FILE. FLAGS is as in print_generic_expr.
References current_function_decl, DECL_INITIAL, and dump_scope_block().
Referenced by debug_scope_blocks(), execute_build_cfg(), and remove_unused_locals().
void dump_var_map | ( | FILE * | f, |
var_map | map ) |
Output partition map MAP to file F.
References map, NULL, NULL_TREE, num_ssa_names, partition_to_var(), print_generic_expr(), ssa_name, TDF_SLIM, virtual_operand_p(), and y.
Referenced by coalesce_ssa_name(), debug(), gimple_lower_bitint(), and remove_ssa_form().
Create a variable partition map of SIZE for region, initialize and return it. Region is a loop if LOOP is non-NULL, otherwise is the current function. If BITINT is non-NULL, only SSA_NAMEs from that bitmap will be coalesced.
References BITMAP_ALLOC, bitmap_set_bit, cfun, FOR_EACH_BB_FN, free(), get_loop_body_in_dom_order(), i, basic_block_def::index, map, n_basic_blocks_for_fn, NULL, NUM_FIXED_BLOCKS, loop::num_nodes, and vNULL.
Referenced by gimple_lower_bitint(), and remove_ssa_form().
Return true if VAR is marked as used.
References bitmap_bit_p, DECL_UID, and usedvars.
Referenced by remove_unused_locals(), and remove_unused_scope_block_p().
bitmap live_vars_at_stmt | ( | vec< bitmap_head > & | active, |
live_vars_map * | vars, | ||
gimple * | stop_after ) |
For ACTIVE computed by compute_live_vars, compute a bitmap of variables live after the STOP_AFTER statement and return that bitmap.
References BITMAP_ALLOC, compute_live_vars_1(), gimple_bb(), and NULL.
Referenced by find_tail_calls().
|
static |
Using LIVE, fill in all the live-on-entry blocks between the defs and uses of all the variables.
References b, BASIC_BLOCK_FOR_FN, bitmap_clear(), cfun, i, last_basic_block_for_fn, loe_visit_block(), tree_live_info_d::map, tree_live_info_d::stack_top, _var_map::vec_bbs, visited, and tree_live_info_d::work_stack.
Referenced by calculate_live_ranges().
|
static |
Visit basic block BB and propagate any required live on entry bits from LIVE into the predecessors. VISITED is the bitmap of visited blocks. TMP is a temporary work bitmap which is passed in to avoid reallocating it each time.
References bitmap_bit_p, bitmap_clear_bit(), bitmap_ior_and_compl_into(), bitmap_set_bit, FOR_EACH_EDGE, gcc_checking_assert, basic_block_def::index, live_on_entry(), tree_live_info_d::liveout, tree_live_info_d::map, basic_block_def::preds, region_contains_p(), tree_live_info_d::stack_top, and visited.
Referenced by live_worklist().
|
inlinestatic |
Mark all VAR_DECLS under *EXPR_P as used, so that they won't be eliminated during the tree->rtl conversion process.
References mark_all_vars_used_1(), NULL, and walk_tree.
Referenced by mark_all_vars_used_1(), and remove_unused_locals().
Helper function for mark_all_vars_used, called via walk_tree.
References b, current_function_decl, DECL_CONTEXT, DECL_INITIAL, IS_EXPR_CODE_CLASS, is_global_var(), IS_TYPE_OR_DECL_P, mark_all_vars_used(), NULL, set_is_used(), SSA_NAME_VAR, TMR_BASE, TMR_INDEX, TMR_INDEX2, TREE_BLOCK, TREE_CODE, TREE_CODE_CLASS, TREE_USED, and VAR_P.
Referenced by mark_all_vars_used().
|
static |
Mark the scope block SCOPE and its subblocks unused when they can be possibly eliminated if dead.
References BLOCK_CHAIN, BLOCK_SUBBLOCKS, debug_hooks, gcc_debug_hooks::ignore_block, mark_scope_block_unused(), and TREE_USED.
Referenced by mark_scope_block_unused(), and remove_unused_locals().
|
static |
Allocate and return a new live range information object base on MAP.
References bitmap_initialize(), bitmap_obstack_initialize(), cfun, i, basic_block_def::index, last_basic_block_for_fn, tree_live_info_d::livein, tree_live_info_d::livein_obstack, tree_live_info_d::liveout, tree_live_info_d::liveout_obstack, map, tree_live_info_d::map, tree_live_info_d::num_blocks, tree_live_info_d::stack_top, and tree_live_info_d::work_stack.
Referenced by calculate_live_ranges().
Create a partition view in MAP which includes just partitions which occur in the bitmap ONLY. If WANT_BASES is true, create the base variable map as well.
References BITMAP_ALLOC, bitmap_bit_p, bitmap_set_bit, EXECUTE_IF_SET_IN_BITMAP, gcc_assert, map, NULL, partition_view_fini(), partition_view_init(), and var_map_base_fini().
Referenced by coalesce_ssa_name().
This routine will finalize the view data for MAP based on the partitions set in SELECTED. This is either the same bitmap returned from partition_view_init, or a trimmed down version if some of those partitions were not desired in this view. SELECTED is freed before returning.
References bitmap_count_bits(), BITMAP_FREE, count, EXECUTE_IF_SET_IN_BITMAP, gcc_assert, i, and map.
Referenced by partition_view_bitmap(), and partition_view_normal().
Compress the partition numbers in MAP such that they fall in the range 0..(num_partitions-1) instead of wherever they turned out during the partitioning exercise. This removes any references to unused partitions, thereby allowing bitmaps and other vectors to be much denser. This is implemented such that compaction doesn't affect partitioning. Ie., once partitions are created and possibly merged, running one or more different kind of compaction will not affect the partitions themselves. Their index might change, but all the same variables will still be members of the same partition group. This allows work on reduced sets, and no loss of information when a larger set is later desired. In particular, coalescing can work on partitions which have 2 or more definitions, and then 'recompact' later to include all the single definitions for assignment to program variables.
Set MAP back to the initial state of having no partition view. Return a bitmap which has a bit set for each partition number which is in use in the varmap.
References BITMAP_ALLOC, bitmap_set_bit, free(), has_zero_uses(), map, NULL, NULL_TREE, ssa_name, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, VAR_P, and virtual_operand_p().
Referenced by partition_view_bitmap(), and partition_view_normal().
void partition_view_normal | ( | var_map | map | ) |
Create a partition view which includes all the used partitions in MAP.
References map, partition_view_fini(), partition_view_init(), and var_map_base_fini().
Referenced by gimple_lower_bitint(), and remove_ssa_form().
void remove_unused_locals | ( | void | ) |
Remove local variables that are not referenced in the IL.
References b, BITMAP_ALLOC, bitmap_bit_p, BITMAP_FREE, bitmap_set_bit, cfun, clear_unused_block_pointer(), current_function_decl, DECL_HARD_REGISTER, DECL_INITIAL, DECL_P, DECL_UID, dump_file, dump_flags, dump_scope_blocks(), FOR_EACH_BB_FN, FOR_EACH_EDGE, FOR_EACH_PHI_ARG, get_base_address(), gimple_assign_lhs(), gimple_block(), gimple_call_internal_p(), gimple_call_lhs(), gimple_clobber_p(), gimple_debug_bind_get_value(), gimple_debug_bind_get_var(), gimple_debug_bind_p(), gimple_num_ops(), gimple_op_ptr(), gimple_phi_arg_location(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), i, is_gimple_debug(), is_global_var(), is_used_p(), LOCATION_BLOCK, mark_all_vars_used(), mark_scope_block_unused(), NULL, NULL_TREE, PHI_ARG_INDEX_FROM_USE, polymorphic_ctor_dtor_p(), release_defs(), release_ssa_name(), remove_unused_scope_block_p(), set_ssa_default_def(), loop::simduid, ssa_default_def(), SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_OP_ALL_USES, statistics_counter_event(), basic_block_def::succs, TDF_DETAILS, timevar_pop(), timevar_push(), TREE_CODE, TREE_OPERAND, TREE_USED, unlink_stmt_vdef(), USE_FROM_PTR, usedvars, VAR_P, vec_safe_length(), and virtual_operand_p().
Referenced by execute_function_todo().
Look if the block is dead (by possibly eliminating its dead subblocks) and return true if so. Block is declared dead if: 1) No statements are associated with it. 2) Declares no live variables 3) All subblocks are dead or there is precisely one subblocks and the block has same abstract origin as outer block and declares no variables, so it is pure wrapper. When we are not outputting full debug info, we also eliminate dead variables out of scope blocks to let them to be recycled by GGC and to save copying work done by the inliner.
References BLOCK_CHAIN, BLOCK_NUM_NONLOCALIZED_VARS, BLOCK_ORIGIN, BLOCK_SOURCE_LOCATION, BLOCK_SUBBLOCKS, BLOCK_SUPERCONTEXT, block_ultimate_origin(), BLOCK_VARS, DECL_CHAIN, DECL_HAS_VALUE_EXPR_P, DECL_IGNORED_P, DINFO_LEVEL_NONE, DINFO_LEVEL_NORMAL, DINFO_LEVEL_VERBOSE, gcc_assert, inlined_function_outer_scope_p(), inlined_polymorphic_ctor_dtor_block_p(), is_used_p(), LOCATION_LOCUS, optinfo_wants_inlining_info_p(), remove_unused_scope_block_p(), TREE_CODE, TREE_USED, UNKNOWN_LOCATION, and VAR_P.
Referenced by remove_unused_locals(), and remove_unused_scope_block_p().
Mark VAR as used, so that it'll be preserved during rtl expansion. Returns true if VAR wasn't marked before.
References bitmap_set_bit, DECL_UID, and usedvars.
Referenced by mark_all_vars_used_1().
|
static |
Calculate the initial live on entry vector for SSA_NAME using immediate_use links. Set the live on entry fields in LIVE. Def's are marked temporarily in the liveout vector.
References as_a(), bitmap_set_bit, cfun, ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_IMM_USE_FAST, gimple_bb(), gimple_phi_arg_edge(), basic_block_def::index, is_gimple_debug(), tree_live_info_d::livein, tree_live_info_d::liveout, tree_live_info_d::map, NO_PARTITION, NULL, PHI_ARG_INDEX_FROM_USE, region_contains_p(), ssa_name, SSA_NAME_DEF_STMT, ssa_undefined_value_p(), USE_STMT, and var_to_partition().
Referenced by calculate_live_ranges().
|
static |
VARMAP maintains a mapping from SSA version number to real variables. All SSA_NAMES are divided into partitions. Initially each ssa_name is the only member of it's own partition. Coalescing will attempt to group any ssa_names which occur in a copy or in a PHI node into the same partition. At the end of out-of-ssa, each partition becomes a "real" variable and is rewritten as a compiler variable. The var_map data structure is used to manage these partitions. It allows partitions to be combined, and determines which partition belongs to what ssa_name or variable, and vice versa.
Remove the base table in MAP.
References free(), map, and NULL.
Referenced by delete_var_map(), partition_view_bitmap(), and partition_view_normal().
This function will combine the partitions in MAP for VAR1 and VAR2. It Returns the partition which represents the new partition. If the two partitions cannot be combined, NO_PARTITION is returned.
References gcc_assert, map, NO_PARTITION, SSA_NAME_VERSION, and TREE_CODE.
Referenced by attempt_coalesce().
|
static |
Verify that the info in LIVE matches the current cfg.
References bitmap_bit_p, cfun, ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, gcc_assert, gimple_bb(), gimple_nop_p(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), has_zero_uses(), i, basic_block_def::index, live_on_entry(), map, tree_live_info_d::map, NULL_TREE, num_var_partitions(), partition_to_var(), gphi_iterator::phi(), print_generic_expr(), print_gimple_stmt(), region_contains_p(), ssa_default_def(), SSA_NAME_DEF_STMT, SSA_NAME_VAR, ssa_undefined_value_p(), basic_block_def::succs, TDF_SLIM, VAR_P, and virtual_operand_p().
Referenced by calculate_live_ranges().
|
static |
Referenced by is_used_p(), remove_unused_locals(), and set_is_used().