public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* -fstrict-aliasing fixes 5/6: make type system independent of flag_strict_aliasing
@ 2015-12-02  8:07 Jan Hubicka
  2015-12-02  9:14 ` Richard Biener
  2015-12-06 17:25 ` Eric Botcazou
  0 siblings, 2 replies; 16+ messages in thread
From: Jan Hubicka @ 2015-12-02  8:07 UTC (permalink / raw)
  To: gcc-patches, rguenther

Hi,
this patch makes the type system to be unchanged by flag_strict_aliasing.
This is needed to prevent optimization loss in flag_strict_aliasing code where
some !flag_strict_aliasing code put alias set 0 into a type (this happens
in all cases I modified in my original patch). It is also necessary to validate
ipa-icf and operand_equal_p transformations to be safe for code transitions
!flag_strict_aliasing->flag_strict_aliasing that I wasn to do in the inliner.

This patch goes the opposite way than my previous attempt (and is short unlike
the explanation ;).  Instead of adding extra parameter to get_alias_set it
makes get_alias_set do ignore flag_strict_aliasing.  To make sure that no TBAA
is used when !flag_strict_aliasing I can simply disable alias_set_subset_of and
alias_sets_conflict_p which are the only way TBAA oracle can disambiguate
items.

Next there are cases where optimizations are disabled to keep TBAA right.  
I audited the code and found only function.c (that uses object_must_conflict
for packing) and ipa-icf/fold-const.  This patch updates objects_must_conflict_p, fold-const
already check flag_strict_aliasing and I did not update ipa-icf because I would
have to disable non-strict-aliasing path in the followup patch.

I checked that there is no code difference with -fno-strict-aliasing -fno-ipa-icf
with this patch on tramp3d and dealII


Bootstrapped/regtested x86_64-linux and also lto-bootstraped. Looks OK?

	* alias.c (alias_set_subset_of, alias_sets_conflict_p,
	objects_must_conflict_p): Short circuit for !flag_strict_aliasing
	(get_alias_set): Remove flag_strict_aliasing check.
	(new_alias_set): Likewise.
Index: alias.c
===================================================================
--- alias.c	(revision 231081)
+++ alias.c	(working copy)
@@ -405,6 +405,10 @@ alias_set_subset_of (alias_set_type set1
 {
   alias_set_entry *ase2;
 
+  /* Disable TBAA oracle with !flag_strict_aliasing.  */
+  if (!flag_strict_aliasing)
+    return true;
+
   /* Everything is a subset of the "aliases everything" set.  */
   if (set2 == 0)
     return true;
@@ -466,6 +470,10 @@ alias_sets_conflict_p (alias_set_type se
   alias_set_entry *ase1;
   alias_set_entry *ase2;
 
+  /* Disable TBAA oracle with !flag_strict_aliasing.  */
+  if (!flag_strict_aliasing)
+    return true;
+
   /* The easy case.  */
   if (alias_sets_must_conflict_p (set1, set2))
     return 1;
@@ -561,6 +569,9 @@ objects_must_conflict_p (tree t1, tree t
 {
   alias_set_type set1, set2;
 
+  if (!flag_strict_aliasing)
+    return 1;
+
   /* If neither has a type specified, we don't know if they'll conflict
      because we may be using them to store objects of various types, for
      example the argument and local variables areas of inlined functions.  */
@@ -816,10 +827,12 @@ get_alias_set (tree t)
 {
   alias_set_type set;
 
-  /* If we're not doing any alias analysis, just assume everything
-     aliases everything else.  Also return 0 if this or its type is
-     an error.  */
-  if (! flag_strict_aliasing || t == error_mark_node
+  /* We can not give up with -fno-strict-aliasing because we need to build
+     proper type representation for possible functions which are build with
+     -fstirct-aliasing.  */
+
+  /* return 0 if this or its type is an error.  */
+  if (t == error_mark_node
       || (! TYPE_P (t)
 	  && (TREE_TYPE (t) == 0 || TREE_TYPE (t) == error_mark_node)))
     return 0;
@@ -1085,15 +1098,10 @@ get_alias_set (tree t)
 alias_set_type
 new_alias_set (void)
 {
-  if (flag_strict_aliasing)
-    {
-      if (alias_sets == 0)
-	vec_safe_push (alias_sets, (alias_set_entry *) NULL);
-      vec_safe_push (alias_sets, (alias_set_entry *) NULL);
-      return alias_sets->length () - 1;
-    }
-  else
-    return 0;
+  if (alias_sets == 0)
+    vec_safe_push (alias_sets, (alias_set_entry *) NULL);
+  vec_safe_push (alias_sets, (alias_set_entry *) NULL);
+  return alias_sets->length () - 1;
 }
 
 /* Indicate that things in SUBSET can alias things in SUPERSET, but that

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-09 16:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02  8:07 -fstrict-aliasing fixes 5/6: make type system independent of flag_strict_aliasing Jan Hubicka
2015-12-02  9:14 ` Richard Biener
2015-12-02 17:12   ` Jan Hubicka
2015-12-06 17:25 ` Eric Botcazou
2015-12-07 18:54   ` Jan Hubicka
2015-12-07 19:49     ` Jan Hubicka
2015-12-08 12:06       ` Eric Botcazou
2015-12-08 12:19         ` Richard Biener
2015-12-08 17:09           ` Eric Botcazou
2015-12-08 19:27             ` Jan Hubicka
2015-12-08 19:49               ` Eric Botcazou
2015-12-09  7:30   ` Jan Hubicka
2015-12-09  8:16     ` Arnaud Charlet
2015-12-09  9:11       ` Richard Biener
2015-12-09 16:58         ` Jan Hubicka
2015-12-09  9:05     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).