typedef const struct func_alloc_sites *const_fallocs_t;
/* All allocation sites in the program. */
-htab_t alloc_sites;
+htab_t alloc_sites = NULL;
/* New global variables. Generated once for whole program. */
htab_t new_global_vars;
tree ref = r_pos->ref;
tree t = *tp;
- if (t == ref)
+ if (t == ref || (TREE_CODE (t) == SSA_NAME && SSA_NAME_VAR (t) == ref))
{
r_pos->pos = tp;
return t;
htab_traverse (accs, dump_acc, NULL);
}
+/* This function is a callback for alloc_sites hashtable
+ traversal. SLOT is a pointer to fallocs_t. This function
+ removes all allocations of the structure defined by DATA. */
+
+static int
+remove_str_allocs_in_func (void **slot, void *data)
+{
+ fallocs_t fallocs = *(fallocs_t *) slot;
+ unsigned i = 0;
+ alloc_site_t *call;
+
+ while (VEC_iterate (alloc_site_t, fallocs->allocs, i, call))
+ {
+ if (call->str == (d_str) data)
+ VEC_ordered_remove (alloc_site_t, fallocs->allocs, i);
+ else
+ i++;
+ }
+
+ return 1;
+}
+
+/* This function remove all entries corresponding to the STR structure
+ from alloc_sites hashtable. */
+
+static void
+remove_str_allocs (d_str str)
+{
+ if (!str)
+ return;
+
+ if (alloc_sites)
+ htab_traverse (alloc_sites, remove_str_allocs_in_func, str);
+}
+
/* This function removes the structure with index I from structures vector. */
static void
if (i >= VEC_length (structure, structures))
return;
- str = VEC_index (structure, structures, i);
+ str = VEC_index (structure, structures, i);
+
+ /* Before removing the structure str, we have to remove its
+ allocations from alloc_sites hashtable. */
+ remove_str_allocs (str);
free_data_struct (str);
VEC_ordered_remove (structure, structures, i);
}
/* This function summarizes counts of the fields into the structure count. */
static void
-sum_counts (d_str str, gcov_type *hotest)
+sum_counts (d_str str, gcov_type *hottest)
{
int i;
fprintf (dump_file, "\" is " HOST_WIDEST_INT_PRINT_DEC, str->count);
}
- if (str->count > *hotest)
- *hotest = str->count;
+ if (str->count > *hottest)
+ *hottest = str->count;
}
/* This function peels the field into separate structure if it's
static void
exclude_cold_structs (void)
{
- gcov_type hotest = 0;
+ gcov_type hottest = 0;
unsigned i;
d_str str;
/* We summarize counts of fields of a structure into the structure count. */
for (i = 0; VEC_iterate (structure, structures, i, str); i++)
- sum_counts (str, &hotest);
+ sum_counts (str, &hottest);
/* Remove cold structures from structures vector. */
i = 0;
while (VEC_iterate (structure, structures, i, str))
- if (str->count * 100 < (hotest * STRUCT_REORG_COLD_STRUCT_RATIO))
+ if (str->count * 100 < (hottest * STRUCT_REORG_COLD_STRUCT_RATIO))
{
if (dump_file)
{
&& (optimize > 0);
}
-struct tree_opt_pass pass_ipa_struct_reorg =
+struct simple_ipa_opt_pass pass_ipa_struct_reorg =
{
+ {
+ SIMPLE_IPA_PASS,
"ipa_struct_reorg", /* name */
struct_reorg_gate, /* gate */
reorg_structs_drive, /* execute */
0, /* properties_provided */
0, /* properties_destroyed */
TODO_verify_ssa, /* todo_flags_start */
- TODO_dump_func | TODO_verify_ssa, /* todo_flags_finish */
- 0 /* letter */
+ TODO_dump_func | TODO_verify_ssa /* todo_flags_finish */
+ }
};