On some targets, preferred alignment is larger than ABI alignment in some cases. For example, on AIX we have special power alignment rules which would cause that. Previously, to support those cases, we added a “PreferredAlignment” field in the RecordLayout to store the AIX special alignment values in “PreferredAlignment” as the community suggested.
However, that patch alone is not enough. There are places in the Clang where PreferredAlignment
should have been used instead of ABI-specified alignment. This patch is aimed at fixing those
spots.
Please undo all the changes to the ASTContext API (both in this file and in ASTContext.cpp) which add the boolean NeedsPreferredAlignment to getTypeInfo/getTypeAlign and related functions; it's not necessary. (OK to leave the change to getAlignmentIfKnown).