]> granicus.if.org Git - clang/commitdiff
Merging r353411:
authorHans Wennborg <hans@hanshq.net>
Tue, 12 Feb 2019 10:56:21 +0000 (10:56 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 12 Feb 2019 10:56:21 +0000 (10:56 +0000)
------------------------------------------------------------------------
r353411 | erichkeane | 2019-02-07 16:14:11 +0100 (Thu, 07 Feb 2019) | 7 lines

Fix r350643 to limit COFF emission to <= 32 BYTES instead of BITS.

The patch in r350643 incorrectly sets the COFF emission based on bits
instead of bytes. This patch converts the 32 via CharUnits to bits to
compare the correct values.

Change-Id: Icf38a16470ad5ae3531374969c033557ddb0d323
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_80@353825 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/microsoft-no-common-align.c

index 244738042cef0971b6f798f2240b0381a33c65ac..2ac59fb4de25f03a30eca2480c3eeedbfda1871d 100644 (file)
@@ -3762,13 +3762,15 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,
     }
   }
 
-  // Microsoft's link.exe doesn't support alignments greater than 32 for common
-  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Microsoft's link.exe doesn't support alignments greater than 32 bytes for
+  // common symbols, so symbols with greater alignment requirements cannot be
+  // common.
   // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
   // alignments for common symbols via the aligncomm directive, so this
   // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
-      Context.getTypeAlignIfKnown(D->getType()) > 32)
+      Context.getTypeAlignIfKnown(D->getType()) >
+          Context.toBits(CharUnits::fromQuantity(32)))
     return true;
 
   return false;
index fc46946c00ed23a5c42d3e8ed14030a984b9b988..a7a27a062704faf8707956e735b0a12bac5dfed2 100644 (file)
@@ -6,3 +6,6 @@ TooLargeAlignment TooBig;
 // CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
 NormalAlignment JustRight;
 // CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, align 4
+
+TooLargeAlignment *IsAPointer;
+// CHECK: @IsAPointer = common dso_local global <16 x float>* null, align 8