]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tbaa-1.c: New testcase.
authorJan Hubicka <jh@suse.cz>
Tue, 6 Nov 2018 10:26:44 +0000 (11:26 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 6 Nov 2018 10:26:44 +0000 (10:26 +0000)
* gcc.dg/lto/tbaa-1.c: New testcase.

* tree.c (fld_type_variant): Copy canonical type.
(fld_incomplete_type_of): Check that canonical types looks sane;
copy canonical type.
(verify_type): Accept when incomplete type has complete canonical type.

From-SVN: r265835

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/tbaa-1.c [new file with mode: 0644]
gcc/tree.c

index eb867d550ef1ffacdaff55d787d0614dcfaa291f..90b4699237a186fe45593630b577b42e9a29bbd8 100644 (file)
@@ -1,3 +1,10 @@
+018-11-06  Jan Hubicka  <jh@suse.cz>
+
+       * tree.c (fld_type_variant): Copy canonical type.
+       (fld_incomplete_type_of): Check that canonical types looks sane;
+       copy canonical type.
+       (verify_type): Accept when incomplete type has complete canonical type.
+
 2018-11-06  Jan Hubicka  <jh@suse.cz>
 
        * tree.c (free_lang_data): Reset overwite_assembler_name,
index 225850d2613fb3a6c743607b2ba79500324102c6..1ba1eaf13efc70e1fb480d7f84cfcb67a64ebc97 100644 (file)
@@ -1,3 +1,7 @@
+2018-11-06  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/lto/tbaa-1.c: New testcase.
+
 2018-11-06  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/87889
diff --git a/gcc/testsuite/gcc.dg/lto/tbaa-1.c b/gcc/testsuite/gcc.dg/lto/tbaa-1.c
new file mode 100644 (file)
index 0000000..74c0496
--- /dev/null
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -flto -fdump-tree-evrp" } */
+typedef struct rtx_def *rtx;
+typedef struct cselib_val_struct
+{
+  union
+  {
+  } u;
+  struct elt_loc_list *locs;
+}
+cselib_val;
+struct elt_loc_list
+{
+  struct elt_loc_list *next;
+  rtx loc;
+};
+static int n_useless_values;
+unchain_one_elt_loc_list (pl)
+     struct elt_loc_list **pl;
+{
+  struct elt_loc_list *l = *pl;
+  *pl = l->next;
+}
+
+discard_useless_locs (x, info)
+     void **x;
+{
+  cselib_val *v = (cselib_val *) * x;
+  struct elt_loc_list **p = &v->locs;
+  int had_locs = v->locs != 0;
+  while (*p)
+    {
+      unchain_one_elt_loc_list (p);
+      p = &(*p)->next;
+    }
+  if (had_locs && v->locs == 0)
+    {
+      n_useless_values++;
+    }
+}
+/* { dg-final { scan-tree-dump-times "n_useless_values" 2 "evrp" } } */                 
index 15fc99d843e2e4cc3db92aeb2eb8424f3e162b2e..f3fce961bedf971e1d4d38a1e2b0db04ec7d57ab 100644 (file)
@@ -5118,6 +5118,7 @@ fld_type_variant (tree first, tree t, struct free_lang_data_d *fld)
   TYPE_ADDR_SPACE (v) = TYPE_ADDR_SPACE (t);
   TYPE_NAME (v) = TYPE_NAME (t);
   TYPE_ATTRIBUTES (v) = TYPE_ATTRIBUTES (t);
+  TYPE_CANONICAL (v) = TYPE_CANONICAL (t);
   add_tree_to_fld_list (v, fld);
   return v;
 }
@@ -5146,6 +5147,8 @@ fld_incomplete_type_of (tree t, struct free_lang_data_d *fld)
          else
            first = build_reference_type_for_mode (t2, TYPE_MODE (t),
                                                TYPE_REF_CAN_ALIAS_ALL (t));
+         gcc_assert (TYPE_CANONICAL (t2) != t2
+                     && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
          add_tree_to_fld_list (first, fld);
          return fld_type_variant (first, t, fld);
        }
@@ -5169,6 +5172,7 @@ fld_incomplete_type_of (tree t, struct free_lang_data_d *fld)
          SET_TYPE_MODE (copy, VOIDmode);
          SET_TYPE_ALIGN (copy, BITS_PER_UNIT);
          TYPE_SIZE_UNIT (copy) = NULL;
+         TYPE_CANONICAL (copy) = TYPE_CANONICAL (t);
          if (AGGREGATE_TYPE_P (t))
            {
              TYPE_FIELDS (copy) = NULL;
@@ -13887,7 +13891,8 @@ verify_type (const_tree t)
              with variably sized arrays because their sizes possibly
              gimplified to different variables.  */
           && !variably_modified_type_p (ct, NULL)
-          && !gimple_canonical_types_compatible_p (t, ct, false))
+          && !gimple_canonical_types_compatible_p (t, ct, false)
+          && COMPLETE_TYPE_P (t))
     {
       error ("TYPE_CANONICAL is not compatible");
       debug_tree (ct);