================ @@ -1687,7 +1687,8 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const { if (VD->hasGlobalStorage() && !ForAlignof) { uint64_t TypeSize = !BaseT->isIncompleteType() ? getTypeSize(T.getTypePtr()) : 0; - Align = std::max(Align, getTargetInfo().getMinGlobalAlign(TypeSize)); + Align = std::max(Align, getTargetInfo().getMinGlobalAlign( + TypeSize, VD->hasDefinition())); ---------------- JonPsson1 wrote:
Good point! It seems to me though that this is something the backend must handle. Even with this patch, e.g. a weak 4-byte integer would get the natural alignment, and could later be replaced with an unaligned 4-byte integer by the linker. This patch only removes the ABI minimal alignment, i.e. the requirement to align everything by at least 2 bytes. A recent GCC does not handle this either: it emits a LARL for a weak int. Could it be that the linker preserves the alignment of the original (weak) object? https://github.com/llvm/llvm-project/pull/73511 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits