<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Georgia;
        panose-1:2 4 5 2 5 4 5 2 3 3;}
@font-face
        {font-family:Times;
        panose-1:2 2 6 3 5 4 5 2 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.gmail-msocommenttext, li.gmail-msocommenttext, div.gmail-msocommenttext
        {mso-style-name:gmail-msocommenttext;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I don’t think using a boolean argument is appropriate here; nobody is going to pass in anything other than constant true/false, so a real name is more readable.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I guess the question here is what the “default” getTypeAlign means; either it’s the ABI alignment, and we fix all the places that want the “AIX preferred” alignment, or it’s the “AIX preferred” alignment, and we fix all the places that
 want the ABI alignment.  I think it’s essentially a numbers game: which one is actually more commonly used?  Please give more examples.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-Eli<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b>From:</b> Xiangling Liao <xiangxdh@gmail.com>
<br>
<b>Sent:</b> Wednesday, August 12, 2020 10:56 AM<br>
<b>To:</b> cfe-dev@lists.llvm.org<br>
<b>Cc:</b> hubert.reinterpretcast@gmail.com; jasonliu.development@gmail.com; Eli Friedman <efriedma@quicinc.com>; James Y Knight <jyknight@google.com>; Reid Kleckner <rnk@google.com><br>
<b>Subject:</b> [EXT] [RFC] Use preferred alignment instead of ABI alignment for complete object when applicable<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">On some targets, preferred alignment is larger than ABI alignment in some cases. For example, on AIX we have special power alignment rules which would cause
 that. The full discussion details can be found here if interested: <a href="http://lists.llvm.org/pipermail/cfe-dev/2020-April/065304.html">
<span style="color:#0563C1">http://lists.llvm.org/pipermail/cfe-dev/2020-April/065304.html</span></a> .</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Previously, to support those cases, we added a “PreferredAlignment” field in the `RecordLayout` to store the AIX special alignment values in “PreferredAlignment”
 as the community suggested. It makes sure both `_alignof` and `alignof` return correct values for AIX objects. (The related patch is here:
<a href="https://reviews.llvm.org/D79719"><span style="color:#DCA10D;text-decoration:none">https://reviews.llvm.org/D79719</span></a> .)</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="gmail-msocommenttext" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt">
<span style="font-size:12.0pt;font-family:"Times",serif">However, that patch alone is not enough. With AIX’s special alignment rule, we need to use “PreferredAlignment” for a majority of the places where ABI alignment are currently used in .</span><span style="font-size:10.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="gmail-msocommenttext" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt">
<span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:10.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Take the cookie size for array new operator calculation for example, the clang invokes `<i>getTypeAlignInChars`
</i>to get ABI alignment value:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">CharUnits ItaniumCXXABI::getArrayCookieSizeImpl(QualType elementType) {</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  // The array cookie is a size_t; pad that up to the element alignment.</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  // The cookie is actually right-justified in that space.</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  return std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes),</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">                           
<b>CGM.getContext().getTypeAlignInChars(elementType));</b></span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">}</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">So far, we identify that there are 4 functions returning ABI alignment:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">1) getTypeAlignInChars [invokes getTypeAlign]</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">2) getTypeAlign <=> getTypeInfo(T).<a href="https://clang.llvm.org/doxygen/structclang_1_1TypeInfo.html#af98dcefc364629eff868a1bb4010ebd8"><span style="color:#DCA10D">Align</span></a></span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">3) getTypeInfo [ invokes ‘getTypeInfoImpl’]</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">4) getTypeInfoInChars</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif"> </span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Some possible ways we can think of are:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif">1. Create a new function to be invoked instead</span></b><span style="font-size:12.0pt;font-family:"Times",serif">, e.g:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// getTypeProperAlignInChars - Return the ABI-specified alignment of a type, in</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// characters. Except on AIX, return the preferred type alignment instead when</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// under power alignment rules.</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">CharUnits ASTContext::getTypeProperAlignInChars(QualType T) const {</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  if (Target->defaultsToAIXPowerAlignment())</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    return toCharUnitsFromBits(getPreferredTypeAlign(T.getTypePtr()));</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9"> </span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  return getTypeAlignInChars(T);</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">}</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif"> </span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Take the calculation of cookie size for array new operator for example, we need:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">CharUnits ItaniumCXXABI::getArrayCookieSizeImpl(QualType elementType) {</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  // The array cookie is a size_t; pad that up to the element alignment.</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  // The cookie is actually right-justified in that space.</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  return std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes),</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">-                           CGM.getContext().getTypeAlignInChars(elementType));</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+                          CGM.getContext().getTypeProperAlignInChars(elementType));</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">}</span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><i><span style="font-size:12.0pt;font-family:"Times",serif"> </span></i><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><i><span style="font-size:12.0pt;font-family:"Times",serif">Cons:</span></i></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">The migration risk is high. We cannot guarantee in the future the developers would know this is the interface they should use as always for any common path
 code. So it seems this is not a viable method.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif">2. Add a flag
