[llvm] [clang] [clang, SystemZ] Pass HasDef flag to getMinGlobalAlign(). (PR #73511)

Ulrich Weigand via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 09:21:48 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()));
----------------
uweigand wrote:

So the intent of the option is to 1) when emitting a symbol definition directly, keep using the 2-byte ABI alignment, but 2) when refering to a symbol that *might* be defined externally, do not make using any alignment assumption.  In GCC this is using the same checks used elsewhere to test where a symbol is guaranteed local or might be external (keeping in mind things like weak symbols or ELF overrides).

https://github.com/llvm/llvm-project/pull/73511


More information about the cfe-commits mailing list