<div dir="ltr">


















<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times">On some targets, preferred alignment is larger than
ABI alignment in some cases. For example, </span><span style="font-family:Times" lang="EN-US">on AIX we have special power alignment rules which would cause that. The
full discussion details can be found here if interested: </span><span style="font-family:Times"><a href="http://lists.llvm.org/pipermail/cfe-dev/2020-April/065304.html" style="color:rgb(5,99,193);text-decoration:underline"><span lang="EN-US">http://lists.llvm.org/pipermail/cfe-dev/2020-April/065304.html</span></a></span><span style="font-family:Times" lang="EN-US"> .<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">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: </span><span style="font-family:Times"><a href="https://reviews.llvm.org/D79719" style="color:rgb(5,99,193);text-decoration:underline"><span style="color:rgb(220,161,13);text-decoration:none" lang="EN-US">https://reviews.llvm.org/D79719</span></a></span><span style="font-family:Times" lang="EN-US"> .)<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="gmail-MsoCommentText" style="margin:0cm;font-size:10pt;font-family:"Georgia",serif"><span style="font-size:12pt;font-family:Times">However,
that patch alone is not enough. </span><span style="font-size:12pt;font-family:Times" lang="EN-US">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:12pt;font-family:Times"><span></span></span></p>

<p class="gmail-MsoCommentText" style="margin:0cm;font-size:10pt;font-family:"Georgia",serif"><span style="font-size:12pt;font-family:Times"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Take the cookie size for array new operator
calculation for example, the clang invokes `</span><i><span style="font-family:Times" lang="EN-US">getTypeAlignInChars` </span></i><span style="font-family:Times" lang="EN-US">to get ABI alignment value</span><span style="font-family:Times" lang="EN-US">:</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><br></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif">


















</p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">CharUnits
ItaniumCXXABI::getArrayCookieSizeImpl(QualType elementType) {</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>// The array cookie is a size_t; pad that up
to the element alignment.</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>// The cookie is actually right-justified in
that space.</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>return
std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes),</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>                            </span><b>CGM.getContext().getTypeAlignInChars(elementType));</b></span></i><b><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">}</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>





<div><br></div><div>


















