On Mon, 5 Nov 2018, Jan Hubicka wrote:

> > Hmm, this _should_ be a no-op.  Can you, before that line, add
> > 
> >   gcc_assert (TYPE_CANONICAL (t2) != t2
> >               && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
> > 
> > ?  That is, the incomplete variant should share TYPE_CANONICAL with
> > the pointed-to type and be _not_ the canonical leader (otherwise
> > all other pointer types are bogus).
> 
> It looks like good idea.  I am re-checking with that change that already
> found a bug - build_distinct_type_variant actually resets TYPE_CANONICAL
> which I have missed earlier. So I am testing
> 
> Index: tree.c
> ===================================================================
> --- tree.c    (revision 265807)
> +++ tree.c    (working copy)
> @@ -5146,6 +5146,9 @@ 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));
> +       gcc_assert (TYPE_CANONICAL (t2) != t2
> +                   && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
> +       TYPE_CANONICAL (first) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
as said the TYPE_CANONICAL assign should be already done exactly this
way in build_{poitner,reference}_for_mode.  So you should be able to
drop this from the patch.

>         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 f
>         SET_TYPE_MODE (copy, VOIDmode);
>         SET_TYPE_ALIGN (copy, BITS_PER_UNIT);
>         TYPE_SIZE_UNIT (copy) = NULL;
> +       TYPE_CANONICAL (copy) = t;

Or use build_variant_type_copy in the first place?  But you do not
seme to queue the new types in the variant list?

>         if (AGGREGATE_TYPE_P (t))
>           {
>             TYPE_FIELDS (copy) = NULL;
> 
> Honza
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to