[cfe-dev] Clang-Cl - max type alignment not effecting arrays?
Gaier, Bjoern via cfe-dev
cfe-dev at lists.llvm.org
Thu Jun 4 23:19:13 PDT 2020
Thank you John!
This cleared things for me :3
-----Original Message-----
From: John McCall <rjmccall at apple.com>
Sent: 03 June 2020 19:25
To: Gaier, Bjoern <Bjoern.Gaier at horiba.com>
Cc: Clang Dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] Clang-Cl - max type alignment not effecting arrays?
On 3 Jun 2020, at 2:24, Gaier, Bjoern wrote:
> 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?
I believe so, yes. You may be able to request lower alignment en masse with a pragma, but you’d have to be careful about what you sweep in under it because, again, that pragma could be ABI-breaking.
John.
>
> 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.
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.
More information about the cfe-dev
mailing list