[Bug c++/93667] [10 regression] ICE in esra with nested [[no_unique_address]] field

2020-02-13 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667

--- Comment #5 from Martin Jambor  ---
It is easy to prevent the ICE with the following, which prevents total
scalarization from happening.  However, if someone marked a field with
such an attribute, the encompassing structure perhaps should be
optimized a much as we can?

So I am thinking of adding a predicate
bunch_of_empty_records_p which will return true for a type which only
consists of records which only have field_decls which are other
records but nothing else and still allow total scalarization of
those.

The easy fix is:

--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -958,6 +958,9 @@ scalarizable_type_p (tree type, bool const_decl)
   if (type_contains_placeholder_p (type))
 return false;

+  bool have_predecesor_field = false;
+  HOST_WIDE_INT prev_pos = 0;
+
   switch (TREE_CODE (type))
   {
   case RECORD_TYPE:
@@ -966,6 +969,14 @@ scalarizable_type_p (tree type, bool const_decl)
{
  tree ft = TREE_TYPE (fld);

+ HOST_WIDE_INT pos = int_bit_position (fld);
+ if (have_predecesor_field
+ && pos <= prev_pos)
+   return false;
+
+ have_predecesor_field = true;
+ prev_pos = pos;
+
  if (DECL_BIT_FIELD (fld))
return false;

[Bug c++/93667] [10 regression] ICE in esra with nested [[no_unique_address]] field

2020-02-11 Thread jamborm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667

Martin Jambor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jamborm at gcc dot 
gnu.org

--- Comment #4 from Martin Jambor  ---
Mine.

[Bug c++/93667] [10 regression] ICE in esra with nested [[no_unique_address]] field

2020-02-11 Thread eric.niebler at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667

--- Comment #3 from Eric Niebler  ---
> Is this a duplicate / variant of 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93516?

Bug 93516 is not triggered by [[no_unique_addresss]] and the ICE is not on the
same line. That's why I created a new issue.

[Bug c++/93667] [10 regression] ICE in esra with nested [[no_unique_address]] field

2020-02-11 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-02-11
   Target Milestone|--- |10.0
 Ever confirmed|0   |1

--- Comment #2 from Richard Biener  ---
So I guess d and e overlap?  And we end up with "empty" (still 1-byte) actual
accesses in the IL?

[Bug c++/93667] [10 regression] ICE in esra with nested [[no_unique_address]] field

2020-02-10 Thread gcc-bugs at marehr dot dialup.fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667

gcc-bugs at marehr dot dialup.fu-berlin.de changed:

   What|Removed |Added

 CC||gcc-bugs at marehr dot 
dialup.fu-b
   ||erlin.de

--- Comment #1 from gcc-bugs at marehr dot dialup.fu-berlin.de ---
Is this a duplicate / variant of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93516?