[cfe-dev] Clang-Cl - max type alignment not effecting arrays?

Gaier, Bjoern via cfe-dev cfe-dev at lists.llvm.org
Tue May 26 06:32:24 PDT 2020

Hello Clang-Deves,

I'm currently playing around with Clang-Cl and use it to generate LLVM assembly files. In one of my files I create a double array like this:
double planschiArray[3] = {1.0, 1.1, 1.2};

Clang will generate the following LLVM assembly for it:
@"?planschiArray@@3PANA" = dso_local local_unnamed_addr global [3 x double] [double 1.000000e+00, double 1.100000e+00, double 1.200000e+00], align 16

As far as I understand, the array was aligned to 16 byte - however for an generic address calculation done by us I need an 8byte aligment even though this might effect the SIMD instructions. So I added "-Xclang -fmax-type-align=8" to the compile command but it didn't effected the array. The full command is:

"D:\Program Files\LLVM10\bin\clang-cl" /c -Xclang -emit-llvm -Xclang -fmax-type-align=8 -m64 -ferror-limit=3000 /FAcs /GS- /MT /EHsc /W4 /O2 /Ob2 /Oi /Ot -Wno-unused-command-line-argument -Wno-microsoft-cast -Wno-writable-strings -Wno-microsoft-enum-forward-reference -Wno-invalid-token-paste -Wno-microsoft-include   "%(FullPath)" /Fo"x64\Release\ObjectFile.obj"

Is there a way to force the 8byte alignment via the command line? Using
alignas(sizeof(double)) double planschiArray[3] = {1.0, 1.1, 1.2};

does work however, but I hoped "-Xclang -fmax-type-align=8" would take care of this automatically.

Does anyone know what I'm doing wrong?

Kind greetings
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200526/d99d1e2a/attachment.html>

More information about the cfe-dev mailing list