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

John McCall via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 2 10:49:42 PDT 2020


On 26 May 2020, at 9:32, Gaier, Bjoern via cfe-dev wrote:
> 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
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200602/a3e09eb1/attachment.html>


More information about the cfe-dev mailing list