summaryrefslogtreecommitdiff
path: root/gcc/tree-flow.h
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-11 16:14:06 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-11 16:14:06 +0000
commitc227f8def1ec1ff3dba7bc6459029e97da4885af (patch)
tree40007b60a5085028843a5b427234f0fd32072b58 /gcc/tree-flow.h
parent10e1d11768fec298b027d11575e9847febb3ed9a (diff)
downloadgcc-c227f8def1ec1ff3dba7bc6459029e97da4885af.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123719 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-flow.h')
-rw-r--r--gcc/tree-flow.h125
1 files changed, 121 insertions, 4 deletions
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index ea2d677be43..4d9b36e4ab8 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -41,10 +41,85 @@ typedef struct basic_block_def *basic_block;
#endif
struct static_var_ann_d;
+/* Memory reference statistics for individual memory symbols,
+ collected during alias analysis. */
+struct mem_sym_stats_d GTY(())
+{
+ /* Memory symbol. */
+ tree var;
+
+ /* Nonzero if this entry has been assigned a partition. */
+ unsigned int partitioned_p : 1;
+
+ /* Nonzero if VAR is a memory partition tag that already contains
+ call-clobbered variables in its partition set. */
+ unsigned int has_call_clobbered_vars : 1;
+
+ /* Number of direct reference sites. A direct reference to VAR is any
+ reference of the form 'VAR = ' or ' = VAR'. For GIMPLE reg
+ pointers, this is the number of sites where the pointer is
+ dereferenced. */
+ long num_direct_writes;
+ long num_direct_reads;
+
+ /* Number of indirect reference sites. An indirect reference to VAR
+ is any reference via a pointer that contains VAR in its points-to
+ set or, in the case of call-clobbered symbols, a function call. */
+ long num_indirect_writes;
+ long num_indirect_reads;
+
+ /* Execution frequency. This is the sum of the execution
+ frequencies of all the statements that reference this object
+ weighted by the number of references in each statement. This is
+ the main key used to sort the list of symbols to partition.
+ Symbols with high execution frequencies are put at the bottom of
+ the work list (ie, they are partitioned last).
+ Execution frequencies are taken directly from each basic block,
+ so compiling with PGO enabled will increase the precision of this
+ estimate. */
+ long frequency_reads;
+ long frequency_writes;
+
+ /* Set of memory tags that contain VAR in their alias set. */
+ bitmap parent_tags;
+};
+
+typedef struct mem_sym_stats_d *mem_sym_stats_t;
+DEF_VEC_P(mem_sym_stats_t);
+DEF_VEC_ALLOC_P(mem_sym_stats_t, heap);
+
+/* Memory reference statistics collected during alias analysis. */
+struct mem_ref_stats_d GTY(())
+{
+ /* Number of statements that make memory references. */
+ long num_mem_stmts;
+
+ /* Number of statements that make function calls. */
+ long num_call_sites;
+
+ /* Number of statements that make calls to pure/const functions. */
+ long num_pure_const_call_sites;
+
+ /* Number of ASM statements. */
+ long num_asm_sites;
+
+ /* Estimated number of virtual operands needed as computed by
+ compute_memory_partitions. */
+ long num_vuses;
+ long num_vdefs;
+
+ /* This maps every symbol used to make "memory" references
+ (pointers, arrays, structures, etc) to an instance of struct
+ mem_sym_stats_d describing reference statistics for the symbol. */
+ struct pointer_map_t * GTY((skip)) mem_sym_stats;
+};
+
+
/* Gimple dataflow datastructure. All publicly available fields shall have
gimple_ accessor defined in tree-flow-inline.h, all publicly modifiable
fields should have gimple_set accessor. */
-struct gimple_df GTY(()) {
+struct gimple_df GTY(())
+{
/* Array of all variables referenced in the function. */
htab_t GTY((param_is (struct int_tree_map))) referenced_vars;
@@ -98,6 +173,11 @@ struct gimple_df GTY(()) {
/* Hashtable of variables annotations. Used for static variables only;
local variables have direct pointer in the tree node. */
htab_t GTY((param_is (struct static_var_ann_d))) var_anns;
+
+ /* Memory reference statistics collected during alias analysis.
+ This information is used to drive the memory partitioning
+ heuristics in compute_memory_partitions. */
+ struct mem_ref_stats_d mem_ref_stats;
};
/* Accessors for internal use only. Generic code should use abstraction
@@ -205,6 +285,30 @@ enum need_phi_state {
NEED_PHI_STATE_MAYBE
};
+
+/* The "no alias" attribute allows alias analysis to make more
+ aggressive assumptions when assigning alias sets, computing
+ points-to information and memory partitions. These attributes
+ are the result of user annotations or flags (e.g.,
+ -fargument-noalias). */
+enum noalias_state {
+ /* Default state. No special assumptions can be made about this
+ symbol. */
+ MAY_ALIAS = 0,
+
+ /* The symbol does not alias with other symbols that have a
+ NO_ALIAS* attribute. */
+ NO_ALIAS,
+
+ /* The symbol does not alias with other symbols that have a
+ NO_ALIAS*, and it may not alias with global symbols. */
+ NO_ALIAS_GLOBAL,
+
+ /* The symbol does not alias with any other symbols. */
+ NO_ALIAS_ANYTHING
+};
+
+
struct subvar;
typedef struct subvar *subvar_t;
@@ -246,12 +350,18 @@ struct var_ann_d GTY(())
in the VDEF list. */
unsigned in_vdef_list : 1;
- /* True for HEAP and PARM_NOALIAS artificial variables. */
+ /* True for HEAP artificial variables. These variables represent
+ the memory area allocated by a call to malloc. */
unsigned is_heapvar : 1;
/* True if the variable is call clobbered. */
unsigned int call_clobbered : 1;
+ /* This field describes several "no alias" attributes that some
+ symbols are known to have. See the enum's definition for more
+ information on each attribute. */
+ ENUM_BITFIELD (noalias_state) noalias_state : 2;
+
/* Memory partition tag assigned to this symbol. */
tree mpt;
@@ -694,10 +804,10 @@ extern void add_referenced_var (tree);
extern void remove_referenced_var (tree);
extern void mark_symbols_for_renaming (tree);
extern void find_new_referenced_vars (tree *);
-
extern tree make_rename_temp (tree, const char *);
extern void set_default_def (tree, tree);
extern tree gimple_default_def (struct function *, tree);
+extern struct mem_sym_stats_d *mem_sym_stats (struct function *, tree);
/* In tree-phinodes.c */
extern void reserve_phi_args_for_new_edge (basic_block);
@@ -725,7 +835,8 @@ extern bool may_be_aliased (tree);
extern bool is_aliased_with (tree, tree);
extern struct ptr_info_def *get_ptr_info (tree);
extern void new_type_alias (tree, tree, tree);
-extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *, bool *);
+extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *,
+ unsigned *);
static inline subvar_t get_subvars_for_var (tree);
static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT);
static inline bool ref_contains_array_ref (tree);
@@ -737,6 +848,12 @@ static inline bool overlap_subvar (unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT,
tree, bool *);
extern tree create_tag_raw (enum tree_code, tree, const char *);
+extern void delete_mem_ref_stats (struct function *);
+extern void dump_mem_ref_stats (FILE *);
+extern void debug_mem_ref_stats (void);
+extern void debug_memory_partitions (void);
+extern void debug_mem_sym_stats (tree var);
+extern void debug_all_mem_sym_stats (void);
/* Call-back function for walk_use_def_chains(). At each reaching
definition, a function with this prototype is called. */