On Tue, Feb 28, 2023 at 08:58:20AM +0000, Richard Biener wrote:
> > Without LTO, TYPE_POINTER_TO/TYPE_REFERENCE_TO chains are only maintained
> > inside of build_{pointer,reference}_type_for_mode and those routines
> > ensure that the pointer/reference type added to the chain is really
> > unqualified (including address space), without extra user alignment
> > and has just one entry for each of the TYPE_MODE/TYPE_REF_CAN_ALIAS_ALL
> > pair (unless something would modify the types in place, but that would
> > be wrong).
> 
> Is that so?  I can't find any code verifying that (verify_type?).
> Of course build_{pointer,reference}_type_for_mode will always build
> unqualified pointers, but then the LTO code does
> 
>   /* The following reconstructs the pointer chains
>      of the new pointed-to type if we are a main variant.  We do
>      not stream those so they are broken before fixup.  */
>   if (TREE_CODE (t) == POINTER_TYPE
>       && TYPE_MAIN_VARIANT (t) == t)
>     {
>       TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (TREE_TYPE (t));
>       TYPE_POINTER_TO (TREE_TYPE (t)) = t;
>     }
>   else if (TREE_CODE (t) == REFERENCE_TYPE
>            && TYPE_MAIN_VARIANT (t) == t)
>     {
>       TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (TREE_TYPE (t));
>       TYPE_REFERENCE_TO (TREE_TYPE (t)) = t;
>     }
> 
> which was supposed to ensure only putting unqualified pointers
> (not pointed to types!) to the chain.  So to me the question is
> rather why a type with TYPE_USER_ALIGN is a the main variant - that's
> what looks wrong here?

First of all, it is unclear how the above ensures that type isn't
added to those chains even when it already is there (or some similar type).
Say lto1 during initialization needs build_pointer_type (float_type_node)
and later on lto_fixup_prevailing_type is called on some float *.

I'll try to debug why those user aligned types become TYPE_MAIN_VARIANT
though...

        Jakub

Reply via email to