[llvm-dev] DebugInfo: purpose of align field

Victor Leschuk via llvm-dev llvm-dev at lists.llvm.org
Sat Sep 10 12:50:35 PDT 2016

Hello all,

I am currently implementing support for DWARFv5 DW_AT_alignment attr and 
I got a question about align field in debug info section of IR/Bitcode. 
Currently it is being dumped almost in any case, however according to 
code we use align from DI* objects only when dealing with 
class/structure bitfields: DwarfUnit::constructMemberDIE.

Dumping align information everywhere only for 1 case looks like overhead 
to me.

Consider the following code:

struct S {
   char c;
} s;

When compiled with debug enabled in IR we get smth like that:

!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", 
file: !5, line: 1, size: 8, align: 8, elements: !7)

Am I missing something? What is the purpose of "align: 8" here? Maybe we 
could include alignment information into DI* objects only when required 
(and thus dump it only when required): for types with bitfields and when 
alignas() was specified in code.

Please advise.

Best Regards,

More information about the llvm-dev mailing list