tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): Properly handle DECL_BIT_...
authorRichard Biener <rguenther@suse.de>
Tue, 28 Jun 2016 11:55:19 +0000 (11:55 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 28 Jun 2016 11:55:19 +0000 (11:55 +0000)
2016-06-28  Richard Biener  <rguenther@suse.de>

* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p):
Properly handle DECL_BIT_FIELD_REPRESENTATIVE occuring as
COMPONENT_REF operand.
(nonoverlapping_component_refs_p): Likewise.
* stor-layout.c (start_bitfield_representative): Mark
DECL_BIT_FIELD_REPRESENTATIVE as DECL_NONADDRESSABLE_P.

From-SVN: r237818

gcc/ChangeLog
gcc/stor-layout.c
gcc/tree-ssa-alias.c

index 52b3e1c5ac60cfd435ed233c22595883eb840935..1ec8955cdb6cac089f0c0836a5f941fa0ee3734e 100644 (file)
@@ -1,3 +1,12 @@
+2016-06-28  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p):
+       Properly handle DECL_BIT_FIELD_REPRESENTATIVE occuring as
+       COMPONENT_REF operand.
+       (nonoverlapping_component_refs_p): Likewise.
+       * stor-layout.c (start_bitfield_representative): Mark
+       DECL_BIT_FIELD_REPRESENTATIVE as DECL_NONADDRESSABLE_P.
+
 2016-06-28  Jakub Jelinek  <jakub@redhat.com>
 
        * Makefile.in: Don't cat ../stage_current if it does not exist.
index 40170efb33f736677d5409d060baef7159decfc6..d66d769e3fc351242abafed93e003712d6f708ca 100644 (file)
@@ -1808,6 +1808,11 @@ start_bitfield_representative (tree field)
   DECL_SIZE_UNIT (repr) = DECL_SIZE_UNIT (field);
   DECL_PACKED (repr) = DECL_PACKED (field);
   DECL_CONTEXT (repr) = DECL_CONTEXT (field);
+  /* There are no indirect accesses to this field.  If we introduce
+     some then they have to use the record alias set.  This makes
+     sure to properly conflict with [indirect] accesses to addressable
+     fields of the bitfield group.  */
+  DECL_NONADDRESSABLE_P (repr) = 1;
   return repr;
 }
 
index b663ddfb0d5097b34d58cd14dba8e9a4bce4d24a..70c24b59446313b7a001f0ca32ab6f1504d8181d 100644 (file)
@@ -929,13 +929,20 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
       if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE)
         goto may_overlap;
 
-      /* Different fields of the same record type cannot overlap.
-        ??? Bitfields can overlap at RTL level so punt on them.  */
       if (field1 != field2)
        {
          component_refs1.release ();
          component_refs2.release ();
-         return !(DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2));
+         /* A field and its representative need to be considered the
+            same.  */
+         if (DECL_BIT_FIELD_REPRESENTATIVE (field1) == field2
+             || DECL_BIT_FIELD_REPRESENTATIVE (field2) == field1)
+           return false;
+         /* Different fields of the same record type cannot overlap.
+            ??? Bitfields can overlap at RTL level so punt on them.  */
+         if (DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2))
+           return false;
+         return true;
        }
     }
 
@@ -1031,9 +1038,20 @@ nonoverlapping_component_refs_p (const_tree x, const_tree y)
       if (typex == typey)
        {
          /* We're left with accessing different fields of a structure,
-            no possible overlap, unless they are both bitfields.  */
+            no possible overlap.  */
          if (fieldx != fieldy)
-           return !(DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy));
+           {
+             /* A field and its representative need to be considered the
+                same.  */
+             if (DECL_BIT_FIELD_REPRESENTATIVE (fieldx) == fieldy
+                 || DECL_BIT_FIELD_REPRESENTATIVE (fieldy) == fieldx)
+               return false;
+             /* Different fields of the same record type cannot overlap.
+                ??? Bitfields can overlap at RTL level so punt on them.  */
+             if (DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy))
+               return false;
+             return true;
+           }
        }
       if (TYPE_UID (typex) < TYPE_UID (typey))
        {