[Bug tree-optimization/34472] gcc.dg/struct/wo_prof_malloc_size_var.c doesn't work
olga at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Dec 19 18:57:00 GMT 2007
------- Comment #4 from olga at gcc dot gnu dot org 2007-12-19 18:57 -------
Thank you for debugging! Now I see approximately where it fails. Although I am
not sure that the following patch solves the issue, please try it, and let me
know whether it helps.
Thank you a lot,
Olga
Index: ipa-struct-reorg.c
===================================================================
--- ipa-struct-reorg.c (revision 130906)
+++ ipa-struct-reorg.c (working copy)
@@ -3068,6 +3068,17 @@
dump_access_sites (str->accs);
}
+/* Auxiliary data structure for safe_cond_expr_check callback function. */
+struct cond_check_data
+{
+ /* Structure declaration. */
+ tree type;
+
+ /* Vector of unsuitable types. If the type participates in unsafe
+ conditional expression, it will be added to this vector. */
+ VEC (tree, heap) **unsuitable_types;
+};
+
/* This function checks whether an access statement, pointed by SLOT,
is a condition we are capable to transform. If not, it removes
the structure with index, represented by DATA, from the vector
@@ -3077,6 +3088,7 @@
safe_cond_expr_check (void **slot, void *data)
{
struct access_site *acc = *(struct access_site **) slot;
+ struct cond_check_data dt = *(struct cond_check_data *) data;
if (TREE_CODE (acc->stmt) == COND_EXPR)
{
@@ -3087,7 +3099,7 @@
fprintf (dump_file, "\nUnsafe conditional statement ");
print_generic_stmt (dump_file, acc->stmt, 0);
}
- remove_structure (*(unsigned *) data);
+ add_unsuitable_type (dt.unsuitable_types, dt.type);
}
}
return 1;
@@ -3541,10 +3553,23 @@
{
d_str str;
unsigned i;
+ VEC (tree, heap) *unsuitable_types = VEC_alloc (tree, heap,
+ VEC_length (structure,
+ structures));
+ struct cond_check_data data;
+ data.type = NULL_TREE;
+ data.unsuitable_types = &unsuitable_types;
+
for (i = 0; VEC_iterate (structure, structures, i, str); i++)
if (str->accs)
- htab_traverse (str->accs, safe_cond_expr_check, &i);
+ {
+ data.type = str->decl;
+ htab_traverse (str->accs, safe_cond_expr_check, &data);
+ }
+
+ remove_unsuitable_types (unsuitable_types);
+ VEC_free (tree, heap, unsuitable_types);
}
/* We exclude from non-field accesses of the structure
@@ -3848,6 +3873,9 @@
gcov_type hotest = 0;
unsigned i;
d_str str;
+ VEC (tree, heap) *unsuitable_types = VEC_alloc (tree, heap,
+ VEC_length (structure,
+ structures));
/* We summarize counts of fields of a structure into the structure count.
*/
for (i = 0; VEC_iterate (structure, structures, i, str); i++)
@@ -3863,8 +3891,11 @@
print_generic_expr (dump_file, str->decl, 0);
fprintf (dump_file, " is cold.");
}
- remove_structure (i);
+ add_unsuitable_type (&unsuitable_types, str->decl);
}
+
+ remove_unsuitable_types (unsuitable_types);
+ VEC_free (tree, heap, unsuitable_types);
}
/* This function decomposes original structure into substructures,
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34472
More information about the Gcc-bugs
mailing list