[cfe-dev] Alignment of bitfield structs

Bradley Smith bradley.smith at arm.com
Tue Apr 21 02:44:35 PDT 2015


> > However, when this IR goes down to LLVM there is no context of the
> bitfields
> > left so LLVM just sees an i64 load from an i40. InstCombine sees this
> and
> > blindly (but correctly I believe, based on the information it has)
> converts
> > this load to the ABI alignment of i64, which is now incorrect.
> 
> Why is this incorrect?  It's only done because @g doesn't have an
> explicit alignment, and will thus have the i64 ABI alignment.  If
> that's not the expected behavior, would adding an explicit ", align 4"
> to @g solve the issue?

>From what I understand, the ABI alignment of (the actual) @g should be 4 since it is a struct containing int bitfields, Clang has invented the i40 type. Although as I said, from InstCombine's perspective the ABI alignment is indeed 8 as all it sees is the i40, so I don't believe it is InstCombine in itself that is wrong.

Regards,
Bradley smith






More information about the cfe-dev mailing list