[cfe-dev] Clang-Cl - max type alignment not effecting arrays?
Gaier, Bjoern via cfe-dev
cfe-dev at lists.llvm.org
Tue Jun 2 23:24:41 PDT 2020
That makes sense to me! Thank you for the explanation. So using “alignas” is the only way to force an 8byte alignment for that array?
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.
Despite the name, -fmax-type-align is specifically just about controlling implicit alignment assumptions and doesn’t actually change the alignment of anything. If it capped alignments in general, it would be ABI-breaking.
John.
Does anyone know what I'm doing wrong?
Kind greetings
Björn
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.
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
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/20200603/45474914/attachment.html>
More information about the cfe-dev
mailing list