[clang] [clang] Increase alignment for large globals when in the same code object (x86-64) (PR #185487)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 05:05:28 PDT 2026


zmodem wrote:

Thanks for working on this!

> This patch introduces size-based preferred alignment for x86-64 global variables, similar to the existing LargeArrayAlign mechanism for arrays.

I wasn't aware of the `LargeArrayAlign` mechanism, but apparently that was motivated by a requirement in the x86-64 psABI: https://github.com/llvm/llvm-project/issues/5971

I agree with Eli that it seems better to do this optimization in the backend. It should probably be easier to do it there too: you can use `GlobalObject::canIncreaseAlignment()` rather than replicate it, you could check if the variable is actually used by memcpy etc., and it will also benefit Rust code which is a slowly growing part of Chromium and presumably Edge too.

https://github.com/llvm/llvm-project/pull/185487


More information about the cfe-commits mailing list