[cfe-dev] libc++ std::cout alignment trouble (was: Re: [llvm] r240144 - [SLP] Vectorize for all-constant entries.)

Ed Maste via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 16:06:18 PDT 2015


On 14 October 2015 at 22:31, Tim Northover <t.p.northover at gmail.com> wrote:
>
> So the AMD64 ABI alignment should override the attribute? I think
> Dmitri has a good point that that's not how GCC interprets it (even
> the documentation seems to allow under-aligning non-struct variables).
> But even if so the bug would be in Clang 3.6[*] for emitting that
> declaration into libc++.so with only 8 bytes alignment.

GCC says "This attribute specifies a minimum alignment (in bytes) for
variables of the specified type." which implies to me the 16-byte ABI
alignment should apply. However, that's not true for all GCC versions
we've examined and Clang 3.6 and earlier, and it seems to be true on
Clang 3.7 only by accident.

Perhaps this issue is _also_ a Clang bug. But if we assume the
alignment attribute is a minimum, and we want the natural 8-byte
alignment for ostream, libc++ is also in error.

> My summary position is:
> 1. We need to stop over-aligning externally visible globals on ELF.
> Ideally only if they're going into a shared library, but I don't think
> that info is available.

I'm not sure how we avoid overalignment though?

> 2. "align 8" is correct for a "__attribute__((aligned(8))) char
> arr[LOTS]" declaration.

I don't believe this is true according to GCC's documentation. I agree
that if we expect aligned(8) to specify exact instead of at least
8-byte alignment then this is a Clang bug.


More information about the llvm-commits mailing list