[llvm] [clang] [clang, SystemZ] Pass HasDef flag to getMinGlobalAlign(). (PR #73511)
Jonas Paulsson via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 28 08:19:23 PST 2023
================
@@ -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
More information about the cfe-commits
mailing list