</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Adding a flag like the following can help us:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">e.g.1 – getTypeAlignInChars</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// If `<b> NeedsABIAlignment
</b>` is false, this function will smartly return preferred alignment </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// or ABI alignment depends on if the target defaults to AIX power alignment or not;</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">/// Set `<b> NeedsABIAlignment
</b>` as true if an ABI alignment is needed no matter what target is.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">CharUnits ASTContext::getTypeAlignInChars(QualType T, <b>bool NeedsABIAlignment = false</b>) const {<br>
   if (NeedsABIAlignment)<br>
     return toCharUnitsFromBits(getTypeAlign(T));<br>
   if (Target->defaultsToAIXPowerAlignment())<br>
     return toCharUnitsFromBits(getPreferredTypeAlign(T.getTypePtr())); </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">   return toCharUnitsFromBits(getTypeAlign(T));<br>
}</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Take cookie size for array new operator calculation for example again, we don’t need to make any change anymore.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">e.g.2 - getTypeInfoImpl</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">TypeInfo ASTContext::getTypeInfoImpl(const Type *T,
<b>bool NeedsABIAlignment = false</b>) const {</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">...</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  switch (T->getTypeClass()) {</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">...</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    case Type::Record:</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        const auto *RT = cast<RecordType>(TT);</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        const RecordDecl *RD = RT->getDecl();</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        const ASTRecordLayout &Layout = getASTRecordLayout(RD);</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        Width = toBits(Layout.getSize());</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+     if (NeedsABIAlignment)</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+       Align = toBits(Layout.getAlignment());</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+     else if (</span></i></b><b><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">Target->defaultsToAIXPowerAlignment()<i>)</i></span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+       Align = toBits(Layout.getPreferredAlignment());</span></i></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><i><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+     else</span></i></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">          Align = toBits(Layout.getAlignment());</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        AlignIsRequired = RD->hasAttr<AlignedAttr>();</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        break;</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  }</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">...</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">}</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Georgia",serif">An usage example on the call site:</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><Clang/ lib/AST/RecordLayoutBuilder.cpp><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  auto setDeclInfo = [&](bool IsIncompleteArrayType) {</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">-   TypeInfo TI = Context.getTypeInfo(D->getType());</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">+  TypeInfo TI = Context.getTypeInfo(D->getType(), true/* NeedsABIAlignment */);</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    FieldAlign = Context.toCharUnitsFromBits(TI.Align);</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    // Flexible array members don't have any size, but they have to be</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    // aligned appropriately for their element type.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    EffectiveFieldSize = FieldSize =</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">        IsIncompleteArrayType ? CharUnits::Zero()</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">                              : Context.toCharUnitsFromBits(TI.Width);</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">    AlignIsRequired = TI.AlignIsRequired;</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif;color:black;background:#D9D9D9">  };</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif">Pros:</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">1) By adding a flag like above, we can minimize the changes needed to make. The scope of changes will be shortened to only a few spots where an ABI alignment
 is necessary even when AIX special alignment is set.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">2) Letting people consciously pass `true`  in if needed is another benefit. Then targets like AIX don’t need to worry about things going wrong accidentally
 in the future.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;font-family:"Times",serif">cons:</span></b><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif">Those four functions I mentioned above won’t return ABI-specified alignment values all the time anymore.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif">I would like to see how people think about our proposal. Any concerns? Or any other ideas to suggest?</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif">Please let me know if there are any questions about our current proposal and design. Your feedback is appreciated.</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif">Regards,</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif"> </span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in;text-align:justify"><span style="font-size:12.0pt;font-family:"Times",serif">Xiangling Liao</span><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:12.0pt;font-family:"Georgia",serif"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>