This performs timevar push/pop at the single remaining entry to incremental SSA rewrite setup. The other entry, register_new_name_mapping, is removed by making its only other user use create_new_def_for. Which needs to handle a NULL DEF for this case, as we have no access to a DEF op for an SSA name LHS (but we do for a PHI node). Something Micha may change soon.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-08-20 Richard Guenther <rguent...@suse.de> * tree-flow.h (register_new_name_mapping): Remove. * tree-into-ssa.c (register_new_name_mapping): Likewise. (add_new_name_mapping): Do not push/pop timevar here. (create_new_def_for): Instead do it here. Initialize update-ssa here, handle a NULL def. * tree-vrp.c (build_assert_expr_for): Use create_new_def_for. Index: gcc/tree-flow.h =================================================================== *** gcc/tree-flow.h (revision 190525) --- gcc/tree-flow.h (working copy) *************** void release_defs_bitset (bitmap toremov *** 516,522 **** /* In tree-into-ssa.c */ void update_ssa (unsigned); void delete_update_ssa (void); - void register_new_name_mapping (tree, tree); tree create_new_def_for (tree, gimple, def_operand_p); bool need_ssa_update_p (struct function *); bool name_registered_for_update_p (tree); --- 516,521 ---- Index: gcc/tree-into-ssa.c =================================================================== *** gcc/tree-into-ssa.c (revision 190525) --- gcc/tree-into-ssa.c (working copy) *************** static VEC(gimple_vec, heap) *phis_to_re *** 111,125 **** static bitmap blocks_with_phis_to_rewrite; /* Growth factor for NEW_SSA_NAMES and OLD_SSA_NAMES. These sets need ! to grow as the callers to register_new_name_mapping will typically ! create new names on the fly. FIXME. Currently set to 1/3 to avoid ! frequent reallocations but still need to find a reasonable growth ! strategy. */ #define NAME_SETS_GROWTH_FACTOR (MAX (3, num_ssa_names / 3)) /* The function the SSA updating data structures have been initialized for. ! NULL if they need to be initialized by register_new_name_mapping. */ static struct function *update_ssa_initialized_fn = NULL; /* Global data to attach to the main dominator walk structure. */ --- 111,125 ---- static bitmap blocks_with_phis_to_rewrite; /* Growth factor for NEW_SSA_NAMES and OLD_SSA_NAMES. These sets need ! to grow as the callers to create_new_def_for will create new names on ! the fly. ! FIXME. Currently set to 1/3 to avoid frequent reallocations but still ! need to find a reasonable growth strategy. */ #define NAME_SETS_GROWTH_FACTOR (MAX (3, num_ssa_names / 3)) /* The function the SSA updating data structures have been initialized for. ! NULL if they need to be initialized by create_new_def_for. */ static struct function *update_ssa_initialized_fn = NULL; /* Global data to attach to the main dominator walk structure. */ *************** add_to_repl_tbl (tree new_tree, tree old *** 587,594 **** static void add_new_name_mapping (tree new_tree, tree old) { - timevar_push (TV_TREE_SSA_INCREMENTAL); - /* OLD and NEW_TREE must be different SSA names for the same symbol. */ gcc_assert (new_tree != old && SSA_NAME_VAR (new_tree) == SSA_NAME_VAR (old)); --- 587,592 ---- *************** add_new_name_mapping (tree new_tree, tre *** 613,620 **** respectively. */ SET_BIT (new_ssa_names, SSA_NAME_VERSION (new_tree)); SET_BIT (old_ssa_names, SSA_NAME_VERSION (old)); - - timevar_pop (TV_TREE_SSA_INCREMENTAL); } --- 611,616 ---- *************** delete_update_ssa (void) *** 2842,2857 **** /* Create a new name for OLD_NAME in statement STMT and replace the ! operand pointed to by DEF_P with the newly created name. Return ! the new name and register the replacement mapping <NEW, OLD> in update_ssa's tables. */ tree create_new_def_for (tree old_name, gimple stmt, def_operand_p def) { ! tree new_name = duplicate_ssa_name (old_name, stmt); ! SET_DEF (def, new_name); if (gimple_code (stmt) == GIMPLE_PHI) { --- 2838,2865 ---- /* 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. */ tree create_new_def_for (tree old_name, gimple stmt, def_operand_p def) { ! tree new_name; ! timevar_push (TV_TREE_SSA_INCREMENTAL); ! ! if (!update_ssa_initialized_fn) ! init_update_ssa (cfun); ! ! gcc_assert (update_ssa_initialized_fn == cfun); ! ! new_name = duplicate_ssa_name (old_name, stmt); ! if (def) ! SET_DEF (def, new_name); ! else ! gimple_assign_set_lhs (stmt, new_name); if (gimple_code (stmt) == GIMPLE_PHI) { *************** create_new_def_for (tree old_name, gimpl *** 2861,2890 **** SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name) = bb_has_abnormal_pred (bb); } ! register_new_name_mapping (new_name, old_name); /* For the benefit of passes that will be updating the SSA form on their own, set the current reaching definition of OLD_NAME to be NEW_NAME. */ get_ssa_name_ann (old_name)->info.current_def = new_name; ! return new_name; ! } ! ! ! /* Register name NEW to be a replacement for name OLD. This function ! must be called for every replacement that should be performed by ! update_ssa. */ ! ! void ! register_new_name_mapping (tree new_tree, tree old) ! { ! if (!update_ssa_initialized_fn) ! init_update_ssa (cfun); ! ! gcc_assert (update_ssa_initialized_fn == cfun); ! add_new_name_mapping (new_tree, old); } --- 2869,2884 ---- SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name) = bb_has_abnormal_pred (bb); } ! add_new_name_mapping (new_name, old_name); /* For the benefit of passes that will be updating the SSA form on their own, set the current reaching definition of OLD_NAME to be NEW_NAME. */ get_ssa_name_ann (old_name)->info.current_def = new_name; ! timevar_pop (TV_TREE_SSA_INCREMENTAL); ! return new_name; } *************** insert_updated_phi_nodes_for (tree var, *** 3056,3068 **** 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 register_new_name_mapping for every pair of names that the caller wants to replace. ! The caller identifies the new names that have been inserted and the ! names that need to be replaced by calling register_new_name_mapping ! for every pair <NEW, OLD>. Note that the function assumes that the ! new names have already been inserted in the IL. For instance, given the following code: --- 3050,3062 ---- 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: Index: gcc/tree-vrp.c =================================================================== *** gcc/tree-vrp.c (revision 190525) --- gcc/tree-vrp.c (working copy) *************** debug_all_value_ranges (void) *** 4152,4184 **** static gimple build_assert_expr_for (tree cond, tree v) { ! tree n; gimple assertion; ! gcc_assert (TREE_CODE (v) == SSA_NAME); ! n = duplicate_ssa_name (v, NULL); ! if (COMPARISON_CLASS_P (cond)) ! { ! tree a = build2 (ASSERT_EXPR, TREE_TYPE (v), v, cond); ! assertion = gimple_build_assign (n, a); ! } ! else if (TREE_CODE (cond) == SSA_NAME) ! { ! /* Given V, build the assignment N = true. */ ! gcc_assert (v == cond); ! assertion = gimple_build_assign (n, boolean_true_node); ! } ! else ! gcc_unreachable (); ! ! SSA_NAME_DEF_STMT (n) = assertion; /* The new ASSERT_EXPR, creates a new SSA name that replaces the ! operand of the ASSERT_EXPR. Register the new name and the old one ! in the replacement table so that we can fix the SSA web after ! adding all the ASSERT_EXPRs. */ ! register_new_name_mapping (n, v); return assertion; } --- 4152,4171 ---- static gimple build_assert_expr_for (tree cond, tree v) { ! tree a, n; gimple assertion; ! gcc_assert (TREE_CODE (v) == SSA_NAME ! && COMPARISON_CLASS_P (cond)); ! a = build2 (ASSERT_EXPR, TREE_TYPE (v), v, cond); ! assertion = gimple_build_assign (NULL_TREE, a); /* The new ASSERT_EXPR, creates a new SSA name that replaces the ! operand of the ASSERT_EXPR. Create it so the new name and the old one ! are registered in the replacement table so that we can fix the SSA web ! after adding all the ASSERT_EXPRs. */ ! n = create_new_def_for (v, assertion, NULL); return assertion; }