<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">So far, we identify that there are 4 functions
returning ABI alignment:<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">1) getTypeAlignInChars [invokes getTypeAlign]<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">2) getTypeAlign <=> getTypeInfo(T).</span><span style="font-family:Times"><a href="https://clang.llvm.org/doxygen/structclang_1_1TypeInfo.html#af98dcefc364629eff868a1bb4010ebd8"><span style="color:rgb(220,161,13)" lang="EN-US">Align</span></a></span><span style="font-family:Times" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">3) getTypeInfo [ invokes ‘getTypeInfoImpl’]<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">4) getTypeInfoInChars<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times" lang="EN-US"><span> </span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Some possible ways we can think of are:<span></span></span></p><span style="font-family:Times" lang="EN-US"><span></span></span></div><div>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times" lang="EN-US">1. Create a new function to be invoked instead</span></b><span style="font-family:Times" lang="EN-US">, e.g:<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// getTypeProperAlignInChars
- Return the ABI-specified alignment of a type, in</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// characters. Except on
AIX, return the preferred type alignment instead when</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// under power alignment
rules.</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">CharUnits
ASTContext::getTypeProperAlignInChars(QualType T) const {</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>if (Target->defaultsToAIXPowerAlignment())</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>    </span>return
toCharUnitsFromBits(getPreferredTypeAlign(T.getTypePtr()));</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span> </span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>return getTypeAlignInChars(T);</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">}</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times" lang="EN-US"><span> </span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Take the calculation of cookie size for array new
operator for example, we need:<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">CharUnits
ItaniumCXXABI::getArrayCookieSizeImpl(QualType elementType) {</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>// The array cookie is a size_t; pad that up
to the element alignment.</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>// The cookie is actually right-justified in
that space.</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>return std::max(CharUnits::fromQuantity(CGM.SizeSizeInBytes),</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">-<span>                           </span>CGM.getContext().getTypeAlignInChars(elementType));</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">+<span>                          </span>CGM.getContext().getTypeProperAlignInChars(elementType));</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">}</span></i><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><i><span style="font-family:Times" lang="EN-US"><span> </span></span></i></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><i><span style="font-family:Times" lang="EN-US">Cons:<span></span></span></i></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">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></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times" lang="EN-US">2. Add a flag </span></b><span style="font-family:Times" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Adding a flag like the following can help us:<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">e.g.1 – getTypeAlignInChars<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// If `</span><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"> NeedsABIAlignment </span></b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">` is false, this function
will smartly return preferred alignment </span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// or ABI alignment depends on
if the target defaults to AIX power alignment or not;</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">/// Set `</span><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"> NeedsABIAlignment </span></b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">` as true if an ABI alignment
is needed no matter what target is.<br></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">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-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>   </span>return toCharUnitsFromBits(getTypeAlign(T));<br>
}</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span><br></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Take cookie size for array new
operator calculation for example again, we don’t need to make any change anymore.<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span><br></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">e.g.2 - getTypeInfoImpl<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">TypeInfo
ASTContext::getTypeInfoImpl(const Type *T, </span><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">bool </span></b><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">NeedsABIAlignment</span></b><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"> <span lang="EN-US">= false</span></span></b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">) const {</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">...</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>switch (T->getTypeClass()) {</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">...</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>    </span>case Type::Record:</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>const auto *RT =
cast<RecordType>(TT);</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>const RecordDecl *RD =
RT->getDecl();</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>const ASTRecordLayout &Layout =
getASTRecordLayout(RD);</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>Width = toBits(Layout.getSize());</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">+<span>     </span>if (NeedsABIAlignment)</span></b><b><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">+<span>       </span></span></b><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">Align = toBits(Layout.getAlignment());</span></b><b><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">+<span>     </span>else if (</span></i></b><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">Target->defaultsToAIXPowerAlignment()</span></b><b><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">)</span></i></b><b><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">+<span>       </span>Align =
toBits(Layout.getPreferredAlignment());</span></i></b><b><i><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></i></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><i><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">+<span>     </span>else</span></i></b><b><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>          </span>Align =
toBits(Layout.getAlignment());</span></b><b><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>AlignIsRequired =
RD->hasAttr<AlignedAttr>();</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>        </span>break;</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span>  </span>}</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">...</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US">}</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%" lang="EN-US"><span><br></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b>An usage example on the call site:<span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><Clang/ lib/AST/RecordLayoutBuilder.cpp><span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>  </span>auto setDeclInfo = [&](bool
IsIncompleteArrayType) {</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">-<span>   </span>TypeInfo TI =
Context.getTypeInfo(D->getType());</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%">+<span>  </span>TypeInfo TI = Context.getTypeInfo(D->getType(),
true/* NeedsABIAlignment */);</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>    </span>FieldAlign =
Context.toCharUnitsFromBits(TI.Align);</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>    </span>// Flexible array members don't have any
size, but they have to be</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>    </span>// aligned appropriately for their element
type.</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>    </span>EffectiveFieldSize = FieldSize =</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>        </span>IsIncompleteArrayType ?
CharUnits::Zero()</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>                              </span>:
Context.toCharUnitsFromBits(TI.Width);</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>    </span>AlignIsRequired = TI.AlignIsRequired;</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;color:black;background:rgb(217,217,217) none repeat scroll 0% 0%"><span>  </span>};</span><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span><br></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times;background:rgb(217,217,217) none repeat scroll 0% 0%"><span><br></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times" lang="EN-US">Pros:<span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">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></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times">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></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><b><span style="font-family:Times" lang="EN-US">cons:<span></span></span></b></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Those four functions I mentioned above won’t return
ABI-specified alignment values all the time anymore.<span></span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"><span> </span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">I would like to see how people think about our proposal. Any concerns?
Or any other ideas to suggest?<span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"> <span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Please let me know if there are any questions about our current proposal
and design. Your feedback is appreciated.<span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"> <span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Regards,<span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US"> <span></span></span></p>

<p class="MsoNormal" style="text-align:justify;margin:0cm;font-size:12pt;font-family:"Georgia",serif"><span style="font-family:Times" lang="EN-US">Xiangling Liao<span></span></span></p>





</div><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:"Georgia",serif"><br><span style="font-family:Times" lang="EN-US"><span></span></span></p>





</div>