This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Do less generous pointer globbing in alias.c
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Richard Biener <rguenther at suse dot de>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 30 May 2015 08:38:43 -0700
- Subject: Re: Do less generous pointer globbing in alias.c
- Authentication-results: sourceware.org; auth=none
- References: <20150527052850 dot GB88897 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1505271046320 dot 30088 at zhemvz dot fhfr dot qr> <20150527144221 dot GB51385 at kam dot mff dot cuni dot cz> <20150527145821 dot GC51385 at kam dot mff dot cuni dot cz> <20150527150413 dot GD51385 at kam dot mff dot cuni dot cz> <5B58CC66-6A43-401E-9A83-A26D076D2A45 at suse dot de> <20150528132943 dot GA8474 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1505281544250 dot 30088 at zhemvz dot fhfr dot qr> <20150528140924 dot GA86368 at kam dot mff dot cuni dot cz> <20150528201251 dot GA407 at kam dot mff dot cuni dot cz>
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" } */
}