<div dir="ltr">Also, I should put some discussion I had with David in email.<div><br></div><div>I think maybe TypeInfo should be a triple of Width, Align, and RequiredAlignment (or AttributedAlign or some other name). If we want to go hog wild, we can encode it as log2 in two bytes to keep the struct small. Right now the MSVC record layout algorithm queries getTypeInfo twice: once with the fully desugared type and once with the regular type so it can get both alignments. It uses one or the other depending on the presence of pragma pack attributes.</div>
<div><br></div><div>This information could also help Itanium record layout of structs with ms_struct attributes.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 1, 2014 at 11:44 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">What is HasAlignAttribute, and how is it different from AlignmentIsRequired? I have a feeling that they are different names for the same thing. If you want to rename it, that's fine with me.</div>
<div class="gmail_extra">
<br><br><div class="gmail_quote"><div class="">On Fri, Aug 1, 2014 at 10:45 AM, jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>></span> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">
<div style="word-wrap:break-word">Hi John,<div><br></div><div>Here is the revised patch.</div><div><br></div><div><span style="white-space:pre-wrap">     </span></div></div>
<br></div><div style="word-wrap:break-word"><div></div><div>- Fariborz</div><div><div class="h5"><div><br><div><div><div>On Jul 28, 2014, at 6:58 PM, John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>> wrote:</div>

<br><blockquote type="cite"><div style="word-wrap:break-word">On Jul 28, 2014, at 4:22 PM, jahanian <<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>> wrote:<br><div><blockquote type="cite">

<div style="word-wrap:break-word">This patch enforces SuitableAlign’s alignment when loading objects with more relaxed alignment. Currently, SuitableAlign is used in a<div>warning when type is over aligned. This patch optionally enforces this in IRGen. I defined a new field in TargetInfo which is optionally set to</div>

<div>SuitableAlign. Currently, this is only defined for Apple’s targets as I don’t know its implication for all other supported targets. Long term,</div><div>we want to use one value for both (Sema and code gen). This is <a>rdar://</a><span style="font-family:Menlo;font-size:11px">16254558</span></div>

</div></blockquote><div><br></div>We can’t change the ABI alignment; that would change struct layout.</div><div><br></div><div>The right way of doing this is a code generation option that caps the effective alignment that we’ll honor on an access to a pointer lacking an explicit alignment attribute.  It should be exposed to users; I suggest spelling it something like -fmax-type-align=N, with an option to disable it completely called -fno-max-type-align.  You can have the driver pass down -fmax-type-align=16 by default when targeting Darwin.</div>

<div><br></div><div>+  static bool RestrictedCompleteObjectAlign(QualType T) {</div><div><br></div><div>What this is really asking is whether the type has an explicit alignment attribute.  The most reasonable thing to do is to have ASTContext::getTypeInfoImpl compute (and cache) this information; that will correctly look through recursive sugar, which you are not doing.  You can add a new accessor (ASTContext::getTypeAlignInCharsAndIsExplicit?) which returns a pair of the alignment and this bool.</div>

<div><br></div><div>You should add a test case that checks that a typedef of an aligned typedef is still considered explicitly aligned.</div><div><br></div><div>There is nothing here that should be specific to ElaboratedType.  Whatever that logic is, it should be testing for RecordType.  But I actually think you should be applying the same logic to structs and unions that you do to any other type: we should be capping the (non-ABI) alignment of structs and unions unless they have an explicit AlignedAttr.</div>

<div><br></div><div>John.</div></div></blockquote></div><br></div></div></div></div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>