On 9/30/26 11:37 AM, POLISHCHUK Illia wrote:
c++: Don't assume full alignment for possible base subobjects [PR103303]
Thanks!
When a class has a virtual base that needs more alignment than the rest of the class, its alignment as a base (the Itanium ABI "nvalign", CLASSTYPE_ALIGN) is smaller than TYPE_ALIGN. A base subobject of such a class, e.g. a virtual base of a derived class, may therefore be placed at an address that is only aligned to nvalign. But accesses through 'this' or any other pointer to the class were given the full TYPE_ALIGN, so e.g. the SLP vectorizer used movaps to store adjacent members in the base constructor, which faults at runtime. Fix this by giving an INDIRECT_REF of such a class type a variant of the type with the base alignment, unless the class is final or the reference is obviously to a complete object.
Makes sense, though let's try to use resolves_to_fixed_type_p rather than duplicating the checks for final/*&x.
This is done at gimplification time since fixup_type_variants resets the alignment of type variants whenever a member function is lazily declared.
Let's fix that rather than work around it. A fixup_type_variants from lazily_declare_fn is only trying to update TYPE_FIELDS; it seems like only the calls from finish_struct_bits and trees_in::read_class_def should mess with alignment.
Jason
