[llvm] Fix emulated TLS alignment for large variables (PR #171037)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 22 13:52:07 PST 2026
================
@@ -150,6 +150,17 @@ bool addEmuTlsVar(Module &M, const GlobalVariable *GV) {
Type *GVType = GV->getValueType();
Align GVAlignment = DL.getValueOrABITypeAlignment(GV->getAlign(), GVType);
+ // For larger TLS variables that might be accessed via memcpy/memmove,
+ // use the preferred alignment to ensure the backend can use optimized
+ // vector instructions (e.g., ARM NEON vld1.64 requires 16-byte alignment).
+ // This fixes the mismatch where emulated TLS allocates with lower alignment
+ // than what the code generator assumes.
+ TypeSize TS = DL.getTypeStoreSize(GVType);
+ if (TS.isScalable() || TS.getFixedValue() >= 32) {
----------------
efriedma-quic wrote:
Global variables can't have scalable size. (The underlying file formats don't allow it.)
Why are we checking for 32, specifically?
Needs testcase.
https://github.com/llvm/llvm-project/pull/171037
More information about the llvm-commits
mailing list