GCC Middle and Back End API Reference
|
Data Structures | |
struct | def_blocks_d |
struct | mark_def_sites_global_data |
struct | common_info_d |
struct | var_info_d |
struct | var_info_hasher |
struct | ssa_name_info |
struct | dom_dfsnum |
Typedefs | |
typedef struct def_blocks_d * | def_blocks_p |
typedef struct common_info_d * | common_info_p |
typedef struct var_info_d * | var_info_p |
typedef struct ssa_name_info * | ssa_name_info_p |
Enumerations | |
enum | rewrite_mode { REWRITE_ALL, REWRITE_UPDATE } |
Variables | |
static vec< tree > | block_defs_stack |
static sbitmap | old_ssa_names |
static sbitmap | new_ssa_names |
static sbitmap | interesting_blocks |
static bitmap | names_to_release |
static vec< gimple_vec > | phis_to_rewrite |
static bitmap | blocks_with_phis_to_rewrite |
static struct function * | update_ssa_initialized_fn = NULL |
static hash_table < var_info_hasher > | var_infos |
static vec< ssa_name_info_p > | info_for_ssa_name |
static unsigned | current_info_for_ssa_name_age |
static bitmap_obstack | update_ssa_obstack |
static bitmap | blocks_to_update |
static bitmap | symbols_to_rename_set |
static vec< tree > | symbols_to_rename |
typedef struct common_info_d* common_info_p |
The information associated with decls and SSA names.
typedef struct def_blocks_d* def_blocks_p |
typedef struct ssa_name_info* ssa_name_info_p |
The information associated with names.
typedef struct var_info_d* var_info_p |
The information associated with decls.
enum rewrite_mode |
The main entry point to the SSA renamer (rewrite_blocks) may be called several times to do different, but related, tasks. Initially, we need it to rename the whole program into SSA form. At other times, we may need it to only rename into SSA newly exposed symbols. Finally, we can also call it to incrementally fix an already built SSA web.
|
static |
Add a new mapping NEW_TREE -> OLD REPL_TBL. Every entry N_i in REPL_TBL represents the set of names O_1 ... O_j replaced by N_i. This is used by update_ssa and its helpers to introduce new SSA names in an already formed SSA web.
References add_to_repl_tbl(), bitmap_ior_into(), bitmap_set_bit(), is_new_name(), names_replaced_by(), and sbitmap_resize().
Referenced by create_new_def_for(), and insert_phi_nodes_for().
|
inlinestatic |
Add OLD to REPL_TBL[NEW_TREE].SET.
References bitmap_set_bit(), get_ssa_name_ann(), and ssa_name_info::repl_set.
Referenced by add_new_name_mapping().
|
static |
Clears info for SSA names.
References current_info_for_ssa_name_age.
Referenced by delete_update_ssa().
|
static |
Compares two entries of type struct dom_dfsnum by dfs_num field. Callback for qsort.
References dom_dfsnum::dfs_num.
Referenced by prune_unused_phi_nodes().
tree create_new_def_for | ( | ) |
Create a new name for OLD_NAME in statement STMT and replace the operand pointed to by DEF_P with the newly created name. If DEF_P is NULL then STMT should be a GIMPLE assignment. Return the new name and register the replacement mapping <NEW, OLD> in update_ssa's tables.
References add_new_name_mapping(), bb_has_abnormal_pred(), cfun, duplicate_ssa_name(), get_ssa_name_ann(), gimple_assign_set_lhs(), gimple_bb(), ssa_name_info::info, init_update_ssa(), timevar_pop(), and timevar_push().
DEBUG_FUNCTION void debug_currdefs | ( | ) |
Dump the current reaching definition of every symbol to stderr.
References dump_currdefs().
DEBUG_FUNCTION void debug_decl_set | ( | ) |
Dump bitmap SET (assumed to contain VAR_DECLs) to FILE.
References dump_decl_set().
void debug_def_blocks | ( | void | ) |
void debug_defs_stack | ( | int | ) |
DEBUG_FUNCTION void debug_defs_stack | ( | ) |
Dump the renaming stack (block_defs_stack) to stderr. Traverse the stack up to a maximum of N levels. If N is -1, the whole stack is dumped. New levels are created when the dominator tree traversal used for renaming enters a new sub-tree.
References dump_defs_stack().
void debug_names_replaced_by | ( | tree | ) |
DEBUG_FUNCTION void debug_names_replaced_by | ( | ) |
Dump all the names replaced by NAME to stderr.
References dump_names_replaced_by().
DEBUG_FUNCTION void debug_tree_ssa | ( | ) |
Dump SSA information to stderr.
References dump_tree_ssa().
DEBUG_FUNCTION void debug_tree_ssa_stats | ( | ) |
Dump SSA statistics on stderr.
References dump_tree_ssa_stats().
DEBUG_FUNCTION void debug_update_ssa | ( | ) |
Dump SSA update information to stderr.
References dump_update_ssa().
DEBUG_FUNCTION void debug_var_infos | ( | ) |
Dump the VAR_INFOS hash table on stderr.
References dump_var_infos().
int debug_var_infos_r | ( | ) |
Callback for htab_traverse to dump the VAR_INFOS hash table.
References bitmap_print(), dump_flags, var_info_d::info, print_generic_expr(), and var_info_d::var.
Referenced by dump_var_infos().
void delete_update_ssa | ( | void | ) |
Deallocate data structures used for incremental SSA updates.
References clear_ssa_name_info(), fini_ssa_renamer(), phis, release_ssa_name(), and sbitmap_free().
Referenced by copy_loop_before(), slpeel_tree_peel_loop_to_edge(), and update_ssa().
void dump_currdefs | ( | FILE * | ) |
Referenced by debug_currdefs(), and dump_tree_ssa().
void dump_currdefs | ( | ) |
Dump the current reaching definition of every symbol to FILE.
References get_common_info(), and print_generic_expr().
void dump_decl_set | ( | ) |
Dump bitmap SET (assumed to contain VAR_DECLs) to FILE.
Referenced by debug_decl_set(), dump_points_to_solution(), and dump_update_ssa().
void dump_defs_stack | ( | FILE * | , |
int | |||
) |
Referenced by debug_defs_stack(), and dump_tree_ssa().
void dump_defs_stack | ( | ) |
Dump the renaming stack (block_defs_stack) to FILE. Traverse the stack up to a maximum of N levels. If N is -1, the whole stack is dumped. New levels are created when the dominator tree traversal used for renaming enters a new sub-tree.
References is_gimple_reg(), and print_generic_expr().
void dump_names_replaced_by | ( | FILE * | , |
tree | |||
) |
Referenced by debug_names_replaced_by(), and dump_update_ssa().
void dump_names_replaced_by | ( | ) |
Dump all the names replaced by NAME to FILE.
References names_replaced_by(), and print_generic_expr().
void dump_tree_ssa | ( | FILE * | ) |
Prototypes for debugging functions.
Referenced by debug_tree_ssa().
void dump_tree_ssa | ( | ) |
Dump SSA information to FILE.
References current_function_decl, lang_hooks::decl_printable_name, dump_currdefs(), dump_defs_stack(), dump_tree_ssa_stats(), and dump_var_infos().
void dump_tree_ssa_stats | ( | FILE * | ) |
Referenced by debug_tree_ssa_stats(), dump_tree_ssa(), and rewrite_blocks().
void dump_tree_ssa_stats | ( | ) |
Dump SSA statistics on FILE.
References htab_statistics(), and hash_table< Descriptor, Allocator >::is_created().
void dump_update_ssa | ( | FILE * | ) |
Referenced by debug_update_ssa(), and update_ssa().
void dump_update_ssa | ( | ) |
Dump SSA update information to FILE.
References bitmap_empty_p(), bitmap_first_set_bit(), cfun, dump_decl_set(), dump_names_replaced_by(), need_ssa_update_p(), and print_generic_expr().
void dump_var_infos | ( | FILE * | ) |
Referenced by debug_var_infos(), and dump_tree_ssa().
void dump_var_infos | ( | ) |
Dump the VAR_INFOS hash table on FILE.
References debug_var_infos_r(), hash_table< Descriptor, Allocator >::is_created(), and hash_table< Descriptor, Allocator >::traverse().
|
staticread |
Return the set of blocks where variable VAR is defined and the blocks where VAR is live on entry (livein). Return NULL, if no entry is found in DEF_BLOCKS.
References def_blocks_d::def_blocks, and get_common_info().
Referenced by insert_phi_nodes_for(), and insert_updated_phi_nodes_for().
|
static |
Among the intervals starting at the N points specified in DEFS, find the one that contains S, and return its bb_index.
References dom_dfsnum::bb_index, and dom_dfsnum::dfs_num.
Referenced by prune_unused_phi_nodes().
|
static |
Deallocate internal data structures used by the renamer.
References bitmap_obstack_release(), cfun, hash_table< Descriptor, Allocator >::dispose(), function::gimple_df, gimple_df::in_ssa_p, hash_table< Descriptor, Allocator >::is_created(), gimple_df::rename_vops, and gimple_df::ssa_renaming_needed.
Referenced by delete_update_ssa(), and rewrite_into_ssa().
|
inlinestatic |
Get access to the auxiliar information stored per SSA name or decl.
References get_ssa_name_ann(), get_var_info(), var_info_d::info, and ssa_name_info::info.
Referenced by dump_currdefs(), find_def_blocks_for(), get_current_def(), get_reaching_def(), mark_use_interesting(), register_new_def(), register_new_update_single(), rewrite_debug_stmt_uses(), rewrite_leave_block(), rewrite_update_leave_block(), set_current_def(), set_def_block(), and set_livein_block().
tree get_current_def | ( | ) |
Return the current definition for VAR.
References get_common_info().
|
staticread |
Return the set of blocks where variable VAR is defined and the blocks where VAR is live on entry (livein). If no entry is found in DEF_BLOCKS, a new one is created and returned.
References def_blocks_d::def_blocks, def_blocks_d::livein_blocks, and def_blocks_d::phi_blocks.
Referenced by mark_use_interesting(), rewrite_debug_stmt_uses(), set_def_block(), and set_livein_block().
|
static |
Perform a depth-first traversal of the dominator tree looking for variables to rename. BB is the block where to start searching. Renaming is a five step process: 1- Every definition made by PHI nodes at the start of the blocks is registered as the current definition for the corresponding variable. 2- Every statement in BB is rewritten. USE and VUSE operands are rewritten with their corresponding reaching definition. DEF and VDEF targets are registered as new definitions. 3- All the PHI nodes in successor blocks of BB are visited. The argument corresponding to BB is replaced with its current reaching definition. 4- Recursively rewrite every dominator child block of BB. 5- Restore (in reverse order) the current reaching definition for every new definition introduced in this block. This is done so that when we return from the recursive call, all the current reaching definitions are restored to the names that were valid in the dominator parent of BB.
Return the current definition for variable VAR. If none is found, create a new SSA name to act as the zeroth definition for VAR.
References cfun, get_common_info(), get_or_create_ssa_default_def(), and var_info_d::info.
Referenced by maybe_replace_use(), rewrite_add_phi_arguments(), rewrite_stmt(), and rewrite_update_phi_arguments().
|
inlinestatic |
Get the information associated with NAME.
References ssa_name_info::age, current_info_for_ssa_name_age, ssa_name_info::info, len, NEED_PHI_STATE_UNKNOWN, and ssa_name_info::repl_set.
Referenced by add_to_repl_tbl(), create_new_def_for(), get_common_info(), maybe_replace_use_in_debug_stmt(), names_replaced_by(), and update_ssa().
|
inlinestatic |
Return and allocate the auxiliar information for DECL.
References hash_table< Descriptor, Allocator >::find_slot_with_hash(), and var_info_d::var.
Referenced by get_common_info(), maybe_replace_use_in_debug_stmt(), and update_ssa().
|
static |
Dump statistics for the hash table HTAB.
References hash_table< Descriptor, Allocator >::collisions(), hash_table< Descriptor, Allocator >::elements(), and hash_table< Descriptor, Allocator >::size().
Referenced by dump_dominator_optimization_stats(), and dump_tree_ssa_stats().
|
static |
Initialize internal data needed during renaming.
References bitmap_obstack_initialize(), cfun, hash_table< Descriptor, Allocator >::create(), function::gimple_df, gimple_df::in_ssa_p, hash_table< Descriptor, Allocator >::is_created(), function::local_decls, and vec_safe_length().
Referenced by rewrite_into_ssa().
|
static |
Initialize data structures used for incremental SSA updates.
References bitmap_clear(), bitmap_obstack_initialize(), and sbitmap_alloc().
Referenced by create_new_def_for(), and update_ssa().
|
static |
Cleans up the REWRITE_THIS_STMT and REGISTER_DEFS_IN_THIS_STMT flags for all statements in basic block BB.
References gimple_modified_p(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), set_register_defs(), and set_rewrite_uses().
Referenced by mark_block_for_update().
|
static |
Insert PHI nodes at the dominance frontier of blocks with variable definitions. DFS contains the dominance frontier information for the flowgraph.
References compute_idf(), hash_table< Descriptor, Allocator >::elements(), var_info_d::info, insert_phi_nodes_compare_var_infos(), insert_phi_nodes_for(), NEED_PHI_STATE_NO, timevar_pop(), timevar_push(), and var_info_d::var.
Referenced by rewrite_into_ssa().
|
static |
Sort var_infos after DECL_UID of their var.
References var_info_d::var.
Referenced by insert_phi_nodes().
|
static |
Insert PHI nodes for variable VAR using the iterated dominance frontier given in PHI_INSERTION_POINTS. If UPDATE_P is true, this function assumes that the caller is incrementally updating the existing SSA form, in which case VAR may be an SSA name instead of a symbol. PHI_INSERTION_POINTS is updated to reflect nodes that already had a PHI node for VAR. On exit, only the nodes that received a PHI node for VAR will be present in PHI_INSERTION_POINTS.
References add_new_name_mapping(), add_phi_arg(), bitmap_and_compl_into(), create_phi_node(), def_blocks_d::def_blocks, dump_file, dump_flags, duplicate_ssa_name(), find_def_blocks_for(), gsi_after_labels(), gsi_insert_before(), GSI_SAME_STMT, def_blocks_d::livein_blocks, mark_block_for_update(), mark_phi_for_rewrite(), def_blocks_d::phi_blocks, basic_block_def::preds, print_generic_expr(), prune_unused_phi_nodes(), set_register_defs(), si, and target_for_debug_bind().
Referenced by insert_phi_nodes(), and insert_updated_phi_nodes_for().
|
static |
Sort symbols_to_rename after their DECL_UID.
Referenced by update_ssa().
|
static |
Insert new PHI nodes to replace VAR. DFS contains dominance frontier information. BLOCKS is the set of blocks to be updated. This is slightly different than the regular PHI insertion algorithm. The value of UPDATE_FLAGS controls how PHI nodes for real names (i.e., GIMPLE registers) are inserted: - If UPDATE_FLAGS == TODO_update_ssa, we are only interested in PHI nodes inside the region affected by the block that defines VAR and the blocks that define all its replacements. All these definition blocks are stored in DEF_BLOCKS[VAR]->DEF_BLOCKS. First, we compute the entry point to the region (ENTRY). This is given by the nearest common dominator to all the definition blocks. When computing the iterated dominance frontier (IDF), any block not strictly dominated by ENTRY is ignored. We then call the standard PHI insertion algorithm with the pruned IDF. - If UPDATE_FLAGS == TODO_update_ssa_full_phi, the IDF for real names is not pruned. PHI nodes are inserted at every IDF block.
References bitmap_copy(), bitmap_empty_p(), bitmap_ior_into(), bitmap_set_bit(), CDI_DOMINATORS, compute_idf(), def_blocks_d::def_blocks, dominated_by_p(), find_def_blocks_for(), basic_block_def::index, insert_phi_nodes_for(), is_old_name(), marked_for_renaming(), nearest_common_dominator_for_set(), basic_block_def::preds, and edge_def::src.
Referenced by update_ssa().
|
inlinestatic |
Return true if NAME is in NEW_SSA_NAMES.
References bitmap_bit_p().
Referenced by add_new_name_mapping(), mark_def_interesting(), maybe_register_def(), name_registered_for_update_p(), and rewrite_update_enter_block().
|
inlinestatic |
Return true if NAME is in OLD_SSA_NAMES.
References bitmap_bit_p().
Referenced by insert_updated_phi_nodes_for(), maybe_register_def(), maybe_replace_use(), maybe_replace_use_in_debug_stmt(), name_registered_for_update_p(), rewrite_update_enter_block(), and rewrite_update_phi_arguments().
gimple_opt_pass* make_pass_build_ssa | ( | ) |
|
static |
Mark block BB as interesting for update_ssa.
References bitmap_set_bit(), basic_block_def::index, and initialize_flags_in_bb().
Referenced by insert_phi_nodes_for(), mark_use_interesting(), prepare_block_for_update(), and prepare_def_site_for().
|
static |
Mark the definition of VAR at STMT and BB as interesting for the renamer. BLOCKS is the set of blocks that need updating.
References bitmap_bit_p(), basic_block_def::index, is_new_name(), names_replaced_by(), set_def_block(), and set_register_defs().
Referenced by prepare_block_for_update(), and prepare_def_site_for().
|
static |
Mark the definition site blocks for each variable, so that we know where the variable is actually live. The INTERESTING_BLOCKS global will be filled in with all the blocks that should be processed by the renamer. It is assumed that the caller has already initialized and zeroed it.
References dom_walk_data::after_dom_children, dom_walk_data::before_dom_children, dom_walk_data::block_local_data_size, CDI_DOMINATORS, fini_walk_dominator_tree(), dom_walk_data::global_data, init_walk_dominator_tree(), dom_walk_data::initialize_block_local_data, mark_def_sites_global_data::kills, mark_def_sites_block(), and walk_dominator_tree().
Referenced by rewrite_into_ssa().
|
static |
Call back for walk_dominator_tree used to collect definition sites for every variable in the function. For every statement S in block BB: 1- Variables defined by S in the DEFS of S are marked in the bitmap KILLS. 2- If S uses a variable VAR and there is no preceding kill of VAR, then it is marked in the LIVEIN_BLOCKS bitmap associated with VAR. This information is used to determine which variables are live across block boundaries to reduce the number of PHI nodes we create.
References bitmap_bit_p(), bitmap_set_bit(), basic_block_def::index, is_gimple_debug(), register_defs_p(), rewrite_uses_p(), set_def_block(), set_livein_block(), set_register_defs(), set_rewrite_uses(), and update_stmt().
Referenced by mark_def_sites_block().
|
static |
Block processing routine for mark_def_sites. Clear the KILLS bitmap at the start of each block, and call mark_def_sites for each statement.
References bitmap_clear(), dom_walk_data::global_data, gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), mark_def_sites_global_data::kills, and mark_def_sites().
Referenced by mark_def_site_blocks().
|
static |
|
static |
Marks phi node PHI in basic block BB for rewrite.
References bitmap_set_bit(), basic_block_def::index, phis, rewrite_uses_p(), and set_rewrite_uses().
Referenced by insert_phi_nodes_for(), and mark_use_interesting().
|
inlinestatic |
Mark the use of VAR at STMT and BB as interesting for the renamer. INSERT_PHI_P is true if we are going to insert new PHI nodes.
References bitmap_bit_p(), def_blocks_d::def_blocks, get_common_info(), get_def_blocks_for(), gimple_bb(), basic_block_def::index, is_gimple_debug(), mark_block_for_update(), mark_phi_for_rewrite(), set_livein_block(), and set_rewrite_uses().
Referenced by prepare_block_for_update(), and prepare_use_sites_for().
void mark_virtual_operands_for_renaming | ( | ) |
Mark virtual operands of FN for renaming by update_ssa.
|
static |
Return true if SYM is marked for renaming.
References bitmap_bit_p().
Referenced by insert_updated_phi_nodes_for(), maybe_register_def(), maybe_replace_use(), maybe_replace_use_in_debug_stmt(), rewrite_update_enter_block(), rewrite_update_phi_arguments(), and update_ssa().
|
inlinestatic |
If the operand pointed to by DEF_P is an SSA name in NEW_SSA_NAMES or OLD_SSA_NAMES, or if it is a symbol marked for renaming, register it as the current definition for the names replaced by DEF_P.
References edge_def::dest, edge_def::flags, gsi_bb(), gsi_insert_after(), gsi_insert_on_edge_immediate(), gsi_one_before_end_p(), GSI_SAME_STMT, is_new_name(), is_old_name(), make_ssa_name(), marked_for_renaming(), names_replaced_by(), register_new_update_set(), register_new_update_single(), single_pred_p(), stmt_ends_bb_p(), basic_block_def::succs, and target_for_debug_bind().
Referenced by rewrite_update_stmt().
|
inlinestatic |
If the operand pointed to by USE_P is a name in OLD_SSA_NAMES or it is a symbol marked for renaming, replace it with USE_P's current reaching definition.
References get_reaching_def(), is_old_name(), and marked_for_renaming().
Referenced by rewrite_update_stmt().
|
inlinestatic |
Same as maybe_replace_use, but without introducing default stmts, returning false to indicate a need to do so.
References get_ssa_name_ann(), get_var_info(), var_info_d::info, ssa_name_info::info, is_old_name(), and marked_for_renaming().
Referenced by rewrite_update_stmt().
bool name_registered_for_update_p | ( | ) |
Return true if name N has been registered in the replacement table.
References cfun, is_new_name(), and is_old_name().
|
inlinestatic |
Return the names replaced by NEW_TREE (i.e., REPL_TBL[NEW_TREE].SET).
References get_ssa_name_ann(), and ssa_name_info::repl_set.
Referenced by add_new_name_mapping(), dump_names_replaced_by(), mark_def_interesting(), maybe_register_def(), and rewrite_update_enter_block().
bool need_ssa_update_p | ( | ) |
Return true if there is any work to be done by update_ssa for function FN.
|
static |
Do a dominator walk starting at BB processing statements that reference symbols in SSA operands. This is very similar to mark_def_sites, but the scan handles statements whose operands may already be SSA names. If INSERT_PHI_P is true, mark those uses as live in the corresponding block. This is later used by the PHI placement algorithm to make PHI pruning decisions. FIXME. Most of this would be unnecessary if we could associate a symbol to all the SSA names that reference it. But that sounds like it would be expensive to maintain. Still, it would be interesting to see if it makes better sense to do that.
References CDI_DOMINATORS, cfun, first_dom_son(), function::gimple_df, gimple_phi_result(), gimple_vdef(), gimple_vuse(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), mark_block_for_update(), mark_def_interesting(), mark_for_renaming(), mark_use_interesting(), next_dom_son(), basic_block_def::preds, gimple_df::rename_vops, si, edge_def::src, and virtual_operand_p().
Referenced by update_ssa().
|
static |
Helper for prepare_names_to_update. Mark the definition site for NAME as interesting. BLOCKS and INSERT_PHI_P are as in prepare_names_to_update.
References bitmap_bit_p(), gimple_bb(), basic_block_def::index, mark_block_for_update(), and mark_def_interesting().
Referenced by prepare_names_to_update().
|
static |
Mark definition and use sites of names in NEW_SSA_NAMES and OLD_SSA_NAMES. INSERT_PHI_P is true if the caller wants to insert PHI nodes for newly created names.
References bitmap_bit_p(), bitmap_clear_bit(), prepare_def_site_for(), and prepare_use_sites_for().
Referenced by update_ssa().
|
static |
Helper for prepare_names_to_update. Mark all the use sites for NAME as interesting. BLOCKS and INSERT_PHI_P are as in prepare_names_to_update.
References gimple_bb(), gimple_phi_arg_edge(), mark_use_interesting(), and edge_def::src.
Referenced by prepare_names_to_update().
|
static |
Clean bits from PHIS for phi nodes whose value cannot be used in USES. KILLS is a bitmap of blocks where the value is defined before any use.
References bb_dom_dfs_in(), bb_dom_dfs_out(), dom_dfsnum::bb_index, bitmap_and_compl(), bitmap_and_compl_into(), bitmap_bit_p(), bitmap_clear(), bitmap_copy(), bitmap_count_bits(), bitmap_empty_p(), bitmap_ior(), bitmap_set_bit(), CDI_DOMINATORS, cmp_dfsnum(), defs, dom_dfsnum::dfs_num, find_dfsnum_interval(), free(), get_immediate_dominator(), basic_block_def::index, basic_block_def::preds, edge_def::src, and worklist.
Referenced by insert_phi_nodes_for().
|
inlinestatic |
Return true if the DEFs created by statement STMT should be registered when marking new definition sites. This is slightly different than rewrite_uses_p: it's used by update_ssa to distinguish statements that need to have both uses and defs processed from those that only need to have their defs processed. Statements that define new SSA names only need to have their defs registered, but they don't need to have their uses renamed.
References GF_PLF_1, and gimple_plf().
Referenced by mark_def_sites(), rewrite_stmt(), rewrite_update_enter_block(), and rewrite_update_stmt().
|
static |
Push SYM's current reaching definition into BLOCK_DEFS_STACK and register DEF (an SSA_NAME) to be a new definition for SYM.
References get_common_info(), var_info_d::info, is_gimple_reg(), and NEED_PHI_STATE_NO.
Referenced by rewrite_enter_block(), and rewrite_stmt().
|
inlinestatic |
Register NEW_NAME to be the new reaching definition for all the names in OLD_NAMES. Used by the incremental SSA update routines to replace old SSA names with new ones.
References register_new_update_single().
Referenced by maybe_register_def(), and rewrite_update_enter_block().
|
inlinestatic |
Register NEW_NAME to be the new reaching definition for OLD_NAME.
References get_common_info(), and var_info_d::info.
Referenced by maybe_register_def(), register_new_update_set(), and rewrite_update_enter_block().
void release_ssa_name_after_update_ssa | ( | ) |
Mark NAME to be released after update_ssa has finished.
References bitmap_set_bit(), and cfun.
|
static |
SSA Rewriting Step 3. Visit all the successor blocks of BB looking for PHI nodes. For every PHI node found, add a new argument containing the current reaching definition for the variable and the edge through which that definition is reaching the PHI node.
References add_phi_arg(), edge_def::dest, get_reaching_def(), gimple_location(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), basic_block_def::succs, and virtual_operand_p().
Referenced by rewrite_enter_block().
|
static |
Rewrite the actual blocks, statements, and PHI arguments, to be in SSA form. ENTRY indicates the block where to start. Every block dominated by ENTRY will be rewritten. WHAT indicates what actions will be taken by the renamer (see enum rewrite_mode). BLOCKS are the set of interesting blocks for the dominator walker to process. If this set is NULL, then all the nodes dominated by ENTRY are walked. Otherwise, blocks dominated by ENTRY that are not present in BLOCKS are ignored.
References dom_walk_data::after_dom_children, dom_walk_data::before_dom_children, CDI_DOMINATORS, dump_dfa_stats(), dump_file, dump_flags, dump_tree_ssa_stats(), fini_walk_dominator_tree(), init_walk_dominator_tree(), hash_table< Descriptor, Allocator >::is_created(), memset(), REWRITE_ALL, rewrite_enter_block(), rewrite_leave_block(), REWRITE_UPDATE, rewrite_update_enter_block(), rewrite_update_leave_block(), timevar_pop(), timevar_push(), and walk_dominator_tree().
Referenced by rewrite_into_ssa(), and update_ssa().
|
static |
Helper function for rewrite_stmt. Rewrite uses in a debug stmt.
References bitmap_bit_p(), CDI_DOMINATORS, dominated_by_p(), get_common_info(), get_def_blocks_for(), gimple_bb(), gimple_debug_bind_reset_value(), gimple_debug_source_bind_get_value(), gimple_debug_source_bind_get_var(), gimple_debug_source_bind_p(), gsi_after_labels(), gsi_end_p(), gsi_insert_before(), gsi_next(), GSI_SAME_STMT, gsi_stmt(), basic_block_def::index, var_info_d::info, def_blocks_d::livein_blocks, NEED_PHI_STATE_NO, single_succ(), single_succ_p(), update_stmt(), and var_info_d::var.
Referenced by rewrite_stmt().
|
static |
SSA Rewriting Step 1. Initialization, create a block local stack of reaching definitions for new SSA names produced in this block (BLOCK_DEFS). Register new definitions for every PHI node in the block.
References bitmap_bit_p(), dump_file, dump_flags, gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, register_new_def(), rewrite_add_phi_arguments(), and rewrite_stmt().
Referenced by rewrite_blocks().
|
static |
Main entry point into the SSA builder. The renaming process proceeds in four main phases: 1- Compute dominance frontier and immediate dominators, needed to insert PHI nodes and rename the function in dominator tree order. 2- Find and mark all the blocks that define variables (mark_def_site_blocks). 3- Insert PHI nodes at dominance frontiers (insert_phi_nodes). 4- Rename all the blocks (rewrite_blocks) and statements in the program. Steps 3 and 4 are done using the dominator tree walker (walk_dominator_tree).
References bitmap_clear(), bitmap_default_obstack, calculate_dominance_info(), CDI_DOMINATORS, cfun, compute_dominance_frontiers(), fini_ssa_renamer(), free(), basic_block_def::index, init_ssa_operands(), init_ssa_renamer(), insert_phi_nodes(), mark_def_site_blocks(), REWRITE_ALL, rewrite_blocks(), sbitmap_alloc(), and sbitmap_free().
|
static |
Called after visiting all the statements in basic block BB and all of its dominator children. Restore CURRDEFS to its original value.
References get_common_info(), and is_gimple_reg().
Referenced by rewrite_blocks().
|
static |
SSA Rewriting Step 2. Rewrite every variable used in each statement in the block with its immediate reaching definitions. Update the current definition of a variable when a new real or virtual definition is found.
References cfun, dump_file, dump_flags, get_or_create_ssa_default_def(), get_reaching_def(), gimple_build_nop(), gimple_clobber_p(), gimple_vdef(), gsi_insert_after(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), is_gimple_debug(), is_gimple_reg(), make_ssa_name(), print_gimple_stmt(), register_defs_p(), register_new_def(), rewrite_debug_stmt_uses(), rewrite_uses_p(), and target_for_debug_bind().
Referenced by rewrite_enter_block().
|
static |
Initialization of block data structures for the incremental SSA update pass. Create a block local stack of reaching definitions for new SSA names produced in this block (BLOCK_DEFS). Register new definitions for every PHI node in the block.
References bb_has_abnormal_pred(), bitmap_bit_p(), dump_file, dump_flags, gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, is_new_name(), is_old_name(), marked_for_renaming(), names_replaced_by(), register_defs_p(), register_new_update_set(), register_new_update_single(), rewrite_update_phi_arguments(), and rewrite_update_stmt().
Referenced by rewrite_blocks().
|
static |
Called after visiting block BB. Unwind BLOCK_DEFS_STACK to restore the current reaching definition of every name re-written in BB to the original reaching definition before visiting BB. This unwinding must be done in the opposite order to what is done in register_new_update_set.
References get_common_info(), and var_info_d::var.
Referenced by rewrite_blocks().
|
static |
Visit all the successor blocks of BB looking for PHI nodes. For every PHI node found, check if any of its arguments is in OLD_SSA_NAMES. If so, and if the argument has a current reaching definition, replace it.
References bitmap_bit_p(), edge_def::dest, edge_def::flags, get_reaching_def(), gimple_location(), gimple_phi_arg_location(), gimple_phi_arg_set_location(), gimple_phi_num_args(), gimple_phi_result(), basic_block_def::index, is_old_name(), marked_for_renaming(), phis, rewrite_uses_p(), basic_block_def::succs, and virtual_operand_p().
Referenced by rewrite_update_enter_block().
|
static |
Update every variable used in the statement pointed-to by SI. The statement is assumed to be in SSA form already. Names in OLD_SSA_NAMES used by SI will be updated to their current reaching definition. Names in OLD_SSA_NAMES or NEW_SSA_NAMES defined by SI will be registered as a new definition for their corresponding name in OLD_SSA_NAMES.
References dump_file, dump_flags, gimple_debug_bind_reset_value(), is_gimple_debug(), maybe_register_def(), maybe_replace_use(), maybe_replace_use_in_debug_stmt(), print_gimple_stmt(), register_defs_p(), rewrite_uses_p(), and update_stmt().
Referenced by rewrite_update_enter_block().
|
inlinestatic |
Return true if STMT needs to be rewritten. When renaming a subset of the variables, not all statements will be processed. This is decided in mark_def_sites.
References gimple_visited_p().
Referenced by mark_def_sites(), mark_phi_for_rewrite(), rewrite_stmt(), rewrite_update_phi_arguments(), and rewrite_update_stmt().
void set_current_def | ( | ) |
Sets current definition of VAR to DEF.
References get_common_info().
|
static |
Mark block BB as the definition site for variable VAR. PHI_P is true if VAR is defined by a PHI node.
References bitmap_set_bit(), def_blocks_d::def_blocks, get_common_info(), get_def_blocks_for(), basic_block_def::index, NEED_PHI_STATE_MAYBE, NEED_PHI_STATE_NO, NEED_PHI_STATE_UNKNOWN, and def_blocks_d::phi_blocks.
Referenced by mark_def_interesting(), and mark_def_sites().
|
static |
Mark block BB as having VAR live at the entry to BB.
References bitmap_first_set_bit(), bitmap_set_bit(), CDI_DOMINATORS, def_blocks_d::def_blocks, dominated_by_p(), get_common_info(), get_def_blocks_for(), basic_block_def::index, def_blocks_d::livein_blocks, NEED_PHI_STATE_MAYBE, and NEED_PHI_STATE_NO.
Referenced by mark_def_sites(), and mark_use_interesting().
|
inlinestatic |
If REGISTER_DEFS_P is true, mark STMT to have its DEFs registered.
References GF_PLF_1, and gimple_set_plf().
Referenced by initialize_flags_in_bb(), insert_phi_nodes_for(), mark_def_interesting(), and mark_def_sites().
|
inlinestatic |
Set the rewrite marker on STMT to the value given by REWRITE_P.
References gimple_set_visited().
Referenced by initialize_flags_in_bb(), mark_def_sites(), mark_phi_for_rewrite(), and mark_use_interesting().
void update_ssa | ( | ) |
Given a set of newly created SSA names (NEW_SSA_NAMES) and a set of existing SSA names (OLD_SSA_NAMES), update the SSA form so that: 1- The names in OLD_SSA_NAMES dominated by the definitions of NEW_SSA_NAMES are all re-written to be reached by the appropriate definition from NEW_SSA_NAMES. 2- If needed, new PHI nodes are added to the iterated dominance frontier of the blocks where each of NEW_SSA_NAMES are defined. The mapping between OLD_SSA_NAMES and NEW_SSA_NAMES is setup by calling create_new_def_for to create new defs for names that the caller wants to replace. The caller cretaes the new names to be inserted and the names that need to be replaced by calling create_new_def_for for each old definition to be replaced. Note that the function assumes that the new defining statement has already been inserted in the IL. For instance, given the following code: 1 L0: 2 x_1 = PHI (0, x_5) 3 if (x_1 < 10) 4 if (x_1 > 7) 5 y_2 = 0 6 else 7 y_3 = x_1 + x_7 8 endif 9 x_5 = x_1 + 1 10 goto L0; 11 endif Suppose that we insert new names x_10 and x_11 (lines 4 and 8). 1 L0: 2 x_1 = PHI (0, x_5) 3 if (x_1 < 10) 4 x_10 = ... 5 if (x_1 > 7) 6 y_2 = 0 7 else 8 x_11 = ... 9 y_3 = x_1 + x_7 10 endif 11 x_5 = x_1 + 1 12 goto L0; 13 endif We want to replace all the uses of x_1 with the new definitions of x_10 and x_11. Note that the only uses that should be replaced are those at lines 5, 9 and 11. Also, the use of x_7 at line 9 should *not* be replaced (this is why we cannot just mark symbol 'x' for renaming). Additionally, we may need to insert a PHI node at line 11 because that is a merge point for x_10 and x_11. So the use of x_1 at line 11 will be replaced with the new PHI node. The insertion of PHI nodes is optional. They are not strictly necessary to preserve the SSA form, and depending on what the caller inserted, they may not even be useful for the optimizers. UPDATE_FLAGS controls various aspects of how update_ssa operates, see the documentation for TODO_update_ssa*.
References bitmap_clear(), bitmap_copy(), bitmap_default_obstack, bitmap_first_set_bit(), bitmap_set_bit(), calculate_dominance_info(), CDI_DOMINATORS, cfun, compute_dominance_frontiers(), hash_table< Descriptor, Allocator >::create(), delete_update_ssa(), dump_file, dump_flags, dump_update_ssa(), free(), get_ssa_name_ann(), get_var_info(), function::gimple_df, basic_block_def::index, var_info_d::info, ssa_name_info::info, init_update_ssa(), insert_updated_phi_nodes_compare_uids(), insert_updated_phi_nodes_for(), internal_error(), marked_for_renaming(), nearest_common_dominator_for_set(), need_ssa_update_p(), prepare_block_for_update(), prepare_names_to_update(), print_generic_expr(), rewrite_blocks(), REWRITE_UPDATE, sbitmap_alloc(), sbitmap_free(), gimple_df::ssa_renaming_needed, timevar_pop(), timevar_push(), and virtual_operand_p().
Stack of trees used to restore the global currdefs to its original state after completing rewriting of a block and its dominator children. Its elements have the following properties: - An SSA_NAME (N) indicates that the current definition of the underlying variable should be set to the given SSA_NAME. If the symbol associated with the SSA_NAME is not a GIMPLE register, the next slot in the stack must be a _DECL node (SYM). In this case, the name N in the previous slot is the current reaching definition for SYM. - A _DECL node indicates that the underlying variable has no current definition. - A NULL node at the top entry is used to mark the last slot associated with the current block.
|
static |
The set of blocks affected by update_ssa.
|
static |
The bitmap of non-NULL elements of PHIS_TO_REWRITE.
|
static |
Referenced by clear_ssa_name_info(), and get_ssa_name_ann().
|
static |
|
static |
|
static |
Set of SSA names that have been marked to be released after they were registered in the replacement table. They will be finally released after we finish updating the SSA web.
|
static |
Set of new SSA names being added by update_ssa. Note that both NEW_SSA_NAMES and OLD_SSA_NAMES are dense bitmaps because most of the operations done on them are presence tests.
|
static |
Set of existing SSA names being replaced by update_ssa.
|
static |
vec of vec of PHIs to rewrite in a basic block. Element I corresponds the to basic block with index I. Allocated once per compilation, *not* released between different functions.
|
static |
The set of symbols we ought to re-write into SSA form in update_ssa.
|
static |
The function the SSA updating data structures have been initialized for. NULL if they need to be initialized by create_new_def_for.
|
static |
|
static |
Each entry in VAR_INFOS contains an element of type STRUCT VAR_INFO_D.