[gcc(refs/users/giulianob/heads/autopar_rebase2)] Fix incorrect scalar storage order handling

Giuliano Belinassi giulianob@gcc.gnu.org
Mon Aug 17 22:18:42 GMT 2020


https://gcc.gnu.org/g:6f969fdb40697744601213f09ed4cf6e8b3cd447

commit 6f969fdb40697744601213f09ed4cf6e8b3cd447
Author: Eric Botcazou <ebotcazou@gcc.gnu.org>
Date:   Tue May 12 13:14:20 2020 +0200

    Fix incorrect scalar storage order handling
    
    This fixes an oversight in the new canonicalization code for packable
    types: it does not take into account the scalar storage order.
    
            PR ada/95035
            * gcc-interface/utils.c (packable_type_hasher::equal): Also compare
            the scalar storage order.
            (hash_packable_type): Also hash the scalar storage order.
            (hash_pad_type): Likewise.

Diff:
---
 gcc/ada/ChangeLog             |  8 ++++++++
 gcc/ada/gcc-interface/utils.c | 15 ++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index c70119b4724..3502eb83d5e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR ada/95035
+	* gcc-interface/utils.c (packable_type_hasher::equal): Also compare
+	the scalar storage order.
+	(hash_packable_type): Also hash the scalar storage order.
+	(hash_pad_type): Likewise.
+
 2020-05-09  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gcc-interface/*.[ch]: Update copyright year.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 391b6827a5e..1527be4f6d1 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1026,14 +1026,15 @@ packable_type_hasher::equal (packable_type_hash *t1, packable_type_hash *t2)
   type1 = t1->type;
   type2 = t2->type;
 
-  /* We consider that packable types are equivalent if they have the same
-     name, size, alignment and RM size.  Taking the mode into account is
-     redundant since it is determined by the others.  */
+  /* We consider that packable types are equivalent if they have the same name,
+     size, alignment, RM size and storage order. Taking the mode into account
+     is redundant since it is determined by the others.  */
   return
     TYPE_NAME (type1) == TYPE_NAME (type2)
     && TYPE_SIZE (type1) == TYPE_SIZE (type2)
     && TYPE_ALIGN (type1) == TYPE_ALIGN (type2)
-    && TYPE_ADA_SIZE (type1) == TYPE_ADA_SIZE (type2);
+    && TYPE_ADA_SIZE (type1) == TYPE_ADA_SIZE (type2)
+    && TYPE_REVERSE_STORAGE_ORDER (type1) == TYPE_REVERSE_STORAGE_ORDER (type2);
 }
 
 /* Compute the hash value for the packable TYPE.  */
@@ -1047,6 +1048,8 @@ hash_packable_type (tree type)
   hashcode = iterative_hash_expr (TYPE_SIZE (type), hashcode);
   hashcode = iterative_hash_hashval_t (TYPE_ALIGN (type), hashcode);
   hashcode = iterative_hash_expr (TYPE_ADA_SIZE (type), hashcode);
+  hashcode
+    = iterative_hash_hashval_t (TYPE_REVERSE_STORAGE_ORDER (type), hashcode);
 
   return hashcode;
 }
@@ -1402,7 +1405,7 @@ pad_type_hasher::equal (pad_type_hash *t1, pad_type_hash *t2)
   type1 = t1->type;
   type2 = t2->type;
 
-  /* We consider that the padded types are equivalent if they pad the same type
+  /* We consider that padded types are equivalent if they pad the same type
      and have the same size, alignment, RM size and storage order.  Taking the
      mode into account is redundant since it is determined by the others.  */
   return
@@ -1425,6 +1428,8 @@ hash_pad_type (tree type)
   hashcode = iterative_hash_expr (TYPE_SIZE (type), hashcode);
   hashcode = iterative_hash_hashval_t (TYPE_ALIGN (type), hashcode);
   hashcode = iterative_hash_expr (TYPE_ADA_SIZE (type), hashcode);
+  hashcode
+    = iterative_hash_hashval_t (TYPE_REVERSE_STORAGE_ORDER (type), hashcode);
 
   return hashcode;
 }


More information about the Gcc-cvs mailing list