[PATCH] D24425: DebugInfo: support for DWARFv5 DW_AT_alignment attribute

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 10 10:26:06 PDT 2016


On Sat, Sep 10, 2016 at 10:16 AM Victor Leschuk <vleschuk at accesssoftek.com>
wrote:

> vleschuk added a comment.
>
> In https://reviews.llvm.org/D24425#539393, @dblaikie wrote:
>
> > In https://reviews.llvm.org/D24425#539340, @vleschuk wrote:
> >
> > > In https://reviews.llvm.org/D24425#539028, @dblaikie wrote:
> > >
> > > > 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?)
> > >
> > >
> > > The alignment could be not specified and default alignment is used.
> Consider the following example:
> > >
> > >   struct S {
> > >   } s;
> > >
> > >
> > > This will result in the following IR code:
> > >
> > >   !5 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file:
> !1, line: 1, align: 8, elements: !2)
> > >
> > >
> > > And getAlignInBits() will return 8. Thus we need to mark entities with
> non-default alignment.
> >
> >
> > 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?
>
>
> 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.
>
> Alignment value (whether it is default or user-defined) must be present in
> IR in order to be able to generate correct code,


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)


> 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.
>

I'll try to rephrase:

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.


>
>
> https://reviews.llvm.org/D24425
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160910/c5015bd3/attachment.html>


More information about the llvm-commits mailing list