https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87868
--- Comment #2 from Jan Hubicka <hubicka at ucw dot cz> --- I am attaching testcase and patch I am lto-botstrapping now. It copies canonical from original type which is important for us to not lose TBAA during ealry opts as well. 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++; } } * tree.c (fld_incomplete_type_of): Copy type_canonical. Index: tree.c =================================================================== --- tree.c (revision 265712) +++ tree.c (working copy) @@ -5146,6 +5146,7 @@ fld_incomplete_type_of (tree t, struct f else first = build_reference_type_for_mode (t2, TYPE_MODE (t), TYPE_REF_CAN_ALIAS_ALL (t)); + TYPE_CANONICAL (first) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t)); add_tree_to_fld_list (first, fld); return fld_type_variant (first, t, fld); }