[llvm-dev] Over-alignment of globals?

Eli Friedman via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 24 13:49:43 PDT 2020


If you request that the global should be placed in a specific section, LLVM will honor the precise alignment specified.  Otherwise, LLVM assumes it's free to increase the alignment to whatever makes sense.

LLVM IR doesn't try to distinguish whether the alignment was specified explicitly or implicitly at the source level.  We could change that, I guess, but I'm not sure what the goal would be; programs don't really have control over the layout of their .data section anyway.

-Eli

> -----Original Message-----
> From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Luís Marques
> via llvm-dev
> Sent: Wednesday, June 24, 2020 1:04 PM
> To: llvm-dev <llvm-dev at lists.llvm.org>
> Subject: [EXT] [llvm-dev] Over-alignment of globals?
>
> Hi,
>
> If we specify an explicit alignment attribute for globals (either at
> the Clang or LLVM IR level) we get asm alignment directives with
> values that seem to be `max(natural_alignment, specified_alignment)`.
> This seems to happen for multiple archs. GCC instead just emits the
> asked-for alignment. Is there a good reason for this LLVM behavior?
>
> Example:
> https://godbolt.org/z/B5ZcN_ (Clang)
> https://godbolt.org/z/qpV7PV (GCC)
>
> Thanks,
> Luís
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list