<div dir="ltr"><div>Yes, the MinGW toolchain can handle this by specifying the alignment of a common symbol using the aligncomm directive. The MSVC toolchain has no such mechanism.</div><div><br></div><div>This is why the check uses isKnownWindowsMSVCEnvironment.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 8, 2019 at 1:09 PM Shoaib Meenai <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_365309267065569355WordSection1">
<p class="MsoNormal">It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover other COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW adds an aligncomm directive to specify alignment for common symbols, so perhaps that's part
 of it?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:0.5in"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">"Keane, Erich" <<a href="mailto:erich.keane@intel.com" target="_blank">erich.keane@intel.com</a>><br>
<b>Date: </b>Tuesday, January 8, 2019 at 1:04 PM<br>
<b>To: </b>Shoaib Meenai <<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>>, "<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>, David Majnemer <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>><br>
<b>Subject: </b>RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:0.5in"><u></u> <u></u></p>
</div>
<p class="MsoNormal" style="margin-left:0.5in"><span style="color:rgb(31,73,125)">Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, which I believe would be different for other architectures.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:0.5in"><a name="m_365309267065569355______replyseparator"></a><b>From:</b> Shoaib Meenai [mailto:<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>]
<br>
<b>Sent:</b> Tuesday, January 8, 2019 12:41 PM<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com" target="_blank">erich.keane@intel.com</a>>; <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>; David Majnemer <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>><br>
<b>Subject:</b> Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:0.5in"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">Ah, looks like you were originally checking for COFF, and then David suggested checking for MSVC instead? I'm curious about why, although I'm sure the suggestion is legit :)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in"> <u></u><u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:1in"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">cfe-commits <<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@lists.llvm.org</a>> on behalf of Shoaib Meenai via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
<b>Reply-To: </b>Shoaib Meenai <<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>><br>
<b>Date: </b>Tuesday, January 8, 2019 at 12:39 PM<br>
<b>To: </b>Erich Keane <<a href="mailto:erich.keane@intel.com" target="_blank">erich.keane@intel.com</a>>, "<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
<b>Subject: </b>Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1in"> <u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:1in">Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the same limitation, since it's an object file format issue
 and not an ABI issue?<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:1in"> <u></u><u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:1.5in"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">cfe-commits <<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@lists.llvm.org</a>> on behalf of Erich Keane via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
<b>Reply-To: </b>Erich Keane <<a href="mailto:erich.keane@intel.com" target="_blank">erich.keane@intel.com</a>><br>
<b>Date: </b>Tuesday, January 8, 2019 at 10:48 AM<br>
<b>To: </b>"<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br>
<b>Subject: </b>r350643 - Limit COFF 'common' emission to <=32 alignment types.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Author: erichkeane<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Date: Tue Jan  8 10:44:22 2019<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">New Revision: 350643<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I&e=" target="_blank">
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Log:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Limit COFF 'common' emission to <=32 alignment types.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">As reported in PR33035, LLVM crashes if given a common object with an<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">alignment of greater than 32 bits. This is because the COFF file format<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">does not support these alignments, so emitting them is broken anyway.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">This patch changes any global definitions greater than 32 bit alignment<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">to no longer be in 'common'.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM&e=" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo&e=" target="_blank">
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Added:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">    cfe/trunk/test/CodeGen/microsoft-no-common-align.c<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Modified:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">    cfe/trunk/lib/CodeGen/CodeGenModule.cpp<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo&e=" target="_blank">
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">==============================================================================<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">       }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">     }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">   }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+  // COFF doesn't support alignments greater than 32, so these cannot be<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+  // in common.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+      Context.getTypeAlignIfKnown(D->getType()) > 32)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+    return true;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">   return false;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY&e=" target="_blank">
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">==============================================================================<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 10:44:22 2019<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">@@ -0,0 +1,8 @@<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+typedef float NormalAlignment __attribute__((__vector_size__(4)));<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+TooLargeAlignment TooBig;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+NormalAlignment JustRight;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, align 4<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">_______________________________________________<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in">cfe-commits mailing list<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=Myn7SZhcOe32EZiKZr4ByJAZOoFl5aIfmWV9555Vh9A&e=" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0&s=Myn7SZhcOe32EZiKZr4ByJAZOoFl5aIfmWV9555Vh9A&e=</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:1.5in"> <u></u><u></u></p>
</div>
</div>
</div>

</blockquote></div></div>