aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2007-04-11 16:14:06 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2007-04-11 12:14:06 -0400
commite9e0aa2c9677074a7912521f4fa1aebf53640198 (patch)
tree40007b60a5085028843a5b427234f0fd32072b58 /gcc/tree-dfa.c
parent574e75f5fb8c1ee2e38d6da90a88bb6c546ebb84 (diff)
downloadgcc-e9e0aa2c9677074a7912521f4fa1aebf53640198.zip
gcc-e9e0aa2c9677074a7912521f4fa1aebf53640198.tar.gz
gcc-e9e0aa2c9677074a7912521f4fa1aebf53640198.tar.bz2
re PR tree-optimization/30735 (50% slow down due to mem-ssa merge)
PR 30735 PR 31090 * doc/invoke.texi: Document --params max-aliased-vops and avg-aliased-vops. * tree-ssa-operands.h (get_mpt_for, dump_memory_partitions, debug_memory_partitions): Move to tree-flow.h * params.h (AVG_ALIASED_VOPS): Define. * tree-ssa-alias.c (struct mp_info_def): Remove. Update all users. (mp_info_t): Likewise. (get_mem_sym_stats_for): New. (set_memory_partition): Move from tree-flow-inline.h. (mark_non_addressable): Only clear the set of symbols for the partition if it exists. (dump_memory_partitions): Move from tree-ssa-operands.c (debug_memory_partitions): Likewise. (need_to_partition_p): New. (dump_mem_ref_stats): New. (debug_mem_ref_stats): New. (dump_mem_sym_stats): New. (debug_mem_sym_stats): New. (update_mem_sym_stats_from_stmt): New. (compare_mp_info_entries): New. (mp_info_cmp): Call it. (sort_mp_info): Change argument to a list of mem_sym_stats_t objects. (get_mpt_for): Move from tree-ssa-operands.c. (find_partition_for): New. (create_partition_for): Remove. (estimate_vop_reduction): New. (update_reference_counts): New. (build_mp_info): New. (compute_memory_partitions): Refactor. Document new heuristic. Call build_mp_info, update_reference_counts, find_partition_for and estimate_vop_reduction. (compute_may_aliases): Populate virtual operands before calling debugging dumps. (delete_mem_sym_stats): New. (delete_mem_ref_stats): New. (init_mem_ref_stats): New. (init_alias_info): Call it. (maybe_create_global_var): Remove alias_info argument. Get number of call sites and number of pure/const call sites from gimple_mem_ref_stats(). (dump_alias_info): Call dump_memory_partitions first. (dump_points_to_info_for): Show how many times a pointer has been dereferenced. * opts.c (decode_options): For -O2 set --param max-aliased-vops to 500. For -O3 set --param max-aliased-vops to 1000 and --param avg-aliased-vops to 3. * fortran/options.c (gfc_init_options): Remove assignment to MAX_ALIASED_VOPS. * tree-flow-inline.h (gimple_mem_ref_stats): New. * tree-dfa.c (dump_variable): Dump memory reference statistics. Dump NO_ALIAS* settings. (referenced_var_lookup): Tidy. (mem_sym_stats): New. * tree-ssa-copy.c (may_propagate_copy): Return true if DEST and ORIG are different SSA names for a memory partition. * tree-ssa.c (delete_tree_ssa): Call delete_mem_ref_stats. * tree-flow.h (struct mem_sym_stats_d): Define. (mem_sym_stats_t): Define. (struct mem_ref_stats_d): Define. (struct gimple_df): Add field mem_ref_stats. (enum noalias_state): Define. (struct var_ann_d): Add bitfield noalias_state. (mem_sym_stats, delete_mem_ref_stats, dump_mem_ref_stats, debug_mem_ref_stats, debug_memory_partitions, debug_mem_sym_stats): Declare. * tree-ssa-structalias.c (update_alias_info): Update call sites, pure/const call sites and asm sites in structure returned by gimple_mem_ref_stats. Remove local variable IS_POTENTIAL_DEREF. Increase NUM_DEREFS if the memory expression is a potential dereference. Call update_mem_sym_stats_from_stmt. If the memory references memory, call update_mem_sym_stats_from_stmt for all the direct memory symbol references found. (intra_create_variable_infos): Set noalias_state field for pointer arguments according to the value of flag_argument_noalias. * tree-ssa-structalias.h (struct alias_info): Remove fields num_calls_found and num_pure_const_calls_found. (update_mem_sym_stats_from_stmt): Declare. * params.def (PARAM_MAX_ALIASED_VOPS): Change description. Set default value to 100. (PARAM_AVG_ALIASED_VOPS): Define. From-SVN: r123719
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r--gcc/tree-dfa.c67
1 files changed, 55 insertions, 12 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 70563e7..bc07023 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -346,34 +346,54 @@ dump_variable (FILE *file, tree var)
if (TREE_THIS_VOLATILE (var))
fprintf (file, ", is volatile");
+ if (mem_sym_stats (cfun, var))
+ {
+ mem_sym_stats_t stats = mem_sym_stats (cfun, var);
+ fprintf (file, ", direct reads: %ld", stats->num_direct_reads);
+ fprintf (file, ", direct writes: %ld", stats->num_direct_writes);
+ fprintf (file, ", indirect reads: %ld", stats->num_indirect_reads);
+ fprintf (file, ", indirect writes: %ld", stats->num_indirect_writes);
+ fprintf (file, ", read frequency: %ld", stats->frequency_reads);
+ fprintf (file, ", write frequency: %ld", stats->frequency_writes);
+ }
+
if (is_call_clobbered (var))
{
+ const char *s = "";
var_ann_t va = var_ann (var);
unsigned int escape_mask = va->escape_mask;
fprintf (file, ", call clobbered");
fprintf (file, " (");
if (escape_mask & ESCAPE_STORED_IN_GLOBAL)
- fprintf (file, ", stored in global");
+ { fprintf (file, "%sstored in global", s); s = ", "; }
if (escape_mask & ESCAPE_TO_ASM)
- fprintf (file, ", goes through ASM");
+ { fprintf (file, "%sgoes through ASM", s); s = ", "; }
if (escape_mask & ESCAPE_TO_CALL)
- fprintf (file, ", passed to call");
+ { fprintf (file, "%spassed to call", s); s = ", "; }
if (escape_mask & ESCAPE_BAD_CAST)
- fprintf (file, ", bad cast");
+ { fprintf (file, "%sbad cast", s); s = ", "; }
if (escape_mask & ESCAPE_TO_RETURN)
- fprintf (file, ", returned from func");
+ { fprintf (file, "%sreturned from func", s); s = ", "; }
if (escape_mask & ESCAPE_TO_PURE_CONST)
- fprintf (file, ", passed to pure/const");
+ { fprintf (file, "%spassed to pure/const", s); s = ", "; }
if (escape_mask & ESCAPE_IS_GLOBAL)
- fprintf (file, ", is global var");
+ { fprintf (file, "%sis global var", s); s = ", "; }
if (escape_mask & ESCAPE_IS_PARM)
- fprintf (file, ", is incoming pointer");
+ { fprintf (file, "%sis incoming pointer", s); s = ", "; }
if (escape_mask & ESCAPE_UNKNOWN)
- fprintf (file, ", unknown escape");
- fprintf (file, " )");
+ { fprintf (file, "%sunknown escape", s); s = ", "; }
+ fprintf (file, ")");
}
+ if (ann->noalias_state == NO_ALIAS)
+ fprintf (file, ", NO_ALIAS (does not alias other NO_ALIAS symbols)");
+ else if (ann->noalias_state == NO_ALIAS_GLOBAL)
+ fprintf (file, ", NO_ALIAS_GLOBAL (does not alias other NO_ALIAS symbols"
+ " and global vars)");
+ else if (ann->noalias_state == NO_ALIAS_ANYTHING)
+ fprintf (file, ", NO_ALIAS_ANYTHING (does not alias any other symbols)");
+
if (gimple_default_def (cfun, var))
{
fprintf (file, ", default def: ");
@@ -618,8 +638,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 (gimple_referenced_vars (cfun),
- &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;
@@ -1011,3 +1031,26 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
return exp;
}
+
+
+/* Return memory reference statistics for variable VAR in function FN.
+ This is computed by alias analysis, but it is not kept
+ incrementally up-to-date. So, these stats are only accurate if
+ pass_may_alias has been run recently. If no alias information
+ exists, this function returns NULL. */
+
+mem_sym_stats_t
+mem_sym_stats (struct function *fn, tree var)
+{
+ void **slot;
+ struct pointer_map_t *stats_map = gimple_mem_ref_stats (fn)->mem_sym_stats;
+
+ if (stats_map == NULL)
+ return NULL;
+
+ slot = pointer_map_contains (stats_map, var);
+ if (slot == NULL)
+ return NULL;
+
+ return (mem_sym_stats_t) *slot;
+}