On Tue, 28 Feb 2023, Jakub Jelinek wrote: > 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 *.
We try to make sure to put all built types into the type merging machinery, so I think it shouldn't happen - but then I cannot rule it out. I'm also not sure whether duplicates would really pose a problem here (other than waste). If we want to make sure we should probably enhance verify_types to verify the TYPE_POINTER_TO chain ... > I'll try to debug why those user aligned types become TYPE_MAIN_VARIANT > though... > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)