[llvm-dev] Default alignment for 'malloc'
Michael Kruse via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 3 14:46:24 PDT 2016
2016-10-03 20:01 GMT+02:00 Joerg Sonnenberger via llvm-dev
<llvm-dev at lists.llvm.org>:
>> malloc is guaranteed to be properly aligned for any C type. This would
>> be 8 bytes on most systems for double. However, I think in practice
>> most modern implementations return 16-byte aligned pointers. I don't
>> think there is a way to annotate calls malloc to have some specific
>> alignment from the backend, that has effect on passes before the
>> backend.
>
> Note that this only applies to base types. Vector types certainly can
> require larger alignment in practice and that's why posix_memalign
> exists.
You are right and I should have remembered: BlueGene/Q has 32 byte
vector types, and I was using posix_memalign for those. IBM certainly
would not change the system base alignment of PowerPC because of this.
posix_memalign would still have another use case: Alignment to cache
line boundaries.
Michael
More information about the llvm-dev
mailing list