Do less generous pointer globbing in alias.c
H.J. Lu
hjl.tools@gmail.com
Sat May 30 15:54:00 GMT 2015
On Thu, May 28, 2015 at 1:12 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> hello,
> only providing you the testcase why I need transitive closure of "contains
> pointer" via the extra child I noticed that there is extra symmetry to handle:
>
> struct a {void *ptr;}
> char **ptr = (char **)&a.ptr;
> ptr = ...
>
> This one doesn't really fly with my extra subset code, because ptr is not
> universal pointer, but struct a contains one and thus should conflict with
> every pointer. Adding every pointer as subset of every structure with
> universal pointer is impractical (childs of those structures would be appearing
> as new pointer types get alias sets) and thus indeed it is better to handle it
> same way as alias set 0 - by a special case in alias_set_subset_of
> and alias_sets_conflict_p.
>
> So I added the second flag - has_pointer that is transitive closure of
> is_pointer and added the special case to alias_sets_conflict_p instead of
> adding the extra subset relation into the DAG.
>
> I also added statistics and made changes you suggested (making child
> hash to be possibly NULL and clenaing up alias set conflict construction)
>
> I also constructed a testcase that covers all the new code paths.
>
> The patch bootstrapped/regtested ppc64-linux. I am not bound to teaching
> next week, so if I hear no negative comments, I will schedule commiting the
> patch for weekend to deal with possible fallout.
>
> There are few cleanups possible incrementally - i.e. the hash set seems
> irrationaly large for average type, we could avoid some pointer travelling
> overhead and we could also do better at alias_sets_must_conflict_p.
>
> Honza
>
> * alias.c (alias_set_entry_d): Add is_pointer and has_pointer.
> (alias_stats): Add num_universal.
> (alias_set_subset_of): Special case pointers; be ready for NULL
> children.
> (alias_sets_conflict_p): Special case pointers; be ready for NULL
> children.
> (init_alias_set_entry): Break out from ...
> (record_alias_subset): ... here; propagate new fields;
> allocate children only when really needed.
> (get_alias_set): Do less generous pointer globbing.
> (dump_alias_stats_in_alias_c): Update statistics.
> * gcc.dg/alias-8.c: Do not xfail.
> * gcc.dg/pr62167.c: Prevent FRE.
> * gcc.dg/alias-14.c: New testcase.
==========================================
> --- testsuite/gcc.dg/alias-8.c (revision 223772)
> +++ testsuite/gcc.dg/alias-8.c (working copy)
> @@ -8,5 +8,5 @@ struct s {
> void
> func(struct s *ptr)
> {
> - *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" "" { xfail *-*-* } } */
> + *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" "" { } } */
> }
This caused:
ERROR: gcc.dg/alias-8.c: syntax error in target selector "" for "
dg-warning 11 "type-punned pointer" "" { } "
I checked in this fix.
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 223886)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2015-05-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gcc.dg/alias-8.c: Fix dg-warning.
+
2015-05-30 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/alias-8.c: Do not xfail.
Index: gcc.dg/alias-8.c
===================================================================
--- gcc.dg/alias-8.c (revision 223886)
+++ gcc.dg/alias-8.c (working copy)
@@ -8,5 +8,5 @@
void
func(struct s *ptr)
{
- *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" "" { } } */
+ *(void **)&ptr->p = 0; /* { dg-warning "type-punned pointer" } */
}
More information about the Gcc-patches
mailing list