Skip to content

Commit df368fd

Browse files
committed
Merging r353411:
------------------------------------------------------------------------ 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 ------------------------------------------------------------------------ llvm-svn: 353825
1 parent 2ccd8c1 commit df368fd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,13 +3762,15 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context,
37623762
}
37633763
}
37643764

3765-
// Microsoft's link.exe doesn't support alignments greater than 32 for common
3766-
// symbols, so symbols with greater alignment requirements cannot be common.
3765+
// Microsoft's link.exe doesn't support alignments greater than 32 bytes for
3766+
// common symbols, so symbols with greater alignment requirements cannot be
3767+
// common.
37673768
// Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
37683769
// alignments for common symbols via the aligncomm directive, so this
37693770
// restriction only applies to MSVC environments.
37703771
if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
3771-
Context.getTypeAlignIfKnown(D->getType()) > 32)
3772+
Context.getTypeAlignIfKnown(D->getType()) >
3773+
Context.toBits(CharUnits::fromQuantity(32)))
37723774
return true;
37733775

37743776
return false;

clang/test/CodeGen/microsoft-no-common-align.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ TooLargeAlignment TooBig;
66
// CHECK: @TooBig = dso_local global <16 x float> zeroinitializer, align 64
77
NormalAlignment JustRight;
88
// CHECK: @JustRight = common dso_local global <1 x float> zeroinitializer, align 4
9+
10+
TooLargeAlignment *IsAPointer;
11+
// CHECK: @IsAPointer = common dso_local global <16 x float>* null, align 8

0 commit comments

Comments
 (0)