From 85c622497190a445947c8bf09d4e18a295f134c5 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Tue, 8 Jan 2019 18:44:22 +0000 Subject: Limit COFF 'common' emission to <=32 alignment types. As reported in PR33035, LLVM crashes if given a common object with an alignment of greater than 32 bits. This is because the COFF file format does not support these alignments, so emitting them is broken anyway. This patch changes any global definitions greater than 32 bit alignment to no longer be in 'common'. https://bugs.llvm.org/show_bug.cgi?id=33035 Differential Revision: https://reviews.llvm.org/D56391 Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a llvm-svn: 350643 --- clang/lib/CodeGen/CodeGenModule.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 54190493f04..ab0ac67d8e8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context, } } } + // COFF doesn't support alignments greater than 32, so these cannot be + // in common. + if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() && + Context.getTypeAlignIfKnown(D->getType()) > 32) + return true; return false; } -- cgit v1.2.3