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
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
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.
I would prefer not to add more complexity to the alignment of globals if we don't have a particular benefit.
We'll introduce new exciting bugs otherwise, eventually ...