[llvm] CodeGen: Respect function align attribute if less than preferred alignment. (PR #149444)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 05:53:49 PDT 2025


zmodem wrote:

> clang represents this by marking each member function "align 2". This used to allow increasing the alignment if it wasn't specified, but with this patch, all member functions have exactly 2-byte alignment.

Interesting!

For reference, this happens here: https://github.com/llvm/llvm-project/blob/c8986d1ecbcd50a00ecdb7887f7d43141de3196a/clang/lib/CodeGen/CodeGenModule.cpp#L2805-L2812)

---

We hit an interesting bug triggered by this, due to Windows ASan's interception mechanism implicitly relying on functions having higher alignment. (https://crbug.com/437182411)

As discussed above, I don't think the intention of the Clang code was ever to _lower_ the alignment. Do you have any ideas how to best preserve 16-bit alignment at least on Windows x64 for now?

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


More information about the llvm-commits mailing list