<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 10, 2016 at 10:16 AM Victor Leschuk <<a href="mailto:vleschuk@accesssoftek.com">vleschuk@accesssoftek.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">vleschuk added a comment.<br class="gmail_msg">
<br class="gmail_msg">
In <a href="https://reviews.llvm.org/D24425#539393" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24425#539393</a>, @dblaikie wrote:<br class="gmail_msg">
<br class="gmail_msg">
> In <a href="https://reviews.llvm.org/D24425#539340" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24425#539340</a>, @vleschuk wrote:<br class="gmail_msg">
><br class="gmail_msg">
> > In <a href="https://reviews.llvm.org/D24425#539028" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24425#539028</a>, @dblaikie wrote:<br class="gmail_msg">
> ><br class="gmail_msg">
> > > What's the purpose of the flag? Could we just use the non-zero value of the alignment attribute as the signal of whether to emit the DW_AT_alignment attribute? (eg: if the alignment is specified, emit it - simple?)<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> > The alignment could be not specified and default alignment is used. Consider the following example:<br class="gmail_msg">
> ><br class="gmail_msg">
> >   struct S {<br class="gmail_msg">
> >   } s;<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> > This will result in the following IR code:<br class="gmail_msg">
> ><br class="gmail_msg">
> >   !5 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 1, align: 8, elements: !2)<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> > And getAlignInBits() will return 8. Thus we need to mark entities with non-default alignment.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Is the alignment used for anything in this case? Could we just remove it & make it so that whenever it's present we put the DW_AT_alignment attribute on the entity?<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
The DW_AT_alignment is intended to be emitted only if object's alignment is not default. In case above the default alignment for struct S is 1 byte but C++11 and C11 (or compiler-specific directives) allows user to specify different alignment value.<br class="gmail_msg">
<br class="gmail_msg">
Alignment value (whether it is default or user-defined) must be present in IR in order to be able to generate correct code,</blockquote><div><br>I'm not sure I follow this ^ - the metadata here is only for debug info. It's not used for correctness of the resulting program. (the alignment of pointers in the IR for actual code generation is stored separately)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> as for new DWARF attribute: we just give debuggers information that user has explicitly set the alignment value. This knowledge can be useful in case a debugger needs to create an object for use with some expressions to be evaluated.<br class="gmail_msg"></blockquote><div><br>I'll try to rephrase:<br><br>Is the alignment currently emitted in the debug info IR metadata used for anything? Seems it's used for bitfield related things, but perhaps that's not the right solution/we could do that another way? So that the alignment just corresponds directly to the DW_AT_alignment (eg: when present, emit an alignment attribute, otherwise don't) to keep the metadata simple.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D24425" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D24425</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>