[LLVMdev] Union type, is it really used or necessary?
Erik de Castro Lopo
mle+cl at mega-nerd.com
Wed Sep 8 04:49:00 PDT 2010
David Given wrote:
> On 07/09/10 14:22, Erik de Castro Lopo wrote:
> [...]
> > When generating 32 bit code the struct looks like:
> >
> > <{ i32, pointer }>
> >
> > and for 64 bit code:
> >
> > <{ union { i32, i64 }, pointer }>
>
> Surely LLVM will cause the first structure to be correctly aligned on
> 64-bit platforms by automatically inserting padding? Is explicit
> alignment by the user really necessary?
You missed the point. a struct defined with just parentheses like
{ i32, pointer }
may be padded. A struct defined with angle brackets and parentheses
<{ i32, pointer }>
is a packed struct, guaranteed not to have padding.
See:
http://llvm.org/docs/LangRef.html#t_pstruct
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the llvm-dev
mailing list