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

Victor Leschuk via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 10 10:16:03 PDT 2016


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


https://reviews.llvm.org/D24425





More information about the llvm-commits mailing list