GCC Middle and Back End API Reference
|
Variables | |
static struct pointer_map_t * | edge_var_maps |
void delete_tree_ssa | ( | void | ) |
Deallocate memory associated with SSA data structures for FNDECL.
References cfun, gimple_df::decls_to_pointers, gimple_df::default_defs, gimple_df::escaped, fini_ssa_operands(), fini_ssanames(), function::gimple_df, gimple_df::modified_noreturn_calls, pointer_map_destroy(), pt_solution_reset(), redirect_edge_var_map_destroy(), and ssa_operands_active().
Referenced by release_function_body(), and rest_of_clean_state().
|
static |
|
static |
Do the actions required to initialize internal data structures used in tree-ssa optimization passes.
References cfun, and init_tree_ssa().
void execute_update_addresses_taken | ( | void | ) |
Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables.
References bitmap_bit_p(), bitmap_empty_p(), bitmap_set_bit(), cfun, function::decl, get_base_address(), gimple_asm_input_op(), gimple_asm_ninputs(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs1_ptr(), gimple_assign_set_lhs(), gimple_assign_set_rhs_from_tree(), gimple_assign_single_p(), gimple_call_arg(), gimple_call_arg_ptr(), gimple_call_num_args(), gimple_debug_bind_get_value_ptr(), gimple_debug_bind_has_value_p(), gimple_debug_bind_p(), gimple_debug_bind_reset_value(), gimple_get_lhs(), gimple_ior_addresses_taken(), gimple_phi_num_args(), gimple_references_memory_p(), gsi_end_p(), gsi_for_stmt(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), integer_zerop(), is_gimple_debug(), function::local_decls, LOOP_CLOSED_SSA, loops_state_satisfies_p(), maybe_optimize_var(), maybe_rewrite_mem_ref_base(), non_rewritable_lvalue_p(), non_rewritable_mem_ref_base(), number_of_loops(), release_defs(), rewrite_into_loop_closed_ssa(), timevar_pop(), timevar_push(), unlink_stmt_vdef(), update_ssa(), update_stmt(), and useless_type_conversion_p().
Referenced by execute_function_todo().
|
static |
Called via walk_tree, look for SSA_NAMEs that have already been released.
References walk_stmt_info::is_lhs.
Referenced by insert_debug_temp_for_var_def().
void flush_pending_stmts | ( | ) |
Add PHI arguments queued in PENDING_STMT list on edge E to edge E->dest.
References add_phi_arg(), edge_def::dest, gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), redirect_edge_var_map_clear(), redirect_edge_var_map_def(), redirect_edge_var_map_location(), and redirect_edge_var_map_vector().
|
static |
Used by redirect_edge_var_map_destroy to free all memory.
References vec_free().
Referenced by redirect_edge_var_map_destroy().
|
static |
void init_tree_ssa | ( | ) |
Initialize global DFA and SSA structures.
References init_ssanames(), pt_solution_reset(), uid_ssaname_map_eq(), and uid_ssaname_map_hash().
void insert_debug_temp_for_var_def | ( | ) |
Insert a DEBUG BIND stmt before the DEF of VAR if VAR is referenced by other DEBUG stmts, and replace uses of the DEF with the newly-created debug temp.
References CDI_DOMINATORS, degenerate_phi_result(), dom_info_available_p(), find_released_ssa_name(), fold_stmt_inplace(), gimple_assign_rhs_to_tree(), gimple_assign_single_p(), gimple_debug_bind_get_value(), gimple_debug_bind_p(), gimple_debug_bind_reset_value(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, gsi_stmt(), is_gimple_assign(), is_gimple_min_invariant(), is_gimple_reg(), memset(), name_registered_for_update_p(), unshare_expr(), update_stmt(), and walk_gimple_op().
void insert_debug_temps_for_defs | ( | ) |
Insert a DEBUG BIND stmt before STMT for each DEF referenced by other DEBUG stmts, and replace uses of the DEF with the newly-created debug temp.
References gsi_stmt(), and insert_debug_temp_for_var_def().
gimple_opt_pass* make_pass_early_warn_uninitialized | ( | ) |
gimple_opt_pass* make_pass_init_datastructures | ( | ) |
gimple_opt_pass* make_pass_update_address_taken | ( | ) |
|
static |
When possible, clear TREE_ADDRESSABLE bit or set DECL_GIMPLE_REG_P bit and mark the variable VAR for conversion into SSA. Return true when updating stmts is required.
References bitmap_bit_p(), bitmap_set_bit(), dump_file, is_gimple_reg(), is_gimple_reg_type(), is_global_var(), and print_generic_expr().
Referenced by execute_update_addresses_taken().
|
static |
If necessary, rewrite the base of the reference tree *TP from a MEM_REF to a plain or converted symbol.
References bitmap_bit_p(), handled_component_p(), int_const_binop(), integer_zerop(), multiple_of_p(), and useless_type_conversion_p().
Referenced by execute_update_addresses_taken().
|
static |
For an lvalue tree LHS return true if it cannot be rewritten into SSA form. Otherwise return true.
References integer_zerop().
Referenced by execute_update_addresses_taken().
|
static |
For a tree REF return its base if it is the base of a MEM_REF that cannot be rewritten into SSA form. Otherwise return NULL_TREE.
References handled_component_p(), integer_zerop(), mem_ref_offset(), multiple_of_p(), tree_to_double_int(), and useless_type_conversion_p().
Referenced by execute_update_addresses_taken().
void redirect_edge_var_map_add | ( | ) |
Add a mapping with PHI RESULT and PHI DEF associated with edge E.
References _edge_var_map::def, _edge_var_map::locus, pointer_map_create(), pointer_map_insert(), _edge_var_map::result, vec_safe_push(), and vec_safe_reserve().
void redirect_edge_var_map_clear | ( | ) |
Clear the var mappings in edge E.
References pointer_map_contains(), and vec_free().
void redirect_edge_var_map_destroy | ( | void | ) |
Clear the edge variable mappings.
References free_var_map_entry(), pointer_map_destroy(), and pointer_map_traverse().
Referenced by delete_tree_ssa().
void redirect_edge_var_map_dup | ( | ) |
Duplicate the redirected var mappings in OLDE in NEWE. Since we can't remove a mapping, let's just duplicate it. This assumes a pointer_map can have multiple edges mapping to the same var_map (many to one mapping), since we don't remove the previous mappings.
References pointer_map_contains(), pointer_map_insert(), vec_safe_copy(), and vec_safe_reserve().
edge_var_map_vector* redirect_edge_var_map_vector | ( | ) |
Return the variable mappings for a given edge. If there is none, return NULL.
References pointer_map_contains().
void release_defs_bitset | ( | ) |
Delete SSA DEFs for SSA versions in the TOREMOVE bitmap, removing dominated stmts before their dominators, so that release_ssa_defs stands a chance of propagating DEFs into debug bind stmts.
References bitmap_bit_p(), bitmap_clear_bit(), bitmap_empty_p(), walk_stmt_info::gsi, gsi_for_stmt(), gsi_remove(), is_gimple_debug(), release_defs(), and remove_phi_node().
void reset_debug_uses | ( | ) |
Reset all debug stmts that use SSA_NAME(s) defined in STMT.
References gimple_debug_bind_p(), gimple_debug_bind_reset_value(), and update_stmt().
edge ssa_redirect_edge | ( | ) |
Remove the corresponding arguments from the PHI nodes in E's destination block and redirect it to DEST. Return redirected edge. The list of removed arguments is stored in a vector accessed through edge_var_maps.
References edge_def::dest, edge_def::dest_idx, gimple_phi_arg_def(), gimple_phi_arg_location(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), redirect_edge_succ_nodup(), redirect_edge_var_map_add(), and redirect_edge_var_map_clear().
tree target_for_debug_bind | ( | ) |
Given a tree for an expression for which we might want to emit locations or values in debug information (generally a variable, but we might deal with other kinds of trees in the future), return the tree that should be used as the variable of a DEBUG_BIND STMT or VAR_LOCATION INSN or NOTE. Return NULL if VAR is not to be tracked.
References is_gimple_reg_type().
Referenced by dv_onepart_p(), expand_debug_expr(), expand_gimple_basic_block(), insert_debug_decl_map(), insert_init_debug_bind(), insert_phi_nodes_for(), maybe_register_def(), rewrite_stmt(), sra_ipa_reset_debug_stmts(), use_type(), and vt_add_function_parameter().
tree tree_ssa_strip_useless_type_conversions | ( | ) |
Strip conversions from EXP according to tree_ssa_useless_type_conversion and return the resulting expression.
References exp(), and tree_ssa_useless_type_conversion().
bool tree_ssa_useless_type_conversion | ( | ) |
Return true if EXPR is a useless type conversion, otherwise return false.
References useless_type_conversion_p().
bool types_compatible_p | ( | ) |
Return true if a conversion from either type of TYPE1 and TYPE2 to the other is not required. Otherwise return false.
References useless_type_conversion_p().
|
static |
Return true if the DECL_UID in both trees are equal.
Referenced by init_tree_ssa().
|
static |
Hash a tree in a uid_decl_map.
Referenced by init_tree_ssa().
bool useless_type_conversion_p | ( | ) |
Return true if the conversion from INNER_TYPE to OUTER_TYPE is a useless type conversion, otherwise return false. This function implicitly defines the middle-end type system. With the notion of 'a < b' meaning that useless_type_conversion_p (a, b) holds and 'a > b' meaning that useless_type_conversion_p (b, a) holds, the following invariants shall be fulfilled: 1) useless_type_conversion_p is transitive. If a < b and b < c then a < c. 2) useless_type_conversion_p is not symmetric. From a < b does not follow a > b. 3) Types define the available set of operations applicable to values. A type conversion is useless if the operations for the target type is a subset of the operations for the source type. For example casts to void* are useless, casts from void* are not (void* can't be dereferenced or offsetted, but copied, hence its set of operations is a strict subset of that of all other data pointer types). Casts to const T* are useless (can't be written to), casts from const T* to T* are not.
References comp_type_attributes(), prototype_p(), tree_int_cst_equal(), and useless_type_conversion_p().
|
static |
Return true if the definition of SSA_NAME at block BB is malformed. STMT is the statement where SSA_NAME is created. DEFINITION_BLOCK is an array of basic blocks indexed by SSA_NAME version numbers. If DEFINITION_BLOCK[SSA_NAME_VERSION] is set, it means that the block in that array slot contains the definition of SSA_NAME. IS_VIRTUAL is true if SSA_NAME is created by a VDEF.
References error(), basic_block_def::index, print_generic_expr(), print_gimple_stmt(), and verify_ssa_name().
Referenced by verify_ssa().
|
static |
Return true if any of the arguments for PHI node PHI at block BB is malformed. DEFINITION_BLOCK is an array of basic blocks indexed by SSA_NAME version numbers. If DEFINITION_BLOCK[SSA_NAME_VERSION] is set, it means that the block in that array slot contains the definition of SSA_NAME.
References edge_def::dest, error(), edge_def::flags, gimple_phi_arg_imm_use_ptr(), gimple_phi_num_args(), gimple_phi_result(), handled_component_p(), basic_block_def::index, is_gimple_min_invariant(), basic_block_def::preds, print_generic_stmt(), print_gimple_stmt(), edge_def::src, verify_ssa_name(), verify_use(), and virtual_operand_p().
Referenced by verify_ssa().
DEBUG_FUNCTION void verify_ssa | ( | ) |
Verify common invariants in the SSA web. TODO: verify the variable annotations.
References edge_def::aux, bitmap_clear(), bitmap_set_bit(), calculate_dominance_info(), CDI_DOMINATORS, cfun, edge_def::dest, dom_info_state(), DOM_NONE, error(), free(), free_dominance_info(), gimple_bb(), gimple_debug_bind_has_value_p(), gimple_debug_bind_p(), gimple_modified_p(), gimple_nop_p(), gimple_phi_result(), walk_stmt_info::gsi, gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, internal_error(), need_ssa_update_p(), basic_block_def::preds, print_gimple_stmt(), set_dom_info_availability(), edge_def::src, timevar_pop(), timevar_push(), verify_def(), verify_phi_args(), verify_ssa_name(), verify_ssa_operands(), verify_use(), and virtual_operand_p().
|
static |
Return true if SSA_NAME is malformed and mark it visited. IS_VIRTUAL is true if this SSA_NAME was found inside a virtual operand.
References cfun, error(), gimple_nop_p(), gimple_vop(), and virtual_operand_p().
Referenced by verify_def(), verify_phi_args(), and verify_ssa().
|
static |
Return true if the use of SSA_NAME at statement STMT in block BB is malformed. DEF_BB is the block where SSA_NAME was found to be created. IDOM contains immediate dominator information for the flowgraph. CHECK_ABNORMAL is true if the caller wants to check whether this use is flowing through an abnormal edge (only used when checking PHI arguments). If NAMES_DEFINED_IN_BB is not NULL, it contains a bitmap of ssa names that are defined before STMT in basic block BB.
References bitmap_bit_p(), CDI_DOMINATORS, dominated_by_p(), error(), gimple_nop_p(), basic_block_def::index, ssa_use_operand_d::loc, ssa_use_operand_d::prev, print_generic_expr(), print_gimple_stmt(), ssa_use_operand_d::ssa_name, ssa_use_operand_d::use, and verify_imm_links().
Referenced by verify_phi_args(), and verify_ssa().
void walk_use_def_chains | ( | tree | var, |
walk_use_def_chains_fn | fn, | ||
void * | data, | ||
bool | is_dfs | ||
) |
Walk use-def chains starting at the SSA variable VAR. Call function FN at each reaching definition found. FN takes three arguments: VAR, its defining statement (DEF_STMT) and a generic pointer to whatever state information that FN may want to maintain (DATA). FN is able to stop the walk by returning true, otherwise in order to continue the walk, FN should return false. Note, that if DEF_STMT is a PHI node, the semantics are slightly different. The first argument to FN is no longer the original variable VAR, but the PHI argument currently being examined. If FN wants to get at VAR, it should call PHI_RESULT (PHI). If IS_DFS is true, this function will: 1- walk the use-def chains for all the PHI arguments, and, 2- call (*FN) (ARG, PHI, DATA) on all the PHI arguments. If IS_DFS is false, the two steps above are done in reverse order (i.e., a breadth-first search).
References pointer_set_create(), pointer_set_destroy(), visited, and walk_use_def_chains_1().
|
static |
Internal helper for walk_use_def_chains. VAR, FN and DATA are as described in walk_use_def_chains. VISITED is a pointer set used to mark visited SSA_NAMEs to avoid infinite loops. We used to have a bitmap for this to just mark SSA versions we had visited. But non-sparse bitmaps are way too expensive, while sparse bitmaps may cause quadratic behavior. IS_DFS is true if the caller wants to perform a depth-first search when visiting PHI nodes. A DFS will visit each PHI argument and call FN after each one. Otherwise, all the arguments are visited first and then FN is called with each of the visited arguments in a separate pass.
References gimple_phi_arg_def(), gimple_phi_num_args(), and pointer_set_insert().
Referenced by walk_use_def_chains().
void warn_uninit | ( | enum opt_code | wc, |
tree | t, | ||
tree | expr, | ||
tree | var, | ||
const char * | gmsgid, | ||
void * | data | ||
) |
Emit warnings for uninitialized variables. This is done in two passes. The first pass notices real uses of SSA names with undefined values. Such uses are unconditionally uninitialized, and we can be certain that such a use is a mistake. This pass is run before most optimizations, so that we catch as many as we can. The second pass follows PHI nodes to find uses that are potentially uninitialized. In this case we can't necessarily prove that the use is really uninitialized. This pass is run after most optimizations, so that we thread as many jumps and possible, and delete as much dead code as possible, in order to reduce false positives. We also look again for plain uninitialized variables, since optimization may have changed conditionally uninitialized to unconditionally uninitialized.
Emit a warning for EXPR based on variable VAR at the point in the program T, an SSA_NAME, is used being uninitialized. The exact warning text is in MSGID and LOCUS may contain a location or be null. WC is the warning code.
References cfun, function::decl, expand_location(), function::function_end_locus, gimple_assign_rhs1(), gimple_assign_single_p(), gimple_has_location(), gimple_location(), gimple_no_warning_p(), inform(), line_table, ssa_undefined_value_p(), and warning_at().
Referenced by warn_uninitialized_phi(), and warn_uninitialized_vars().
unsigned int warn_uninitialized_vars | ( | ) |
|
static |
@verbatim Miscellaneous SSA utility functions.
Copyright (C) 2001-2013 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/.
Pointer map of variable mappings, keyed by edge.