[cfe-dev] libc++ std::cout alignment trouble (was: Re: [llvm] r240144 - [SLP] Vectorize for all-constant entries.)
Ed Maste via cfe-dev
cfe-dev at lists.llvm.org
Wed Oct 14 17:59:19 PDT 2015
On 14 October 2015 at 23:22, Tim Northover <t.p.northover at gmail.com> wrote:
> I think there might be two places discussing the attribute. One
> applying to types, the other to variables (and typedefs, strangely).
> From https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html,
> I'm basing my thoughts on:
>
> "This attribute specifies a minimum alignment for the variable or
> structure field, measured in bytes. [...] The default alignment is
> fixed for a particular target ABI. [...] When used on a struct, or
> struct member, the aligned attribute can only increase the alignment."
>
> To me those 3 imply that attribute((aligned(N))) takes precedence over
> the ABI and can reduce the alignment below ABI as long as it's not
> applied to a struct. I take the "minimum" to mean that the compiler
> isn't going to deliberately misalign a variable for you to guarantee
> that "addr % (2*N) != 0".
Ok, now I see what you mean. An alignment is inherently a minimum,
since a symbol may always end up with a wider alignment than required.
So the attribute overrides the "minimum alignment," not sets a minimum
value for the alignment (that may end up higher due to ABI).
More information about the cfe-dev
mailing list