From 2d04fd8dddd64aae0c58fcbe0b5793dcd8854b2e Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 28 Nov 2006 14:42:37 +0000 Subject: [PATCH] Privatize SSA variables into gimple_df. * tree-flow-inline.h (gimple_in_ssa_p, gimple_aliases_computed_p, gimple_addressable_vars, gimple_call_clobbered_vars, gimple_referenced_vars, gimple_global_var, gimple_nonlocal_all): New accessors. (first_referenced_var): Update. (mark_stmt_modified): Update. (is_call_clobbered): Update. (mark_call_clobbered): Update. (clear_call_clobbered): Update. (mark_non_addressable): Update. * tree-vrp.c (get_value_range): Update. * tree-into-ssa.c (in_ssa_p): Kill. (get_default_def_for): Update. (rewrite_into_ssa): Update. * tree-complex.c (init_parameter_lattice_values): Update. (update_complex_assignment): Update. (update_parameter_components): Update. (expand_complex_libcall): Update. (expand_complex_operations_1): Update. * tree-tailcall.c (arg_needs_copy_p): Update. (add_virtual_phis): Update. (tree_optimize_tail_calls_1): Update. * tree-ssa-dse.c (memory_ssa_name_same): Update. * tree-ssa-copyrename.c (copy_rename_partition_coalesce): Update. * tree-ssa-math-opts.c (execute_cse_reciprocals): Update. * tree-ssa-propagate.c (set_rhs): Update. * tree-ssa-alias.c (aliases_computed_p, call_clobbered_vars, addressable_vars, global_var):Kill. (set_initial_properties): Update. (init_alias_info): Update. (finalize_ref_all_pointers): Update. (setup_pointers_and_addressables): Update. (maybe_create_global_var): Update. (create_global_var): Update. (dump_points_to_info): Update. * function.h (struct gimple_df): Forward declare. (struct function): Add GIMPLE_DF field. * gimplify.c (force_gimple_operand): Update. * tree-dfa.c (referenced_vars, default_defs): KIll. (make_rename_temp): Update. (dump_variable): Update. (referenced_var_lookup): Update. (referenced_var_check_and_insert): Update. (default_def): Rename to ... (gimple_default_def): ... this one; accept cfun argument. (set_default_def): Update. * tree-cfgcleanup.c (modified_noreturn_calls): Kill. (cleanup_control_flow): Update. * tree-ssa-pre.c (compute_avail): Update * tree-ssa-live.c (calculate_live_on_entry): Update. * tree-ssa.c (verify_use): Update. (verify_call_clobbering): Update. (verify_call_clobbering): Update. (init_tree_ssa): Update. (delete_tree_ssa): Update. * tree-outof-ssa.c (coalesce_ssa_name): Update. (rewrite_out_of_ssa): Update. * tree-flow.h (gimple_df): New structure collecting dataflow variables. (FREE_SSANAMES, SSANAMES, MODIFIED_NORETURN_CALLS, DEFAULT_DEFS): New private accessors. (in_ssa_p, modified_noreturn_calls, referenced_vars, default_defs, ssa_names, global_var, nonlocal_all, call_clobbered_vars, addressable_vars, aliases_computed_p): Kill. (default_def): Rename to... (gimple_default_def): ... this one. (defaule_def_fn): Kill. (num_referenced_vars, ssa_names, num_ssa_names): Update. * tree-ssa-structalias.c (nonlocal_all): Kill. (get_constraint_exp_from_ssa_var): Update. (create_nonlocal_var): Update. (get_constraint_for): Update. (update_alias_info): Update. (find_global_initializers): Update. (intra_create_variable_infos): Update. (intra_create_variable_infos): (find_what_p_points_to): Update. (init_alias_heapvars): Update. * tree-cfg.c (remove_bb): Update. (gimplify_val): Update. * tree-ssa-reassoc.c (get_rank): Update. (init_reassoc): Update. * tree-ssanames.c: Do not include gt-tree-ssanames.h (ssa_names, free_ssanames): Kill. (init_ssanames): Update. (make_ssa_name): Update. (release_ssa_name): Update. (release_defs): Update. (replace_ssa_name_symbol): Update. * tree-ssa-operands.c (access_can_touch_variable): Update. (add_virtual_operand): Update. (add_call_clobber_ops): Update. (add_call_read_ops): Update. (get_call_expr_operands): Update. (get_asm_expr_operands): Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119294 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 99 ++++++++++++++++++++++++++++++++++++++++++++++ gcc/builtins.c | 2 +- gcc/function.h | 3 ++ gcc/gimplify.c | 4 +- gcc/tree-cfg.c | 4 +- gcc/tree-cfgcleanup.c | 23 ++++------- gcc/tree-complex.c | 10 ++--- gcc/tree-dfa.c | 42 +++++++++----------- gcc/tree-flow-inline.h | 81 +++++++++++++++++++++++++++++++++---- gcc/tree-flow.h | 99 +++++++++++++++++++++++++++++----------------- gcc/tree-into-ssa.c | 7 +--- gcc/tree-outof-ssa.c | 4 +- gcc/tree-ssa-alias.c | 59 +++++++++------------------ gcc/tree-ssa-copyrename.c | 6 +-- gcc/tree-ssa-dse.c | 2 +- gcc/tree-ssa-live.c | 2 +- gcc/tree-ssa-math-opts.c | 4 +- gcc/tree-ssa-operands.c | 35 +++++++++------- gcc/tree-ssa-pre.c | 8 ++-- gcc/tree-ssa-propagate.c | 2 +- gcc/tree-ssa-reassoc.c | 8 ++-- gcc/tree-ssa-structalias.c | 36 +++++++++-------- gcc/tree-ssa.c | 38 +++++++++--------- gcc/tree-ssanames.c | 40 ++++++++----------- gcc/tree-tailcall.c | 6 +-- gcc/tree-vrp.c | 2 +- 26 files changed, 390 insertions(+), 236 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index af114616ff4..5ec59668568 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,104 @@ 2006-11-28 Jan Hubicka + Privatize SSA variables into gimple_df. + * tree-flow-inline.h + (gimple_in_ssa_p, gimple_aliases_computed_p, gimple_addressable_vars, + gimple_call_clobbered_vars, gimple_referenced_vars, gimple_global_var, + gimple_nonlocal_all): New accessors. + (first_referenced_var): Update. + (mark_stmt_modified): Update. + (is_call_clobbered): Update. + (mark_call_clobbered): Update. + (clear_call_clobbered): Update. + (mark_non_addressable): Update. + * tree-vrp.c (get_value_range): Update. + * tree-into-ssa.c (in_ssa_p): Kill. + (get_default_def_for): Update. + (rewrite_into_ssa): Update. + * tree-complex.c (init_parameter_lattice_values): Update. + (update_complex_assignment): Update. + (update_parameter_components): Update. + (expand_complex_libcall): Update. + (expand_complex_operations_1): Update. + * tree-tailcall.c (arg_needs_copy_p): Update. + (add_virtual_phis): Update. + (tree_optimize_tail_calls_1): Update. + * tree-ssa-dse.c (memory_ssa_name_same): Update. + * tree-ssa-copyrename.c + (copy_rename_partition_coalesce): Update. + * tree-ssa-math-opts.c (execute_cse_reciprocals): Update. + * tree-ssa-propagate.c (set_rhs): Update. + * tree-ssa-alias.c (aliases_computed_p, call_clobbered_vars, + addressable_vars, global_var):Kill. + (set_initial_properties): Update. + (init_alias_info): Update. + (finalize_ref_all_pointers): Update. + (setup_pointers_and_addressables): Update. + (maybe_create_global_var): Update. + (create_global_var): Update. + (dump_points_to_info): Update. + * function.h (struct gimple_df): Forward declare. + (struct function): Add GIMPLE_DF field. + * gimplify.c (force_gimple_operand): Update. + * tree-dfa.c (referenced_vars, default_defs): KIll. + (make_rename_temp): Update. + (dump_variable): Update. + (referenced_var_lookup): Update. + (referenced_var_check_and_insert): Update. + (default_def): Rename to ... + (gimple_default_def): ... this one; accept cfun argument. + (set_default_def): Update. + * tree-cfgcleanup.c (modified_noreturn_calls): Kill. + (cleanup_control_flow): Update. + * tree-ssa-pre.c (compute_avail): Update + * tree-ssa-live.c (calculate_live_on_entry): Update. + * tree-ssa.c (verify_use): Update. + (verify_call_clobbering): Update. + (verify_call_clobbering): Update. + (init_tree_ssa): Update. + (delete_tree_ssa): Update. + * tree-outof-ssa.c (coalesce_ssa_name): Update. + (rewrite_out_of_ssa): Update. + * tree-flow.h (gimple_df): New structure collecting dataflow variables. + (FREE_SSANAMES, SSANAMES, MODIFIED_NORETURN_CALLS, DEFAULT_DEFS): New + private accessors. + (in_ssa_p, modified_noreturn_calls, referenced_vars, default_defs, + ssa_names, global_var, nonlocal_all, call_clobbered_vars, + addressable_vars, aliases_computed_p): Kill. + (default_def): Rename to... + (gimple_default_def): ... this one. + (defaule_def_fn): Kill. + (num_referenced_vars, ssa_names, num_ssa_names): Update. + * tree-ssa-structalias.c (nonlocal_all): Kill. + (get_constraint_exp_from_ssa_var): Update. + (create_nonlocal_var): Update. + (get_constraint_for): Update. + (update_alias_info): Update. + (find_global_initializers): Update. + (intra_create_variable_infos): Update. + (intra_create_variable_infos): + (find_what_p_points_to): Update. + (init_alias_heapvars): Update. + * tree-cfg.c (remove_bb): Update. + (gimplify_val): Update. + * tree-ssa-reassoc.c (get_rank): Update. + (init_reassoc): Update. + * tree-ssanames.c: Do not include gt-tree-ssanames.h + (ssa_names, free_ssanames): Kill. + (init_ssanames): Update. + (make_ssa_name): Update. + (release_ssa_name): Update. + (release_defs): Update. + (replace_ssa_name_symbol): Update. + * tree-ssa-operands.c (access_can_touch_variable): Update. + (add_virtual_operand): Update. + (add_call_clobber_ops): Update. + (add_call_read_ops): Update. + (get_call_expr_operands): Update. + (get_asm_expr_operands): Update. + +2006-11-28 Jan Hubicka + * builtins.c: Include tree-flow.h. (fold_builtin_memory_op): Be more aggressive on converting memcpy to assignment; convert memmove to memcpy for sizes greater than 1 where diff --git a/gcc/builtins.c b/gcc/builtins.c index f3c1623785f..869f1dc9198 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8237,7 +8237,7 @@ fold_builtin_memory_op (tree arglist, tree type, bool ignore, int endp) return 0; if (srctype == desttype - || (in_ssa_p + || (gimple_in_ssa_p (cfun) && tree_ssa_useless_type_conversion_1 (desttype, srctype))) expr = srcvar; else if ((INTEGRAL_TYPE_P (TREE_TYPE (srcvar)) diff --git a/gcc/function.h b/gcc/function.h index 94c81018d83..63d42dcc79f 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -159,6 +159,7 @@ struct expr_status GTY(()) #define forced_labels (cfun->expr->x_forced_labels) #define stack_pointer_delta (cfun->expr->x_stack_pointer_delta) +struct gimple_df; struct temp_slot; typedef struct temp_slot *temp_slot_p; @@ -188,6 +189,8 @@ struct function GTY(()) /* The control flow graph for this function. */ struct control_flow_graph *cfg; + /* SSA and dataflow information. */ + struct gimple_df *gimple_df; /* The loops in this function. */ struct loops * GTY((skip)) x_current_loops; diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 81a18a0ae58..ce91852eea3 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6365,7 +6365,7 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var) gimple_test_f = simple ? is_gimple_val : is_gimple_reg_rhs; push_gimplify_context (); - gimplify_ctxp->into_ssa = in_ssa_p; + gimplify_ctxp->into_ssa = gimple_in_ssa_p (cfun); if (var) expr = build2 (MODIFY_EXPR, TREE_TYPE (var), var, expr); @@ -6374,7 +6374,7 @@ force_gimple_operand (tree expr, tree *stmts, bool simple, tree var) gimple_test_f, fb_rvalue); gcc_assert (ret != GS_ERROR); - if (referenced_vars) + if (gimple_referenced_vars (cfun)) { for (t = gimplify_ctxp->temps; t ; t = TREE_CHAIN (t)) add_referenced_var (t); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 292fa48fb21..bdbff33fdea 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2040,7 +2040,7 @@ remove_bb (basic_block bb) may be called when not in SSA. For example, final_cleanup calls this function via cleanup_tree_cfg. */ - if (in_ssa_p) + if (gimple_in_ssa_p (cfun)) release_defs (stmt); bsi_remove (&i, true); @@ -5645,7 +5645,7 @@ gimplify_val (block_stmt_iterator *bsi, tree type, tree exp) TREE_BLOCK (new_stmt) = TREE_BLOCK (orig_stmt); bsi_insert_before (bsi, new_stmt, BSI_SAME_STMT); - if (in_ssa_p) + if (gimple_in_ssa_p (cfun)) mark_new_vars_to_rename (new_stmt); return t; diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index d13a53668d4..13a3b0b0ea8 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -127,14 +127,6 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi) return retval; } -/* A list of all the noreturn calls passed to modify_stmt. - cleanup_control_flow uses it to detect cases where a mid-block - indirect call has been turned into a noreturn call. When this - happens, all the instructions after the call are no longer - reachable and must be deleted as dead. */ - -VEC(tree,gc) *modified_noreturn_calls; - /* Try to remove superfluous control structures. */ static bool @@ -146,13 +138,14 @@ cleanup_control_flow (void) tree stmt; /* Detect cases where a mid-block call is now known not to return. */ - while (VEC_length (tree, modified_noreturn_calls)) - { - stmt = VEC_pop (tree, modified_noreturn_calls); - bb = bb_for_stmt (stmt); - if (bb != NULL && last_stmt (bb) != stmt && noreturn_call_p (stmt)) - split_block (bb, stmt); - } + if (cfun->gimple_df) + while (VEC_length (tree, MODIFIED_NORETURN_CALLS (cfun))) + { + stmt = VEC_pop (tree, MODIFIED_NORETURN_CALLS (cfun)); + bb = bb_for_stmt (stmt); + if (bb != NULL && last_stmt (bb) != stmt && noreturn_call_p (stmt)) + split_block (bb, stmt); + } FOR_EACH_BB (bb) { diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index f841844f88e..d3909ae0acc 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -165,7 +165,7 @@ init_parameter_lattice_values (void) for (parm = DECL_ARGUMENTS (cfun->decl); parm ; parm = TREE_CHAIN (parm)) if (is_complex_reg (parm) && var_ann (parm) != NULL) { - tree ssa_name = default_def (parm); + tree ssa_name = gimple_default_def (cfun, parm); VEC_replace (complex_lattice_t, complex_lattice_values, SSA_NAME_VERSION (ssa_name), VARYING); } @@ -625,7 +625,7 @@ update_complex_assignment (block_stmt_iterator *bsi, tree r, tree i) mod = stmt = bsi_stmt (*bsi); if (TREE_CODE (stmt) == RETURN_EXPR) mod = TREE_OPERAND (mod, 0); - else if (in_ssa_p) + else if (gimple_in_ssa_p (cfun)) update_complex_components (bsi, stmt, r, i); type = TREE_TYPE (TREE_OPERAND (mod, 1)); @@ -651,7 +651,7 @@ update_parameter_components (void) continue; type = TREE_TYPE (type); - ssa_name = default_def (parm); + ssa_name = gimple_default_def (cfun, parm); if (!ssa_name) continue; @@ -910,7 +910,7 @@ expand_complex_libcall (block_stmt_iterator *bsi, tree ar, tree ai, = build3 (CALL_EXPR, type, build_fold_addr_expr (fn), args, NULL); update_stmt (stmt); - if (in_ssa_p) + if (gimple_in_ssa_p (cfun)) { tree lhs = TREE_OPERAND (stmt, 0); type = TREE_TYPE (type); @@ -1422,7 +1422,7 @@ expand_complex_operations_1 (block_stmt_iterator *bsi) } } - if (in_ssa_p) + if (gimple_in_ssa_p (cfun)) { al = find_lattice_value (ac); if (al == UNINITIALIZED) diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 5ade6455d96..3330624c19f 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -71,18 +71,6 @@ static tree collect_dfa_stats_r (tree *, int *, void *); static tree find_vars_r (tree *, int *, void *); -/* Global declarations. */ - -/* Array of all variables referenced in the function. */ -htab_t referenced_vars; - -/* Default definition for this symbols. If set for symbol, it - means that the first reference to this variable in the function is a - USE or a VUSE. In those cases, the SSA renamer creates an SSA name - for this variable with an empty defining statement. */ -htab_t default_defs; - - /*--------------------------------------------------------------------------- Dataflow analysis (DFA) routines ---------------------------------------------------------------------------*/ @@ -222,7 +210,7 @@ make_rename_temp (tree type, const char *prefix) if (TREE_CODE (type) == COMPLEX_TYPE) DECL_COMPLEX_GIMPLE_REG_P (t) = 1; - if (referenced_vars) + if (gimple_referenced_vars (cfun)) { add_referenced_var (t); mark_sym_for_renaming (t); @@ -375,10 +363,10 @@ dump_variable (FILE *file, tree var) } } - if (default_def (var)) + if (gimple_default_def (cfun, var)) { fprintf (file, ", default def: "); - print_generic_expr (file, default_def (var), dump_flags); + print_generic_expr (file, gimple_default_def (cfun, var), dump_flags); } if (may_aliases (var)) @@ -611,7 +599,8 @@ referenced_var_lookup (unsigned int uid) { struct int_tree_map *h, in; in.uid = uid; - h = (struct int_tree_map *) htab_find_with_hash (referenced_vars, &in, uid); + h = (struct int_tree_map *) htab_find_with_hash (gimple_referenced_vars (cfun), + &in, uid); gcc_assert (h || uid == 0); if (h) return h->to; @@ -630,7 +619,8 @@ referenced_var_check_and_insert (tree to) in.uid = uid; in.to = to; - h = (struct int_tree_map *) htab_find_with_hash (referenced_vars, &in, uid); + h = (struct int_tree_map *) htab_find_with_hash (gimple_referenced_vars (cfun), + &in, uid); if (h) { @@ -643,7 +633,8 @@ referenced_var_check_and_insert (tree to) h = GGC_NEW (struct int_tree_map); h->uid = uid; h->to = to; - loc = htab_find_slot_with_hash (referenced_vars, h, uid, INSERT); + loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), + h, uid, INSERT); *(struct int_tree_map **) loc = h; return true; } @@ -652,12 +643,13 @@ referenced_var_check_and_insert (tree to) variable. */ tree -default_def (tree var) +gimple_default_def (struct function *fn, tree var) { struct int_tree_map *h, in; gcc_assert (SSA_VAR_P (var)); in.uid = DECL_UID (var); - h = (struct int_tree_map *) htab_find_with_hash (default_defs, &in, + h = (struct int_tree_map *) htab_find_with_hash (DEFAULT_DEFS (fn), + &in, DECL_UID (var)); if (h) return h->to; @@ -675,14 +667,16 @@ set_default_def (tree var, tree def) gcc_assert (SSA_VAR_P (var)); in.uid = DECL_UID (var); - if (!def && default_def (var)) + if (!def && gimple_default_def (cfun, var)) { - loc = htab_find_slot_with_hash (default_defs, &in, DECL_UID (var), INSERT); - htab_remove_elt (default_defs, *loc); + loc = htab_find_slot_with_hash (DEFAULT_DEFS (cfun), &in, + DECL_UID (var), INSERT); + htab_remove_elt (DEFAULT_DEFS (cfun), *loc); return; } gcc_assert (TREE_CODE (def) == SSA_NAME); - loc = htab_find_slot_with_hash (default_defs, &in, DECL_UID (var), INSERT); + loc = htab_find_slot_with_hash (DEFAULT_DEFS (cfun), &in, + DECL_UID (var), INSERT); /* Default definition might be changed by tail call optimization. */ if (!*loc) { diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h index ceb1bc91869..ae937b1c9b9 100644 --- a/gcc/tree-flow-inline.h +++ b/gcc/tree-flow-inline.h @@ -25,6 +25,72 @@ Boston, MA 02110-1301, USA. */ /* Inline functions for manipulating various data structures defined in tree-flow.h. See tree-flow.h for documentation. */ +/* Return true when gimple SSA form was built. + gimple_in_ssa_p is queried by gimplifier in various early stages before SSA + infrastructure is initialized. Check for presence of the datastructures + at first place. */ +static inline bool +gimple_in_ssa_p (struct function *fun) +{ + return fun && fun->gimple_df && fun->gimple_df->in_ssa_p; +} + +/* 'true' after aliases have been computed (see compute_may_aliases). */ +static inline bool +gimple_aliases_computed_p (struct function *fun) +{ + gcc_assert (fun && fun->gimple_df); + return fun->gimple_df->aliases_computed_p; +} + +/* Addressable variables in the function. If bit I is set, then + REFERENCED_VARS (I) has had its address taken. Note that + CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related. An + addressable variable is not necessarily call-clobbered (e.g., a + local addressable whose address does not escape) and not all + call-clobbered variables are addressable (e.g., a local static + variable). */ +static inline bitmap +gimple_addressable_vars (struct function *fun) +{ + gcc_assert (fun && fun->gimple_df); + return fun->gimple_df->addressable_vars; +} + +/* Call clobbered variables in the function. If bit I is set, then + REFERENCED_VARS (I) is call-clobbered. */ +static inline bitmap +gimple_call_clobbered_vars (struct function *fun) +{ + gcc_assert (fun && fun->gimple_df); + return fun->gimple_df->call_clobbered_vars; +} + +/* Array of all variables referenced in the function. */ +static inline htab_t +gimple_referenced_vars (struct function *fun) +{ + if (!fun->gimple_df) + return NULL; + return fun->gimple_df->referenced_vars; +} + +/* Artificial variable used to model the effects of function calls. */ +static inline tree +gimple_global_var (struct function *fun) +{ + gcc_assert (fun && fun->gimple_df); + return fun->gimple_df->global_var; +} + +/* Artificial variable used to model the effects of nonlocal + variables. */ +static inline tree +gimple_nonlocal_all (struct function *fun) +{ + gcc_assert (fun && fun->gimple_df); + return fun->gimple_df->nonlocal_all; +} /* Initialize the hashtable iterator HTI to point to hashtable TABLE */ static inline void * @@ -79,7 +145,8 @@ first_referenced_var (referenced_var_iterator *iter) { struct int_tree_map *itm; itm = (struct int_tree_map *) first_htab_element (&iter->hti, - referenced_vars); + gimple_referenced_vars + (cfun)); if (!itm) return NULL; return itm->to; @@ -278,8 +345,8 @@ mark_stmt_modified (tree t) ann = stmt_ann (t); if (ann == NULL) ann = create_stmt_ann (t); - else if (noreturn_call_p (t)) - VEC_safe_push (tree, gc, modified_noreturn_calls, t); + else if (noreturn_call_p (t) && cfun->gimple_df) + VEC_safe_push (tree, gc, MODIFIED_NORETURN_CALLS (cfun), t); ann->modified = 1; } @@ -760,7 +827,7 @@ is_call_clobbered (tree var) if (!MTAG_P (var)) return DECL_CALL_CLOBBERED (var); else - return bitmap_bit_p (call_clobbered_vars, DECL_UID (var)); + return bitmap_bit_p (gimple_call_clobbered_vars (cfun), DECL_UID (var)); } /* Mark variable VAR as being clobbered by function calls. */ @@ -770,7 +837,7 @@ mark_call_clobbered (tree var, unsigned int escape_type) var_ann (var)->escape_mask |= escape_type; if (!MTAG_P (var)) DECL_CALL_CLOBBERED (var) = true; - bitmap_set_bit (call_clobbered_vars, DECL_UID (var)); + bitmap_set_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var)); } /* Clear the call-clobbered attribute from variable VAR. */ @@ -783,7 +850,7 @@ clear_call_clobbered (tree var) MTAG_GLOBAL (var) = 0; if (!MTAG_P (var)) DECL_CALL_CLOBBERED (var) = false; - bitmap_clear_bit (call_clobbered_vars, DECL_UID (var)); + bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var)); } /* Mark variable VAR as being non-addressable. */ @@ -792,7 +859,7 @@ mark_non_addressable (tree var) { if (!MTAG_P (var)) DECL_CALL_CLOBBERED (var) = false; - bitmap_clear_bit (call_clobbered_vars, DECL_UID (var)); + bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var)); TREE_ADDRESSABLE (var) = 0; } diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 6108b6210a3..fad1686f104 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -39,8 +39,63 @@ struct basic_block_def; typedef struct basic_block_def *basic_block; #endif -/* True if the code is in ssa form. */ -extern bool in_ssa_p; +/* Gimple dataflow datastructure. All publically available fields shall have + gimple_ accessor defined in tree-flow-inline.h, all publically modifiable + fields should have gimple_set accessor. */ +struct gimple_df GTY(()) { + /* Array of all variables referenced in the function. */ + htab_t GTY((param_is (struct int_tree_map))) referenced_vars; + /* A list of all the noreturn calls passed to modify_stmt. + cleanup_control_flow uses it to detect cases where a mid-block + indirect call has been turned into a noreturn call. When this + happens, all the instructions after the call are no longer + reachable and must be deleted as dead. */ + VEC(tree,gc) *modified_noreturn_calls; + /* Array of all SSA_NAMEs used in the function. */ + VEC(tree,gc) *ssa_names; + + /* Artificial variable used to model the effects of function calls. */ + tree global_var; + + /* Artificial variable used to model the effects of nonlocal + variables. */ + tree nonlocal_all; + + /* Call clobbered variables in the function. If bit I is set, then + REFERENCED_VARS (I) is call-clobbered. */ + bitmap call_clobbered_vars; + + /* Addressable variables in the function. If bit I is set, then + REFERENCED_VARS (I) has had its address taken. Note that + CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related. An + addressable variable is not necessarily call-clobbered (e.g., a + local addressable whose address does not escape) and not all + call-clobbered variables are addressable (e.g., a local static + variable). */ + bitmap addressable_vars; + + /* Free list of SSA_NAMEs. */ + tree free_ssanames; + + /* Hashtable holding definition for symbol. If this field is not NULL, it + means that the first reference to this variable in the function is a + USE or a VUSE. In those cases, the SSA renamer creates an SSA name + for this variable with an empty defining statement. */ + htab_t GTY((param_is (struct int_tree_map))) default_defs; + + /* 'true' after aliases have been computed (see compute_may_aliases). */ + unsigned int aliases_computed_p : 1; + + /* True if the code is in ssa form. */ + unsigned int in_ssa_p : 1; +}; + +/* Accessors for internal use only. Generic code should use abstraction + provided by tree-flow-inline.h or specific modules. */ +#define FREE_SSANAMES(fun) (fun)->gimple_df->free_ssanames +#define SSANAMES(fun) (fun)->gimple_df->ssa_names +#define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls +#define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs typedef struct { @@ -206,7 +261,7 @@ struct var_ann_d GTY(()) /* During into-ssa and the dominator optimizer, this field holds the current version of this variable (an SSA_NAME). */ tree current_def; - + /* If this variable is a structure, this fields holds a list of symbols representing each of the fields of the structure. */ subvar_t subvars; @@ -329,8 +384,6 @@ union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)"))) struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt; }; -extern GTY(()) VEC(tree,gc) *modified_noreturn_calls; - typedef union tree_ann_d *tree_ann_t; typedef struct var_ann_d *var_ann_t; typedef struct function_ann_d *function_ann_t; @@ -422,40 +475,13 @@ typedef struct VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \ (ITER).i++) -/* Array of all variables referenced in the function. */ -extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars; - -/* Default defs for undefined symbols. */ -extern GTY((param_is (struct int_tree_map))) htab_t default_defs; - extern tree referenced_var_lookup (unsigned int); extern bool referenced_var_check_and_insert (tree); -#define num_referenced_vars htab_elements (referenced_vars) +#define num_referenced_vars htab_elements (gimple_referenced_vars (cfun)) #define referenced_var(i) referenced_var_lookup (i) -/* Array of all SSA_NAMEs used in the function. */ -extern GTY(()) VEC(tree,gc) *ssa_names; - -#define num_ssa_names (VEC_length (tree, ssa_names)) -#define ssa_name(i) (VEC_index (tree, ssa_names, (i))) - -/* Artificial variable used to model the effects of function calls. */ -extern GTY(()) tree global_var; - -/* Artificial variable used to model the effects of nonlocal - variables. */ -extern GTY(()) tree nonlocal_all; - -/* Call clobbered variables in the function. If bit I is set, then - REFERENCED_VARS (I) is call-clobbered. */ -extern bitmap call_clobbered_vars; - -/* Addressable variables in the function. If bit I is set, then - REFERENCED_VARS (I) has had its address taken. */ -extern bitmap addressable_vars; - -/* 'true' after aliases have been computed (see compute_may_aliases). */ -extern bool aliases_computed_p; +#define num_ssa_names (VEC_length (tree, cfun->gimple_df->ssa_names)) +#define ssa_name(i) (VEC_index (tree, cfun->gimple_df->ssa_names, (i))) /* Macros for showing usage statistics. */ #define SCALE(x) ((unsigned long) ((x) < 1024*10 \ @@ -652,8 +678,7 @@ extern void find_new_referenced_vars (tree *); extern tree make_rename_temp (tree, const char *); extern void set_default_def (tree, tree); -extern tree default_def (tree); -extern tree default_def_fn (struct function *, tree); +extern tree gimple_default_def (struct function *, tree); /* In tree-phinodes.c */ extern void reserve_phi_args_for_new_edge (basic_block); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 3bcddfebaeb..3fb2c531817 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -55,9 +55,6 @@ Boston, MA 02110-1301, USA. */ Graph. ACM Transactions on Programming Languages and Systems, 13(4):451-490, October 1991. */ -/* True if the code is in ssa form. */ -bool in_ssa_p; - /* Structure to map a variable VAR to the set of blocks that contain definitions for VAR. */ struct def_blocks_d @@ -1074,7 +1071,7 @@ find_def_blocks_for (tree var) static inline tree get_default_def_for (tree sym) { - tree ddef = default_def (sym); + tree ddef = gimple_default_def (cfun, sym); if (ddef == NULL_TREE) { @@ -2122,7 +2119,7 @@ rewrite_into_ssa (void) sbitmap_free (interesting_blocks); timevar_pop (TV_TREE_SSA_OTHER); - in_ssa_p = true; + cfun->gimple_df->in_ssa_p = true; return 0; } diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index b502fccec66..705066a2805 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -870,7 +870,7 @@ coalesce_ssa_name (var_map map, int flags) for (x = 0 ; x < num; x++) { tree var = partition_to_var (map, x); - if (default_def (SSA_NAME_VAR (var)) == var) + if (gimple_default_def (cfun, SSA_NAME_VAR (var)) == var) SET_BIT (live, x); } @@ -2543,7 +2543,7 @@ rewrite_out_of_ssa (void) /* Flush out flow graph and SSA data. */ delete_var_map (map); - in_ssa_p = false; + cfun->gimple_df->in_ssa_p = false; return 0; } diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index a12dca28025..65a8417b9d3 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -52,9 +52,6 @@ Boston, MA 02110-1301, USA. */ aliasing */ static bitmap_obstack alias_obstack; -/* 'true' after aliases have been computed (see compute_may_aliases). */ -bool aliases_computed_p; - /* Structure to map a variable to its alias set and keep track of the virtual operands that will be needed to represent it. */ struct alias_map_d @@ -117,26 +114,6 @@ static void set_pt_anything (tree ptr); /* Global declarations. */ -/* Call clobbered variables in the function. If bit I is set, then - REFERENCED_VARS (I) is call-clobbered. */ -bitmap call_clobbered_vars; - -/* Addressable variables in the function. If bit I is set, then - REFERENCED_VARS (I) has had its address taken. Note that - CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related. An - addressable variable is not necessarily call-clobbered (e.g., a - local addressable whose address does not escape) and not all - call-clobbered variables are addressable (e.g., a local static - variable). */ -bitmap addressable_vars; - -/* When the program has too many call-clobbered variables and call-sites, - this variable is used to represent the clobbering effects of function - calls. In these cases, all the call clobbered variables in the program - are forced to alias this variable. This reduces compile times by not - having to keep track of too many V_MAY_DEF expressions at call sites. */ -tree global_var; - /* qsort comparison function to sort type/name tags by DECL_UID. */ static int @@ -327,10 +304,10 @@ set_initial_properties (struct alias_info *ai) mark_call_clobbered (var, ESCAPE_IS_GLOBAL); } else if (TREE_CODE (var) == PARM_DECL - && default_def (var) + && gimple_default_def (cfun, var) && POINTER_TYPE_P (TREE_TYPE (var))) { - tree def = default_def (var); + tree def = gimple_default_def (cfun, var); get_ptr_info (def)->value_escapes_p = 1; get_ptr_info (def)->escape_mask |= ESCAPE_IS_PARM; } @@ -883,14 +860,14 @@ init_alias_info (void) ai->dereferenced_ptrs_load = BITMAP_ALLOC (&alias_obstack); /* If aliases have been computed before, clear existing information. */ - if (aliases_computed_p) + if (gimple_aliases_computed_p (cfun)) { unsigned i; /* Similarly, clear the set of addressable variables. In this case, we can just clear the set because addressability is only computed here. */ - bitmap_clear (addressable_vars); + bitmap_clear (gimple_addressable_vars (cfun)); /* Clear flow-insensitive alias information from each symbol. */ FOR_EACH_REFERENCED_VAR (var, rvi) @@ -945,7 +922,7 @@ init_alias_info (void) } /* Next time, we will need to reset alias information. */ - aliases_computed_p = true; + cfun->gimple_df->aliases_computed_p = true; return ai; } @@ -1341,8 +1318,8 @@ finalize_ref_all_pointers (struct alias_info *ai) { size_t i; - if (global_var) - add_may_alias (ai->ref_all_symbol_mem_tag, global_var); + if (gimple_global_var (cfun)) + add_may_alias (ai->ref_all_symbol_mem_tag, gimple_global_var (cfun)); else { /* First add the real call-clobbered variables. */ @@ -1761,7 +1738,7 @@ setup_pointers_and_addressables (struct alias_info *ai) cleanup passes. */ if (TREE_ADDRESSABLE (var)) { - if (!bitmap_bit_p (addressable_vars, DECL_UID (var)) + if (!bitmap_bit_p (gimple_addressable_vars (cfun), DECL_UID (var)) && TREE_CODE (var) != RESULT_DECL && !is_global_var (var)) { @@ -1781,7 +1758,8 @@ setup_pointers_and_addressables (struct alias_info *ai) for (sv = svars; sv; sv = sv->next) { - if (bitmap_bit_p (addressable_vars, DECL_UID (sv->var))) + if (bitmap_bit_p (gimple_addressable_vars (cfun), + DECL_UID (sv->var))) okay_to_mark = false; mark_sym_for_renaming (sv->var); } @@ -1902,11 +1880,11 @@ maybe_create_global_var (struct alias_info *ai) bitmap_iterator bi; /* No need to create it, if we have one already. */ - if (global_var == NULL_TREE) + if (gimple_global_var (cfun) == NULL_TREE) { /* Count all the call-clobbered variables. */ n_clobbered = 0; - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, i, bi) { n_clobbered++; } @@ -1949,16 +1927,16 @@ maybe_create_global_var (struct alias_info *ai) /* Mark all call-clobbered symbols for renaming. Since the initial rewrite into SSA ignored all call sites, we may need to rename .GLOBAL_VAR and the call-clobbered variables. */ - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, i, bi) { tree var = referenced_var (i); /* If the function has calls to clobbering functions and .GLOBAL_VAR has been created, make it an alias for all call-clobbered variables. */ - if (global_var && var != global_var) + if (gimple_global_var (cfun) && var != gimple_global_var (cfun)) { - add_may_alias (var, global_var); + add_may_alias (var, gimple_global_var (cfun)); gcc_assert (!get_subvars_for_var (var)); } @@ -2398,8 +2376,8 @@ get_tmt_for (tree ptr, struct alias_info *ai) static void create_global_var (void) { - global_var = build_decl (VAR_DECL, get_identifier (".GLOBAL_VAR"), - void_type_node); + tree global_var = build_decl (VAR_DECL, get_identifier (".GLOBAL_VAR"), + void_type_node); DECL_ARTIFICIAL (global_var) = 1; TREE_READONLY (global_var) = 0; DECL_EXTERNAL (global_var) = 1; @@ -2413,6 +2391,7 @@ create_global_var (void) mark_call_clobbered (global_var, ESCAPE_UNKNOWN); add_referenced_var (global_var); mark_sym_for_renaming (global_var); + cfun->gimple_df->global_var = global_var; } @@ -2622,7 +2601,7 @@ dump_points_to_info (FILE *file) { if (POINTER_TYPE_P (TREE_TYPE (var))) { - tree def = default_def (var); + tree def = gimple_default_def (cfun, var); if (def) dump_points_to_info_for (file, def); } diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c index 45f65678e1a..a0ffefd0a6c 100644 --- a/gcc/tree-ssa-copyrename.c +++ b/gcc/tree-ssa-copyrename.c @@ -219,9 +219,9 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) /* If both values have default defs, we can't coalesce. If only one has a tag, make sure that variable is the new root partition. */ - if (default_def (root1)) + if (gimple_default_def (cfun, root1)) { - if (default_def (root2)) + if (gimple_default_def (cfun, root2)) { if (debug) fprintf (debug, " : 2 default defs. No coalesce.\n"); @@ -233,7 +233,7 @@ copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug) ign1 = false; } } - else if (default_def (root2)) + else if (gimple_default_def (cfun, root2)) { ign1 = true; ign2 = false; diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index fe6701594b6..f7f333f0b2c 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -173,7 +173,7 @@ memory_ssa_name_same (tree *expr_p, int *walk_subtrees ATTRIBUTE_UNUSED, /* If we've found a default definition, then there's no problem. Both stores will post-dominate it. And def_bb will be NULL. */ - if (expr == default_def (SSA_NAME_VAR (expr))) + if (expr == gimple_default_def (cfun, SSA_NAME_VAR (expr))) return NULL_TREE; def_stmt = SSA_NAME_DEF_STMT (expr); diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index a5fe403ef53..b34190f219f 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -736,7 +736,7 @@ calculate_live_on_entry (var_map map) var = partition_to_var (map, i); stmt = SSA_NAME_DEF_STMT (var); tmp = bb_for_stmt (stmt); - d = default_def (SSA_NAME_VAR (var)); + d = gimple_default_def (cfun, SSA_NAME_VAR (var)); if (bitmap_bit_p (live_entry_blocks (live, i), entry_block)) { diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 1ff06285de8..76b0c3ea9b3 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -469,10 +469,10 @@ execute_cse_reciprocals (void) #endif for (arg = DECL_ARGUMENTS (cfun->decl); arg; arg = TREE_CHAIN (arg)) - if (default_def (arg) + if (gimple_default_def (cfun, arg) && FLOAT_TYPE_P (TREE_TYPE (arg)) && is_gimple_reg (arg)) - execute_cse_reciprocals_1 (NULL, default_def (arg)); + execute_cse_reciprocals_1 (NULL, gimple_default_def (cfun, arg)); FOR_EACH_BB (bb) { diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 2c776836ce6..a594d4d5dab 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1050,12 +1050,12 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset, /* If ALIAS is .GLOBAL_VAR then the memory reference REF must be using a call-clobbered memory tag. By definition, call-clobbered memory tags can always touch .GLOBAL_VAR. */ - if (alias == global_var) + if (alias == gimple_global_var (cfun)) return true; /* We cannot prune nonlocal aliases because they are not type specific. */ - if (alias == nonlocal_all) + if (alias == gimple_nonlocal_all (cfun)) return true; /* If ALIAS is an SFT, it can't be touched if the offset @@ -1317,7 +1317,7 @@ add_virtual_operand (tree var, stmt_ann_t s_ann, int flags, set on it, or else we will get the wrong answer on clobbers. */ if (none_added - && !updating_used_alone && aliases_computed_p + && !updating_used_alone && gimple_aliases_computed_p (cfun) && TREE_CODE (var) == SYMBOL_MEMORY_TAG) gcc_assert (SMT_USED_ALONE (var)); @@ -1552,9 +1552,10 @@ add_call_clobber_ops (tree stmt, tree callee) /* If we created .GLOBAL_VAR earlier, just use it. See compute_may_aliases for the heuristic used to decide whether to create .GLOBAL_VAR or not. */ - if (global_var) + if (gimple_global_var (cfun)) { - add_stmt_operand (&global_var, s_ann, opf_is_def); + tree var = gimple_global_var (cfun); + add_stmt_operand (&var, s_ann, opf_is_def); return; } @@ -1564,7 +1565,7 @@ add_call_clobber_ops (tree stmt, tree callee) not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; not_written_b = callee ? ipa_reference_get_not_written_global (callee) : NULL; /* Add a V_MAY_DEF operand for every call clobbered variable. */ - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, u, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, u, bi) { tree var = referenced_var_lookup (u); unsigned int escape_mask = var_ann (var)->escape_mask; @@ -1633,16 +1634,17 @@ add_call_read_ops (tree stmt, tree callee) /* if the function is not pure, it may reference memory. Add a VUSE for .GLOBAL_VAR if it has been created. See add_referenced_var for the heuristic used to decide whether to create .GLOBAL_VAR. */ - if (global_var) + if (gimple_global_var (cfun)) { - add_stmt_operand (&global_var, s_ann, opf_none); + tree var = gimple_global_var (cfun); + add_stmt_operand (&var, s_ann, opf_none); return; } not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; /* Add a VUSE for each call-clobbered variable. */ - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, u, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, u, bi) { tree var = referenced_var (u); tree real_var = var; @@ -1688,8 +1690,8 @@ get_call_expr_operands (tree stmt, tree expr) computed. By not bothering with virtual operands for CALL_EXPRs we avoid adding superfluous virtual operands, which can be a significant compile time sink (See PR 15855). */ - if (aliases_computed_p - && !bitmap_empty_p (call_clobbered_vars) + if (gimple_aliases_computed_p (cfun) + && !bitmap_empty_p (gimple_call_clobbered_vars (cfun)) && !(call_flags & ECF_NOVOPS)) { /* A 'pure' or a 'const' function never call-clobbers anything. @@ -1776,17 +1778,20 @@ get_asm_expr_operands (tree stmt) /* Clobber all call-clobbered variables (or .GLOBAL_VAR if we decided to group them). */ - if (global_var) - add_stmt_operand (&global_var, s_ann, opf_is_def); + if (gimple_global_var (cfun)) + { + tree var = gimple_global_var (cfun); + add_stmt_operand (&var, s_ann, opf_is_def); + } else - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, i, bi) { tree var = referenced_var (i); add_stmt_operand (&var, s_ann, opf_is_def | opf_non_specific); } /* Now clobber all addressables. */ - EXECUTE_IF_SET_IN_BITMAP (addressable_vars, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_addressable_vars (cfun), 0, i, bi) { tree var = referenced_var (i); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 2a0ac9641a4..80986eb0860 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3660,9 +3660,9 @@ compute_avail (void) param; param = TREE_CHAIN (param)) { - if (default_def (param) != NULL) + if (gimple_default_def (cfun, param) != NULL) { - tree def = default_def (param); + tree def = gimple_default_def (cfun, param); vn_lookup_or_add (def, NULL); bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), def); @@ -3676,9 +3676,9 @@ compute_avail (void) if (cfun->static_chain_decl) { param = cfun->static_chain_decl; - if (default_def (param) != NULL) + if (gimple_default_def (cfun, param) != NULL) { - tree def = default_def (param); + tree def = gimple_default_def (cfun, param); vn_lookup_or_add (def, NULL); bitmap_insert_into_set (TMP_GEN (ENTRY_BLOCK_PTR), def); diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index e367559f0cf..a5114862dc8 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -688,7 +688,7 @@ set_rhs (tree *stmt_p, tree expr) *stmt_p = TREE_SIDE_EFFECTS (expr) ? expr : build_empty_stmt (); (*stmt_p)->common.ann = (tree_ann_t) ann; - if (in_ssa_p + if (gimple_in_ssa_p (cfun) && TREE_SIDE_EFFECTS (expr)) { /* Fix all the SSA_NAMEs created by *STMT_P to point to its new diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 477d8c8e407..6835a179125 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -264,7 +264,7 @@ get_rank (tree e) int i; if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL - && e == default_def (SSA_NAME_VAR (e))) + && e == gimple_default_def (cfun, SSA_NAME_VAR (e))) return find_operand_rank (e)->rank; stmt = SSA_NAME_DEF_STMT (e); @@ -1435,9 +1435,9 @@ init_reassoc (void) param; param = TREE_CHAIN (param)) { - if (default_def (param) != NULL) + if (gimple_default_def (cfun, param) != NULL) { - tree def = default_def (param); + tree def = gimple_default_def (cfun, param); insert_operand_rank (def, ++rank); } } @@ -1445,7 +1445,7 @@ init_reassoc (void) /* Give the chain decl a distinct rank. */ if (cfun->static_chain_decl != NULL) { - tree def = default_def (cfun->static_chain_decl); + tree def = gimple_default_def (cfun, cfun->static_chain_decl); if (def != NULL) insert_operand_rank (def, ++rank); } diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 4354b443cba..30769eccae2 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -165,9 +165,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) htab_t heapvar_for_stmt; -/* One variable to represent all non-local accesses. */ -tree nonlocal_all; - static bool use_field_sensitive = true; static int in_ipa_mode = 0; static bitmap_obstack predbitmap_obstack; @@ -1836,7 +1833,7 @@ get_constraint_exp_from_ssa_var (tree t) decl. */ if (TREE_CODE (t) == SSA_NAME && TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL - && default_def (SSA_NAME_VAR (t)) == t) + && gimple_default_def (cfun, SSA_NAME_VAR (t)) == t) return get_constraint_exp_from_ssa_var (SSA_NAME_VAR (t)); cexpr.type = SCALAR; @@ -2101,7 +2098,7 @@ create_nonlocal_var (tree type) { tree nonlocal = create_tmp_var_raw (type, "NONLOCAL"); - if (referenced_vars) + if (gimple_referenced_vars (cfun)) add_referenced_var (nonlocal); DECL_EXTERNAL (nonlocal) = 1; @@ -2224,7 +2221,7 @@ get_constraint_for (tree t, VEC (ce_s, heap) **results) heapvar = create_tmp_var_raw (ptr_type_node, "HEAP"); DECL_EXTERNAL (heapvar) = 1; get_var_ann (heapvar)->is_heapvar = 1; - if (referenced_vars) + if (gimple_referenced_vars (cfun)) add_referenced_var (heapvar); heapvar_insert (t, heapvar); } @@ -2659,7 +2656,7 @@ update_alias_info (tree stmt, struct alias_info *ai) addr_taken = addresses_taken (stmt); if (addr_taken) { - bitmap_ior_into (addressable_vars, addr_taken); + bitmap_ior_into (gimple_addressable_vars (cfun), addr_taken); /* If STMT is an escape point, all the addresses taken by it are call-clobbered. */ @@ -2695,7 +2692,10 @@ update_alias_info (tree stmt, struct alias_info *ai) to the set of addressable variables. */ if (TREE_CODE (op) == ADDR_EXPR) { + bitmap addressable_vars = gimple_addressable_vars (cfun); + gcc_assert (TREE_CODE (stmt) == PHI_NODE); + gcc_assert (addressable_vars); /* PHI nodes don't have annotations for pinning the set of addresses taken, so we collect them here. @@ -2704,7 +2704,8 @@ update_alias_info (tree stmt, struct alias_info *ai) so that they can be treated like regular statements? Currently, they are treated as second-class statements. */ - add_to_addressable_set (TREE_OPERAND (op, 0), &addressable_vars); + add_to_addressable_set (TREE_OPERAND (op, 0), + &addressable_vars); continue; } @@ -3608,7 +3609,7 @@ find_global_initializers (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, case VAR_DECL: /* We might not have walked this because we skip DECL_EXTERNALs during the initial scan. */ - if (referenced_vars) + if (gimple_referenced_vars (cfun)) { get_var_ann (t); if (referenced_var_check_and_insert (t)) @@ -3867,7 +3868,7 @@ intra_create_variable_infos (void) "PARM_NOALIAS"); get_var_ann (heapvar)->is_heapvar = 1; DECL_EXTERNAL (heapvar) = 1; - if (referenced_vars) + if (gimple_referenced_vars (cfun)) add_referenced_var (heapvar); heapvar_insert (t, heapvar); } @@ -3891,13 +3892,14 @@ intra_create_variable_infos (void) make_constraint_from_escaped (p); } } - if (!nonlocal_all) - nonlocal_all = create_nonlocal_var (void_type_node); + if (!gimple_nonlocal_all (cfun)) + cfun->gimple_df->nonlocal_all = create_nonlocal_var (void_type_node); /* Create variable info for the nonlocal var if it does not exist. */ - nonlocal_vars_id = create_variable_info_for (nonlocal_all, - get_name (nonlocal_all)); + nonlocal_vars_id = create_variable_info_for (gimple_nonlocal_all (cfun), + get_name (gimple_nonlocal_all + (cfun))); nonlocal_vi = get_varinfo (nonlocal_vars_id); nonlocal_vi->is_artificial_var = 1; nonlocal_vi->is_heap_var = 1; @@ -3999,7 +4001,7 @@ find_what_p_points_to (tree p) decl. */ if (TREE_CODE (p) == SSA_NAME && TREE_CODE (SSA_NAME_VAR (p)) == PARM_DECL - && default_def (SSA_NAME_VAR (p)) == p) + && gimple_default_def (cfun, SSA_NAME_VAR (p)) == p) lookup_p = SSA_NAME_VAR (p); if (lookup_id_for_tree (lookup_p, &id)) @@ -4591,13 +4593,13 @@ init_alias_heapvars (void) { heapvar_for_stmt = htab_create_ggc (11, tree_map_hash, tree_map_eq, NULL); - nonlocal_all = NULL_TREE; + cfun->gimple_df->nonlocal_all = NULL_TREE; } void delete_alias_heapvars (void) { - nonlocal_all = NULL_TREE; + cfun->gimple_df->nonlocal_all = NULL_TREE; htab_delete (heapvar_for_stmt); } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index b90916f877d..4914510d752 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -231,7 +231,7 @@ verify_use (basic_block bb, basic_block def_bb, use_operand_p use_p, TREE_VISITED (ssa_name) = 1; if (IS_EMPTY_STMT (SSA_NAME_DEF_STMT (ssa_name)) - && default_def (SSA_NAME_VAR (ssa_name)) == ssa_name) + && gimple_default_def (cfun, SSA_NAME_VAR (ssa_name)) == ssa_name) ; /* Default definitions have empty statements. Nothing to do. */ else if (!def_bb) { @@ -627,7 +627,7 @@ verify_call_clobbering (void) that everything in call_clobbered_vars is marked DECL_CALL_CLOBBERED, and that everything marked DECL_CALL_CLOBBERED is in call_clobbered_vars. */ - EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi) + EXECUTE_IF_SET_IN_BITMAP (gimple_call_clobbered_vars (cfun), 0, i, bi) { var = referenced_var (i); if (!MTAG_P (var) && !DECL_CALL_CLOBBERED (var)) @@ -640,7 +640,7 @@ verify_call_clobbering (void) FOR_EACH_REFERENCED_VAR (var, rvi) { if (!MTAG_P (var) && DECL_CALL_CLOBBERED (var) - && !bitmap_bit_p (call_clobbered_vars, DECL_UID (var))) + && !bitmap_bit_p (gimple_call_clobbered_vars (cfun), DECL_UID (var))) { error ("variable marked DECL_CALL_CLOBBERED but not in call_clobbered_vars bitmap."); debug_variable (var); @@ -830,16 +830,16 @@ int_tree_map_hash (const void *item) void init_tree_ssa (void) { - referenced_vars = htab_create_ggc (20, int_tree_map_hash, - int_tree_map_eq, NULL); - default_defs = htab_create_ggc (20, int_tree_map_hash, int_tree_map_eq, NULL); - call_clobbered_vars = BITMAP_ALLOC (NULL); - addressable_vars = BITMAP_ALLOC (NULL); + cfun->gimple_df = ggc_alloc_cleared (sizeof (struct gimple_df)); + cfun->gimple_df->referenced_vars = htab_create_ggc (20, int_tree_map_hash, + int_tree_map_eq, NULL); + cfun->gimple_df->default_defs = htab_create_ggc (20, int_tree_map_hash, + int_tree_map_eq, NULL); + cfun->gimple_df->call_clobbered_vars = BITMAP_GGC_ALLOC (); + cfun->gimple_df->addressable_vars = BITMAP_GGC_ALLOC (); init_alias_heapvars (); init_ssanames (); init_phinodes (); - global_var = NULL_TREE; - aliases_computed_p = false; } @@ -887,21 +887,19 @@ delete_tree_ssa (void) ggc_free (var->common.ann); var->common.ann = NULL; } - htab_delete (referenced_vars); - referenced_vars = NULL; + htab_delete (gimple_referenced_vars (cfun)); + cfun->gimple_df->referenced_vars = NULL; fini_ssanames (); fini_phinodes (); - global_var = NULL_TREE; + cfun->gimple_df->global_var = NULL_TREE; - htab_delete (default_defs); - BITMAP_FREE (call_clobbered_vars); - call_clobbered_vars = NULL; - BITMAP_FREE (addressable_vars); - addressable_vars = NULL; - modified_noreturn_calls = NULL; - aliases_computed_p = false; + htab_delete (cfun->gimple_df->default_defs); + cfun->gimple_df->call_clobbered_vars = NULL; + cfun->gimple_df->addressable_vars = NULL; + cfun->gimple_df->modified_noreturn_calls = NULL; + cfun->gimple_df->aliases_computed_p = false; delete_alias_heapvars (); gcc_assert (!need_ssa_update_p ()); } diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 5077808947b..21d5761d03b 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -57,13 +57,6 @@ Boston, MA 02110-1301, USA. */ We could also use a zone allocator for these objects since they have a very well defined lifetime. If someone wants to experiment with that this is the place to try it. */ - -/* Array of all SSA_NAMEs used in the function. */ -VEC(tree,gc) *ssa_names; - -/* Free list of SSA_NAMEs. This list is wiped at the end of each function - after we leave SSA form. */ -static GTY (()) tree free_ssanames; /* Version numbers with special meanings. We start allocating new version numbers after the special ones. */ @@ -79,7 +72,7 @@ unsigned int ssa_name_nodes_created; void init_ssanames (void) { - ssa_names = VEC_alloc (tree, gc, 50); + SSANAMES (cfun) = VEC_alloc (tree, gc, 50); /* Version 0 is special, so reserve the first slot in the table. Though currently unused, we may use version 0 in alias analysis as part of @@ -88,8 +81,8 @@ init_ssanames (void) We use VEC_quick_push here because we know that SSA_NAMES has at least 50 elements reserved in it. */ - VEC_quick_push (tree, ssa_names, NULL_TREE); - free_ssanames = NULL; + VEC_quick_push (tree, SSANAMES (cfun), NULL_TREE); + FREE_SSANAMES (cfun) = NULL; } /* Finalize management of SSA_NAMEs. */ @@ -97,8 +90,8 @@ init_ssanames (void) void fini_ssanames (void) { - VEC_free (tree, gc, ssa_names); - free_ssanames = NULL; + VEC_free (tree, gc, SSANAMES (cfun)); + FREE_SSANAMES (cfun) = NULL; } /* Dump some simple statistics regarding the re-use of SSA_NAME nodes. */ @@ -129,10 +122,10 @@ make_ssa_name (tree var, tree stmt) gcc_assert (!stmt || EXPR_P (stmt) || TREE_CODE (stmt) == PHI_NODE); /* If our free list has an element, then use it. */ - if (free_ssanames) + if (FREE_SSANAMES (cfun)) { - t = free_ssanames; - free_ssanames = TREE_CHAIN (free_ssanames); + t = FREE_SSANAMES (cfun); + FREE_SSANAMES (cfun) = TREE_CHAIN (FREE_SSANAMES (cfun)); #ifdef GATHER_STATISTICS ssa_name_nodes_reused++; #endif @@ -140,13 +133,13 @@ make_ssa_name (tree var, tree stmt) /* The node was cleared out when we put it on the free list, so there is no need to do so again here. */ gcc_assert (ssa_name (SSA_NAME_VERSION (t)) == NULL); - VEC_replace (tree, ssa_names, SSA_NAME_VERSION (t), t); + VEC_replace (tree, SSANAMES (cfun), SSA_NAME_VERSION (t), t); } else { t = make_node (SSA_NAME); SSA_NAME_VERSION (t) = num_ssa_names; - VEC_safe_push (tree, gc, ssa_names, t); + VEC_safe_push (tree, gc, SSANAMES (cfun), t); #ifdef GATHER_STATISTICS ssa_name_nodes_created++; #endif @@ -183,7 +176,7 @@ release_ssa_name (tree var) /* Never release the default definition for a symbol. It's a special SSA name that should always exist once it's created. */ - if (var == default_def (SSA_NAME_VAR (var))) + if (var == gimple_default_def (cfun, SSA_NAME_VAR (var))) return; /* If VAR has been registered for SSA updating, don't remove it. @@ -213,7 +206,8 @@ release_ssa_name (tree var) while (imm->next != imm) delink_imm_use (imm->next); - VEC_replace (tree, ssa_names, SSA_NAME_VERSION (var), NULL_TREE); + VEC_replace (tree, SSANAMES (cfun), + SSA_NAME_VERSION (var), NULL_TREE); memset (var, 0, tree_size (var)); imm->prev = imm; @@ -234,8 +228,8 @@ release_ssa_name (tree var) SSA_NAME_IN_FREE_LIST (var) = 1; /* And finally link it into the free list. */ - TREE_CHAIN (var) = free_ssanames; - free_ssanames = var; + TREE_CHAIN (var) = FREE_SSANAMES (cfun); + FREE_SSANAMES (cfun) = var; } } @@ -291,7 +285,7 @@ release_defs (tree stmt) /* Make sure that we are in SSA. Otherwise, operand cache may point to garbage. */ - gcc_assert (in_ssa_p); + gcc_assert (gimple_in_ssa_p (cfun)); FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS) if (TREE_CODE (def) == SSA_NAME) @@ -307,5 +301,3 @@ replace_ssa_name_symbol (tree ssa_name, tree sym) SSA_NAME_VAR (ssa_name) = sym; TREE_TYPE (ssa_name) = TREE_TYPE (sym); } - -#include "gt-tree-ssanames.h" diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index e45f0be352f..616a550d55c 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -702,7 +702,7 @@ arg_needs_copy_p (tree param) return false; /* Parameters that are only defined but never used need not be copied. */ - def = default_def (param); + def = gimple_default_def (cfun, param); if (!def) return false; @@ -826,7 +826,7 @@ add_virtual_phis (void) FOR_EACH_REFERENCED_VAR (var, rvi) { - if (!is_gimple_reg (var) && default_def (var) != NULL_TREE) + if (!is_gimple_reg (var) && gimple_default_def (cfun, var) != NULL_TREE) mark_sym_for_renaming (var); } @@ -911,7 +911,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) param = TREE_CHAIN (param)) if (arg_needs_copy_p (param)) { - tree name = default_def (param); + tree name = gimple_default_def (cfun, param); tree new_name = make_ssa_name (param, SSA_NAME_DEF_STMT (name)); tree phi; diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 68c5435709c..fed86cbc5e6 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -273,7 +273,7 @@ get_value_range (tree var) /* If VAR is a default definition, the variable can take any value in VAR's type. */ sym = SSA_NAME_VAR (var); - if (var == default_def (sym)) + if (var == gimple_default_def (cfun, sym)) { /* Try to use the "nonnull" attribute to create ~[0, 0] anti-ranges for pointers. Note that this is only valid with -- 2.11.4.GIT