[LLVMdev] Aligning structures/members?

Caldarale, Charles R Chuck.Caldarale at unisys.com
Tue Nov 19 21:16:56 PST 2013


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of edA-qa mort-ora-y
> Subject: [LLVMdev] Aligning structures/members?

> Is there a way to set the alignment of structure types and/or their members?

Sort of.  You can set a DataLayout string, but it will affect all items of a given type, not just those inside structures.  Look here for details:
http://llvm.org/docs/LangRef.html#data-layout

> I noticed that if I use the alignas keyword in c++ that clang introduces a 
> bunch of [Y x i8] style padding.

Pretty much required in order to conform to the semantics of alignas.  The only other option I'm aware of at the IR level is packed structures, where all the padding is eliminated:
http://llvm.org/docs/LangRef.html#structure-type

 - Chuck





More information about the llvm-dev mailing list